@overmap-ai/core 1.0.60-forms-removal.9 → 1.0.60-forms-refactor-1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/overmap-core.js +449 -469
  2. package/dist/overmap-core.js.map +1 -1
  3. package/dist/overmap-core.umd.cjs +449 -469
  4. package/dist/overmap-core.umd.cjs.map +1 -1
  5. package/dist/sdk/services/BaseAttachmentService.d.ts +8 -4
  6. package/dist/sdk/services/BaseUploadService.d.ts +8 -0
  7. package/dist/sdk/services/FormService.d.ts +18 -0
  8. package/dist/sdk/services/FormSubmissionService.d.ts +24 -0
  9. package/dist/sdk/services/GeoImageService.d.ts +11 -0
  10. package/dist/sdk/services/IssueService.d.ts +1 -1
  11. package/dist/sdk/services/index.d.ts +3 -2
  12. package/dist/sdk/typings.d.ts +3 -2
  13. package/dist/store/slices/assetTypeSlice.d.ts +2 -8
  14. package/dist/store/slices/categorySlice.d.ts +11 -25
  15. package/dist/store/slices/formRevisionAttachmentSlice.d.ts +20 -20
  16. package/dist/store/slices/formRevisionSlice.d.ts +21 -21
  17. package/dist/store/slices/formSlice.d.ts +19 -19
  18. package/dist/store/slices/formSubmissionAttachmentSlice.d.ts +20 -20
  19. package/dist/store/slices/formSubmissionSlice.d.ts +26 -26
  20. package/dist/store/slices/geoImageSlice.d.ts +48 -0
  21. package/dist/store/slices/index.d.ts +1 -0
  22. package/dist/store/slices/issueSlice.d.ts +2 -12
  23. package/dist/store/slices/organizationSlice.d.ts +6 -17
  24. package/dist/store/slices/projectFileSlice.d.ts +4 -15
  25. package/dist/store/slices/projectSlice.d.ts +1 -4
  26. package/dist/store/slices/workspaceSlice.d.ts +5 -10
  27. package/dist/store/store.d.ts +2 -1
  28. package/dist/typings/models/assets.d.ts +1 -1
  29. package/dist/typings/models/forms.d.ts +11 -11
  30. package/dist/typings/models/geo.d.ts +2 -1
  31. package/dist/typings/models/geoImages.d.ts +14 -0
  32. package/dist/typings/models/index.d.ts +1 -0
  33. package/dist/typings/models/issues.d.ts +3 -3
  34. package/dist/typings/models/store.d.ts +2 -2
  35. package/dist/utils/coordinates.d.ts +2 -1
  36. package/dist/utils/forms.d.ts +2 -2
  37. package/package.json +1 -1
  38. package/dist/sdk/services/UserFormService.d.ts +0 -18
  39. package/dist/sdk/services/UserFormSubmissionService.d.ts +0 -25
@@ -379,15 +379,15 @@ const wrapMigration = (migrator) => (state) => {
379
379
  };
380
380
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
381
381
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
382
- const initialState$A = {
382
+ const initialState$B = {
383
383
  accessToken: "",
384
384
  refreshToken: "",
385
385
  isLoggedIn: false
386
386
  };
387
387
  const authSlice = createSlice({
388
388
  name: "auth",
389
- initialState: initialState$A,
390
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$A)),
389
+ initialState: initialState$B,
390
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$B)),
391
391
  reducers: {
392
392
  setTokens: (state, action) => {
393
393
  state.accessToken = action.payload.accessToken;
@@ -418,6 +418,9 @@ const literalToCoordinates = (literal) => {
418
418
  const flipCoordinates = (coordinates) => {
419
419
  return [coordinates[1], coordinates[0]];
420
420
  };
421
+ const flipBounds = (bounds) => {
422
+ return [flipCoordinates(bounds[0]), flipCoordinates(bounds[1])];
423
+ };
421
424
  function offsetPositionByMeters(originalPosition, latMeters, lngMeters) {
422
425
  const { lat, lng } = originalPosition;
423
426
  const earthRadius = 6378137;
@@ -854,72 +857,23 @@ function createModelAdapter(computeModelId) {
854
857
  };
855
858
  }
856
859
  const categoryAdapter = createModelAdapter((category) => category.offline_id);
857
- const initialState$z = categoryAdapter.getInitialState({
858
- categoryVisibility: {
859
- hiddenCategoryIds: [],
860
- isNullCategoryHidden: false
861
- }
862
- });
860
+ const initialState$A = categoryAdapter.getInitialState({});
863
861
  const categorySlice = createSlice({
864
862
  name: "categories",
865
- initialState: initialState$z,
866
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
863
+ initialState: initialState$A,
864
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$A)),
867
865
  reducers: {
868
- initializeCategories: (state, action) => {
869
- categoryAdapter.initialize(state, action);
870
- state.categoryVisibility.hiddenCategoryIds = state.categoryVisibility.hiddenCategoryIds.filter(
871
- (categoryId) => action.payload.some((category) => category.offline_id === categoryId)
872
- );
873
- },
866
+ initializeCategories: categoryAdapter.initialize,
874
867
  addCategory: categoryAdapter.addOne,
875
868
  updateCategory: categoryAdapter.updateOne,
876
- deleteCategory: categoryAdapter.deleteOne,
877
- // Pass in a null value to hide the "No category" category
878
- hideCategory: (state, action) => {
879
- const categoryId = action.payload;
880
- if (categoryId === null) {
881
- state.categoryVisibility.isNullCategoryHidden = true;
882
- } else if (!(categoryId in state.categoryVisibility.hiddenCategoryIds)) {
883
- state.categoryVisibility.hiddenCategoryIds.push(categoryId);
884
- }
885
- },
886
- hideAllCategories: (state) => {
887
- state.categoryVisibility.hiddenCategoryIds = Object.keys(state.instances);
888
- state.categoryVisibility.isNullCategoryHidden = true;
889
- },
890
- // Pass in a null value to unhide the "No category" category
891
- unhideCategory: (state, action) => {
892
- const categoryId = action.payload;
893
- if (categoryId === null) {
894
- state.categoryVisibility.isNullCategoryHidden = false;
895
- } else {
896
- state.categoryVisibility.hiddenCategoryIds = state.categoryVisibility.hiddenCategoryIds.filter(
897
- (id) => id !== categoryId
898
- );
899
- }
900
- },
901
- unhideAllCategories: (state) => {
902
- state.categoryVisibility.hiddenCategoryIds = [];
903
- state.categoryVisibility.isNullCategoryHidden = false;
904
- }
869
+ deleteCategory: categoryAdapter.deleteOne
905
870
  }
906
871
  });
907
- const {
908
- initializeCategories,
909
- addCategory,
910
- updateCategory,
911
- deleteCategory,
912
- hideCategory,
913
- hideAllCategories,
914
- unhideCategory,
915
- unhideAllCategories
916
- } = categorySlice.actions;
872
+ const { initializeCategories, addCategory, updateCategory, deleteCategory } = categorySlice.actions;
917
873
  const selectCategoryMapping = (state) => state.categoryReducer.instances;
918
- const _selectActiveWorkspaceId = (state) => state.workspaceReducer.activeWorkspaceId;
919
- const selectCategories = createSelector(
920
- [selectCategoryMapping, _selectActiveWorkspaceId],
921
- (mapping, activeWorkspaceId) => activeWorkspaceId ? Object.values(mapping).filter((category) => category.workspace === activeWorkspaceId) : []
922
- );
874
+ const selectCategories = createSelector([selectCategoryMapping], (categoryMapping) => {
875
+ return Object.values(categoryMapping);
876
+ });
923
877
  const selectCategoriesOfWorkspace = restructureCreateSelectorWithArgs(
924
878
  createSelector(
925
879
  [selectCategories, (_state, workspaceId) => workspaceId],
@@ -932,36 +886,23 @@ const selectCategoryById = restructureCreateSelectorWithArgs(
932
886
  (mapping, categoryId) => mapping[categoryId]
933
887
  )
934
888
  );
935
- const selectCategoryVisibility = (state) => state.categoryReducer.categoryVisibility;
936
- const selectHiddenCategoryCount = (state) => {
937
- const { hiddenCategoryIds, isNullCategoryHidden } = state.categoryReducer.categoryVisibility;
938
- let hiddenCategoryCount = hiddenCategoryIds.length;
939
- if (isNullCategoryHidden)
940
- hiddenCategoryCount++;
941
- return hiddenCategoryCount;
942
- };
943
889
  const selectIssueCountOfCategory = (categoryId) => (state) => {
944
890
  return Object.values(state.issueReducer.instances).filter((issue) => issue.category === categoryId).length;
945
891
  };
946
892
  const categoryReducer = categorySlice.reducer;
947
893
  const assetTypeAdapter = createModelAdapter((assetType) => assetType.offline_id);
948
- const initialState$y = assetTypeAdapter.getInitialState({
949
- hiddenAssetTypeIds: {}
950
- });
894
+ const initialState$z = assetTypeAdapter.getInitialState({});
951
895
  const assetTypeSlice = createSlice({
952
896
  name: "assetTypes",
953
- initialState: initialState$y,
954
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
897
+ initialState: initialState$z,
898
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
955
899
  reducers: {
956
900
  initializeAssetTypes: assetTypeAdapter.initialize,
957
901
  addAssetType: assetTypeAdapter.addOne,
958
- deleteAssetType: assetTypeAdapter.deleteOne,
959
- toggleAssetTypeVisibility: (state, action) => {
960
- state.hiddenAssetTypeIds[action.payload] = !state.hiddenAssetTypeIds[action.payload];
961
- }
902
+ deleteAssetType: assetTypeAdapter.deleteOne
962
903
  }
963
904
  });
964
- const { addAssetType, initializeAssetTypes, deleteAssetType, toggleAssetTypeVisibility } = assetTypeSlice.actions;
905
+ const { addAssetType, initializeAssetTypes, deleteAssetType } = assetTypeSlice.actions;
965
906
  const selectAssetTypesMapping = (state) => state.assetTypeReducer.instances;
966
907
  const selectAssetTypes = createSelector(
967
908
  [selectAssetTypesMapping],
@@ -997,14 +938,13 @@ const selectAssetTypesByName = restructureCreateSelectorWithArgs(
997
938
  });
998
939
  })
999
940
  );
1000
- const selectHiddenAssetTypeIds = (state) => state.assetTypeReducer.hiddenAssetTypeIds;
1001
941
  const assetTypeReducer = assetTypeSlice.reducer;
1002
942
  const assetAdapter = createModelAdapter((asset) => asset.offline_id);
