@overmap-ai/core 1.0.65-strip-workspace-access.1 → 1.0.65-strip-workspace-access.3

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.
@@ -1281,50 +1281,13 @@ const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
1281
1281
  )
1282
1282
  );
1283
1283
  const assetTypeAttachmentReducer = assetTypeAttachmentSlice.reducer;
1284
- const workspaceAdapter = createModelAdapter((workspace) => workspace.offline_id);
1285
- const initialState$t = workspaceAdapter.getInitialState({});
1286
- const workspaceSlice = createSlice({
1287
- name: "workspace",
1288
- initialState: initialState$t,
1289
- reducers: {
1290
- initializeWorkspaces: workspaceAdapter.initialize,
1291
- setWorkspaces: workspaceAdapter.setMany,
1292
- addWorkspace: workspaceAdapter.addOne,
1293
- updateWorkspace: workspaceAdapter.updateOne,
1294
- deleteWorkspace: workspaceAdapter.deleteOne
1295
- }
1296
- });
1297
- const { initializeWorkspaces, setWorkspaces, addWorkspace, updateWorkspace, deleteWorkspace } = workspaceSlice.actions;
1298
- const selectWorkspaceMapping = (state) => state.workspaceReducer.instances;
1299
- const selectWorkspaces = createSelector([selectWorkspaceMapping], (mapping) => Object.values(mapping));
1300
- const selectMainWorkspace = createSelector(
1301
- [selectWorkspaces],
1302
- (workspaces) => {
1303
- return workspaces.find((workspace) => workspace.name.toLowerCase() === "main");
1304
- }
1305
- );
1306
- const selectWorkspaceById = (id) => (state) => {
1307
- return state.workspaceReducer.instances[id];
1308
- };
1309
- const selectPermittedWorkspaceIds = createSelector(
1310
- [selectWorkspaceMapping],
1311
- (mapping) => {
1312
- return new Set(
1313
- Object.values(mapping).filter((workspace) => workspace.permitted).map((workspace) => workspace.offline_id)
1314
- );
1315
- }
1316
- );
1317
- const workspaceReducer = workspaceSlice.reducer;
1318
- const maxRecentIssues = 10;
1319
1284
  const issueAdapter = createModelAdapter((issue) => issue.offline_id);
1320
- const initialState$s = issueAdapter.getInitialState({
1321
- recentIssueIds: []
1322
- });
1285
+ const initialState$t = issueAdapter.getInitialState({});
1323
1286
  const issueSlice = createSlice({
1324
1287
  name: "issues",
1325
- initialState: initialState$s,
1288
+ initialState: initialState$t,
1326
1289
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1327
- Object.assign(state, initialState$s);
1290
+ Object.assign(state, initialState$t);
1328
1291
  }),
1329
1292
  reducers: {
1330
1293
  initializeIssues: issueAdapter.initialize,
@@ -1332,104 +1295,14 @@ const issueSlice = createSlice({
1332
1295
  addIssues: issueAdapter.addMany,
1333
1296
  updateIssue: issueAdapter.updateOne,
1334
1297
  deleteIssue: issueAdapter.deleteOne,
1335
- deleteIssues: issueAdapter.deleteMany,
1336
- cleanRecentIssues: (state) => {
1337
- state.recentIssueIds = state.recentIssueIds.filter((recentIssue) => state.instances[recentIssue.offlineId]);
1338
- },
1339
- addToRecentIssues: (state, action) => {
1340
- state.recentIssueIds = state.recentIssueIds.filter(
1341
- (recentIssue) => recentIssue.offlineId !== action.payload
1342
- );
1343
- state.recentIssueIds.push({ offlineId: action.payload.toLowerCase(), lastOpenedEpochTime: Date.now() });
1344
- if (state.recentIssueIds.length > maxRecentIssues) {
1345
- state.recentIssueIds.shift();
1346
- }
1347
- },
1348
- resetRecentIssues: (state) => {
1349
- state.recentIssueIds = [];
1350
- },
1351
- removeRecentIssue: (state, action) => {
1352
- const indexToRemove = state.recentIssueIds.findIndex((item) => {
1353
- return item.offlineId == action.payload;
1354
- });
1355
- if (indexToRemove !== -1) {
1356
- state.recentIssueIds.splice(indexToRemove, 1);
1357
- }
1358
- }
1298
+ deleteIssues: issueAdapter.deleteMany
1359
1299
  }
1360
1300
  });
1361
- const {
1362
- initializeIssues,
1363
- addIssue,
1364
- addIssues,
1365
- updateIssue,
1366
- deleteIssue,
1367
- deleteIssues,
1368
- addToRecentIssues,
1369
- cleanRecentIssues,
1370
- removeRecentIssue,
1371
- resetRecentIssues
1372
- } = issueSlice.actions;
1301
+ const { initializeIssues, addIssue, addIssues, updateIssue, deleteIssue, deleteIssues } = issueSlice.actions;
1373
1302
  const selectIssueMapping = (state) => state.issueReducer.instances;
1374
- const selectRecentIssueIds = (state) => state.issueReducer.recentIssueIds;
1375
1303
  const selectIssueById = (id) => (state) => {
1376
1304
  return state.issueReducer.instances[id];
1377
1305
  };
