@overmap-ai/core 1.0.60-forms-removal.8 → 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 +451 -470
  2. package/dist/overmap-core.js.map +1 -1
  3. package/dist/overmap-core.umd.cjs +451 -470
  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,
@@ -2546,7 +2336,8 @@ const _selectLatestFormRevision = (formRevisions, formId) => {
2546
2336
  };
2547
2337
  const selectLatestFormRevisionOfForm = restructureCreateSelectorWithArgs(
2548
2338
  createSelector([selectFormRevisions, (_state, formId) => formId], (revisions, formId) => {
2549
- return revisions.filter((revision) => revision.form === formId).sort(formRevisionSortFn).pop();
2339
+ const sortedRevisions = revisions.filter((revision) => revision.form === formId).sort(formRevisionSortFn).reverse();
2340
+ return sortedRevisions.length > 0 ? sortedRevisions[0] : void 0;
2550
2341
  })
2551
2342
  );
2552
2343
  const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
@@ -2598,11 +2389,11 @@ const selectLatestFormRevisionByForm = createSelector([selectFormRevisionMapping
2598
2389
  });
2599
2390
  const formRevisionReducer = formRevisionsSlice.reducer;
2600
2391
  const formAdapter = createModelAdapter((form) => form.offline_id);
2601
- const initialState$c = formAdapter.getInitialState({});
2392
+ const initialState$d = formAdapter.getInitialState({});
2602
2393
  const formSlice = createSlice({
2603
2394
  name: "forms",
2604
- initialState: initialState$c,
2605
- 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)),
2606
2397
  reducers: {
2607
2398
  setForms: formAdapter.initialize,
2608
2399
  setForm: formAdapter.setOne,
@@ -2684,11 +2475,11 @@ const selectGeneralFormCount = createSelector([selectFormMapping], (userForms) =
2684
2475
  });
2685
2476
  const formReducer = formSlice.reducer;
2686
2477
  const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
2687
- const initialState$b = submissionAdapter.getInitialState({});
2478
+ const initialState$c = submissionAdapter.getInitialState({});
2688
2479
  const formSubmissionSlice = createSlice({
2689
2480
  name: "formSubmissions",
2690
- initialState: initialState$b,
2691
- 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)),
2692
2483
  reducers: {
2693
2484
  setFormSubmission: submissionAdapter.setOne,
2694
2485
  setFormSubmissions: submissionAdapter.setMany,
@@ -2808,29 +2599,32 @@ const selectFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
2808
2599
  }
2809
2600
  )
2810
2601
  );
2811
- const selectFormSubmissionsByAssets = createSelector([selectFormSubmissionsMapping, selectAssetsMapping], (submissions, assets) => {
2812
- var _a2;
2813
- const assetSubmissionMapping = {};
2814
- for (const assetId in assets) {
2815
- assetSubmissionMapping[assetId] = [];
2816
- }
2817
- for (const submissionId in submissions) {
2818
- const submission = submissions[submissionId];
2819
- if (submission.asset) {
2820
- (_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
+ }
2821
2615
  }
2616
+ return assetSubmissionMapping;
2822
2617
  }
2823
- return assetSubmissionMapping;
2824
- });
2618
+ );
2825
2619
  const formSubmissionReducer = formSubmissionSlice.reducer;
2826
2620
  const formSubmissionAttachmentAdapter = createModelAdapter(
2827
2621
  (attachment) => attachment.offline_id
2828
2622
  );