1003
- const initialState$x = assetAdapter.getInitialState({});
943
+ const initialState$y = assetAdapter.getInitialState({});
1004
944
  const assetSlice = createSlice({
1005
945
  name: "assets",
1006
- initialState: initialState$x,
1007
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
946
+ initialState: initialState$y,
947
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
1008
948
  reducers: {
1009
949
  initializeAssets: (state, action) => {
1010
950
  assetAdapter.initialize(state, action);
@@ -1107,11 +1047,11 @@ const selectAssetTypesFromIds = (assetTypeIds) => (state) => {
1107
1047
  };
1108
1048
  const assetReducer = assetSlice.reducer;
1109
1049
  const assetAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
1110
- const initialState$w = assetAttachmentAdapter.getInitialState({});
1050
+ const initialState$x = assetAttachmentAdapter.getInitialState({});
1111
1051
  const assetAttachmentSlice = createSlice({
1112
1052
  name: "assetAttachments",
1113
- initialState: initialState$w,
1114
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1053
+ initialState: initialState$x,
1054
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
1115
1055
  reducers: {
1116
1056
  initializeAssetAttachments: assetAttachmentAdapter.initialize,
1117
1057
  addAssetAttachment: assetAttachmentAdapter.addOne,
@@ -1169,13 +1109,13 @@ const selectAttachmentsOfAssetByType = restructureCreateSelectorWithArgs(
1169
1109
  )
1170
1110
  );
1171
1111
  const assetAttachmentReducer = assetAttachmentSlice.reducer;
1172
- const initialState$v = {
1112
+ const initialState$w = {
1173
1113
  completionsByAssetId: {}
1174
1114
  };
1175
1115
  const assetStageCompletionSlice = createSlice({
1176
1116
  name: "assetStageCompletions",
1177
- initialState: initialState$v,
1178
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1117
+ initialState: initialState$w,
1118
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1179
1119
  reducers: {
1180
1120
  addStageCompletion: (state, action) => {
1181
1121
  let stageToCompletionDateMapping = state.completionsByAssetId[action.payload.asset];
@@ -1227,11 +1167,11 @@ const selectCompletedStageIdsForAsset = restructureCreateSelectorWithArgs(
1227
1167
  );
1228
1168
  const assetStageCompletionReducer = assetStageCompletionSlice.reducer;
1229
1169
  const assetStageAdapter = createModelAdapter((assetStage) => assetStage.offline_id);
1230
- const initialState$u = assetStageAdapter.getInitialState({});
1170
+ const initialState$v = assetStageAdapter.getInitialState({});
1231
1171
  const assetStageSlice = createSlice({
1232
1172
  name: "assetStages",
1233
- initialState: initialState$u,
1234
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$u)),
1173
+ initialState: initialState$v,
1174
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1235
1175
  reducers: {
1236
1176
  initializeStages: assetStageAdapter.initialize,
1237
1177
  setStage: assetStageAdapter.setOne,
@@ -1300,8 +1240,8 @@ const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
1300
1240
  if (!stage) {
1301
1241
  throw new Error("No stage exists with the id " + stageId);
1302
1242
  }
1303
- if (stage.user_form) {
1304
- ret[stageId] = stage.user_form;
1243
+ if (stage.form) {
1244
+ ret[stageId] = stage.form;
1305
1245
  }
1306
1246
  }
1307
1247
  return ret;
@@ -1312,11 +1252,11 @@ const assetStageReducer = assetStageSlice.reducer;
1312
1252
  const assetTypeAttachmentAdapter = createModelAdapter(
1313
1253
  (attachment) => attachment.offline_id
1314
1254
  );
1315
- const initialState$t = assetTypeAttachmentAdapter.getInitialState({});
1255
+ const initialState$u = assetTypeAttachmentAdapter.getInitialState({});
1316
1256
  const assetTypeAttachmentSlice = createSlice({
1317
1257
  name: "assetTypeAttachments",
1318
- initialState: initialState$t,
1319
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$t)),
1258
+ initialState: initialState$u,
1259
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$u)),
1320
1260
  reducers: {
1321
1261
  initializeAssetTypeAttachments: assetTypeAttachmentAdapter.initialize,
1322
1262
  addAssetTypeAttachment: assetTypeAttachmentAdapter.addOne,
@@ -1375,31 +1315,19 @@ const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
1375
1315
  );
1376
1316
  const assetTypeAttachmentReducer = assetTypeAttachmentSlice.reducer;
1377
1317
  const workspaceAdapter = createModelAdapter((workspace) => workspace.offline_id);
1378
- const initialState$s = workspaceAdapter.getInitialState({
1379
- activeWorkspaceId: null
1380
- });
1318
+ const initialState$t = workspaceAdapter.getInitialState({});
1381
1319
  const workspaceSlice = createSlice({
1382
1320
  name: "workspace",
1383
- initialState: initialState$s,
1321
+ initialState: initialState$t,
1384
1322
  reducers: {
1385
1323
  initializeWorkspaces: workspaceAdapter.initialize,
1386
1324
  setWorkspaces: workspaceAdapter.setMany,
1387
1325
  addWorkspace: workspaceAdapter.addOne,
1388
1326
  updateWorkspace: workspaceAdapter.updateOne,
1389
- deleteWorkspace: workspaceAdapter.deleteOne,
1390
- setActiveWorkspaceId: (state, action) => {
1391
- state.activeWorkspaceId = action.payload;
1392
- }
1327
+ deleteWorkspace: workspaceAdapter.deleteOne
1393
1328
  }
1394
1329
  });
1395
- const {
1396
- initializeWorkspaces,
1397
- setWorkspaces,
1398
- addWorkspace,
1399
- updateWorkspace,
1400
- setActiveWorkspaceId,
1401
- deleteWorkspace
1402
- } = workspaceSlice.actions;
1330
+ const { initializeWorkspaces, setWorkspaces, addWorkspace, updateWorkspace, deleteWorkspace } = workspaceSlice.actions;
1403
1331
  const selectWorkspaceMapping = (state) => state.workspaceReducer.instances;
1404
1332
  const selectWorkspaces = createSelector([selectWorkspaceMapping], (mapping) => Object.values(mapping));
1405
1333
  const selectMainWorkspace = createSelector(
@@ -1408,20 +1336,9 @@ const selectMainWorkspace = createSelector(
1408
1336
  return workspaces.find((workspace) => workspace.name.toLowerCase() === "main");
1409
1337
  }
1410
1338
  );
1411
- const selectWorkspace = restructureCreateSelectorWithArgs(
1412
- createSelector([selectWorkspaceMapping, (_state, workspaceId) => workspaceId], (mapping, workspaceId) => {
1413
- return mapping[workspaceId];
1414
- })
1415
- );
1416
- const selectActiveWorkspaceId = (state) => state.workspaceReducer.activeWorkspaceId;
1417
- const selectActiveWorkspace = createSelector(
1418
- [selectWorkspaceMapping, selectActiveWorkspaceId],
1419
- (mapping, activeWorkspaceId) => {
1420
- if (!activeWorkspaceId)
1421
- return null;
1422
- return mapping[activeWorkspaceId];
1423
- }
1424
- );
1339
+ const selectWorkspaceById = (workspaceId) => (state) => {
1340
+ return state.workspaceReducer.instances[workspaceId];
1341
+ };
1425
1342
  const selectPermittedWorkspaceIds = createSelector(
1426
1343
  [selectWorkspaceMapping],
1427
1344
  (mapping) => {
@@ -1433,16 +1350,14 @@ const selectPermittedWorkspaceIds = createSelector(
1433
1350
  const workspaceReducer = workspaceSlice.reducer;
1434
1351
  const maxRecentIssues = 10;
1435
1352
  const issueAdapter = createModelAdapter((issue) => issue.offline_id);
1436
- const initialState$r = issueAdapter.getInitialState({
1437
- visibleStatuses: [IssueStatus.BACKLOG, IssueStatus.SELECTED],
1438
- visibleUserIds: null,
1353
+ const initialState$s = issueAdapter.getInitialState({
1439
1354
  recentIssueIds: []
1440
1355
  });
1441
1356
  const issueSlice = createSlice({
1442
1357
  name: "issues",
1443
- initialState: initialState$r,
1358
+ initialState: initialState$s,
1444
1359
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1445
- Object.assign(state, initialState$r);
1360
+ Object.assign(state, initialState$s);
1446
1361
  }),
1447
1362
  reducers: {
1448
1363
  initializeIssues: issueAdapter.initialize,
@@ -1451,12 +1366,6 @@ const issueSlice = createSlice({
1451
1366
  updateIssue: issueAdapter.updateOne,
1452
1367
  deleteIssue: issueAdapter.deleteOne,
1453
1368
  deleteIssues: issueAdapter.deleteMany,
1454
- setVisibleStatuses: (state, action) => {
1455
- state.visibleStatuses = action.payload;
1456
- },
1457
- setVisibleUserIds: (state, action) => {
1458
- state.visibleUserIds = [...new Set(action.payload)];
1459
- },
1460
1369
  cleanRecentIssues: (state) => {
1461
1370
  state.recentIssueIds = state.recentIssueIds.filter((recentIssue) => state.instances[recentIssue.offlineId]);
1462
1371
  },
@@ -1489,8 +1398,6 @@ const {
1489
1398
  updateIssue,
1490
1399
  deleteIssue,
1491
1400
  deleteIssues,
1492
- setVisibleStatuses,
1493
- setVisibleUserIds,
1494
1401
  addToRecentIssues,
1495
1402
  cleanRecentIssues,
1496
1403
  removeRecentIssue,
@@ -1498,51 +1405,6 @@ const {
1498
1405
  } = issueSlice.actions;
1499
1406
  const selectIssueMapping = (state) => state.issueReducer.instances;
1500
1407
  const selectRecentIssueIds = (state) => state.issueReducer.recentIssueIds;
1501
- const selectVisibleUserIds = (state) => state.issueReducer.visibleUserIds;
1502
- const selectVisibleStatuses = (state) => state.issueReducer.visibleStatuses;
1503
- const selectIssues = restructureCreateSelectorWithArgs(
1504
- createSelector(
1505
- [
1506
- selectIssueMapping,
1507
- selectVisibleUserIds,
1508
- selectVisibleStatuses,
1509
- selectCategoryVisibility,
1510
- selectActiveWorkspaceId,
1511
- (_state, args) => args
1512
- ],
1513
- (mapping, visibleUserIds, visibleStatuses, categoryVisibility, activeWorkspaceId, args) => {
1514
- let ret = Object.values(mapping);
1515
- const visibleUserIdsSet = new Set(visibleUserIds);
1516
- const visibleStatusesSet = new Set(visibleStatuses);
1517
- if (args.filterByAssignedTo && (visibleUserIds == null ? void 0 : visibleUserIds.length)) {
1518
- ret = ret.filter((issue) => {
1519
- return visibleUserIdsSet.has(issue.assigned_to || null);
1520
- });
1521
- }
1522
- if (args.filterByStatus) {
1523
- ret = ret.filter((issue) => {
1524
- return visibleStatusesSet.has(issue.status);
1525
- });
1526
- }
1527
- if (args.filterByCategory) {
1528
- const isNullCategoryHidden = categoryVisibility.isNullCategoryHidden;
1529
- const hiddenCategoryIds = categoryVisibility.hiddenCategoryIds;
1530
- ret = ret.filter((issue) => {
1531
- if (!issue.category) {
1532
- return !isNullCategoryHidden;
1533
- }
1534
- return !hiddenCategoryIds.includes(issue.category);
1535
- });
1536
- if (args.filterByWorkspace) {
1537
- ret = ret.filter((issue) => {
1538
- return activeWorkspaceId && issue.visible_in_workspaces.includes(activeWorkspaceId);
1539
- });
1540
- }
1541
- }
1542
- return ret;
1543
- }
1544
- )
1545
- );
1546
1408
  const selectIssue = restructureCreateSelectorWithArgs(
1547
1409
  createSelector([selectIssueMapping, (_state, id) => id], (mapping, id) => {
1548
1410
  return mapping[id];
@@ -1639,12 +1501,12 @@ const selectRecentIssuesAsSearchResults = createSelector(
1639
1501
  );
1640
1502
  const issueReducer = issueSlice.reducer;
1641
1503
  const issueTypeAdapter = createModelAdapter((issueType) => issueType.offline_id);
1642
- const initialState$q = issueTypeAdapter.getInitialState({});
1504
+ const initialState$r = issueTypeAdapter.getInitialState({});
1643
1505
  const issueTypeSlice = createSlice({
1644
1506
  name: "issueTypes",
1645
- initialState: initialState$q,
1507
+ initialState: initialState$r,
1646
1508
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1647
- Object.assign(state, initialState$q);
1509
+ Object.assign(state, initialState$r);
1648
1510
  }),
1649
1511
  reducers: {
1650
1512
  initializeIssueTypes: issueTypeAdapter.initialize,
@@ -1693,15 +1555,15 @@ const selectIssuesOfIssueTypeCount = (issueTypeId) => (state) => {
1693
1555
  return ((_a2 = selectIssuesOfIssueType(issueTypeId)(state)) == null ? void 0 : _a2.length) ?? 0;
1694
1556
  };
1695
1557
  const issueTypeReducer = issueTypeSlice.reducer;
1696
- const initialState$p = {
1558
+ const initialState$q = {
1697
1559
  s3Urls: {}
1698
1560
  };
1699
1561
  const msPerHour = 1e3 * 60 * 60;
1700
1562
  const msPerWeek = msPerHour * 24 * 7;
1701
1563
  const fileSlice = createSlice({
1702
1564
  name: "file",
1703
- initialState: initialState$p,
1704
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1565
+ initialState: initialState$q,
1566
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1705
1567
  reducers: {
1706
1568
  setUploadUrl: (state, action) => {
1707
1569
  const { url, fields, sha1 } = action.payload;
@@ -1782,7 +1644,7 @@ var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
1782
1644
  LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
1783
1645
  return LicenseStatus2;
1784
1646
  })(LicenseStatus || {});
1785
- const initialState$o = {
1647
+ const initialState$p = {
1786
1648
  users: {},
1787
1649
  currentUser: {
1788
1650
  id: 0,
@@ -1793,8 +1655,8 @@ const initialState$o = {
1793
1655
  };
1794
1656
  const userSlice = createSlice({
1795
1657
  name: "users",
1796
- initialState: initialState$o,
1797
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1658
+ initialState: initialState$p,
1659
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1798
1660
  reducers: {
1799
1661
  setUsers: (state, action) => {
1800
1662
  const usersMapping = {};
@@ -1859,11 +1721,11 @@ const userReducer = userSlice.reducer;
1859
1721
  const organizationAccessAdapter = createModelAdapter(
1860
1722
  (organizationAccess) => organizationAccess.offline_id
1861
1723
  );
1862
- const initialState$n = organizationAccessAdapter.getInitialState({});
1724
+ const initialState$o = organizationAccessAdapter.getInitialState({});
1863
1725
  const organizationAccessSlice = createSlice({
1864
1726
  name: "organizationAccess",
1865
- initialState: initialState$n,
1866
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1727
+ initialState: initialState$o,
1728
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1867
1729
  reducers: {
1868
1730
  initializeOrganizationAccesses: organizationAccessAdapter.initialize,
1869
1731
  updateOrganizationAccess: organizationAccessAdapter.updateOne,
@@ -1900,11 +1762,11 @@ const selectOrganizationAccessUserMapping = (state) => {
1900
1762
  };
1901
1763
  const organizationAccessReducer = organizationAccessSlice.reducer;
1902
1764
  const licenseAdapter = createModelAdapter((license) => license.offline_id);
1903
- const initialState$m = licenseAdapter.getInitialState({});
1765
+ const initialState$n = licenseAdapter.getInitialState({});
1904
1766
  const licenseSlice = createSlice({
1905
1767
  name: "license",
1906
- initialState: initialState$m,
1907
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1768
+ initialState: initialState$n,
1769
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1908
1770
  reducers: {
1909
1771
  setLicenses: licenseAdapter.initialize,
1910
1772
  addLicenses: licenseAdapter.addMany,
@@ -1930,11 +1792,11 @@ const selectLicensesForProjectsMapping = createSelector(
1930
1792
  );
1931
1793
  const licenseReducer = licenseSlice.reducer;
1932
1794
  const projectAccessAdapter = createModelAdapter((projectAccess) => projectAccess.offline_id);
1933
- const initialState$l = projectAccessAdapter.getInitialState({});
1795
+ const initialState$m = projectAccessAdapter.getInitialState({});
1934
1796
  const projectAccessSlice = createSlice({
1935
1797
  name: "projectAccess",
1936
- initialState: initialState$l,
1937
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1798
+ initialState: initialState$m,
1799
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1938
1800
  reducers: {
1939
1801
  setProjectAccesses: projectAccessAdapter.initialize,
1940
1802
  updateProjectAccess: projectAccessAdapter.updateOne,
@@ -1980,15 +1842,14 @@ const selectProjectAccessUserMapping = (state) => {
1980
1842
  return projectAccesses;
1981
1843
  };
1982
1844
  const projectAccessReducer = projectAccessSlice.reducer;
1983
- const initialState$k = {
1845
+ const initialState$l = {
1984
1846
  projects: {},
1985
- activeProjectId: null,
1986
- recentProjectIds: [],
1987
- recentSearchableQueries: []
1847
+ activeProjectId: null
1988
1848
  };
1989
1849
  const projectSlice = createSlice({
1990
1850
  name: "projects",
1991
- initialState: initialState$k,
1851
+ initialState: initialState$l,
1852
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1992
1853
  reducers: {
1993
1854
  setProjects: (state, action) => {
1994
1855
  const projectsMap = {};
@@ -2068,21 +1929,6 @@ const selectProject = restructureCreateSelectorWithArgs(
2068
1929
  (projects, projectId) => projects[projectId]
2069
1930
  )
2070
1931
  );
2071
- const selectSortedProjects = createSelector(
2072
- [selectActiveProject, selectProjects],
2073
- (activeProject, projects) => {
2074
- return Object.values(projects).sort((projectA, projectB) => {
2075
- if (activeProject) {
2076
- if (activeProject.id === projectA.id) {
2077
- return -1;
2078
- } else if (activeProject.id === projectB.id) {
2079
- return 1;
2080
- }
2081
- }
2082
- return projectA.name.toLowerCase().localeCompare(projectB.name.toLowerCase(), void 0, { numeric: true });
2083
- });
2084
- }
2085
- );
2086
1932
  const projectReducer = projectSlice.reducer;
2087
1933
  const selectProjectUsersIds = createSelector(
2088
1934
  [selectProjectAccessMapping],
@@ -2117,38 +1963,22 @@ const selectSortedProjectUsers = createSelector(
2117
1963
  });
2118
1964
  }
2119
1965
  );
2120
- const initialState$j = {
2121
- organizations: {},
2122
- activeOrganizationId: null
1966
+ const initialState$k = {
1967
+ organizations: {}
2123
1968
  };
2124
1969
  const organizationSlice = createSlice({
2125
1970
  name: "organizations",
2126
- initialState: initialState$j,
2127
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1971
+ initialState: initialState$k,
1972
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
2128
1973
  reducers: {
2129
1974
  setOrganizations: (state, action) => {
2130
1975
  for (const org of action.payload) {
2131
1976
  state.organizations[org.id] = org;
2132
1977
  }
2133
- },
2134
- updateActiveOrganization: (state, action) => {
2135
- if (!state.activeOrganizationId) {
2136
- throw new Error("Cannot update name of active organization. Active organization ID does not exist");
2137
- }
2138
- if (state.activeOrganizationId !== action.payload.id) {
2139
- throw new Error("Tried updating active organization with different organization");
2140
- }
2141
- state.organizations[state.activeOrganizationId] = action.payload;
2142
- },
2143
- setActiveOrganizationId: (state, action) => {
2144
- state.activeOrganizationId = action.payload;
2145
1978
  }
2146
1979
  }
2147
1980
  });
2148
- const { setOrganizations, setActiveOrganizationId, updateActiveOrganization } = organizationSlice.actions;
2149
- const selectActiveOrganizationId = (state) => {
2150
- return state.organizationReducer.activeOrganizationId;
2151
- };
1981
+ const { setOrganizations } = organizationSlice.actions;
2152
1982
  const selectOrganizations = (state) => {
2153
1983
  return Object.values(state.organizationReducer.organizations);
2154
1984
  };
@@ -2159,43 +1989,21 @@ const selectOrganizationsWithAccess = createSelector(
2159
1989
  [selectOrganizations],
2160
1990
  (organizations) => Object.values(organizations).filter((organization) => organization.has_access)
2161
1991
  );
2162
- const selectActiveOrganization = (state) => {
2163
- const id = selectActiveOrganizationId(state);
2164
- if (!id) {
2165
- return null;
2166
- }
2167
- const organization = state.organizationReducer.organizations[id];
2168
- if (!organization) {
2169
- return null;
2170
- }
2171
- return organization;
1992
+ const selectOrganizationById = (organizationId) => (state) => {
1993
+ return state.organizationReducer.organizations[organizationId];
2172
1994
  };
2173
1995
  const selectOrganizationUsersIds = createSelector(
2174
1996
  [selectOrganizationAccesses],
2175
1997
  (organizationAccesses) => Object.values(organizationAccesses).map((organizationAccess) => organizationAccess.user)
2176
1998
  );
2177
- const selectActiveOrganizationProjects = createSelector(
2178
- [selectProjects, selectActiveOrganizationId],
2179
- (projects, activeOrganizationId) => activeOrganizationId ? Object.values(projects).filter((project) => project.owner_organization === activeOrganizationId) : []
2180
- );
2181
- const selectActiveOrganizationLicenses = createSelector(
2182
- [selectActiveOrganizationId, selectLicenses],
2183
- (activeOrganizationId, licenses) => !activeOrganizationId ? [] : Object.values(licenses).filter((license) => license.organization_owner === activeOrganizationId)
1999
+ const selectProjectsOfOrganization = restructureCreateSelectorWithArgs(
2000
+ createSelector([selectProjects, (_, organizationId) => organizationId], (projects, organizationId) => {
2001
+ return Object.values(projects).filter((project) => project.owner_organization === organizationId);
2002
+ })
2184
2003
  );
2185
- const selectSortedOrganizationLicenses = createSelector(
2186
- [selectActiveOrganizationLicenses, selectProjects],
2187
- (licences, projects) => licences.sort((licenseA, licenseB) => {
2188
- if (!licenseA.project) {
2189
- return 1;
2190
- }
2191
- if (!licenseB.project) {
2192
- return -1;
2193
- }
2194
- return projects[licenseA.project].name.toLowerCase().localeCompare(
2195
- projects[licenseB.project].name.toLowerCase(),
2196
- void 0,
2197
- { numeric: true }
2198
- );
2004
+ const selectLicensesOfOrganization = restructureCreateSelectorWithArgs(
2005
+ createSelector([selectLicenses, (_, organizationId) => organizationId], (licenses, organizationId) => {
2006
+ return Object.values(licenses).filter((license) => license.organization_owner === organizationId);
2199
2007
  })
2200
2008
  );
2201
2009
  const selectOrganizationUsersAsMapping = createSelector(
@@ -2244,14 +2052,14 @@ const createOfflineAction = (request2, baseUrl, serviceName) => {
2244
2052
  }
2245
2053
  };
2246
2054
  };
2247
- const initialState$i = {
2055
+ const initialState$j = {
2248
2056
  deletedRequests: [],
2249
2057
  latestRetryTime: 0
2250
2058
  };
2251
2059
  const outboxSlice = createSlice({
2252
2060
  name: "outbox",
2253
- initialState: initialState$i,
2254
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2061
+ initialState: initialState$j,
2062
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
2255
2063
  reducers: {
2256
2064
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
2257
2065
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -2283,16 +2091,15 @@ const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
2283
2091
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
2284
2092
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
2285
2093
  const outboxReducer = outboxSlice.reducer;
2286
- const initialState$h = {
2094
+ const initialState$i = {
2287
2095
  projectFiles: {},
2288
2096
  activeProjectFileId: null,
2289
- isImportingProjectFile: false,
2290
- enabledProjectFiles: {}
2097
+ isImportingProjectFile: false
2291
2098
  };
2292
2099
  const projectFileSlice = createSlice({
2293
2100
  name: "projectFiles",
2294
- initialState: initialState$h,
2295
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2101
+ initialState: initialState$i,
2102
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2296
2103
  reducers: {
2297
2104
  addOrReplaceProjectFiles: (state, action) => {
2298
2105
  for (let fileObj of action.payload) {
@@ -2317,9 +2124,6 @@ const projectFileSlice = createSlice({
2317
2124
  }
2318
2125
  state.projectFiles[action.payload.offline_id] = action.payload;
2319
2126
  },
2320
- setProjectFileVisible: (state, action) => {
2321
- state.enabledProjectFiles[action.payload.fileId] = action.payload.visible;
2322
- },
2323
2127
  setIsImportingProjectFile: (state, action) => {
2324
2128
  state.isImportingProjectFile = action.payload;
2325
2129
  },
@@ -2339,19 +2143,14 @@ const projectFileSlice = createSlice({
2339
2143
  // TODO: Move to MapContext. Should not be persisted.
2340
2144
  setActiveProjectFileId: (state, action) => {
2341
2145
  state.activeProjectFileId = action.payload;
2342
- if (action.payload) {
2343
- state.enabledProjectFiles[action.payload] = true;
2344
- }
2345
2146
  },
2346
2147
  removeProjectFile: (state, action) => {
2347
2148
  delete state.projectFiles[action.payload];
2348
- delete state.enabledProjectFiles[action.payload];
2349
2149
  },
2350
2150
  removeProjectFilesOfProject: (state, action) => {
2351
2151
  const filesToDelete = Object.values(state.projectFiles).filter((file) => file.project === action.payload);
2352
2152
  for (const file of filesToDelete) {
2353
2153
  delete state.projectFiles[file.offline_id];
2354
- delete state.enabledProjectFiles[file.offline_id];
2355
2154
  }
2356
2155
  },
2357
2156
  resetProjectFileObjectUrls: (state, ..._args) => {
@@ -2364,7 +2163,6 @@ const projectFileSlice = createSlice({
2364
2163
  const {
2365
2164
  addOrReplaceProjectFiles,
2366
2165
  addOrReplaceProjectFile,
2367
- setProjectFileVisible,
2368
2166
  setIsImportingProjectFile,
2369
2167
  setActiveProjectFileId,
2370
2168
  saveActiveProjectFileBounds,
@@ -2372,33 +2170,25 @@ const {
2372
2170
  removeProjectFilesOfProject,
2373
2171
  resetProjectFileObjectUrls
2374
2172
  } = projectFileSlice.actions;
2375
- const selectEnabledProjectFiles = (state) => state.projectFileReducer.enabledProjectFiles;
2376
- const selectProjectFileVisibility = createSelector(
2377
- [selectEnabledProjectFiles],
2378
- (enabledProjectFiles) => {
2379
- const ret = {};
2380
- for (const [fileId, enabled] of Object.entries(enabledProjectFiles)) {
2381
- ret[fileId] = enabled === true || enabled === void 0;
2382
- }
2383
- return ret;
2384
- }
2385
- );
2386
- const selectEnabledProjectFileMapping = (state) => state.projectFileReducer.projectFiles;
2173
+ const selectProjectFileMapping = (state) => state.projectFileReducer.projectFiles;
2387
2174
  const selectProjectFiles = createSelector(
2388
- [selectEnabledProjectFileMapping, selectActiveProjectId],
2175
+ [selectProjectFileMapping, selectActiveProjectId],
2389
2176
  (mapping, activeProjectId) => {
2390
2177
  return Object.values(mapping).filter((file) => file.project === activeProjectId).sort((a, b) => a.z_index - b.z_index);
2391
2178
  }
2392
2179
  );
2393
2180
  const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProjectFileId;
2394
2181
  const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
2182
+ const selectProjectFileById = (id) => (state) => {
2183
+ return state.projectFileReducer.projectFiles[id];
2184
+ };
2395
2185
  const projectFileReducer = projectFileSlice.reducer;
2396
2186
  const projectAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2397
- const initialState$g = projectAttachmentAdapter.getInitialState({});
2187
+ const initialState$h = projectAttachmentAdapter.getInitialState({});
2398
2188
  const projectAttachmentSlice = createSlice({
2399
2189
  name: "projectAttachments",
2400
- initialState: initialState$g,
2401
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2190
+ initialState: initialState$h,
2191
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2402
2192
  reducers: {
2403
2193
  initializeProjectAttachments: projectAttachmentAdapter.initialize,
2404
2194
  addProjectAttachment: projectAttachmentAdapter.addOne,
@@ -2456,12 +2246,12 @@ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
2456
2246
  )
2457
2247
  );
2458
2248
  const projectAttachmentReducer = projectAttachmentSlice.reducer;
2459
- const initialState$f = {
2249
+ const initialState$g = {
2460
2250
  isRehydrated: false
2461
2251
  };
2462
2252
  const rehydratedSlice = createSlice({
2463
2253
  name: "rehydrated",
2464
- initialState: initialState$f,
2254
+ initialState: initialState$g,
2465
2255
  // The `reducers` field lets us define reducers and generate associated actions
2466
2256
  reducers: {
2467
2257
  setRehydrated: (state, action) => {
@@ -2472,13 +2262,13 @@ const rehydratedSlice = createSlice({
2472
2262
  const { setRehydrated } = rehydratedSlice.actions;
2473
2263
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
2474
2264
  const rehydratedReducer = rehydratedSlice.reducer;
2475
- const initialState$e = {
2265
+ const initialState$f = {
2476
2266
  isFetchingInitialData: false
2477
2267
  };
2478
2268
  const settingSlice = createSlice({
2479
2269
  name: "settings",
2480
- initialState: initialState$e,
2481
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2270
+ initialState: initialState$f,
2271
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2482
2272
  reducers: {
2483
2273
  setIsFetchingInitialData: (state, action) => {
2484
2274
  state.isFetchingInitialData = action.payload;
@@ -2502,11 +2292,11 @@ const formRevisionSortFn = (formRevisionA, formRevisionB) => {
2502
2292
  }
2503
2293
  };
2504
2294
  const formRevisionAdapter = createModelAdapter((revision) => revision.offline_id);
2505
- const initialState$d = formRevisionAdapter.getInitialState({});
2295
+ const initialState$e = formRevisionAdapter.getInitialState({});
2506
2296
  const formRevisionsSlice = createSlice({
2507
2297
  name: "formRevisions",
2508
- initialState: initialState$d,
2509
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2298
+ initialState: initialState$e,
2299
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2510
2300
  reducers: {
2511
2301
  initializeFormRevisions: formRevisionAdapter.initialize,
2512
2302
  setFormRevision: formRevisionAdapter.setOne,
@@ -2599,11 +2389,11 @@ const selectLatestFormRevisionByForm = createSelector([selectFormRevisionMapping
2599
2389
  });
2600
2390
  const formRevisionReducer = formRevisionsSlice.reducer;
2601
2391
  const formAdapter = createModelAdapter((form) => form.offline_id);
2602
- const initialState$c = formAdapter.getInitialState({});
2392
+ const initialState$d = formAdapter.getInitialState({});
2603
2393
  const formSlice = createSlice({
2604
2394
  name: "forms",
2605
- initialState: initialState$c,
2606
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2395
+ initialState: initialState$d,
2396
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2607
2397
  reducers: {
2608
2398
  setForms: formAdapter.initialize,
2609
2399
  setForm: formAdapter.setOne,
@@ -2685,11 +2475,11 @@ const selectGeneralFormCount = createSelector([selectFormMapping], (userForms) =
2685
2475
  });
2686
2476
  const formReducer = formSlice.reducer;
2687
2477
  const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
2688
- const initialState$b = submissionAdapter.getInitialState({});
2478
+ const initialState$c = submissionAdapter.getInitialState({});
2689
2479
  const formSubmissionSlice = createSlice({
2690
2480
  name: "formSubmissions",
2691
- initialState: initialState$b,
2692
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2481
+ initialState: initialState$c,
2482
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2693
2483
  reducers: {
2694
2484
  setFormSubmission: submissionAdapter.setOne,
2695
2485
  setFormSubmissions: submissionAdapter.setMany,
@@ -2809,29 +2599,32 @@ const selectFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
2809
2599
  }
2810
2600
  )
2811
2601
  );
2812
- const selectFormSubmissionsByAssets = createSelector([selectFormSubmissionsMapping, selectAssetsMapping], (submissions, assets) => {
2813
- var _a2;
2814
- const assetSubmissionMapping = {};
2815
- for (const assetId in assets) {
2816
- assetSubmissionMapping[assetId] = [];
2817
- }
2818
- for (const submissionId in submissions) {
2819
- const submission = submissions[submissionId];
2820
- if (submission.asset) {
2821
- (_a2 = assetSubmissionMapping[submission.asset]) == null ? void 0 : _a2.push(submission);
2602
+ const selectFormSubmissionsByAssets = createSelector(
2603
+ [selectFormSubmissionsMapping, selectAssetsMapping],
2604
+ (submissions, assets) => {
2605
+ var _a2;
2606
+ const assetSubmissionMapping = {};
2607
+ for (const assetId in assets) {
2608
+ assetSubmissionMapping[assetId] = [];
2609
+ }
2610
+ for (const submissionId in submissions) {
2611
+ const submission = submissions[submissionId];
2612
+ if (submission.asset) {
2613
+ (_a2 = assetSubmissionMapping[submission.asset]) == null ? void 0 : _a2.push(submission);
2614
+ }
2822
2615
  }
2616
+ return assetSubmissionMapping;
2823
2617
  }
2824
- return assetSubmissionMapping;
2825
- });
2618
+ );
2826
2619
  const formSubmissionReducer = formSubmissionSlice.reducer;
2827
2620
  const formSubmissionAttachmentAdapter = createModelAdapter(
2828
2621
  (attachment) => attachment.offline_id
2829
2622
  );
2830
- const initialState$a = formSubmissionAttachmentAdapter.getInitialState({});
2623
+ const initialState$b = formSubmissionAttachmentAdapter.getInitialState({});
2831
2624
  const formSubmissionAttachmentSlice = createSlice({
2832
2625
  name: "formSubmissionAttachments",
2833
- initialState: initialState$a,
2834
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2626
+ initialState: initialState$b,
2627
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2835
2628
  reducers: {
2836
2629
  initializeFormSubmissionAttachments: formSubmissionAttachmentAdapter.initialize,
2837
2630
  addFormSubmissionAttachment: formSubmissionAttachmentAdapter.addOne,
@@ -2870,11 +2663,11 @@ const formSubmissionAttachmentReducer = formSubmissionAttachmentSlice.reducer;
2870
2663
  const formRevisionAttachmentAdapter = createModelAdapter(
2871
2664
  (attachment) => attachment.offline_id
2872
2665
  );
2873
- const initialState$9 = formRevisionAttachmentAdapter.getInitialState({});
2666
+ const initialState$a = formRevisionAttachmentAdapter.getInitialState({});
2874
2667
  const formRevisionAttachmentSlice = createSlice({
2875
2668
  name: "formRevisionAttachments",
2876
- initialState: initialState$9,
2877
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
2669
+ initialState: initialState$a,
2670
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2878
2671
  reducers: {
2879
2672
  initializeFormRevisionAttachments: formRevisionAttachmentAdapter.initialize,
2880
2673
  addFormRevisionAttachment: formRevisionAttachmentAdapter.addOne,
@@ -2911,10 +2704,10 @@ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
2911
2704
  );
2912
2705
  const formRevisionAttachmentReducer = formRevisionAttachmentSlice.reducer;
2913
2706
  const emailDomainAdapter = createModelAdapter((emailDomain) => emailDomain.offline_id);
2914
- const initialState$8 = emailDomainAdapter.getInitialState({});
2707
+ const initialState$9 = emailDomainAdapter.getInitialState({});
2915
2708
  const emailDomainsSlice = createSlice({
2916
2709
  name: "emailDomains",
2917
- initialState: initialState$8,
2710
+ initialState: initialState$9,
2918
2711
  reducers: {
2919
2712
  initializeEmailDomains: emailDomainAdapter.initialize,
2920
2713
  addEmailDomain: emailDomainAdapter.addOne,
@@ -2933,14 +2726,14 @@ const selectEmailDomainsOfOrganization = restructureCreateSelectorWithArgs(
2933
2726
  )
2934
2727
  );
2935
2728
  const emailDomainsReducer = emailDomainsSlice.reducer;
2936
- const initialState$7 = {
2729
+ const initialState$8 = {
2937
2730
  documents: {}
2938
2731
  };
2939
2732
  const documentSlice = createSlice({
2940
2733
  name: "documents",
2941
- initialState: initialState$7,
2734
+ initialState: initialState$8,
2942
2735
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2943
- Object.assign(state, initialState$7);
2736
+ Object.assign(state, initialState$8);
2944
2737
  }),
2945
2738
  reducers: {
2946
2739
  setDocuments: (state, action) => {
@@ -3115,11 +2908,11 @@ const selectRootDocuments = createSelector(
3115
2908
  );
3116
2909
  const documentsReducer = documentSlice.reducer;
3117
2910
  const documentAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
3118
- const initialState$6 = documentAttachmentAdapter.getInitialState({});
2911
+ const initialState$7 = documentAttachmentAdapter.getInitialState({});
3119
2912
  const documentAttachmentSlice = createSlice({
3120
2913
  name: "documentAttachments",
3121
- initialState: initialState$6,
3122
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
2914
+ initialState: initialState$7,
2915
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
3123
2916
  reducers: {
3124
2917
  initializeDocumentAttachments: documentAttachmentAdapter.initialize,
3125
2918
  addDocumentAttachment: documentAttachmentAdapter.addOne,
@@ -3178,11 +2971,11 @@ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
3178
2971
  );
3179
2972
  const documentAttachmentReducer = documentAttachmentSlice.reducer;
3180
2973
  const teamAdapter = createModelAdapter((team) => team.offline_id);
3181
- const initialState$5 = teamAdapter.getInitialState({});
2974
+ const initialState$6 = teamAdapter.getInitialState({});
3182
2975
  const teamSlice = createSlice({
3183
2976
  name: "teams",
3184
- initialState: initialState$5,
3185
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
2977
+ initialState: initialState$6,
2978
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3186
2979
  reducers: {
3187
2980
  setTeam: teamAdapter.setOne,
3188
2981
  setTeams: teamAdapter.initialize,
@@ -3216,11 +3009,11 @@ const teamReducer = teamSlice.reducer;
3216
3009
  const agentUserConversationAdapter = createModelAdapter(
3217
3010
  (conversation) => conversation.offline_id
3218
3011
  );
3219
- const initialState$4 = agentUserConversationAdapter.getInitialState({});
3012
+ const initialState$5 = agentUserConversationAdapter.getInitialState({});
3220
3013
  const agentsSlice = createSlice({
3221
3014
  name: "agents",
3222
- initialState: initialState$4,
3223
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3015
+ initialState: initialState$5,
3016
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3224
3017
  reducers: {
3225
3018
  initializeConversations: agentUserConversationAdapter.initialize,
3226
3019
  addConversation: agentUserConversationAdapter.addOne,
@@ -3242,11 +3035,11 @@ const selectConversation = restructureCreateSelectorWithArgs(
3242
3035
  );
3243
3036
  const agentsReducer = agentsSlice.reducer;
3244
3037
  const issueCommentAdapter = createModelAdapter((comment) => comment.offline_id);
3245
- const initialState$3 = issueCommentAdapter.getInitialState({});
3038
+ const initialState$4 = issueCommentAdapter.getInitialState({});
3246
3039
  const issueCommentSlice = createSlice({
3247
3040
  name: "issueComments",
3248
- initialState: initialState$3,
3249
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3041
+ initialState: initialState$4,
3042
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3250
3043
  reducers: {
3251
3044
  addIssueComment: issueCommentAdapter.addOne,
3252
3045
  addIssueComments: issueCommentAdapter.addMany,
@@ -3275,11 +3068,11 @@ const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
3275
3068
  );
3276
3069
  const issueCommentReducer = issueCommentSlice.reducer;
3277
3070
  const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
3278
- const initialState$2 = issueUpdateAdapter.getInitialState({});
3071
+ const initialState$3 = issueUpdateAdapter.getInitialState({});
3279
3072
  const issueUpdateSlice = createSlice({
3280
3073
  name: "issueUpdates",
3281
- initialState: initialState$2,
3282
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$2)),
3074
+ initialState: initialState$3,
3075
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3283
3076
  reducers: {
3284
3077
  initializeIssueUpdates: issueUpdateAdapter.setMany,
3285
3078
  setIssueUpdate: issueUpdateAdapter.setOne,
@@ -3308,11 +3101,11 @@ const selectIssueUpdatesOfIssue = restructureCreateSelectorWithArgs(
3308
3101
  );
3309
3102
  const issueUpdateReducer = issueUpdateSlice.reducer;
3310
3103
  const issueAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
3311
- const initialState$1 = issueAttachmentAdapter.getInitialState({});
3104
+ const initialState$2 = issueAttachmentAdapter.getInitialState({});
3312
3105
  const issueAttachmentSlice = createSlice({
3313
3106
  name: "issueAttachments",
3314
- initialState: initialState$1,
3315
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$1)),
3107
+ initialState: initialState$2,
3108
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$2)),
3316
3109
  reducers: {
3317
3110
  initializeIssueAttachments: issueAttachmentAdapter.initialize,
3318
3111
  addIssueAttachment: issueAttachmentAdapter.addOne,
@@ -3370,15 +3163,59 @@ const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
3370
3163
  )
3371
3164
  );
3372
3165
  const issueAttachmentReducer = issueAttachmentSlice.reducer;
3373
- const initialState = {
3166
+ const initialState$1 = {
3374
3167
  version: 0
3375
3168
  };
3376
3169
  const versioningSlice = createSlice({
3377
3170
  name: "versioning",
3378
- initialState,
3171
+ initialState: initialState$1,
3379
3172
  reducers: {}
3380
3173
  });
3381
3174
  const versioningReducer = versioningSlice.reducer;
3175
+ const geoImageAdapter = createModelAdapter((model) => model.offline_id);
3176
+ const initialState = geoImageAdapter.getInitialState({});
3177
+ const geoImageSlice = createSlice({
3178
+ name: "geoImages",
3179
+ initialState,
3180
+ extraReducers: (builder) => {
3181
+ builder.addCase("RESET", (state) => {
3182
+ Object.assign(state, initialState);
3183
+ });
3184
+ },
3185
+ reducers: {
3186
+ initializeGeoImages: geoImageAdapter.initialize,
3187
+ setGeoImage: geoImageAdapter.setOne,
3188
+ setGeoImages: geoImageAdapter.setMany,
3189
+ addGeoImage: geoImageAdapter.addOne,
3190
+ addGeoImages: geoImageAdapter.addMany,
3191
+ updateGeoImage: geoImageAdapter.updateOne,
3192
+ updateGeoImages: geoImageAdapter.updateMany,
3193
+ deleteGeoImage: geoImageAdapter.deleteOne,
3194
+ deleteGeoImages: geoImageAdapter.deleteMany
3195
+ }
3196
+ });
3197
+ const {
3198
+ initializeGeoImages,
3199
+ setGeoImage,
3200
+ setGeoImages,
3201
+ addGeoImage,
3202
+ addGeoImages,
3203
+ updateGeoImage,
3204
+ updateGeoImages,
3205
+ deleteGeoImage,
3206
+ deleteGeoImages
3207
+ } = geoImageSlice.actions;
3208
+ const selectGeoImageMapping = (state) => state.geoImageReducer.instances;
3209
+ const selectGeoImages = (state) => Object.values(state.geoImageReducer.instances);
3210
+ const selectGeoImageById = (id) => (state) => {
3211
+ return state.geoImageReducer.instances[id];
3212
+ };
3213
+ const selectGeoImagesOfProject = restructureCreateSelectorWithArgs(
3214
+ createSelector([selectGeoImages, (_, projectId) => projectId], (mapImages, projectId) => {
3215
+ return mapImages.filter((mapImage) => mapImage.project === projectId);
3216
+ })
3217
+ );
3218
+ const geoImageReducer = geoImageSlice.reducer;
3382
3219
  const fullAssetMarkerSize = 45;
3383
3220
  const DEFAULT_ISSUE_STATUS = IssueStatus.BACKLOG;
3384
3221
  const DEFAULT_ISSUE_PRIORITY = IssuePriority.MEDIUM;
@@ -3450,7 +3287,8 @@ const overmapReducers = {
3450
3287
  teamReducer,
3451
3288
  agentsReducer,
3452
3289
  issueCommentReducer,
3453
- issueUpdateReducer
3290
+ issueUpdateReducer,
3291
+ geoImageReducer
3454
3292
  };
3455
3293
  const overmapReducer = combineReducers(overmapReducers);
3456
3294
  const resetStore = "RESET";
@@ -4006,8 +3844,6 @@ class JWTService extends BaseAuthService {
4006
3844
  console.debug(this.constructor.name, "clearing auth;");
4007
3845
  this.dispatch(setLoggedIn(false));
4008
3846
  this.clearTokens();
4009
- this.dispatch(setActiveProjectId(null));
4010
- this.dispatch(setActiveWorkspaceId(null));
4011
3847
  this.dispatch({ type: RESET_STATE });
4012
3848
  this.dispatch({ type: resetStore });
4013
3849
  }
@@ -4504,13 +4340,13 @@ class AssetStageService extends BaseApiService {
4504
4340
  if (!stage) {
4505
4341
  throw new Error(`No asset stage with id ${stageId} found in the store`);
4506
4342
  }
4507
- this.dispatch(updateStage({ ...stage, user_form: formId }));
4343
+ this.dispatch(updateStage({ ...stage, form: formId }));
4508
4344
  try {
4509
4345
  await this.enqueueRequest({
4510
4346
  description: "Link asset stage to form",
4511
4347
  method: HttpMethod.POST,
4512
4348
  url: `/assets/stages/${stageId}/associate-with-form/`,
4513
- payload: { user_form: formId },
4349
+ payload: { form: formId },
4514
4350
  blockers: [stageId, formId],
4515
4351
  blocks: [stageId]
4516
4352
  });
@@ -4525,7 +4361,7 @@ class AssetStageService extends BaseApiService {
4525
4361
  if (!stage) {
4526
4362
  throw new Error(`No asset stage with id ${stageId} found in the store`);
4527
4363
  }
4528
- this.dispatch(updateStage({ ...stage, user_form: void 0 }));
4364
+ this.dispatch(updateStage({ ...stage, form: void 0 }));
4529
4365
  try {
4530
4366
  await this.enqueueRequest({
4531
4367
  description: "Unlink asset stage from form",
@@ -4550,39 +4386,7 @@ class AssetStageService extends BaseApiService {
4550
4386
  this.dispatch(initializeStages(result));
4551
4387
  }
4552
4388
  }
4553
- const AttachmentModelMeta = {
4554
- [AttachmentModel.Issue]: {
4555
- name: "issue",
4556
- attachUrlPrefix: "/issues",
4557
- deleteUrlPrefix: "/issues",
4558
- fetchUrlPostfix: "/issue-attachments"
4559
- },
4560
- [AttachmentModel.Asset]: {
4561
- name: "asset",
4562
- attachUrlPrefix: "/assets",
4563
- deleteUrlPrefix: "/assets",
4564
- fetchUrlPostfix: "/asset-attachments"
4565
- },
4566
- [AttachmentModel.AssetType]: {
4567
- name: "asset type",
4568
- attachUrlPrefix: "/assets/types",
4569
- deleteUrlPrefix: "/assets/types",
4570
- fetchUrlPostfix: "/asset-type-attachments"
4571
- },
4572
- [AttachmentModel.Project]: {
4573
- name: "project",
4574
- attachUrlPrefix: "/projects",
4575
- deleteUrlPrefix: "/projects",
4576
- fetchUrlPostfix: "/attachments"
4577
- },
4578
- [AttachmentModel.Document]: {
4579
- name: "document",
4580
- attachUrlPrefix: "/documents",
4581
- deleteUrlPrefix: "/documents",
4582
- fetchUrlPostfix: "/document-attachments"
4583
- }
4584
- };
4585
- class BaseAttachmentService extends BaseApiService {
4389
+ class BaseUploadService extends BaseApiService {
4586
4390
  getNumberOfAttachmentsWithSha1(sha1) {
4587
4391
  const {
4588
4392
  issueAttachmentReducer: issueAttachmentReducer2,
@@ -4590,8 +4394,9 @@ class BaseAttachmentService extends BaseApiService {
4590
4394
  assetTypeAttachmentReducer: assetTypeAttachmentReducer2,
4591
4395
  documentAttachmentReducer: documentAttachmentReducer2,
4592
4396
  projectAttachmentReducer: projectAttachmentReducer2,
4397
+ formRevisionAttachmentReducer: formRevisionAttachmentReducer2,
4593
4398
  formSubmissionAttachmentReducer: formSubmissionAttachmentReducer2,
4594
- formRevisionAttachmentReducer: formRevisionAttachmentReducer2
4399
+ geoImageReducer: geoImageReducer2
4595
4400
  } = this.client.store.getState();
4596
4401
  const objectsWithSha1 = [].concat(
4597
4402
  Object.values(issueAttachmentReducer2.instances),
@@ -4600,7 +4405,8 @@ class BaseAttachmentService extends BaseApiService {
4600
4405
  Object.values(documentAttachmentReducer2.instances),
4601
4406
  Object.values(projectAttachmentReducer2.instances),
4602
4407
  Object.values(formRevisionAttachmentReducer2.instances),
4603
- Object.values(formSubmissionAttachmentReducer2.instances)
4408
+ Object.values(formSubmissionAttachmentReducer2.instances),
4409
+ Object.values(geoImageReducer2.instances)
4604
4410
  );
4605
4411
  return objectsWithSha1.filter((object) => object.file_sha1 === sha1).length;
4606
4412
  }
@@ -4620,6 +4426,40 @@ class BaseAttachmentService extends BaseApiService {
4620
4426
  });
4621
4427
  }
4622
4428
  }
4429
+ }
4430
+ const AttachmentModelMeta = {
4431
+ [AttachmentModel.Issue]: {
4432
+ name: "issue",
4433
+ attachUrlPrefix: "/issues",
4434
+ deleteUrlPrefix: "/issues",
4435
+ fetchUrlPostfix: "/issue-attachments"
4436
+ },
4437
+ [AttachmentModel.Asset]: {
4438
+ name: "asset",
4439
+ attachUrlPrefix: "/assets",
4440
+ deleteUrlPrefix: "/assets",
4441
+ fetchUrlPostfix: "/asset-attachments"
4442
+ },
4443
+ [AttachmentModel.AssetType]: {
4444
+ name: "asset type",
4445
+ attachUrlPrefix: "/assets/types",
4446
+ deleteUrlPrefix: "/assets/types",
4447
+ fetchUrlPostfix: "/asset-type-attachments"
4448
+ },
4449
+ [AttachmentModel.Project]: {
4450
+ name: "project",
4451
+ attachUrlPrefix: "/projects",
4452
+ deleteUrlPrefix: "/projects",
4453
+ fetchUrlPostfix: "/attachments"
4454
+ },
4455
+ [AttachmentModel.Document]: {
4456
+ name: "document",
4457
+ attachUrlPrefix: "/documents",
4458
+ deleteUrlPrefix: "/documents",
4459
+ fetchUrlPostfix: "/document-attachments"
4460
+ }
4461
+ };
4462
+ class BaseAttachmentService extends BaseUploadService {
4623
4463
  async attachFiles(files, modelId, buildOfflineAttachment) {
4624
4464
  const { store } = this.client;
4625
4465
  const currentUser = store.getState().userReducer.currentUser;
@@ -4975,11 +4815,10 @@ class IssueService extends BaseApiService {
4975
4815
  // Basic CRUD functions
4976
4816
  // TODO: Once all models are represented in `Created<TModel>`, use `Created` in `OptimisticModelResult`, so we don't
4977
4817
  // have to repeat it for all optimistic model results (all optimistic results are created).
4978
- add(issue, issueType = null) {
4818
+ add(issue, workspaceId, issueType = null) {
4979
4819
  const { store } = this.client;
4980
4820
  const dateWithoutMilliseconds = /* @__PURE__ */ new Date();
4981
4821
  const state = store.getState();
4982
- const workspaceId = state.workspaceReducer.activeWorkspaceId;
4983
4822
  const currentUserId = state.userReducer.currentUser.id;
4984
4823
  dateWithoutMilliseconds.setMilliseconds(0);
4985
4824
  if (!workspaceId) {
@@ -5490,10 +5329,6 @@ class ProjectService extends BaseApiService {
5490
5329
  if (!project) {
5491
5330
  throw new Error("Expected project to exist");
5492
5331
  }
5493
- const activeProjectId = state.projectReducer.activeProjectId;
5494
- if (activeProjectId === projectId) {
5495
- this.dispatch({ type: "project/setActiveProjectId", payload: null });
5496
- }
5497
5332
  const filesToDelete = selectProjectFiles(state).filter((file) => file.project === projectId);
5498
5333
  this.dispatch(removeProjectFilesOfProject(project.id));
5499
5334
  const attachmentsOfProject = selectAttachmentsOfProject(project.id)(state);
@@ -5520,7 +5355,6 @@ class ProjectService extends BaseApiService {
5520
5355
  this.dispatch(setProjectAccesses(Object.values(projectAccesses)));
5521
5356
  this.dispatch(addOrReplaceProjectFiles(filesToDelete));
5522
5357
  this.dispatch(setProjectAttachments(attachmentsOfProject));
5523
- this.dispatch(setActiveProjectId(activeProjectId));
5524
5358
  this.dispatch({ type: "rehydrated/setRehydrated", payload: true });
5525
5359
  if (license) {
5526
5360
  this.dispatch(updateLicense({ ...license, project: project.id }));
@@ -5591,7 +5425,7 @@ const separateImageFromFields = async (fields) => {
5591
5425
  }
5592
5426
  return { fields: newFields, images };
5593
5427
  };
5594
- class UserFormService extends BaseApiService {
5428
+ class FormService extends BaseApiService {
5595
5429
  constructor() {
5596
5430
  super(...arguments);
5597
5431
  // Attach images to revision, after uploading them to S3
@@ -5910,7 +5744,7 @@ const separateFilesFromValues = (values) => {
5910
5744
  }
5911
5745
  return { values: newValues, files };
5912
5746
  };
5913
- class UserFormSubmissionService extends BaseApiService {
5747
+ class FormSubmissionService extends BaseUploadService {
5914
5748
  constructor() {
5915
5749
  super(...arguments);
5916
5750
  // Attach files to submission, after uploading them to S3
@@ -5991,7 +5825,6 @@ class UserFormSubmissionService extends BaseApiService {
5991
5825
  // TODO: adapt the support bulk adding to any model type
5992
5826
  async bulkAdd(args, batchSize) {
5993
5827
  const { formRevision, commonFieldValues, fieldValuesByAsset } = args;
5994
- const allFilesRecord = {};
5995
5828
  const { values: fileSeperatedCommonFieldValues, files: commonFiles } = separateFilesFromValues(commonFieldValues);
5996
5829
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5997
5830
  const transactionId = v4();
@@ -6033,7 +5866,6 @@ class UserFormSubmissionService extends BaseApiService {
6033
5866
  file_type: file.type,
6034
5867
  size: file.size
6035
5868
  };
6036
- allFilesRecord[sha1] = filePayload;
6037
5869
  filePaylods.push(filePayload);
6038
5870
  }
6039
5871
  return {
@@ -6069,22 +5901,7 @@ class UserFormSubmissionService extends BaseApiService {
6069
5901
  blocks
6070
5902
  });
6071
5903
  void promise.then(({ presigned_urls }) => {
6072
- for (const [sha1, presignedUrl] of Object.entries(presigned_urls)) {
6073
- const file = allFilesRecord[sha1];
6074
- if (!file)
6075
- continue;
6076
- void this.enqueueRequest({
6077
- url: presignedUrl.url,
6078
- description: "Upload file",
6079
- method: HttpMethod.POST,
6080
- isExternalUrl: true,
6081
- isAuthNeeded: false,
6082
- attachmentHash: sha1,
6083
- blockers: [`s3-${file.sha1}.${file.extension}`],
6084
- blocks: [sha1],
6085
- s3url: presignedUrl
6086
- });
6087
- }
5904
+ this.processPresignedUrls(presigned_urls);
6088
5905
  });
6089
5906
  prevBatchId = batchId;
6090
5907
  batchPromises.push(promise);
@@ -6555,7 +6372,7 @@ class OrganizationService extends BaseApiService {
6555
6372
  });
6556
6373
  }
6557
6374
  async update(organization) {
6558
- const promise = this.enqueueRequest({
6375
+ return this.enqueueRequest({
6559
6376
  description: "Edit organization",
6560
6377
  method: HttpMethod.PATCH,
6561
6378
  url: `/organizations/${organization.id}/`,
@@ -6563,10 +6380,6 @@ class OrganizationService extends BaseApiService {
6563
6380
  blockers: [`add-org-${organization.name}`, organization.id.toString()],
6564
6381
  blocks: [organization.id.toString()]
6565
6382
  });
6566
- return promise.then((result) => {
6567
- this.dispatch(updateActiveOrganization(organization));
6568
- return result;
6569
- });
6570
6383
  }
6571
6384
  async invite(organizationId, email) {
6572
6385
  return this.enqueueRequest({
@@ -7144,6 +6957,179 @@ class UserService extends BaseApiService {
7144
6957
  this.dispatch(setUsers(Object.values(usersRecord)));
7145
6958
  }
7146
6959
  }
6960
+ class GeoImageService extends BaseUploadService {
6961
+ async add(payload) {
6962
+ const { store } = this.client;
6963
+ const { file, ...payloadWithoutFile } = payload;
6964
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6965
+ const currentUser = store.getState().userReducer.currentUser;
6966
+ const projectId = payloadWithoutFile.project;
6967
+ const sha1 = await hashFile(file);
6968
+ const filePayload = {
6969
+ sha1,
6970
+ file_type: file.type,
6971
+ extension: file.name.split(".").pop(),
6972
+ size: file.size
6973
+ };
6974
+ const offlineMapImage = offline({
6975
+ ...payloadWithoutFile,
6976
+ file_name: file.name,
6977
+ file_sha1: sha1,
6978
+ file: URL.createObjectURL(file),
6979
+ submitted_at: submittedAt,
6980
+ created_by: currentUser.id
6981
+ });
6982
+ store.dispatch(addGeoImage(offlineMapImage));
6983
+ const promise = this.enqueueRequest({
6984
+ description: "Add geo image",
6985
+ method: HttpMethod.POST,
6986
+ url: "/geo-images/",
6987
+ payload: {
6988
+ offline_id: offlineMapImage.offline_id,
6989
+ submitted_at: submittedAt,
6990
+ title: offlineMapImage.title,
6991
+ description: offlineMapImage.description,
6992
+ geo_marker: offlineMapImage.geo_marker,
6993
+ canvas_marker: offlineMapImage.canvas_marker,
6994
+ sha1: offlineMapImage.file_sha1,
6995
+ project: offlineMapImage.project,
6996
+ file_name: offlineMapImage.file_name,
6997
+ direction: offlineMapImage.direction,
6998
+ original_date: offlineMapImage.original_date,
6999
+ file: filePayload
7000
+ },
7001
+ blocks: [projectId.toString()],
7002
+ blockers: [projectId.toString()]
7003
+ });
7004
+ promise.then((result) => {
7005
+ this.processPresignedUrls(result.presigned_urls);
7006
+ store.dispatch(setGeoImage(result.geo_image));
7007
+ }).catch(() => {
7008
+ store.dispatch(deleteGeoImage(offlineMapImage.offline_id));
7009
+ });
7010
+ return [offlineMapImage, promise.then((result) => result.geo_image)];
7011
+ }
7012
+ async bulkAdd(payloads, projectId) {
7013
+ const { store } = this.client;
7014
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7015
+ const currentUser = store.getState().userReducer.currentUser;
7016
+ const offlineGeoImages = [];
7017
+ const offlineIds = [];
7018
+ const geoImagePayloads = [];
7019
+ const filePayloadRecord = {};
7020
+ for (const payloadAndFile of payloads) {
7021
+ const { file, ...payload } = payloadAndFile;
7022
+ const sha1 = await hashFile(file);
7023
+ if (!(sha1 in filePayloadRecord)) {
7024
+ filePayloadRecord[sha1] = {
7025
+ sha1,
7026
+ file_type: file.type,
7027
+ extension: file.name.split(".").pop(),
7028
+ size: file.size
7029
+ };
7030
+ await this.client.files.addCache(file, sha1);
7031
+ }
7032
+ const offlineMapImage = offline({
7033
+ ...payload,
7034
+ file_name: file.name,
7035
+ file_sha1: sha1,
7036
+ file: URL.createObjectURL(file),
7037
+ submitted_at: submittedAt,
7038
+ created_by: currentUser.id,
7039
+ project: projectId
7040
+ });
7041
+ offlineGeoImages.push(offlineMapImage);
7042
+ offlineIds.push(offlineMapImage.offline_id);
7043
+ geoImagePayloads.push({
7044
+ offline_id: offlineMapImage.offline_id,
7045
+ sha1: offlineMapImage.file_sha1,
7046
+ file_name: offlineMapImage.file_name,
7047
+ title: offlineMapImage.title,
7048
+ description: offlineMapImage.description,
7049
+ geo_marker: offlineMapImage.geo_marker,
7050
+ canvas_marker: offlineMapImage.canvas_marker,
7051
+ direction: offlineMapImage.direction,
7052
+ original_date: offlineMapImage.original_date
7053
+ });
7054
+ }
7055
+ store.dispatch(addGeoImages(offlineGeoImages));
7056
+ const promise = this.enqueueRequest({
7057
+ description: "Bulk add geo images",
7058
+ method: HttpMethod.POST,
7059
+ url: "/geo-images/bulk/",
7060
+ payload: {
7061
+ submitted_at: submittedAt,
7062
+ project: projectId,
7063
+ geo_images: geoImagePayloads,
7064
+ files: Object.values(filePayloadRecord)
7065
+ },
7066
+ blocks: [projectId.toString()],
7067
+ blockers: offlineIds
7068
+ });
7069
+ promise.then((result) => {
7070
+ this.processPresignedUrls(result.presigned_urls);
7071
+ store.dispatch(setGeoImages(result.geo_images));
7072
+ }).catch(() => {
7073
+ store.dispatch(deleteGeoImages(offlineIds));
7074
+ });
7075
+ return [offlineGeoImages, promise.then((result) => result.geo_images)];
7076
+ }
7077
+ update(payload) {
7078
+ const { store } = this.client;
7079
+ const state = store.getState();
7080
+ const geoImageToUpdate = selectGeoImageById(payload.offline_id)(state);
7081
+ if (!geoImageToUpdate) {
7082
+ throw new Error(`Map image with offline_id ${payload.offline_id} does not exist in the store`);
7083
+ }
7084
+ const updatedGeoImage = { ...geoImageToUpdate, ...payload };
7085
+ store.dispatch(updateGeoImage(updatedGeoImage));
7086
+ const promise = this.enqueueRequest({
7087
+ description: "Update geo image",
7088
+ method: HttpMethod.PATCH,
7089
+ url: `/geo-images/${payload.offline_id}/`,
7090
+ payload,
7091
+ blocks: [payload.offline_id],
7092
+ blockers: [payload.offline_id]
7093
+ });
7094
+ promise.then((result) => {
7095
+ store.dispatch(setGeoImage(result));
7096
+ }).catch(() => {
7097
+ store.dispatch(setGeoImage(geoImageToUpdate));
7098
+ });
7099
+ return [updatedGeoImage, promise];
7100
+ }
7101
+ async delete(geoImageId) {
7102
+ const { store } = this.client;
7103
+ const state = store.getState();
7104
+ const geoImageToDelete = selectGeoImageById(geoImageId)(state);
7105
+ if (!geoImageToDelete) {
7106
+ throw new Error(`Map image with offline_id ${geoImageId} does not exist in the store`);
7107
+ }
7108
+ store.dispatch(deleteGeoImage(geoImageId));
7109
+ const promise = this.enqueueRequest({
7110
+ description: "Delete geo image",
7111
+ method: HttpMethod.DELETE,
7112
+ url: `/geo-images/${geoImageId}/`,
7113
+ blocks: [geoImageId],
7114
+ blockers: [geoImageId]
7115
+ });
7116
+ promise.catch(() => {
7117
+ store.dispatch(setGeoImage(geoImageToDelete));
7118
+ });
7119
+ return promise;
7120
+ }
7121
+ async refreshStore(projectId) {
7122
+ const { store } = this.client;
7123
+ const result = await this.enqueueRequest({
7124
+ description: "Get geo images",
7125
+ method: HttpMethod.GET,
7126
+ url: `/projects/${projectId}/geo-images/`,
7127
+ blocks: [projectId.toString()],
7128
+ blockers: []
7129
+ });
7130
+ store.dispatch(initializeGeoImages(result));
7131
+ }
7132
+ }
7147
7133
  export {
7148
7134
  APIError,
7149
7135
  AgentService,
@@ -7167,7 +7153,10 @@ export {
7167
7153
  EmailDomainsService,
7168
7154
  EmailVerificationService,
7169
7155
  FileService,
7156
+ FormService,
7157
+ FormSubmissionService,
7170
7158
  GREEN,
7159
+ GeoImageService,
7171
7160
  HttpMethod,
7172
7161
  IssueAttachmentService,
7173
7162
  IssueCommentService,
@@ -7193,8 +7182,6 @@ export {
7193
7182
  ProjectFileService,
7194
7183
  ProjectService,
7195
7184
  TeamService,
7196
- UserFormService,
7197
- UserFormSubmissionService,
7198
7185
  UserService,
7199
7186
  VERSION_REDUCER_KEY,
7200
7187
  VerificationCodeType,
@@ -7229,6 +7216,8 @@ export {
7229
7216
  addFormSubmissionAttachments,
7230
7217
  addFormSubmissions,
7231
7218
  addForms,
7219
+ addGeoImage,
7220
+ addGeoImages,
7232
7221
  addIssue,
7233
7222
  addIssueAttachment,
7234
7223
  addIssueAttachments,
@@ -7304,6 +7293,8 @@ export {
7304
7293
  deleteFormSubmissionAttachment,
7305
7294
  deleteFormSubmissionAttachments,
7306
7295
  deleteFormSubmissions,
7296
+ deleteGeoImage,
7297
+ deleteGeoImages,
7307
7298
  deleteIssue,
7308
7299
  deleteIssueAttachment,
7309
7300
  deleteIssueAttachments,
@@ -7337,6 +7328,7 @@ export {
7337
7328
  fileReducer,
7338
7329
  fileSlice,
7339
7330
  fileToBlob,
7331
+ flipBounds,
7340
7332
  flipCoordinates,
7341
7333
  formReducer,
7342
7334
  formRevisionAttachmentReducer,
@@ -7351,6 +7343,8 @@ export {
7351
7343
  fullAssetMarkerSize,
7352
7344
  generateBadgeColors,
7353
7345
  genericMemo,
7346
+ geoImageReducer,
7347
+ geoImageSlice,
7354
7348
  getFileIdentifier,
7355
7349
  getFileS3Key,
7356
7350
  getLocalDateString,
@@ -7359,8 +7353,6 @@ export {
7359
7353
  getRenamedFile,
7360
7354
  getStageColor,
7361
7355
  hashFile,
7362
- hideAllCategories,
7363
- hideCategory,
7364
7356
  initSDK,
7365
7357
  initializeAssetAttachments,
7366
7358
  initializeAssetTypeAttachments,
@@ -7373,6 +7365,7 @@ export {
7373
7365
  initializeFormRevisionAttachments,
7374
7366
  initializeFormRevisions,
7375
7367
  initializeFormSubmissionAttachments,
7368
+ initializeGeoImages,
7376
7369
  initializeIssueAttachments,
7377
7370
  initializeIssueTypes,
7378
7371
  initializeIssueUpdates,
@@ -7445,18 +7438,12 @@ export {
7445
7438
  searchIssues,
7446
7439
  selectAccessToken,
7447
7440
  selectActiveLicense,
7448
- selectActiveOrganization,
7449
7441
  selectActiveOrganizationAccess,
7450
- selectActiveOrganizationId,
7451
- selectActiveOrganizationLicenses,
7452
- selectActiveOrganizationProjects,
7453
7442
  selectActiveProject,
7454
7443
  selectActiveProjectAccess,
7455
7444
  selectActiveProjectFileId,
7456
7445
  selectActiveProjectId,
7457
7446
  selectActiveStatusLicenses,
7458
- selectActiveWorkspace,
7459
- selectActiveWorkspaceId,
7460
7447
  selectAllDocumentAttachments,
7461
7448
  selectAllProjectAttachments,
7462
7449
  selectAncestorIdsOfDocument,
@@ -7493,7 +7480,6 @@ export {
7493
7480
  selectCategoriesOfWorkspace,
7494
7481
  selectCategoryById,
7495
7482
  selectCategoryMapping,
7496
- selectCategoryVisibility,
7497
7483
  selectCommentsOfIssue,
7498
7484
  selectCompletedStageIdsForAsset,
7499
7485
  selectCompletedStages,
@@ -7510,8 +7496,6 @@ export {
7510
7496
  selectEmailDomains,
7511
7497
  selectEmailDomainsAsMapping,
7512
7498
  selectEmailDomainsOfOrganization,
7513
- selectEnabledProjectFileMapping,
7514
- selectEnabledProjectFiles,
7515
7499
  selectFavouriteProjects,
7516
7500
  selectFilteredForms,
7517
7501
  selectForm,
@@ -7535,8 +7519,10 @@ export {
7535
7519
  selectFormsCount,
7536
7520
  selectFormsMapping,
7537
7521
  selectGeneralFormCount,
7538
- selectHiddenAssetTypeIds,
7539
- selectHiddenCategoryCount,
7522
+ selectGeoImageById,
7523
+ selectGeoImageMapping,
7524
+ selectGeoImages,
7525
+ selectGeoImagesOfProject,
7540
7526
  selectIsFetchingInitialData,
7541
7527
  selectIsImportingProjectFile,
7542
7528
  selectIsLoggedIn,
@@ -7553,7 +7539,6 @@ export {
7553
7539
  selectIssueTypesOfOrganization,
7554
7540
  selectIssueUpdateMapping,
7555
7541
  selectIssueUpdatesOfIssue,
7556
- selectIssues,
7557
7542
  selectIssuesOfIssueType,
7558
7543
  selectIssuesOfIssueTypeCount,
7559
7544
  selectLatestFormRevisionByForm,
@@ -7564,6 +7549,7 @@ export {
7564
7549
  selectLicenseForProject,
7565
7550
  selectLicenses,
7566
7551
  selectLicensesForProjectsMapping,
7552
+ selectLicensesOfOrganization,
7567
7553
  selectMainWorkspace,
7568
7554
  selectNumberOfAssetTypesMatchingCaseInsensitiveName,
7569
7555
  selectNumberOfAssetsOfAssetType,
@@ -7572,6 +7558,7 @@ export {
7572
7558
  selectOrganizationAccessForUser,
7573
7559
  selectOrganizationAccessUserMapping,
7574
7560
  selectOrganizationAccesses,
7561
+ selectOrganizationById,
7575
7562
  selectOrganizationUsersAsMapping,
7576
7563
  selectOrganizationUsersIds,
7577
7564
  selectOrganizations,
@@ -7586,21 +7573,21 @@ export {
7586
7573
  selectProjectAccesses,
7587
7574
  selectProjectAttachment,
7588
7575
  selectProjectAttachmentMapping,
7589
- selectProjectFileVisibility,
7576
+ selectProjectFileById,
7577
+ selectProjectFileMapping,
7590
7578
  selectProjectFiles,
7591
7579
  selectProjectUsersAsMapping,
7592
7580
  selectProjectUsersIds,
7593
7581
  selectProjects,
7582
+ selectProjectsOfOrganization,
7594
7583
  selectProjectsWithAccess,
7595
7584
  selectRecentIssueIds,
7596
7585
  selectRecentIssuesAsSearchResults,
7597
7586
  selectRehydrated,
7598
7587
  selectRootDocuments,
7599
7588
  selectSortedFormSubmissionsOfForm,
7600
- selectSortedOrganizationLicenses,
7601
7589
  selectSortedOrganizationUsers,
7602
7590
  selectSortedProjectUsers,
7603
- selectSortedProjects,
7604
7591
  selectStage,
7605
7592
  selectStageFormIdsFromStageIds,
7606
7593
  selectStageMapping,
@@ -7617,15 +7604,11 @@ export {
7617
7604
  selectUser,
7618
7605
  selectUserFormRevisionAttachmentsMapping,
7619
7606
  selectUsersAsMapping,
7620
- selectVisibleStatuses,
7621
- selectVisibleUserIds,
7622
- selectWorkspace,
7607
+ selectWorkspaceById,
7623
7608
  selectWorkspaceMapping,
7624
7609
  selectWorkspaces,
7625
- setActiveOrganizationId,
7626
7610
  setActiveProjectFileId,
7627
7611
  setActiveProjectId,
7628
- setActiveWorkspaceId,
7629
7612
  setAsset,
7630
7613
  setAssetAttachment,
7631
7614
  setAssetAttachments,
@@ -7646,6 +7629,8 @@ export {
7646
7629
  setFormSubmissionAttachments,
7647
7630
  setFormSubmissions,
7648
7631
  setForms,
7632
+ setGeoImage,
7633
+ setGeoImages,
7649
7634
  setIsFetchingInitialData,
7650
7635
  setIsImportingProjectFile,
7651
7636
  setIssueAttachment,
@@ -7661,7 +7646,6 @@ export {
7661
7646
  setProjectAccesses,
7662
7647
  setProjectAttachment,
7663
7648
  setProjectAttachments,
7664
- setProjectFileVisible,
7665
7649
  setProjects,
7666
7650
  setRehydrated,
7667
7651
  setStage,
@@ -7672,8 +7656,6 @@ export {
7672
7656
  setTourStep,
7673
7657
  setUploadUrl,
7674
7658
  setUsers,
7675
- setVisibleStatuses,
7676
- setVisibleUserIds,
7677
7659
  setWorkspaces,
7678
7660
  settingReducer,
7679
7661
  settingSlice,
@@ -7685,11 +7667,7 @@ export {
7685
7667
  teamSlice,
7686
7668
  toFileNameSafeString,
7687
7669
  toOfflineIdRecord,
7688
- toggleAssetTypeVisibility,
7689
7670
  truncate,
7690
- unhideAllCategories,
7691
- unhideCategory,
7692
- updateActiveOrganization,
7693
7671
  updateAsset,
7694
7672
  updateAssetAttachment,
7695
7673
  updateAssetAttachments,
@@ -7708,6 +7686,8 @@ export {
7708
7686
  updateFormSubmissionAttachment,
7709
7687
  updateFormSubmissionAttachments,
7710
7688
  updateFormSubmissions,
7689
+ updateGeoImage,
7690
+ updateGeoImages,
7711
7691
  updateIssue,
7712
7692
  updateIssueAttachment,
7713
7693
  updateIssueAttachments,