1378
- const searchIssues = restructureCreateSelectorWithArgs(
1379
- createSelector(
1380
- [selectIssueMapping, selectWorkspaceMapping, (_state, searchArgs) => searchArgs],
1381
- (mapping, workspaceMapping, searchArgs) => {
1382
- let searchTerm = searchArgs.searchTerm;
1383
- const maxResults = searchArgs.maxResults;
1384
- searchTerm = searchTerm.toLowerCase();
1385
- const ret = [];
1386
- const issues = Object.values(mapping);
1387
- let nbResults = 0;
1388
- for (const issue of issues) {
1389
- if (!issue.index_workspace) {
1390
- logOnlyOnce(
1391
- "issue-has-no-index-workspace",
1392
- issue.offline_id,
1393
- "warn",
1394
- `Issue ${issue.offline_id} has no index_workspace and cannot be searched.`
1395
- );
1396
- continue;
1397
- }
1398
- const workspace = workspaceMapping[issue.index_workspace];
1399
- if (!workspace) {
1400
- logOnlyOnce(
1401
- "issue-has-non-existent-index-workspace",
1402
- issue.offline_id,
1403
- "warn",
1404
- `Encountered issue with an index_workspace that doesn't exist. Issue ${issue.offline_id} has
1405
- index_workspace = ${issue.index_workspace}, which does not exist in:`,
1406
- Object.keys(workspaceMapping)
1407
- );
1408
- continue;
1409
- }
1410
- const workspaceAbbreviation = workspace.abbreviation;
1411
- if (!workspaceAbbreviation) {
1412
- logOnlyOnce(
1413
- "workspace-has-no-abbreviation",
1414
- workspace.offline_id,
1415
- "error",
1416
- `Workspace ${workspace.name} has no abbreviation. Not including any issues in search.`
1417
- );
1418
- continue;
1419
- }
1420
- const tag = "index" in issue ? `${workspaceAbbreviation.toUpperCase()}-${issue.index}` : null;
1421
- if ((issue.title || "").toLowerCase().includes(searchTerm) || tag && tag.toLowerCase().includes(searchTerm)) {
1422
- ret.push(issueToSearchResult(issue, tag));
1423
- nbResults++;
1424
- if (maxResults && nbResults >= maxResults) {
1425
- return ret;
1426
- }
1427
- }
1428
- }
1429
- return ret;
1430
- }
1431
- )
1432
- );
1433
1306
  const selectIssuesByIds = restructureCreateSelectorWithArgs(
1434
1307
  createSelector([selectIssueMapping, (_, issueIds) => issueIds], (issuesMapping, issueIds) => {
1435
1308
  const issues = [];
@@ -1444,48 +1317,14 @@ const selectIssuesByIds = restructureCreateSelectorWithArgs(
1444
1317
  return fallbackToEmptyArray(issues);
1445
1318
  })
1446
1319
  );
1447
- const selectRecentIssuesAsSearchResults = createSelector(
1448
- [selectIssueMapping, selectRecentIssueIds, selectWorkspaceMapping],
1449
- (issueMapping, recentIssueIds, workspaceMapping) => {
1450
- const ret = [];
1451
- for (const recentIssueResult of recentIssueIds) {
1452
- const issue = issueMapping[recentIssueResult.offlineId];
1453
- if (!issue) {
1454
- console.info("Recent issue no longer exists");
1455
- continue;
1456
- }
1457
- if ("index" in issue && issue.index_workspace) {
1458
- const indexWorkspace = workspaceMapping[issue.index_workspace];
1459
- if (!indexWorkspace) {
1460
- logOnlyOnce(
1461
- "issue-has-index-but-not-index-workspace",
1462
- issue.offline_id,
1463
- "warn",
1464
- `Issue ${issue.offline_id} has an index but no index_workspace. This may be because the
1465
- workspace has been deleted, but the new index has not been returned by the server yet. It will not
1466
- be included in search results.`
1467
- );
1468
- continue;
1469
- }
1470
- const workspaceTag = `${indexWorkspace.abbreviation}-${issue.index}`;
1471
- const searchResult = {
1472
- ...issueToSearchResult(issue, workspaceTag),
1473
- lastOpenedEpochTime: recentIssueResult.lastOpenedEpochTime
1474
- };
1475
- ret.push(searchResult);
1476
- }
1477
- }
1478
- return ret;
1479
- }
1480
- );
1481
1320
  const issueReducer = issueSlice.reducer;
1482
1321
  const issueTypeAdapter = createModelAdapter((issueType) => issueType.offline_id);
1483
- const initialState$r = issueTypeAdapter.getInitialState({});
1322
+ const initialState$s = issueTypeAdapter.getInitialState({});
1484
1323
  const issueTypeSlice = createSlice({
1485
1324
  name: "issueTypes",
1486
- initialState: initialState$r,
1325
+ initialState: initialState$s,
1487
1326
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1488
- Object.assign(state, initialState$r);
1327
+ Object.assign(state, initialState$s);
1489
1328
  }),
1490
1329
  reducers: {
1491
1330
  initializeIssueTypes: issueTypeAdapter.initialize,
@@ -1542,15 +1381,15 @@ const selectIssuesOfIssueTypeCount = (issueTypeId) => (state) => {
1542
1381
  return selectIssuesOfIssueType(issueTypeId)(state).length;
1543
1382
  };
1544
1383
  const issueTypeReducer = issueTypeSlice.reducer;
1545
- const initialState$q = {
1384
+ const initialState$r = {
1546
1385
  s3Urls: {}
1547
1386
  };
1548
1387
  const msPerHour = 1e3 * 60 * 60;
1549
1388
  const msPerWeek = msPerHour * 24 * 7;
1550
1389
  const fileSlice = createSlice({
1551
1390
  name: "file",
1552
- initialState: initialState$q,
1553
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1391
+ initialState: initialState$r,
1392
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1554
1393
  reducers: {
1555
1394
  setUploadUrl: (state, action) => {
1556
1395
  const { url, fields, sha1 } = action.payload;
@@ -1631,19 +1470,14 @@ var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
1631
1470
  LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
1632
1471
  return LicenseStatus2;
1633
1472
  })(LicenseStatus || {});
1634
- const initialState$p = {
1473
+ const initialState$q = {
1635
1474
  users: {},
1636
- currentUser: {
1637
- id: 0,
1638
- username: "",
1639
- email: "",
1640
- profile: { file: null, file_sha1: null, favourite_project_ids: [], tour_step: -1 }
1641
- }
1475
+ currentUser: null
1642
1476
  };
1643
1477
  const userSlice = createSlice({
1644
1478
  name: "users",
1645
- initialState: initialState$p,
1646
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1479
+ initialState: initialState$q,
1480
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1647
1481
  reducers: {
1648
1482
  setUsers: (state, action) => {
1649
1483
  const usersMapping = {};
@@ -1661,6 +1495,8 @@ const userSlice = createSlice({
1661
1495
  state.currentUser = action.payload;
1662
1496
  },
1663
1497
  setProfilePicture: (state, action) => {
1498
+ if (!state.currentUser)
1499
+ return;
1664
1500
  state.currentUser.profile.file = action.payload.file ?? null;
1665
1501
  state.currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
1666
1502
  const currentUser = state.users[state.currentUser.id];
@@ -1670,32 +1506,12 @@ const userSlice = createSlice({
1670
1506
  currentUser.profile.file = action.payload.file ?? null;
1671
1507
  currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
1672
1508
  },
1673
- addFavouriteProjectId: (state, action) => {
1674
- state.currentUser.profile.favourite_project_ids.push(action.payload);
1675
- },
1676
- removeFavouriteProjectId: (state, action) => {
1677
- state.currentUser.profile.favourite_project_ids = state.currentUser.profile.favourite_project_ids.filter(
1678
- (id) => id !== action.payload
1679
- );
1680
- },
1681
- setTourStep: (state, action) => {
1682
- state.currentUser.profile.tour_step = action.payload;
1683
- },
1684
1509
  removeUser: (state, action) => {
1685
1510
  delete state.users[action.payload];
1686
1511
  }
1687
1512
  }
1688
1513
  });
1689
- const {
1690
- setCurrentUser,
1691
- setProfilePicture,
1692
- setUsers,
1693
- addUsers,
1694
- addFavouriteProjectId,
1695
- removeFavouriteProjectId,
1696
- setTourStep,
1697
- removeUser
1698
- } = userSlice.actions;
1514
+ const { setCurrentUser, setProfilePicture, setUsers, addUsers, removeUser } = userSlice.actions;
1699
1515
  const userReducer = userSlice.reducer;
1700
1516
  const selectCurrentUser = (state) => state.userReducer.currentUser;
1701
1517
  const selectUsersMapping = (state) => state.userReducer.users;
@@ -1716,15 +1532,14 @@ const selectUsersByIds = restructureCreateSelectorWithArgs(
1716
1532
  return fallbackToEmptyArray(users);
1717
1533
  })
1718
1534
  );
1719
- const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
1720
1535
  const organizationAccessAdapter = createModelAdapter(
1721
1536
  (organizationAccess) => organizationAccess.offline_id
1722
1537
  );
1723
- const initialState$o = organizationAccessAdapter.getInitialState({});
1538
+ const initialState$p = organizationAccessAdapter.getInitialState({});
1724
1539
  const organizationAccessSlice = createSlice({
1725
1540
  name: "organizationAccess",
1726
- initialState: initialState$o,
1727
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1541
+ initialState: initialState$p,
1542
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1728
1543
  reducers: {
1729
1544
  initializeOrganizationAccesses: organizationAccessAdapter.initialize,
1730
1545
  updateOrganizationAccess: organizationAccessAdapter.updateOne,
@@ -1742,7 +1557,7 @@ const selectActiveOrganizationAccess = createSelector(
1742
1557
  [selectCurrentUser, selectOrganizationAccesses],
1743
1558
  (currentUser, organizationAccesses) => {
1744
1559
  const activeOrganizationAccess = Object.values(organizationAccesses).find(
1745
- (organizationAccess) => organizationAccess.user === currentUser.id
1560
+ (organizationAccess) => organizationAccess.user === (currentUser == null ? void 0 : currentUser.id)
1746
1561
  );
1747
1562
  return activeOrganizationAccess ?? null;
1748
1563
  }
@@ -1761,11 +1576,11 @@ const selectOrganizationAccessUserMapping = (state) => {
1761
1576
  };
1762
1577
  const organizationAccessReducer = organizationAccessSlice.reducer;
1763
1578
  const licenseAdapter = createModelAdapter((license) => license.offline_id);
1764
- const initialState$n = licenseAdapter.getInitialState({});
1579
+ const initialState$o = licenseAdapter.getInitialState({});
1765
1580
  const licenseSlice = createSlice({
1766
1581
  name: "license",
1767
- initialState: initialState$n,
1768
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1582
+ initialState: initialState$o,
1583
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1769
1584
  reducers: {
1770
1585
  initializeLicences: licenseAdapter.initialize,
1771
1586
  addLicenses: licenseAdapter.addMany,
@@ -1790,11 +1605,11 @@ const selectLicensesForProjectsMapping = createSelector(
1790
1605
  );
1791
1606
  const licenseReducer = licenseSlice.reducer;
1792
1607
  const projectAccessAdapter = createModelAdapter((projectAccess) => projectAccess.offline_id);
1793
- const initialState$m = projectAccessAdapter.getInitialState({});
1608
+ const initialState$n = projectAccessAdapter.getInitialState({});
1794
1609
  const projectAccessSlice = createSlice({
1795
1610
  name: "projectAccess",
1796
- initialState: initialState$m,
1797
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1611
+ initialState: initialState$n,
1612
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1798
1613
  reducers: {
1799
1614
  initializeProjectAccesses: projectAccessAdapter.initialize,
1800
1615
  updateProjectAccess: projectAccessAdapter.updateOne,
@@ -1819,7 +1634,7 @@ const selectActiveProjectAccess = (state) => {
1819
1634
  const currentUser = state.userReducer.currentUser;
1820
1635
  const activeProjectId = state.projectReducer.activeProjectId;
1821
1636
  return Object.values(state.projectAccessReducer.instances).find((projectAccess) => {
1822
- return projectAccess.user === currentUser.id && projectAccess.project === activeProjectId;
1637
+ return projectAccess.user === (currentUser == null ? void 0 : currentUser.id) && projectAccess.project === activeProjectId;
1823
1638
  }) ?? null;
1824
1639
  };
1825
1640
  const selectProjectAccessForUser = (user) => (state) => {
@@ -1835,14 +1650,14 @@ const selectProjectAccessUserMapping = (state) => {
1835
1650
  return projectAccesses;
1836
1651
  };
1837
1652
  const projectAccessReducer = projectAccessSlice.reducer;
1838
- const initialState$l = {
1653
+ const initialState$m = {
1839
1654
  projects: {},
1840
1655
  activeProjectId: null
1841
1656
  };
1842
1657
  const projectSlice = createSlice({
1843
1658
  name: "projects",
1844
- initialState: initialState$l,
1845
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1659
+ initialState: initialState$m,
1660
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1846
1661
  reducers: {
1847
1662
  setProjects: (state, action) => {
1848
1663
  const projectsMap = {};
@@ -1932,9 +1747,9 @@ const selectSortedProjectUsers = createSelector(
1932
1747
  [selectCurrentUser, selectProjectUsersAsMapping, selectProjectAccessUserMapping],
1933
1748
  (currentUser, userMapping, projectAccessMapping) => {
1934
1749
  return Object.values(userMapping).sort((userA, userB) => {
1935
- if (userA.id === currentUser.id) {
1750
+ if (userA.id === (currentUser == null ? void 0 : currentUser.id)) {
1936
1751
  return -1;
1937
- } else if (userB.id === currentUser.id) {
1752
+ } else if (userB.id === (currentUser == null ? void 0 : currentUser.id)) {
1938
1753
  return 1;
1939
1754
  }
1940
1755
  const projectAccessesA = projectAccessMapping[userA.id];
@@ -1949,13 +1764,13 @@ const selectSortedProjectUsers = createSelector(
1949
1764
  });
1950
1765
  }
1951
1766
  );
1952
- const initialState$k = {
1767
+ const initialState$l = {
1953
1768
  organizations: {}
1954
1769
  };
1955
1770
  const organizationSlice = createSlice({
1956
1771
  name: "organizations",
1957
- initialState: initialState$k,
1958
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1772
+ initialState: initialState$l,
1773
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1959
1774
  reducers: {
1960
1775
  setOrganizations: (state, action) => {
1961
1776
  for (const org of action.payload) {
@@ -2011,9 +1826,9 @@ const selectSortedOrganizationUsers = createSelector(
2011
1826
  [selectCurrentUser, selectOrganizationUsersAsMapping, selectOrganizationAccessUserMapping],
2012
1827
  (currentUser, userMapping, organizationAccessMapping) => {
2013
1828
  return Object.values(userMapping).sort((userA, userB) => {
2014
- if (userA.id === currentUser.id) {
1829
+ if (userA.id === (currentUser == null ? void 0 : currentUser.id)) {
2015
1830
  return -1;
2016
- } else if (userB.id === currentUser.id) {
1831
+ } else if (userB.id === (currentUser == null ? void 0 : currentUser.id)) {
2017
1832
  return 1;
2018
1833
  }
2019
1834
  const organizationAccessesA = organizationAccessMapping[userA.id];
@@ -2046,14 +1861,14 @@ const createOfflineAction = (request2, baseUrl, serviceName) => {
2046
1861
  }
2047
1862
  };
2048
1863
  };
2049
- const initialState$j = {
1864
+ const initialState$k = {
2050
1865
  deletedRequests: [],
2051
1866
  latestRetryTime: 0
2052
1867
  };
2053
1868
  const outboxSlice = createSlice({
2054
1869
  name: "outbox",
2055
- initialState: initialState$j,
2056
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1870
+ initialState: initialState$k,
1871
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
2057
1872
  reducers: {
2058
1873
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
2059
1874
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -2085,15 +1900,15 @@ const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
2085
1900
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
2086
1901
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
2087
1902
  const outboxReducer = outboxSlice.reducer;
2088
- const initialState$i = {
1903
+ const initialState$j = {
2089
1904
  projectFiles: {},
2090
1905
  activeProjectFileId: null,
2091
1906
  isImportingProjectFile: false
2092
1907
  };
2093
1908
  const projectFileSlice = createSlice({
2094
1909
  name: "projectFiles",
2095
- initialState: initialState$i,
2096
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1910
+ initialState: initialState$j,
1911
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
2097
1912
  reducers: {
2098
1913
  addOrReplaceProjectFiles: (state, action) => {
2099
1914
  for (let fileObj of action.payload) {
@@ -2180,11 +1995,11 @@ const selectProjectFileById = (id) => (state) => {
2180
1995
  };
2181
1996
  const projectFileReducer = projectFileSlice.reducer;
2182
1997
  const projectAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2183
- const initialState$h = projectAttachmentAdapter.getInitialState({});
1998
+ const initialState$i = projectAttachmentAdapter.getInitialState({});
2184
1999
  const projectAttachmentSlice = createSlice({
2185
2000
  name: "projectAttachments",
2186
- initialState: initialState$h,
2187
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2001
+ initialState: initialState$i,
2002
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2188
2003
  reducers: {
2189
2004
  initializeProjectAttachments: projectAttachmentAdapter.initialize,
2190
2005
  addProjectAttachment: projectAttachmentAdapter.addOne,
@@ -2239,12 +2054,12 @@ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
2239
2054
  )
2240
2055
  );
2241
2056
  const projectAttachmentReducer = projectAttachmentSlice.reducer;
2242
- const initialState$g = {
2057
+ const initialState$h = {
2243
2058
  isRehydrated: false
2244
2059
  };
2245
2060
  const rehydratedSlice = createSlice({
2246
2061
  name: "rehydrated",
2247
- initialState: initialState$g,
2062
+ initialState: initialState$h,
2248
2063
  // The `reducers` field lets us define reducers and generate associated actions
2249
2064
  reducers: {
2250
2065
  setRehydrated: (state, action) => {
@@ -2269,11 +2084,11 @@ const formRevisionSortFn = (formRevisionA, formRevisionB) => {
2269
2084
  }
2270
2085
  };
2271
2086
  const formRevisionAdapter = createModelAdapter((revision) => revision.offline_id);
2272
- const initialState$f = formRevisionAdapter.getInitialState({});
2087
+ const initialState$g = formRevisionAdapter.getInitialState({});
2273
2088
  const formRevisionsSlice = createSlice({
2274
2089
  name: "formRevisions",
2275
- initialState: initialState$f,
2276
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2090
+ initialState: initialState$g,
2091
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2277
2092
  reducers: {
2278
2093
  initializeFormRevisions: formRevisionAdapter.initialize,
2279
2094
  setFormRevision: formRevisionAdapter.setOne,
@@ -2345,11 +2160,11 @@ const selectLatestFormRevisionByForm = createSelector([selectFormRevisionMapping
2345
2160
  });
2346
2161
  const formRevisionReducer = formRevisionsSlice.reducer;
2347
2162
  const formAdapter = createModelAdapter((form) => form.offline_id);
2348
- const initialState$e = formAdapter.getInitialState({});
2163
+ const initialState$f = formAdapter.getInitialState({});
2349
2164
  const formSlice = createSlice({
2350
2165
  name: "forms",
2351
- initialState: initialState$e,
2352
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2166
+ initialState: initialState$f,
2167
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2353
2168
  reducers: {
2354
2169
  initializeForms: formAdapter.initialize,
2355
2170
  setForm: formAdapter.setOne,
@@ -2383,7 +2198,7 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
2383
2198
  }
2384
2199
  const latestRevision = _selectLatestFormRevision(revisions, formId);
2385
2200
  if (latestRevision.title.toLowerCase().includes(searchTerm.toLowerCase())) {
2386
- regularMatches.push({ ...form, latestRevision });
2201
+ regularMatches.push(form);
2387
2202
  }
2388
2203
  }
2389
2204
  return [...regularMatches.slice(0, maxResults)];
@@ -2418,11 +2233,11 @@ const selectGeneralFormCount = createSelector([selectFormMapping], (formsMapping
2418
2233
  return Object.values(formsMapping).filter((form) => !form.asset_type).length;
2419
2234
  });
2420
2235
  const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
2421
- const initialState$d = submissionAdapter.getInitialState({});
2236
+ const initialState$e = submissionAdapter.getInitialState({});
2422
2237
  const formSubmissionSlice = createSlice({
2423
2238
  name: "formSubmissions",
2424
- initialState: initialState$d,
2425
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2239
+ initialState: initialState$e,
2240
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2426
2241
  reducers: {
2427
2242
  initializeFormSubmissions: submissionAdapter.initialize,
2428
2243
  setFormSubmission: submissionAdapter.setOne,
@@ -2634,11 +2449,11 @@ const formSubmissionReducer = formSubmissionSlice.reducer;
2634
2449
  const formSubmissionAttachmentAdapter = createModelAdapter(
2635
2450
  (attachment) => attachment.offline_id
2636
2451
  );
2637
- const initialState$c = formSubmissionAttachmentAdapter.getInitialState({});
2452
+ const initialState$d = formSubmissionAttachmentAdapter.getInitialState({});
2638
2453
  const formSubmissionAttachmentSlice = createSlice({
2639
2454
  name: "formSubmissionAttachments",
2640
- initialState: initialState$c,
2641
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2455
+ initialState: initialState$d,
2456
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2642
2457
  reducers: {
2643
2458
  initializeFormSubmissionAttachments: formSubmissionAttachmentAdapter.initialize,
2644
2459
  addFormSubmissionAttachment: formSubmissionAttachmentAdapter.addOne,
@@ -2690,11 +2505,11 @@ const formSubmissionAttachmentReducer = formSubmissionAttachmentSlice.reducer;
2690
2505
  const formRevisionAttachmentAdapter = createModelAdapter(
2691
2506
  (attachment) => attachment.offline_id
2692
2507
  );
2693
- const initialState$b = formRevisionAttachmentAdapter.getInitialState({});
2508
+ const initialState$c = formRevisionAttachmentAdapter.getInitialState({});
2694
2509
  const formRevisionAttachmentSlice = createSlice({
2695
2510
  name: "formRevisionAttachments",
2696
- initialState: initialState$b,
2697
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2511
+ initialState: initialState$c,
2512
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2698
2513
  reducers: {
2699
2514
  initializeFormRevisionAttachments: formRevisionAttachmentAdapter.initialize,
2700
2515
  addFormRevisionAttachment: formRevisionAttachmentAdapter.addOne,
@@ -2732,6 +2547,40 @@ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
2732
2547
  )
2733
2548
  );
2734
2549
  const formRevisionAttachmentReducer = formRevisionAttachmentSlice.reducer;
2550
+ const workspaceAdapter = createModelAdapter((workspace) => workspace.offline_id);
2551
+ const initialState$b = workspaceAdapter.getInitialState({});
2552
+ const workspaceSlice = createSlice({
2553
+ name: "workspace",
2554
+ initialState: initialState$b,
2555
+ reducers: {
2556
+ initializeWorkspaces: workspaceAdapter.initialize,
2557
+ setWorkspaces: workspaceAdapter.setMany,
2558
+ addWorkspace: workspaceAdapter.addOne,
2559
+ updateWorkspace: workspaceAdapter.updateOne,
2560
+ deleteWorkspace: workspaceAdapter.deleteOne
2561
+ }
2562
+ });
2563
+ const { initializeWorkspaces, setWorkspaces, addWorkspace, updateWorkspace, deleteWorkspace } = workspaceSlice.actions;
2564
+ const selectWorkspaceMapping = (state) => state.workspaceReducer.instances;
2565
+ const selectWorkspaces = createSelector([selectWorkspaceMapping], (mapping) => Object.values(mapping));
2566
+ const selectMainWorkspace = createSelector(
2567
+ [selectWorkspaces],
2568
+ (workspaces) => {
2569
+ return workspaces.find((workspace) => workspace.name.toLowerCase() === "main");
2570
+ }
2571
+ );
2572
+ const selectWorkspaceById = (id) => (state) => {
2573
+ return state.workspaceReducer.instances[id];
2574
+ };
2575
+ const selectPermittedWorkspaceIds = createSelector(
2576
+ [selectWorkspaceMapping],
2577
+ (mapping) => {
2578
+ return new Set(
2579
+ Object.values(mapping).filter((workspace) => workspace.permitted).map((workspace) => workspace.offline_id)
2580
+ );
2581
+ }
2582
+ );
2583
+ const workspaceReducer = workspaceSlice.reducer;
2735
2584
  const emailDomainAdapter = createModelAdapter((emailDomain) => emailDomain.offline_id);
2736
2585
  const initialState$a = emailDomainAdapter.getInitialState({});
2737
2586
  const emailDomainsSlice = createSlice({
@@ -3120,13 +2969,13 @@ const {
3120
2969
  deleteIssueComments
3121
2970
  } = issueCommentSlice.actions;
3122
2971
  const selectIssueCommentMapping = (state) => state.issueCommentReducer.instances;
2972
+ const selectIssueCommentById = (id) => (state) => {
2973
+ return state.issueCommentReducer.instances[id];
2974
+ };
3123
2975
  const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
3124
- createSelector(
3125
- [selectIssueCommentMapping, (_state, issueId) => issueId],
3126
- (commentMapping, issueId) => {
3127
- return fallbackToEmptyArray(Object.values(commentMapping).filter((comment) => comment.issue === issueId));
3128
- }
3129
- )
2976
+ createSelector([selectIssueCommentMapping, (_state, issueId) => issueId], (commentMapping, issueId) => {
2977
+ return fallbackToEmptyArray(Object.values(commentMapping).filter((comment) => comment.issue === issueId));
2978
+ })
3130
2979
  );
3131
2980
  const issueCommentReducer = issueCommentSlice.reducer;
3132
2981
  const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
@@ -4036,15 +3885,15 @@ class BaseApiService extends BaseService {
4036
3885
  }
4037
3886
  }
4038
3887
  class CategoryService extends BaseApiService {
4039
- add(payload, workspaceId) {
3888
+ add(payload) {
3889
+ var _a2;
4040
3890
  const { store } = this.client;
4041
- const createdBy = store.getState().userReducer.currentUser.id;
3891
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
4042
3892
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4043
3893
  const offlineCategory = offline({
4044
3894
  ...payload,
4045
3895
  created_by: createdBy,
4046
- submitted_at: submittedAt,
4047
- workspace: workspaceId
3896
+ submitted_at: submittedAt
4048
3897
  });
4049
3898
  this.dispatch(addCategory(offlineCategory));
4050
3899
  const promise = this.enqueueRequest({
@@ -4052,48 +3901,50 @@ class CategoryService extends BaseApiService {
4052
3901
  method: HttpMethod.POST,
4053
3902
  url: "/categories/",
4054
3903
  queryParams: {
4055
- workspace_id: workspaceId.toString()
3904
+ workspace_id: payload.workspace.toString()
4056
3905
  },
4057
3906
  payload: offlineCategory,
4058
- blockers: [workspaceId],
3907
+ blockers: [payload.workspace],
4059
3908
  blocks: [offlineCategory.offline_id]
4060
3909
  });
4061
3910
  return [offlineCategory, promise];
4062
3911
  }
4063
- update(category, workspaceId) {
3912
+ update(payload) {
4064
3913
  const state = this.client.store.getState();
4065
- const existingCategory = selectCategoryById(category.offline_id)(state);
3914
+ const existingCategory = selectCategoryById(payload.offline_id)(state);
4066
3915
  if (!existingCategory) {
4067
- throw new Error(`Expected an existing category with offline_id ${category.offline_id}`);
3916
+ throw new Error(`Expected an existing category with offline_id ${payload.offline_id}`);
4068
3917
  }
4069
- const optimisticCategory = { ...existingCategory, ...category };
3918
+ const optimisticCategory = { ...existingCategory, ...payload };
4070
3919
  this.dispatch(updateCategory(optimisticCategory));
4071
3920
  const promise = this.enqueueRequest({
4072
3921
  description: "Edit Category",
4073
3922
  method: HttpMethod.PATCH,
4074
- url: `/categories/${category.offline_id}/`,
4075
- queryParams: {
4076
- workspace_id: workspaceId.toString()
4077
- },
4078
- payload: category,
4079
- blockers: [category.offline_id],
4080
- blocks: [category.offline_id]
3923
+ url: `/categories/${payload.offline_id}/`,
3924
+ payload,
3925
+ blockers: [payload.offline_id],
3926
+ blocks: [payload.offline_id]
4081
3927
  });
4082
3928
  return [optimisticCategory, promise];
4083
3929
  }
4084
- remove(category, workspaceId) {
4085
- this.dispatch(deleteCategory(category.offline_id));
4086
- return this.enqueueRequest({
3930
+ remove(id) {
3931
+ const { store } = this.client;
3932
+ const category = selectCategoryById(id)(store.getState());
3933
+ if (!category) {
3934
+ throw new Error(`No category with id ${id} found in the store`);
3935
+ }
3936
+ this.dispatch(deleteCategory(id));
3937
+ const promise = this.enqueueRequest({
4087
3938
  description: "Delete Category",
4088
3939
  method: HttpMethod.DELETE,
4089
3940
  url: `/categories/${category.offline_id}/`,
4090
- // TODO: Shouldn't be necessary to specify workspace_id here
4091
- queryParams: {
4092
- workspace_id: workspaceId.toString()
4093
- },
4094
3941
  blockers: [category.offline_id],
4095
3942
  blocks: []
4096
3943
  });
3944
+ promise.catch(() => {
3945
+ this.dispatch(addCategory(category));
3946
+ });
3947
+ return promise;
4097
3948
  }
4098
3949
  async refreshStore(projectId) {
4099
3950
  const result = await this.enqueueRequest({
@@ -4547,8 +4398,9 @@ const AttachmentModelMeta = {
4547
4398
  };
4548
4399
  class BaseAttachmentService extends BaseUploadService {
4549
4400
  async attachFiles(files, modelId, buildOfflineAttachment) {
4401
+ var _a2;
4550
4402
  const { store } = this.client;
4551
- const currentUser = store.getState().userReducer.currentUser;
4403
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
4552
4404
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4553
4405
  const offlineAttachments = [];
4554
4406
  const attachmentPayloads = [];
@@ -4568,7 +4420,7 @@ class BaseAttachmentService extends BaseUploadService {
4568
4420
  file,
4569
4421
  sha1,
4570
4422
  submittedAt,
4571
- createdBy: currentUser.id,
4423
+ createdBy,
4572
4424
  description: "",
4573
4425
  modelId
4574
4426
  });
@@ -4772,21 +4624,21 @@ class AssetTypeAttachmentService extends BaseAttachmentService {
4772
4624
  }
4773
4625
  }
4774
4626
  class IssueCommentService extends BaseApiService {
4775
- // Omit author and submitted_at since these will always be set internally
4776
- add(comment) {
4627
+ add(payload) {
4628
+ var _a2;
4777
4629
  const { store } = this.client;
4778
4630
  const offlineComment = offline({
4779
- ...comment,
4780
- author: store.getState().userReducer.currentUser.id,
4631
+ ...payload,
4632
+ author: (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id,
4781
4633
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
4782
4634
  });
4783
4635
  this.dispatch(addIssueComment(offlineComment));
4784
4636
  const promise = this.enqueueRequest({
4785
- description: `${truncate(comment.content, 80)}`,
4637
+ description: "Add issue comment",
4786
4638
  method: HttpMethod.POST,
4787
- url: `/issues/${comment.issue}/comment/`,
4639
+ url: `/issues/${payload.issue}/comment/`,
4788
4640
  payload: offlineComment,
4789
- blockers: [comment.issue],
4641
+ blockers: [payload.issue],
4790
4642
  blocks: [offlineComment.offline_id]
4791
4643
  });
4792
4644
  promise.catch(() => {
@@ -4794,37 +4646,41 @@ class IssueCommentService extends BaseApiService {
4794
4646
  });
4795
4647
  return [offlineComment, promise];
4796
4648
  }
4797
- update(comment) {
4649
+ update(payload) {
4798
4650
  const { store } = this.client;
4799
- const commentToUpdate = store.getState().issueCommentReducer.instances[comment.offline_id];
4651
+ const commentToUpdate = selectIssueCommentById(payload.offline_id)(store.getState());
4800
4652
  if (!commentToUpdate) {
4801
- throw new Error(`Comment with offline_id ${comment.offline_id} not found in store`);
4653
+ throw new Error(`Comment with offline_id ${payload.offline_id} not found in store`);
4802
4654
  }
4803
- this.dispatch(setIssueComment(comment));
4655
+ const updatedComment = {
4656
+ ...commentToUpdate,
4657
+ ...payload
4658
+ };
4659
+ this.dispatch(setIssueComment(updatedComment));
4804
4660
  const promise = this.enqueueRequest({
4805
- description: `Edit comment: ${truncate(comment.content, 80)}`,
4661
+ description: "Edit issue comment",
4806
4662
  method: HttpMethod.PATCH,
4807
- url: `/issues/comments/${comment.offline_id}/`,
4808
- payload: comment,
4809
- blockers: [comment.issue],
4810
- blocks: [comment.offline_id]
4663
+ url: `/issues/comments/${payload.offline_id}/`,
4664
+ payload,
4665
+ blockers: [payload.offline_id],
4666
+ blocks: [payload.offline_id]
4811
4667
  });
4812
4668
  promise.catch(() => {
4813
4669
  this.dispatch(setIssueComment(commentToUpdate));
4814
4670
  });
4815
- return [comment, promise];
4671
+ return [updatedComment, promise];
4816
4672
  }
4817
- remove(offline_id) {
4818
- const commentToRemove = this.client.store.getState().issueCommentReducer.instances[offline_id];
4673
+ remove(id) {
4674
+ const commentToRemove = this.client.store.getState().issueCommentReducer.instances[id];
4819
4675
  if (!commentToRemove) {
4820
- throw new Error(`Comment with offline_id ${offline_id} not found in store`);
4676
+ throw new Error(`Comment with offline_id ${id} not found in store`);
4821
4677
  }
4822
- this.dispatch(deleteIssueComment(offline_id));
4678
+ this.dispatch(deleteIssueComment(id));
4823
4679
  const promise = this.enqueueRequest({
4824
4680
  description: "Delete comment",
4825
4681
  method: HttpMethod.DELETE,
4826
- url: `/issues/comments/${offline_id}/`,
4827
- blockers: [offline_id],
4682
+ url: `/issues/comments/${id}/`,
4683
+ blockers: [id],
4828
4684
  blocks: []
4829
4685
  });
4830
4686
  promise.catch(() => {
@@ -4897,67 +4753,59 @@ class IssueAttachmentService extends BaseAttachmentService {
4897
4753
  }
4898
4754
  class IssueService extends BaseApiService {
4899
4755
  // Basic CRUD functions
4900
- // TODO: Once all models are represented in `Created<TModel>`, use `Created` in `OptimisticModelResult`, so we don't
4901
- // have to repeat it for all optimistic model results (all optimistic results are created).
4902
- add(issue, workspaceId, issueType = null) {
4756
+ add(payload) {
4757
+ var _a2;
4903
4758
  const { store } = this.client;
4904
- const dateWithoutMilliseconds = /* @__PURE__ */ new Date();
4905
4759
  const state = store.getState();
4906
- const currentUserId = state.userReducer.currentUser.id;
4907
- dateWithoutMilliseconds.setMilliseconds(0);
4908
- if (!workspaceId) {
4909
- throw new Error("No active workspace ID while creating issue.");
4910
- }
4911
- const issuePayload = offline({
4912
- ...issue,
4913
- submitted_at: dateWithoutMilliseconds.toISOString(),
4914
- index_workspace: workspaceId,
4915
- created_by: currentUserId,
4916
- status: issue.status ?? DEFAULT_ISSUE_STATUS,
4917
- priority: issue.priority ?? DEFAULT_ISSUE_PRIORITY
4918
- });
4919
- this.dispatch(addIssue(issuePayload));
4920
- this.dispatch(addToRecentIssues(issuePayload.offline_id));
4760
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4761
+ const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
4762
+ const offlineIssue = offline({
4763
+ ...payload,
4764
+ submitted_at: submittedAt,
4765
+ created_by: createdBy
4766
+ });
4767
+ this.dispatch(addIssue(offlineIssue));
4921
4768
  this.dispatch(addActiveProjectIssuesCount(1));
4922
4769
  const promise = this.enqueueRequest({
4923
4770
  description: "Create issue",
4924
4771
  method: HttpMethod.POST,
4925
4772
  url: "/issues/",
4926
4773
  queryParams: {
4927
- workspace_id: workspaceId,
4928
- ...issueType ? { issue_type: issueType } : {}
4774
+ workspace_id: payload.index_workspace,
4775
+ ...payload.issue_type ? { issue_type: payload.issue_type } : {}
4929
4776
  },
4930
- payload: issuePayload,
4931
- blockers: ["add-issue", ...issuePayload.index_workspace ? [issuePayload.index_workspace] : []],
4932
- blocks: [issuePayload.offline_id]
4777
+ payload: offlineIssue,
4778
+ blockers: ["add-issue", ...offlineIssue.index_workspace ? [offlineIssue.index_workspace] : []],
4779
+ blocks: [offlineIssue.offline_id]
4933
4780
  });
4934
4781
  void promise.then((result) => {
4935
4782
  this.dispatch(updateIssue(result));
4936
4783
  }).catch((error) => {
4937
- var _a2;
4784
+ var _a3;
4938
4785
  console.error(error);
4939
4786
  if (error instanceof APIError) {
4940
- (_a2 = unsafeShowToast) == null ? void 0 : _a2({
4787
+ (_a3 = unsafeShowToast) == null ? void 0 : _a3({
4941
4788
  title: "Could not create issue",
4942
4789
  description: error.message,
4943
4790
  accentColor: "red"
4944
4791
  });
4945
4792
  }
4946
- this.dispatch(deleteIssue(issuePayload.offline_id));
4793
+ this.dispatch(deleteIssue(offlineIssue.offline_id));
4947
4794
  this.dispatch(addActiveProjectIssuesCount(-1));
4948
4795
  throw error;
4949
4796
  });
4950
- return [issuePayload, promise];
4797
+ return [offlineIssue, promise];
4951
4798
  }
4952
- update(issue) {
4799
+ update(payload) {
4800
+ var _a2;
4953
4801
  const state = this.client.store.getState();
4954
- const issueToBeUpdated = selectIssueById(issue.offline_id)(state);
4802
+ const issueToBeUpdated = selectIssueById(payload.offline_id)(state);
4955
4803
  if (!issueToBeUpdated) {
4956
4804
  throw new Error(
4957
- `Attempting to update an issue with offline_id ${issue.offline_id} that doesn't exist in the store`
4805
+ `Attempting to update an issue with offline_id ${payload.offline_id} that doesn't exist in the store`
4958
4806
  );
4959
4807
  }
4960
- const updatedIssue = { ...issueToBeUpdated, ...issue };
4808
+ const updatedIssue = { ...issueToBeUpdated, ...payload };
4961
4809
  this.dispatch(updateIssue(updatedIssue));
4962
4810
  const changes = {};
4963
4811
  for (const issueUpdateChange of [
@@ -4969,11 +4817,11 @@ class IssueService extends BaseApiService {
4969
4817
  IssueUpdateChange.ASSIGNED_TO,
4970
4818
  IssueUpdateChange.DUE_DATE
4971
4819
  ]) {
4972
- if (issueUpdateChange in issue && issue[issueUpdateChange] !== issueToBeUpdated[issueUpdateChange]) {
4820
+ if (issueUpdateChange in payload && payload[issueUpdateChange] !== issueToBeUpdated[issueUpdateChange]) {
4973
4821
  switch (issueUpdateChange) {
4974
4822
  case "category": {
4975
4823
  let categoryOrNull = null;
4976
- const categoryIdOrNull = issue[issueUpdateChange];
4824
+ const categoryIdOrNull = payload[issueUpdateChange];
4977
4825
  if (categoryIdOrNull) {
4978
4826
  categoryOrNull = state.categoryReducer.instances[categoryIdOrNull] ?? null;
4979
4827
  if (!categoryOrNull)
@@ -4990,7 +4838,7 @@ class IssueService extends BaseApiService {
4990
4838
  }
4991
4839
  case "assigned_to": {
4992
4840
  let userOrNull = null;
4993
- const userIdOrNull = issue[issueUpdateChange];
4841
+ const userIdOrNull = payload[issueUpdateChange];
4994
4842
  if (userIdOrNull) {
4995
4843
  userOrNull = state.userReducer.users[userIdOrNull] ?? null;
4996
4844
  if (!userOrNull)
@@ -5005,24 +4853,24 @@ class IssueService extends BaseApiService {
5005
4853
  break;
5006
4854
  }
5007
4855
  case "description":
5008
- changes[issueUpdateChange] = issue[issueUpdateChange] ?? null;
4856
+ changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
5009
4857
  break;
5010
4858
  case "title":
5011
- changes[issueUpdateChange] = issue[issueUpdateChange] ?? null;
4859
+ changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
5012
4860
  break;
5013
4861
  case "priority":
5014
- changes[issueUpdateChange] = issue[issueUpdateChange];
4862
+ changes[issueUpdateChange] = payload[issueUpdateChange];
5015
4863
  break;
5016
4864
  case "status":
5017
- changes[issueUpdateChange] = issue[issueUpdateChange];
4865
+ changes[issueUpdateChange] = payload[issueUpdateChange];
5018
4866
  break;
5019
4867
  case "due_date":
5020
- changes[issueUpdateChange] = issue[issueUpdateChange] ? issue[issueUpdateChange] : null;
4868
+ changes[issueUpdateChange] = payload[issueUpdateChange] ? payload[issueUpdateChange] : null;
5021
4869
  }
5022
4870
  }
5023
4871
  }
5024
4872
  const offlineIssueUpdate = offline({
5025
- created_by: state.userReducer.currentUser.id,
4873
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5026
4874
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5027
4875
  issue: issueToBeUpdated.offline_id,
5028
4876
  changes
@@ -5031,10 +4879,10 @@ class IssueService extends BaseApiService {
5031
4879
  const promise = this.enqueueRequest({
5032
4880
  description: "Edit issue",
5033
4881
  method: HttpMethod.PATCH,
5034
- url: `/issues/${issue.offline_id}/`,
5035
- payload: issue,
5036
- blockers: [issue.offline_id],
5037
- blocks: [issue.offline_id]
4882
+ url: `/issues/${payload.offline_id}/`,
4883
+ payload,
4884
+ blockers: [payload.offline_id],
4885
+ blocks: [payload.offline_id]
5038
4886
  });
5039
4887
  promise.catch(() => {
5040
4888
  this.dispatch(updateIssue(issueToBeUpdated));
@@ -5086,7 +4934,6 @@ class IssueService extends BaseApiService {
5086
4934
  throw e;
5087
4935
  }
5088
4936
  }
5089
- // Special functions
5090
4937
  async refreshStore(projectId) {
5091
4938
  const result = await this.enqueueRequest({
5092
4939
  description: "Get issues",
@@ -5094,33 +4941,24 @@ class IssueService extends BaseApiService {
5094
4941
  url: `/projects/${projectId}/issues/`,
5095
4942
  blockers: [],
5096
4943
  blocks: []
5097
- }).then((result2) => {
5098
- const filteredResult = result2.filter(onlyUniqueOfflineIds);
5099
- if (result2.length !== filteredResult.length) {
5100
- console.error(
5101
- `Received duplicate issues from the API (new length ${filteredResult.length});
5102
- filtered in browser.`
5103
- );
5104
- }
5105
- return filteredResult;
5106
4944
  });
5107
4945
  this.dispatch(initializeIssues(result));
5108
4946
  }
5109
4947
  }
5110
4948
  class IssueTypeService extends BaseApiService {
5111
- add(payload, organizationId) {
4949
+ add(payload) {
4950
+ var _a2;
5112
4951
  const { store } = this.client;
5113
4952
  const state = store.getState();
5114
4953
  const offlineIssueType = offline({
5115
4954
  ...payload,
5116
4955
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5117
- created_by: state.userReducer.currentUser.id,
5118
- organization: organizationId
4956
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id
5119
4957
  });
5120
4958
  this.dispatch(addIssueType(offlineIssueType));
5121
4959
  const promise = this.enqueueRequest({
5122
4960
  method: HttpMethod.POST,
5123
- url: `/organizations/${organizationId}/issue-types/`,
4961
+ url: `/organizations/${payload.organization}/issue-types/`,
5124
4962
  // Sending only whats needed here
5125
4963
  payload: {
5126
4964
  offline_id: offlineIssueType.offline_id,
@@ -5166,20 +5004,20 @@ class IssueTypeService extends BaseApiService {
5166
5004
  });
5167
5005
  return [offlineUpdatedIssueType, promise];
5168
5006
  }
5169
- delete(issueTypeId) {
5007
+ delete(id) {
5170
5008
  const { store } = this.client;
5171
5009
  const state = store.getState();
5172
- const issueTypeToDelete = selectIssueTypeById(issueTypeId)(state);
5010
+ const issueTypeToDelete = selectIssueTypeById(id)(state);
5173
5011
  if (!issueTypeToDelete) {
5174
- throw new Error(`IssueType with offline_id ${issueTypeId} does not exist in the store.`);
5012
+ throw new Error(`IssueType with offline_id ${id} does not exist in the store.`);
5175
5013
  }
5176
- const issuesOfIssueType = selectIssuesOfIssueType(issueTypeId)(state);
5177
- this.dispatch(removeIssueType(issueTypeId));
5014
+ const issuesOfIssueType = selectIssuesOfIssueType(id)(state);
5015
+ this.dispatch(removeIssueType(id));
5178
5016
  this.dispatch(deleteIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
5179
5017
  const promise = this.enqueueRequest({
5180
5018
  method: HttpMethod.DELETE,
5181
- url: `/issues/types/${issueTypeId}/`,
5182
- blockers: [issueTypeId],
5019
+ url: `/issues/types/${id}/`,
5020
+ blockers: [id],
5183
5021
  blocks: []
5184
5022
  });
5185
5023
  promise.catch(() => {
@@ -5237,17 +5075,6 @@ class ProjectAccessService extends BaseApiService {
5237
5075
  }
5238
5076
  }
5239
5077
  class ProjectFileService extends BaseApiService {
5240
- async refreshStore(projectId) {
5241
- const result = await this.enqueueRequest({
5242
- description: "Get project files",
5243
- method: HttpMethod.GET,
5244
- url: `/projects/${projectId}/files/`,
5245
- blockers: [],
5246
- blocks: []
5247
- });
5248
- this.dispatch(addOrReplaceProjectFiles([]));
5249
- this.dispatch(addOrReplaceProjectFiles(result));
5250
- }
5251
5078
  async saveExisting(file) {
5252
5079
  if (!file.offline_id) {
5253
5080
  throw new Error(
@@ -5335,6 +5162,17 @@ class ProjectFileService extends BaseApiService {
5335
5162
  blocks: []
5336
5163
  });
5337
5164
  }
5165
+ async refreshStore(projectId) {
5166
+ const result = await this.enqueueRequest({
5167
+ description: "Get project files",
5168
+ method: HttpMethod.GET,
5169
+ url: `/projects/${projectId}/files/`,
5170
+ blockers: [],
5171
+ blocks: []
5172
+ });
5173
+ this.dispatch(addOrReplaceProjectFiles([]));
5174
+ this.dispatch(addOrReplaceProjectFiles(result));
5175
+ }
5338
5176
  }
5339
5177
  class ProjectAttachmentService extends BaseAttachmentService {
5340
5178
  constructor() {
@@ -5520,8 +5358,9 @@ const separateImageFromFields = async (fields) => {
5520
5358
  };
5521
5359
  class FormService extends BaseUploadService {
5522
5360
  async bulkAddRevisionAttachments(revisionId, files) {
5361
+ var _a2;
5523
5362
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5524
- const createdBy = this.client.store.getState().userReducer.currentUser.id;
5363
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5525
5364
  const filePayloads = {};
5526
5365
  const offlineFormRevisionAttachments = [];
5527
5366
  const attachmentPayloads = [];
@@ -5623,10 +5462,11 @@ class FormService extends BaseUploadService {
5623
5462
  return [form, offlineFormRevision, offlineFormRevisionAttachments, formPromise, attachmentsPromise];
5624
5463
  }
5625
5464
  addForOrganization(organizationId, initialRevision) {
5465
+ var _a2;
5626
5466
  const state = this.client.store.getState();
5627
5467
  const offlineForm = offline({
5628
5468
  favorite: false,
5629
- created_by: state.userReducer.currentUser.id,
5469
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5630
5470
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5631
5471
  organization: organizationId
5632
5472
  });
@@ -5638,45 +5478,49 @@ class FormService extends BaseUploadService {
5638
5478
  );
5639
5479
  }
5640
5480
  addForProject(projectId, initialRevision) {
5481
+ var _a2;
5641
5482
  const state = this.client.store.getState();
5642
5483
  const offlineForm = offline({
5643
5484
  favorite: false,
5644
- created_by: state.userReducer.currentUser.id,
5485
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5645
5486
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5646
5487
  project: projectId
5647
5488
  });
5648
5489
  return this.add(projectId.toString(), offlineForm, initialRevision, `/projects/${projectId}/create-form/`);
5649
5490
  }
5650
5491
  addForIssueType(issueTypeId, initialRevision) {
5492
+ var _a2;
5651
5493
  const state = this.client.store.getState();
5652
5494
  const offlineForm = offline({
5653
5495
  favorite: false,
5654
- created_by: state.userReducer.currentUser.id,
5496
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5655
5497
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5656
5498
  issue_type: issueTypeId
5657
5499
  });
5658
5500
  return this.add(issueTypeId, offlineForm, initialRevision, `/issues/types/${issueTypeId}/create-form/`);
5659
5501
  }
5660
5502
  addForAssetType(assetTypeId, initialRevision) {
5503
+ var _a2;
5661
5504
  const state = this.client.store.getState();
5662
5505
  const offlineForm = offline({
5663
5506
  favorite: false,
5664
- created_by: state.userReducer.currentUser.id,
5507
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5665
5508
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5666
5509
  asset_type: assetTypeId
5667
5510
  });
5668
5511
  return this.add(assetTypeId, offlineForm, initialRevision, `/assets/types/${assetTypeId}/create-form/`);
5669
5512
  }
5670
5513
  async createRevision(formId, revision) {
5514
+ var _a2;
5671
5515
  const offlineRevision = offline(revision);
5672
5516
  const { store } = this.client;
5673
5517
  const state = store.getState();
5674
- const currentUserId = state.userReducer.currentUser.id;
5518
+ const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
5675
5519
  const { fields, images } = await separateImageFromFields(offlineRevision.fields);
5676
5520
  const fullRevision = {
5677
5521
  ...offlineRevision,
5678
5522
  fields,
5679
- created_by: currentUserId,
5523
+ created_by: createdBy,
5680
5524
  revision: "Pending",
5681
5525
  form: formId,
5682
5526
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -5825,8 +5669,9 @@ const separateFilesFromValues = (values) => {
5825
5669
  };
5826
5670
  class FormSubmissionService extends BaseUploadService {
5827
5671
  async bulkAddSubmissionAttachments(submissionId, files) {
5672
+ var _a2;
5828
5673
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5829
- const createdBy = this.client.store.getState().userReducer.currentUser.id;
5674
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5830
5675
  const filePayloads = {};
5831
5676
  const offlineFormSubmissionAttachments = [];
5832
5677
  const attachmentPayloads = [];
@@ -5908,13 +5753,14 @@ class FormSubmissionService extends BaseUploadService {
5908
5753
  }
5909
5754
  // Outer promise is for hashing and caching files for submission attachments
5910
5755
  async add(payload) {
5756
+ var _a2;
5911
5757
  const { store } = this.client;
5912
5758
  const state = store.getState();
5913
5759
  const { values, files } = separateFilesFromValues(payload.values);
5914
5760
  const offlineSubmission = offline({
5915
5761
  ...payload,
5916
5762
  values,
5917
- created_by: state.userReducer.currentUser.id,
5763
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5918
5764
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
5919
5765
  });
5920
5766
  const promise = this.enqueueRequest({
@@ -6170,8 +6016,9 @@ class FormSubmissionService extends BaseUploadService {
6170
6016
  }
6171
6017
  class WorkspaceService extends BaseApiService {
6172
6018
  add(payload) {
6019
+ var _a2;
6173
6020
  const { store } = this.client;
6174
- const createdBy = store.getState().userReducer.currentUser.id;
6021
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6175
6022
  const offlineWorkspace = offline({
6176
6023
  ...payload,
6177
6024
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -6193,8 +6040,14 @@ class WorkspaceService extends BaseApiService {
6193
6040
  });
6194
6041
  return [offlineWorkspace, promise];
6195
6042
  }
6196
- update(workspace) {
6197
- this.dispatch(addWorkspace(workspace));
6043
+ update(payload) {
6044
+ const { store } = this.client;
6045
+ const workspace = selectWorkspaceById(payload.offline_id)(store.getState());
6046
+ if (!workspace) {
6047
+ throw new Error(`Expected an existing workspace with offline_id ${payload.offline_id}`);
6048
+ }
6049
+ const updatedWorkspace = { ...workspace, ...payload };
6050
+ this.dispatch(updateWorkspace(updatedWorkspace));
6198
6051
  const promise = this.enqueueRequest({
6199
6052
  description: "Update Workspace",
6200
6053
  method: HttpMethod.PATCH,
@@ -6203,10 +6056,17 @@ class WorkspaceService extends BaseApiService {
6203
6056
  blockers: [workspace.offline_id],
6204
6057
  blocks: [workspace.offline_id]
6205
6058
  });
6059
+ promise.then((result) => {
6060
+ this.dispatch(updateWorkspace(result));
6061
+ }).catch(() => {
6062
+ this.dispatch(updateWorkspace(workspace));
6063
+ });
6206
6064
  return [workspace, promise];
6207
6065
  }
6208
6066
  delete(workspaceId) {
6209
6067
  const { store } = this.client;
6068
+ const originalWorkspace = selectWorkspaceById(workspaceId)(store.getState());
6069
+ this.dispatch(deleteWorkspace(workspaceId));
6210
6070
  const promise = this.enqueueRequest({
6211
6071
  description: "Delete Workspace",
6212
6072
  method: HttpMethod.DELETE,
@@ -6214,8 +6074,6 @@ class WorkspaceService extends BaseApiService {
6214
6074
  blockers: [workspaceId],
6215
6075
  blocks: []
6216
6076
  });
6217
- const originalWorkspace = store.getState().workspaceReducer.instances[workspaceId];
6218
- this.dispatch(deleteWorkspace(workspaceId));
6219
6077
  void promise.then(() => {
6220
6078
  }).catch((reason) => {
6221
6079
  if (originalWorkspace) {
@@ -6717,12 +6575,13 @@ class LicenseService extends BaseApiService {
6717
6575
  }
6718
6576
  class DocumentService extends BaseApiService {
6719
6577
  add(payload) {
6578
+ var _a2;
6720
6579
  const { store } = this.client;
6721
- const currentUserId = store.getState().userReducer.currentUser.id;
6580
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6722
6581
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6723
6582
  const offlineDocument = offline({
6724
6583
  ...payload,
6725
- created_by: currentUserId,
6584
+ created_by: createdBy,
6726
6585
  submitted_at: submittedAt
6727
6586
  });
6728
6587
  this.dispatch(addDocuments([offlineDocument]));
@@ -6751,7 +6610,11 @@ class DocumentService extends BaseApiService {
6751
6610
  `attempting to update a document with offline_id ${document2.offline_id} that does not exist in store.documents`
6752
6611
  );
6753
6612
  }
6754
- this.dispatch(updateDocuments([document2]));
6613
+ const updatedDocument = {
6614
+ ...documentToBeUpdated,
6615
+ ...document2
6616
+ };
6617
+ this.dispatch(updateDocuments([updatedDocument]));
6755
6618
  const promise = this.enqueueRequest({
6756
6619
  description: "Update Document",
6757
6620
  method: HttpMethod.PATCH,
@@ -6763,8 +6626,7 @@ class DocumentService extends BaseApiService {
6763
6626
  promise.catch(() => {
6764
6627
  updateDocuments([documentToBeUpdated]);
6765
6628
  });
6766
- const fullDocument = store.getState().documentsReducer.documents[document2.offline_id];
6767
- return [fullDocument, promise];
6629
+ return [updatedDocument, promise];
6768
6630
  }
6769
6631
  move(documentId, targetDocumentId, position) {
6770
6632
  const { store } = this.client;
@@ -6811,22 +6673,22 @@ class DocumentService extends BaseApiService {
6811
6673
  });
6812
6674
  return promise;
6813
6675
  }
6814
- delete(documentId) {
6676
+ delete(id) {
6815
6677
  const { store } = this.client;
6816
6678
  const documentsMapping = selectDocumentsMapping(store.getState());
6817
- const documentToBeDeleted = documentsMapping[documentId];
6679
+ const documentToBeDeleted = selectDocumentById(id)(store.getState());
6818
6680
  if (!documentToBeDeleted) {
6819
6681
  throw new Error(
6820
- `attempting to delete a document with offline_id ${documentId} that does not exist in store.documents`
6682
+ `attempting to delete a document with offline_id ${id} that does not exist in store.documents`
6821
6683
  );
6822
6684
  }
6823
6685
  const parentDocument = documentToBeDeleted.parent_document ? documentsMapping[documentToBeDeleted.parent_document] : void 0;
6824
- this.dispatch(removeDocuments([documentId]));
6686
+ this.dispatch(removeDocuments([id]));
6825
6687
  const promise = this.enqueueRequest({
6826
6688
  description: "Delete Document",
6827
6689
  method: HttpMethod.DELETE,
6828
- url: `/documents/${documentId}/`,
6829
- blockers: [documentId],
6690
+ url: `/documents/${id}/`,
6691
+ blockers: [id],
6830
6692
  blocks: []
6831
6693
  });
6832
6694
  promise.then((documentsToUpdate) => {
@@ -6884,8 +6746,9 @@ class DocumentAttachmentService extends BaseAttachmentService {
6884
6746
  }
6885
6747
  // NOTE: overriding the method from BaseAttachmentService since document attachments get vectorized
6886
6748
  async attachFilesToDocument(files, documentId) {
6749
+ var _a2;
6887
6750
  const { store } = this.client;
6888
- const currentUser = store.getState().userReducer.currentUser;
6751
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6889
6752
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6890
6753
  const offlineAttachments = [];
6891
6754
  const attachmentPayloads = [];
@@ -6907,7 +6770,7 @@ class DocumentAttachmentService extends BaseAttachmentService {
6907
6770
  file,
6908
6771
  sha1,
6909
6772
  submittedAt,
6910
- createdBy: currentUser.id,
6773
+ createdBy,
6911
6774
  description: "",
6912
6775
  modelId: documentId
6913
6776
  });
@@ -7070,10 +6933,9 @@ class AgentService extends BaseApiService {
7070
6933
  }
7071
6934
  }
7072
6935
  class TeamService extends BaseApiService {
7073
- add(teamPayload, organizationId) {
6936
+ add(payload) {
7074
6937
  const offlineTeam = offline({
7075
- ...teamPayload,
7076
- organization: organizationId,
6938
+ ...payload,
7077
6939
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7078
6940
  // TODO: uncomment once supported
7079
6941
  // created_by: state.userReducer.currentUser.id,
@@ -7082,7 +6944,7 @@ class TeamService extends BaseApiService {
7082
6944
  const promise = this.enqueueRequest({
7083
6945
  description: "Create team",
7084
6946
  method: HttpMethod.POST,
7085
- url: `/organizations/${organizationId}/teams/`,
6947
+ url: `/organizations/${payload.organization}/teams/`,
7086
6948
  payload: offlineTeam,
7087
6949
  // No blocks since users and organizations are not offline
7088
6950
  blockers: [],
@@ -7095,25 +6957,24 @@ class TeamService extends BaseApiService {
7095
6957
  });
7096
6958
  return [offlineTeam, promise];
7097
6959
  }
7098
- // TODO: @Audiopolis / Magnus - should we pass a offline_id as one arg and a UpdatedTeamProps as a second arg instead of this set up?
7099
- update(team) {
6960
+ update(payload) {
7100
6961
  const { store } = this.client;
7101
- const teamToBeUpdated = selectTeamById(team.offline_id)(store.getState());
6962
+ const teamToBeUpdated = selectTeamById(payload.offline_id)(store.getState());
7102
6963
  if (!teamToBeUpdated) {
7103
- throw new Error(`Expected team with offline_id ${team.offline_id} to exist`);
6964
+ throw new Error(`Expected team with offline_id ${payload.offline_id} to exist`);
7104
6965
  }
7105
6966
  const offlineUpdatedTeam = {
7106
6967
  ...teamToBeUpdated,
7107
- ...team
6968
+ ...payload
7108
6969
  };
7109
6970
  this.dispatch(updateTeam(offlineUpdatedTeam));
7110
6971
  const promise = this.enqueueRequest({
7111
6972
  description: "Update team",
7112
6973
  method: HttpMethod.PATCH,
7113
- url: `/organizations/teams/${team.offline_id}/`,
6974
+ url: `/organizations/teams/${payload.offline_id}/`,
7114
6975
  payload: offlineUpdatedTeam,
7115
- blockers: [team.offline_id],
7116
- blocks: [team.offline_id]
6976
+ blockers: [payload.offline_id],
6977
+ blocks: [payload.offline_id]
7117
6978
  });
7118
6979
  promise.then((updatedTeam) => {
7119
6980
  this.dispatch(setTeam(updatedTeam));
@@ -7225,10 +7086,11 @@ class UserService extends BaseApiService {
7225
7086
  }
7226
7087
  class GeoImageService extends BaseUploadService {
7227
7088
  async add(payload) {
7089
+ var _a2;
7228
7090
  const { store } = this.client;
7229
7091
  const { file, ...payloadWithoutFile } = payload;
7230
7092
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7231
- const currentUser = store.getState().userReducer.currentUser;
7093
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7232
7094
  const projectId = payloadWithoutFile.project;
7233
7095
  const sha1 = await hashFile(file);
7234
7096
  const filePayload = {
@@ -7243,9 +7105,9 @@ class GeoImageService extends BaseUploadService {
7243
7105
  file_sha1: sha1,
7244
7106
  file: URL.createObjectURL(file),
7245
7107
  submitted_at: submittedAt,
7246
- created_by: currentUser.id
7108
+ created_by: createdBy
7247
7109
  });
7248
- store.dispatch(addGeoImage(offlineMapImage));
7110
+ this.dispatch(addGeoImage(offlineMapImage));
7249
7111
  const promise = this.enqueueRequest({
7250
7112
  description: "Add geo image",
7251
7113
  method: HttpMethod.POST,
@@ -7269,16 +7131,17 @@ class GeoImageService extends BaseUploadService {
7269
7131
  });
7270
7132
  promise.then((result) => {
7271
7133
  this.processPresignedUrls(result.presigned_urls);
7272
- store.dispatch(setGeoImage(result.geo_image));
7134
+ this.dispatch(setGeoImage(result.geo_image));
7273
7135
  }).catch(() => {
7274
- store.dispatch(deleteGeoImage(offlineMapImage.offline_id));
7136
+ this.dispatch(deleteGeoImage(offlineMapImage.offline_id));
7275
7137
  });
7276
7138
  return [offlineMapImage, promise.then((result) => result.geo_image)];
7277
7139
  }
7278
7140
  async bulkAdd(payloads, projectId) {
7141
+ var _a2;
7279
7142
  const { store } = this.client;
7280
7143
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7281
- const currentUser = store.getState().userReducer.currentUser;
7144
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7282
7145
  const offlineGeoImages = [];
7283
7146
  const offlineIds = [];
7284
7147
  const geoImagePayloads = [];
@@ -7301,7 +7164,7 @@ class GeoImageService extends BaseUploadService {
7301
7164
  file_sha1: sha1,
7302
7165
  file: URL.createObjectURL(file),
7303
7166
  submitted_at: submittedAt,
7304
- created_by: currentUser.id,
7167
+ created_by: createdBy,
7305
7168
  project: projectId
7306
7169
  });
7307
7170
  offlineGeoImages.push(offlineMapImage);
@@ -7318,7 +7181,7 @@ class GeoImageService extends BaseUploadService {
7318
7181
  original_date: offlineMapImage.original_date
7319
7182
  });
7320
7183
  }
7321
- store.dispatch(addGeoImages(offlineGeoImages));
7184
+ this.dispatch(addGeoImages(offlineGeoImages));
7322
7185
  const promise = this.enqueueRequest({
7323
7186
  description: "Bulk add geo images",
7324
7187
  method: HttpMethod.POST,
@@ -7334,9 +7197,9 @@ class GeoImageService extends BaseUploadService {
7334
7197
  });
7335
7198
  promise.then((result) => {
7336
7199
  this.processPresignedUrls(result.presigned_urls);
7337
- store.dispatch(setGeoImages(result.geo_images));
7200
+ this.dispatch(setGeoImages(result.geo_images));
7338
7201
  }).catch(() => {
7339
- store.dispatch(deleteGeoImages(offlineIds));
7202
+ this.dispatch(deleteGeoImages(offlineIds));
7340
7203
  });
7341
7204
  return [offlineGeoImages, promise.then((result) => result.geo_images)];
7342
7205
  }
@@ -7348,7 +7211,7 @@ class GeoImageService extends BaseUploadService {
7348
7211
  throw new Error(`Map image with offline_id ${payload.offline_id} does not exist in the store`);
7349
7212
  }
7350
7213
  const updatedGeoImage = { ...geoImageToUpdate, ...payload };
7351
- store.dispatch(updateGeoImage(updatedGeoImage));
7214
+ this.dispatch(updateGeoImage(updatedGeoImage));
7352
7215
  const promise = this.enqueueRequest({
7353
7216
  description: "Update geo image",
7354
7217
  method: HttpMethod.PATCH,
@@ -7358,9 +7221,9 @@ class GeoImageService extends BaseUploadService {
7358
7221
  blockers: [payload.offline_id]
7359
7222
  });
7360
7223
  promise.then((result) => {
7361
- store.dispatch(setGeoImage(result));
7224
+ this.dispatch(setGeoImage(result));
7362
7225
  }).catch(() => {
7363
- store.dispatch(setGeoImage(geoImageToUpdate));
7226
+ this.dispatch(setGeoImage(geoImageToUpdate));
7364
7227
  });
7365
7228
  return [updatedGeoImage, promise];
7366
7229
  }
@@ -7371,7 +7234,7 @@ class GeoImageService extends BaseUploadService {
7371
7234
  if (!geoImageToDelete) {
7372
7235
  throw new Error(`Map image with offline_id ${geoImageId} does not exist in the store`);
7373
7236
  }
7374
- store.dispatch(deleteGeoImage(geoImageId));
7237
+ this.dispatch(deleteGeoImage(geoImageId));
7375
7238
  const promise = this.enqueueRequest({
7376
7239
  description: "Delete geo image",
7377
7240
  method: HttpMethod.DELETE,
@@ -7380,12 +7243,11 @@ class GeoImageService extends BaseUploadService {
7380
7243
  blockers: [geoImageId]
7381
7244
  });
7382
7245
  promise.catch(() => {
7383
- store.dispatch(setGeoImage(geoImageToDelete));
7246
+ this.dispatch(setGeoImage(geoImageToDelete));
7384
7247
  });
7385
7248
  return promise;
7386
7249
  }
7387
7250
  async refreshStore(projectId) {
7388
- const { store } = this.client;
7389
7251
  const result = await this.enqueueRequest({
7390
7252
  description: "Get geo images",
7391
7253
  method: HttpMethod.GET,
@@ -7393,14 +7255,15 @@ class GeoImageService extends BaseUploadService {
7393
7255
  blocks: [projectId.toString()],
7394
7256
  blockers: []
7395
7257
  });
7396
- store.dispatch(initializeGeoImages(result));
7258
+ this.dispatch(initializeGeoImages(result));
7397
7259
  }
7398
7260
  }
7399
7261
  class IssueAssociationService extends BaseUploadService {
7400
7262
  add(payload) {
7263
+ var _a2;
7401
7264
  const { store } = this.client;
7402
7265
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7403
- const createdBy = store.getState().userReducer.currentUser.id;
7266
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7404
7267
  const offlineIssueAssociation = offline({
7405
7268
  ...payload,
7406
7269
  submitted_at: submittedAt,
@@ -7414,7 +7277,6 @@ class IssueAssociationService extends BaseUploadService {
7414
7277
  payload: {
7415
7278
  offline_id: offlineIssueAssociation.offline_id,
7416
7279
  submitted_at: submittedAt,
7417
- created_by: createdBy,
7418
7280
  ...payload
7419
7281
  },
7420
7282
  blockers: [
@@ -7539,7 +7401,6 @@ export {
7539
7401
  addDocumentAttachments,
7540
7402
  addDocuments,
7541
7403
  addEmailDomain,
7542
- addFavouriteProjectId,
7543
7404
  addForm,
7544
7405
  addFormRevision,
7545
7406
  addFormRevisionAttachment,
@@ -7573,7 +7434,6 @@ export {
7573
7434
  addStageCompletions,
7574
7435
  addStages,
7575
7436
  addTeam,
7576
- addToRecentIssues,
7577
7437
  addUsers,
7578
7438
  addWorkspace,
7579
7439
  agentsReducer,
@@ -7598,7 +7458,6 @@ export {
7598
7458
  categoryReducer,
7599
7459
  categorySlice,
7600
7460
  classNames,
7601
- cleanRecentIssues,
7602
7461
  clearTokens,
7603
7462
  constructUploadedFilePayloads,
7604
7463
  coordinatesAreEqual,
@@ -7769,20 +7628,16 @@ export {
7769
7628
  rehydratedReducer,
7770
7629
  rehydratedSlice,
7771
7630
  removeDocuments,
7772
- removeFavouriteProjectId,
7773
7631
  removeIssueType,
7774
7632
  removeProjectFile,
7775
7633
  removeProjectFilesOfProject,
7776
- removeRecentIssue,
7777
7634
  removeStageCompletions,
7778
7635
  removeStages,
7779
7636
  removeUser,
7780
7637
  resetProjectFileObjectUrls,
7781
- resetRecentIssues,
7782
7638
  resetStore,
7783
7639
  restructureCreateSelectorWithArgs,
7784
7640
  saveActiveProjectFileBounds,
7785
- searchIssues,
7786
7641
  selectAccessToken,
7787
7642
  selectActiveOrganizationAccess,
7788
7643
  selectActiveProject,
@@ -7848,7 +7703,6 @@ export {
7848
7703
  selectEmailDomains,
7849
7704
  selectEmailDomainsAsMapping,
7850
7705
  selectEmailDomainsOfOrganization,
7851
- selectFavouriteProjects,
7852
7706
  selectFilteredForms,
7853
7707
  selectFormById,
7854
7708
  selectFormMapping,
@@ -7889,6 +7743,7 @@ export {
7889
7743
  selectIssueAttachmentMapping,
7890
7744
  selectIssueAttachments,
7891
7745
  selectIssueById,
7746
+ selectIssueCommentById,
7892
7747
  selectIssueCommentMapping,
7893
7748
  selectIssueCountOfCategory,
7894
7749
  selectIssueMapping,
@@ -7938,8 +7793,6 @@ export {
7938
7793
  selectProjectUsersAsMapping,
7939
7794
  selectProjectUsersIds,
7940
7795
  selectProjectsOfOrganization,
7941
- selectRecentIssueIds,
7942
- selectRecentIssuesAsSearchResults,
7943
7796
  selectRehydrated,
7944
7797
  selectRootDocuments,
7945
7798
  selectSortedFormSubmissionsOfForm,
@@ -8005,7 +7858,6 @@ export {
8005
7858
  setStageCompletions,
8006
7859
  setTeam,
8007
7860
  setTokens,
8008
- setTourStep,
8009
7861
  setUploadUrl,
8010
7862
  setUsers,
8011
7863
  setWorkspaces,