2829
- const initialState$a = formSubmissionAttachmentAdapter.getInitialState({});
2623
+ const initialState$b = formSubmissionAttachmentAdapter.getInitialState({});
2830
2624
  const formSubmissionAttachmentSlice = createSlice({
2831
2625
  name: "formSubmissionAttachments",
2832
- initialState: initialState$a,
2833
- 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)),
2834
2628
  reducers: {
2835
2629
  initializeFormSubmissionAttachments: formSubmissionAttachmentAdapter.initialize,
2836
2630
  addFormSubmissionAttachment: formSubmissionAttachmentAdapter.addOne,
@@ -2869,11 +2663,11 @@ const formSubmissionAttachmentReducer = formSubmissionAttachmentSlice.reducer;
2869
2663
  const formRevisionAttachmentAdapter = createModelAdapter(
2870
2664
  (attachment) => attachment.offline_id
2871
2665
  );
2872
- const initialState$9 = formRevisionAttachmentAdapter.getInitialState({});
2666
+ const initialState$a = formRevisionAttachmentAdapter.getInitialState({});
2873
2667
  const formRevisionAttachmentSlice = createSlice({
2874
2668
  name: "formRevisionAttachments",
2875
- initialState: initialState$9,
2876
- 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)),
2877
2671
  reducers: {
2878
2672
  initializeFormRevisionAttachments: formRevisionAttachmentAdapter.initialize,
2879
2673
  addFormRevisionAttachment: formRevisionAttachmentAdapter.addOne,
@@ -2910,10 +2704,10 @@ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
2910
2704
  );
2911
2705
  const formRevisionAttachmentReducer = formRevisionAttachmentSlice.reducer;
2912
2706
  const emailDomainAdapter = createModelAdapter((emailDomain) => emailDomain.offline_id);
2913
- const initialState$8 = emailDomainAdapter.getInitialState({});
2707
+ const initialState$9 = emailDomainAdapter.getInitialState({});
2914
2708
  const emailDomainsSlice = createSlice({
2915
2709
  name: "emailDomains",
2916
- initialState: initialState$8,
2710
+ initialState: initialState$9,
2917
2711
  reducers: {
2918
2712
  initializeEmailDomains: emailDomainAdapter.initialize,
2919
2713
  addEmailDomain: emailDomainAdapter.addOne,
@@ -2932,14 +2726,14 @@ const selectEmailDomainsOfOrganization = restructureCreateSelectorWithArgs(
2932
2726
  )
2933
2727
  );
2934
2728
  const emailDomainsReducer = emailDomainsSlice.reducer;
2935
- const initialState$7 = {
2729
+ const initialState$8 = {
2936
2730
  documents: {}
2937
2731
  };
2938
2732
  const documentSlice = createSlice({
2939
2733
  name: "documents",
2940
- initialState: initialState$7,
2734
+ initialState: initialState$8,
2941
2735
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2942
- Object.assign(state, initialState$7);
2736
+ Object.assign(state, initialState$8);
2943
2737
  }),
2944
2738
  reducers: {
2945
2739
  setDocuments: (state, action) => {
@@ -3114,11 +2908,11 @@ const selectRootDocuments = createSelector(
3114
2908
  );
3115
2909
  const documentsReducer = documentSlice.reducer;
3116
2910
  const documentAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
3117
- const initialState$6 = documentAttachmentAdapter.getInitialState({});
2911
+ const initialState$7 = documentAttachmentAdapter.getInitialState({});
3118
2912
  const documentAttachmentSlice = createSlice({
3119
2913
  name: "documentAttachments",
3120
- initialState: initialState$6,
3121
- 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)),
3122
2916
  reducers: {
3123
2917
  initializeDocumentAttachments: documentAttachmentAdapter.initialize,
3124
2918
  addDocumentAttachment: documentAttachmentAdapter.addOne,
@@ -3177,11 +2971,11 @@ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
3177
2971
  );
3178
2972
  const documentAttachmentReducer = documentAttachmentSlice.reducer;
3179
2973
  const teamAdapter = createModelAdapter((team) => team.offline_id);
3180
- const initialState$5 = teamAdapter.getInitialState({});
2974
+ const initialState$6 = teamAdapter.getInitialState({});
3181
2975
  const teamSlice = createSlice({
3182
2976
  name: "teams",
3183
- initialState: initialState$5,
3184
- 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)),
3185
2979
  reducers: {
3186
2980
  setTeam: teamAdapter.setOne,
3187
2981
  setTeams: teamAdapter.initialize,
@@ -3215,11 +3009,11 @@ const teamReducer = teamSlice.reducer;
3215
3009
  const agentUserConversationAdapter = createModelAdapter(
3216
3010
  (conversation) => conversation.offline_id
3217
3011
  );
3218
- const initialState$4 = agentUserConversationAdapter.getInitialState({});
3012
+ const initialState$5 = agentUserConversationAdapter.getInitialState({});
3219
3013
  const agentsSlice = createSlice({
3220
3014
  name: "agents",
3221
- initialState: initialState$4,
3222
- 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)),
3223
3017
  reducers: {
3224
3018
  initializeConversations: agentUserConversationAdapter.initialize,
3225
3019
  addConversation: agentUserConversationAdapter.addOne,
@@ -3241,11 +3035,11 @@ const selectConversation = restructureCreateSelectorWithArgs(
3241
3035
  );
3242
3036
  const agentsReducer = agentsSlice.reducer;
3243
3037
  const issueCommentAdapter = createModelAdapter((comment) => comment.offline_id);
3244
- const initialState$3 = issueCommentAdapter.getInitialState({});
3038
+ const initialState$4 = issueCommentAdapter.getInitialState({});
3245
3039
  const issueCommentSlice = createSlice({
3246
3040
  name: "issueComments",
3247
- initialState: initialState$3,
3248
- 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)),
3249
3043
  reducers: {
3250
3044
  addIssueComment: issueCommentAdapter.addOne,
3251
3045
  addIssueComments: issueCommentAdapter.addMany,
@@ -3274,11 +3068,11 @@ const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
3274
3068
  );
3275
3069
  const issueCommentReducer = issueCommentSlice.reducer;
3276
3070
  const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
3277
- const initialState$2 = issueUpdateAdapter.getInitialState({});
3071
+ const initialState$3 = issueUpdateAdapter.getInitialState({});
3278
3072
  const issueUpdateSlice = createSlice({
3279
3073
  name: "issueUpdates",
3280
- initialState: initialState$2,
3281
- 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)),
3282
3076
  reducers: {
3283
3077
  initializeIssueUpdates: issueUpdateAdapter.setMany,
3284
3078
  setIssueUpdate: issueUpdateAdapter.setOne,
@@ -3307,11 +3101,11 @@ const selectIssueUpdatesOfIssue = restructureCreateSelectorWithArgs(
3307
3101
  );
3308
3102
  const issueUpdateReducer = issueUpdateSlice.reducer;
3309
3103
  const issueAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
3310
- const initialState$1 = issueAttachmentAdapter.getInitialState({});
3104
+ const initialState$2 = issueAttachmentAdapter.getInitialState({});
3311
3105
  const issueAttachmentSlice = createSlice({
3312
3106
  name: "issueAttachments",
3313
- initialState: initialState$1,
3314
- 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)),
3315
3109
  reducers: {
3316
3110
  initializeIssueAttachments: issueAttachmentAdapter.initialize,
3317
3111
  addIssueAttachment: issueAttachmentAdapter.addOne,
@@ -3369,15 +3163,59 @@ const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
3369
3163
  )
3370
3164
  );
3371
3165
  const issueAttachmentReducer = issueAttachmentSlice.reducer;
3372
- const initialState = {
3166
+ const initialState$1 = {
3373
3167
  version: 0
3374
3168
  };
3375
3169
  const versioningSlice = createSlice({
3376
3170
  name: "versioning",
3377
- initialState,
3171
+ initialState: initialState$1,
3378
3172
  reducers: {}
3379
3173
  });
3380
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;
3381
3219
  const fullAssetMarkerSize = 45;
3382
3220
  const DEFAULT_ISSUE_STATUS = IssueStatus.BACKLOG;
3383
3221
  const DEFAULT_ISSUE_PRIORITY = IssuePriority.MEDIUM;
@@ -3449,7 +3287,8 @@ const overmapReducers = {
3449
3287
  teamReducer,
3450
3288
  agentsReducer,
3451
3289
  issueCommentReducer,
3452
- issueUpdateReducer
3290
+ issueUpdateReducer,
3291
+ geoImageReducer
3453
3292
  };
3454
3293
  const overmapReducer = combineReducers(overmapReducers);
3455
3294
  const resetStore = "RESET";
@@ -4005,8 +3844,6 @@ class JWTService extends BaseAuthService {
4005
3844
  console.debug(this.constructor.name, "clearing auth;");
4006
3845
  this.dispatch(setLoggedIn(false));
4007
3846
  this.clearTokens();
4008
- this.dispatch(setActiveProjectId(null));
4009
- this.dispatch(setActiveWorkspaceId(null));
4010
3847
  this.dispatch({ type: RESET_STATE });
4011
3848
  this.dispatch({ type: resetStore });
4012
3849
  }
@@ -4503,13 +4340,13 @@ class AssetStageService extends BaseApiService {
4503
4340
  if (!stage) {
4504
4341
  throw new Error(`No asset stage with id ${stageId} found in the store`);
4505
4342
  }
4506
- this.dispatch(updateStage({ ...stage, user_form: formId }));
4343
+ this.dispatch(updateStage({ ...stage, form: formId }));
4507
4344
  try {
4508
4345
  await this.enqueueRequest({
4509
4346
  description: "Link asset stage to form",
4510
4347
  method: HttpMethod.POST,
4511
4348
  url: `/assets/stages/${stageId}/associate-with-form/`,
4512
- payload: { user_form: formId },
4349
+ payload: { form: formId },
4513
4350
  blockers: [stageId, formId],
4514
4351
  blocks: [stageId]
4515
4352
  });
@@ -4524,7 +4361,7 @@ class AssetStageService extends BaseApiService {
4524
4361
  if (!stage) {
4525
4362
  throw new Error(`No asset stage with id ${stageId} found in the store`);
4526
4363
  }
4527
- this.dispatch(updateStage({ ...stage, user_form: void 0 }));
4364
+ this.dispatch(updateStage({ ...stage, form: void 0 }));
4528
4365
  try {
4529
4366
  await this.enqueueRequest({
4530
4367
  description: "Unlink asset stage from form",
@@ -4549,39 +4386,7 @@ class AssetStageService extends BaseApiService {
4549
4386
  this.dispatch(initializeStages(result));
4550
4387
  }
4551
4388
  }
4552
- const AttachmentModelMeta = {
4553
- [AttachmentModel.Issue]: {
4554
- name: "issue",
4555
- attachUrlPrefix: "/issues",
4556
- deleteUrlPrefix: "/issues",
4557
- fetchUrlPostfix: "/issue-attachments"
4558
- },
4559
- [AttachmentModel.Asset]: {
4560
- name: "asset",
4561
- attachUrlPrefix: "/assets",
4562
- deleteUrlPrefix: "/assets",
4563
- fetchUrlPostfix: "/asset-attachments"
4564
- },
4565
- [AttachmentModel.AssetType]: {
4566
- name: "asset type",
4567
- attachUrlPrefix: "/assets/types",
4568
- deleteUrlPrefix: "/assets/types",
4569
- fetchUrlPostfix: "/asset-type-attachments"
4570
- },
4571
- [AttachmentModel.Project]: {
4572
- name: "project",
4573
- attachUrlPrefix: "/projects",
4574
- deleteUrlPrefix: "/projects",
4575
- fetchUrlPostfix: "/attachments"
4576
- },
4577
- [AttachmentModel.Document]: {
4578
- name: "document",
4579
- attachUrlPrefix: "/documents",
4580
- deleteUrlPrefix: "/documents",
4581
- fetchUrlPostfix: "/document-attachments"
4582
- }
4583
- };
4584
- class BaseAttachmentService extends BaseApiService {
4389
+ class BaseUploadService extends BaseApiService {
4585
4390
  getNumberOfAttachmentsWithSha1(sha1) {
4586
4391
  const {
4587
4392
  issueAttachmentReducer: issueAttachmentReducer2,
@@ -4589,8 +4394,9 @@ class BaseAttachmentService extends BaseApiService {
4589
4394
  assetTypeAttachmentReducer: assetTypeAttachmentReducer2,
4590
4395
  documentAttachmentReducer: documentAttachmentReducer2,
4591
4396
  projectAttachmentReducer: projectAttachmentReducer2,
4397
+ formRevisionAttachmentReducer: formRevisionAttachmentReducer2,
4592
4398
  formSubmissionAttachmentReducer: formSubmissionAttachmentReducer2,
4593
- formRevisionAttachmentReducer: formRevisionAttachmentReducer2
4399
+ geoImageReducer: geoImageReducer2
4594
4400
  } = this.client.store.getState();
4595
4401
  const objectsWithSha1 = [].concat(
4596
4402
  Object.values(issueAttachmentReducer2.instances),
@@ -4599,7 +4405,8 @@ class BaseAttachmentService extends BaseApiService {
4599
4405
  Object.values(documentAttachmentReducer2.instances),
4600
4406
  Object.values(projectAttachmentReducer2.instances),
4601
4407
  Object.values(formRevisionAttachmentReducer2.instances),
4602
- Object.values(formSubmissionAttachmentReducer2.instances)
4408
+ Object.values(formSubmissionAttachmentReducer2.instances),
4409
+ Object.values(geoImageReducer2.instances)
4603
4410
  );
4604
4411
  return objectsWithSha1.filter((object) => object.file_sha1 === sha1).length;
4605
4412
  }
@@ -4619,6 +4426,40 @@ class BaseAttachmentService extends BaseApiService {
4619
4426
  });
4620
4427
  }
4621
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 {
4622
4463
  async attachFiles(files, modelId, buildOfflineAttachment) {
4623
4464
  const { store } = this.client;
4624
4465
  const currentUser = store.getState().userReducer.currentUser;
@@ -4974,11 +4815,10 @@ class IssueService extends BaseApiService {
4974
4815
  // Basic CRUD functions
4975
4816
  // TODO: Once all models are represented in `Created<TModel>`, use `Created` in `OptimisticModelResult`, so we don't
4976
4817
  // have to repeat it for all optimistic model results (all optimistic results are created).
4977
- add(issue, issueType = null) {
4818
+ add(issue, workspaceId, issueType = null) {
4978
4819
  const { store } = this.client;
4979
4820
  const dateWithoutMilliseconds = /* @__PURE__ */ new Date();
4980
4821
  const state = store.getState();
4981
- const workspaceId = state.workspaceReducer.activeWorkspaceId;
4982
4822
  const currentUserId = state.userReducer.currentUser.id;
4983
4823
  dateWithoutMilliseconds.setMilliseconds(0);
4984
4824
  if (!workspaceId) {
@@ -5489,10 +5329,6 @@ class ProjectService extends BaseApiService {
5489
5329
  if (!project) {
5490
5330
  throw new Error("Expected project to exist");
5491
5331
  }
5492
- const activeProjectId = state.projectReducer.activeProjectId;
5493
- if (activeProjectId === projectId) {
5494
- this.dispatch({ type: "project/setActiveProjectId", payload: null });
5495
- }
5496
5332
  const filesToDelete = selectProjectFiles(state).filter((file) => file.project === projectId);
5497
5333
  this.dispatch(removeProjectFilesOfProject(project.id));
5498
5334
  const attachmentsOfProject = selectAttachmentsOfProject(project.id)(state);
@@ -5519,7 +5355,6 @@ class ProjectService extends BaseApiService {
5519
5355
  this.dispatch(setProjectAccesses(Object.values(projectAccesses)));
5520
5356
  this.dispatch(addOrReplaceProjectFiles(filesToDelete));
5521
5357
  this.dispatch(setProjectAttachments(attachmentsOfProject));
5522
- this.dispatch(setActiveProjectId(activeProjectId));
5523
5358
  this.dispatch({ type: "rehydrated/setRehydrated", payload: true });
5524
5359
  if (license) {
5525
5360
  this.dispatch(updateLicense({ ...license, project: project.id }));
@@ -5590,7 +5425,7 @@ const separateImageFromFields = async (fields) => {
5590
5425
  }
5591
5426
  return { fields: newFields, images };
5592
5427
  };
5593
- class UserFormService extends BaseApiService {
5428
+ class FormService extends BaseApiService {
5594
5429
  constructor() {
5595
5430
  super(...arguments);
5596
5431
  // Attach images to revision, after uploading them to S3
@@ -5909,7 +5744,7 @@ const separateFilesFromValues = (values) => {
5909
5744
  }
5910
5745
  return { values: newValues, files };
5911
5746
  };
5912
- class UserFormSubmissionService extends BaseApiService {
5747
+ class FormSubmissionService extends BaseUploadService {
5913
5748
  constructor() {
5914
5749
  super(...arguments);
5915
5750
  // Attach files to submission, after uploading them to S3
@@ -5990,7 +5825,6 @@ class UserFormSubmissionService extends BaseApiService {
5990
5825
  // TODO: adapt the support bulk adding to any model type
5991
5826
  async bulkAdd(args, batchSize) {
5992
5827
  const { formRevision, commonFieldValues, fieldValuesByAsset } = args;
5993
- const allFilesRecord = {};
5994
5828
  const { values: fileSeperatedCommonFieldValues, files: commonFiles } = separateFilesFromValues(commonFieldValues);
5995
5829
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5996
5830
  const transactionId = v4();
@@ -6032,7 +5866,6 @@ class UserFormSubmissionService extends BaseApiService {
6032
5866
  file_type: file.type,
6033
5867
  size: file.size
6034
5868
  };
6035
- allFilesRecord[sha1] = filePayload;
6036
5869
  filePaylods.push(filePayload);
6037
5870
  }
6038
5871
  return {
@@ -6068,22 +5901,7 @@ class UserFormSubmissionService extends BaseApiService {
6068
5901
  blocks
6069
5902
  });
6070
5903
  void promise.then(({ presigned_urls }) => {
6071
- for (const [sha1, presignedUrl] of Object.entries(presigned_urls)) {
6072
- const file = allFilesRecord[sha1];
6073
- if (!file)
6074
- continue;
6075
- void this.enqueueRequest({
6076
- url: presignedUrl.url,
6077
- description: "Upload file",
6078
- method: HttpMethod.POST,
6079
- isExternalUrl: true,
6080
- isAuthNeeded: false,
6081
- attachmentHash: sha1,
6082
- blockers: [`s3-${file.sha1}.${file.extension}`],
6083
- blocks: [sha1],
6084
- s3url: presignedUrl
6085
- });
6086
- }
5904
+ this.processPresignedUrls(presigned_urls);
6087
5905
  });
6088
5906
  prevBatchId = batchId;
6089
5907
  batchPromises.push(promise);
@@ -6554,7 +6372,7 @@ class OrganizationService extends BaseApiService {
6554
6372
  });
6555
6373
  }
6556
6374
  async update(organization) {
6557
- const promise = this.enqueueRequest({
6375
+ return this.enqueueRequest({
6558
6376
  description: "Edit organization",
6559
6377
  method: HttpMethod.PATCH,
6560
6378
  url: `/organizations/${organization.id}/`,
@@ -6562,10 +6380,6 @@ class OrganizationService extends BaseApiService {
6562
6380
  blockers: [`add-org-${organization.name}`, organization.id.toString()],
6563
6381
  blocks: [organization.id.toString()]
6564
6382
  });
6565
- return promise.then((result) => {
6566
- this.dispatch(updateActiveOrganization(organization));
6567
- return result;
6568
- });
6569
6383
  }
6570
6384
  async invite(organizationId, email) {
6571
6385
  return this.enqueueRequest({
@@ -7143,6 +6957,179 @@ class UserService extends BaseApiService {
7143
6957
  this.dispatch(setUsers(Object.values(usersRecord)));
7144
6958
  }
7145
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
+ }
7146
7133
  export {
7147
7134
  APIError,
7148
7135
  AgentService,
@@ -7166,7 +7153,10 @@ export {
7166
7153
  EmailDomainsService,
7167
7154
  EmailVerificationService,
7168
7155
  FileService,
7156
+ FormService,
7157
+ FormSubmissionService,
7169
7158
  GREEN,
7159
+ GeoImageService,
7170
7160
  HttpMethod,
7171
7161
  IssueAttachmentService,
7172
7162
  IssueCommentService,
@@ -7192,8 +7182,6 @@ export {
7192
7182
  ProjectFileService,
7193
7183
  ProjectService,
7194
7184
  TeamService,
7195
- UserFormService,
7196
- UserFormSubmissionService,
7197
7185
  UserService,
7198
7186
  VERSION_REDUCER_KEY,
7199
7187
  VerificationCodeType,
@@ -7228,6 +7216,8 @@ export {
7228
7216
  addFormSubmissionAttachments,
7229
7217
  addFormSubmissions,
7230
7218
  addForms,
7219
+ addGeoImage,
7220
+ addGeoImages,
7231
7221
  addIssue,
7232
7222
  addIssueAttachment,
7233
7223
  addIssueAttachments,
@@ -7303,6 +7293,8 @@ export {
7303
7293
  deleteFormSubmissionAttachment,
7304
7294
  deleteFormSubmissionAttachments,
7305
7295
  deleteFormSubmissions,
7296
+ deleteGeoImage,
7297
+ deleteGeoImages,
7306
7298
  deleteIssue,
7307
7299
  deleteIssueAttachment,
7308
7300
  deleteIssueAttachments,
@@ -7336,6 +7328,7 @@ export {
7336
7328
  fileReducer,
7337
7329
  fileSlice,
7338
7330
  fileToBlob,
7331
+ flipBounds,
7339
7332
  flipCoordinates,
7340
7333
  formReducer,
7341
7334
  formRevisionAttachmentReducer,
@@ -7350,6 +7343,8 @@ export {
7350
7343
  fullAssetMarkerSize,
7351
7344
  generateBadgeColors,
7352
7345
  genericMemo,
7346
+ geoImageReducer,
7347
+ geoImageSlice,
7353
7348
  getFileIdentifier,
7354
7349
  getFileS3Key,
7355
7350
  getLocalDateString,
@@ -7358,8 +7353,6 @@ export {
7358
7353
  getRenamedFile,
7359
7354
  getStageColor,
7360
7355
  hashFile,
7361
- hideAllCategories,
7362
- hideCategory,
7363
7356
  initSDK,
7364
7357
  initializeAssetAttachments,
7365
7358
  initializeAssetTypeAttachments,
@@ -7372,6 +7365,7 @@ export {
7372
7365
  initializeFormRevisionAttachments,
7373
7366
  initializeFormRevisions,
7374
7367
  initializeFormSubmissionAttachments,
7368
+ initializeGeoImages,
7375
7369
  initializeIssueAttachments,
7376
7370
  initializeIssueTypes,
7377
7371
  initializeIssueUpdates,
@@ -7444,18 +7438,12 @@ export {
7444
7438
  searchIssues,
7445
7439
  selectAccessToken,
7446
7440
  selectActiveLicense,
7447
- selectActiveOrganization,
7448
7441
  selectActiveOrganizationAccess,
7449
- selectActiveOrganizationId,
7450
- selectActiveOrganizationLicenses,
7451
- selectActiveOrganizationProjects,
7452
7442
  selectActiveProject,
7453
7443
  selectActiveProjectAccess,
7454
7444
  selectActiveProjectFileId,
7455
7445
  selectActiveProjectId,
7456
7446
  selectActiveStatusLicenses,
7457
- selectActiveWorkspace,
7458
- selectActiveWorkspaceId,
7459
7447
  selectAllDocumentAttachments,
7460
7448
  selectAllProjectAttachments,
7461
7449
  selectAncestorIdsOfDocument,
@@ -7492,7 +7480,6 @@ export {
7492
7480
  selectCategoriesOfWorkspace,
7493
7481
  selectCategoryById,
7494
7482
  selectCategoryMapping,
7495
- selectCategoryVisibility,
7496
7483
  selectCommentsOfIssue,
7497
7484
  selectCompletedStageIdsForAsset,
7498
7485
  selectCompletedStages,
@@ -7509,8 +7496,6 @@ export {
7509
7496
  selectEmailDomains,
7510
7497
  selectEmailDomainsAsMapping,
7511
7498
  selectEmailDomainsOfOrganization,
7512
- selectEnabledProjectFileMapping,
7513
- selectEnabledProjectFiles,
7514
7499
  selectFavouriteProjects,
7515
7500
  selectFilteredForms,
7516
7501
  selectForm,
@@ -7534,8 +7519,10 @@ export {
7534
7519
  selectFormsCount,
7535
7520
  selectFormsMapping,
7536
7521
  selectGeneralFormCount,
7537
- selectHiddenAssetTypeIds,
7538
- selectHiddenCategoryCount,
7522
+ selectGeoImageById,
7523
+ selectGeoImageMapping,
7524
+ selectGeoImages,
7525
+ selectGeoImagesOfProject,
7539
7526
  selectIsFetchingInitialData,
7540
7527
  selectIsImportingProjectFile,
7541
7528
  selectIsLoggedIn,
@@ -7552,7 +7539,6 @@ export {
7552
7539
  selectIssueTypesOfOrganization,
7553
7540
  selectIssueUpdateMapping,
7554
7541
  selectIssueUpdatesOfIssue,
7555
- selectIssues,
7556
7542
  selectIssuesOfIssueType,
7557
7543
  selectIssuesOfIssueTypeCount,
7558
7544
  selectLatestFormRevisionByForm,
@@ -7563,6 +7549,7 @@ export {
7563
7549
  selectLicenseForProject,
7564
7550
  selectLicenses,
7565
7551
  selectLicensesForProjectsMapping,
7552
+ selectLicensesOfOrganization,
7566
7553
  selectMainWorkspace,
7567
7554
  selectNumberOfAssetTypesMatchingCaseInsensitiveName,
7568
7555
  selectNumberOfAssetsOfAssetType,
@@ -7571,6 +7558,7 @@ export {
7571
7558
  selectOrganizationAccessForUser,
7572
7559
  selectOrganizationAccessUserMapping,
7573
7560
  selectOrganizationAccesses,
7561
+ selectOrganizationById,
7574
7562
  selectOrganizationUsersAsMapping,
7575
7563
  selectOrganizationUsersIds,
7576
7564
  selectOrganizations,
@@ -7585,21 +7573,21 @@ export {
7585
7573
  selectProjectAccesses,
7586
7574
  selectProjectAttachment,
7587
7575
  selectProjectAttachmentMapping,
7588
- selectProjectFileVisibility,
7576
+ selectProjectFileById,
7577
+ selectProjectFileMapping,
7589
7578
  selectProjectFiles,
7590
7579
  selectProjectUsersAsMapping,
7591
7580
  selectProjectUsersIds,
7592
7581
  selectProjects,
7582
+ selectProjectsOfOrganization,
7593
7583
  selectProjectsWithAccess,
7594
7584
  selectRecentIssueIds,
7595
7585
  selectRecentIssuesAsSearchResults,
7596
7586
  selectRehydrated,
7597
7587
  selectRootDocuments,
7598
7588
  selectSortedFormSubmissionsOfForm,
7599
- selectSortedOrganizationLicenses,
7600
7589
  selectSortedOrganizationUsers,
7601
7590
  selectSortedProjectUsers,
7602
- selectSortedProjects,
7603
7591
  selectStage,
7604
7592
  selectStageFormIdsFromStageIds,
7605
7593
  selectStageMapping,
@@ -7616,15 +7604,11 @@ export {
7616
7604
  selectUser,
7617
7605
  selectUserFormRevisionAttachmentsMapping,
7618
7606
  selectUsersAsMapping,
7619
- selectVisibleStatuses,
7620
- selectVisibleUserIds,
7621
- selectWorkspace,
7607
+ selectWorkspaceById,
7622
7608
  selectWorkspaceMapping,
7623
7609
  selectWorkspaces,
7624
- setActiveOrganizationId,
7625
7610
  setActiveProjectFileId,
7626
7611
  setActiveProjectId,
7627
- setActiveWorkspaceId,
7628
7612
  setAsset,
7629
7613
  setAssetAttachment,
7630
7614
  setAssetAttachments,
@@ -7645,6 +7629,8 @@ export {
7645
7629
  setFormSubmissionAttachments,
7646
7630
  setFormSubmissions,
7647
7631
  setForms,
7632
+ setGeoImage,
7633
+ setGeoImages,
7648
7634
  setIsFetchingInitialData,
7649
7635
  setIsImportingProjectFile,
7650
7636
  setIssueAttachment,
@@ -7660,7 +7646,6 @@ export {
7660
7646
  setProjectAccesses,
7661
7647
  setProjectAttachment,
7662
7648
  setProjectAttachments,
7663
- setProjectFileVisible,
7664
7649
  setProjects,
7665
7650
  setRehydrated,
7666
7651
  setStage,
@@ -7671,8 +7656,6 @@ export {
7671
7656
  setTourStep,
7672
7657
  setUploadUrl,
7673
7658
  setUsers,
7674
- setVisibleStatuses,
7675
- setVisibleUserIds,
7676
7659
  setWorkspaces,
7677
7660
  settingReducer,
7678
7661
  settingSlice,
@@ -7684,11 +7667,7 @@ export {
7684
7667
  teamSlice,
7685
7668
  toFileNameSafeString,
7686
7669
  toOfflineIdRecord,
7687
- toggleAssetTypeVisibility,
7688
7670
  truncate,
7689
- unhideAllCategories,
7690
- unhideCategory,
7691
- updateActiveOrganization,
7692
7671
  updateAsset,
7693
7672
  updateAssetAttachment,
7694
7673
  updateAssetAttachments,
@@ -7707,6 +7686,8 @@ export {
7707
7686
  updateFormSubmissionAttachment,
7708
7687
  updateFormSubmissionAttachments,
7709
7688
  updateFormSubmissions,
7689
+ updateGeoImage,
7690
+ updateGeoImages,
7710
7691
  updateIssue,
7711
7692
  updateIssueAttachment,
7712
7693
  updateIssueAttachments,