@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.
@@ -1269,50 +1269,13 @@ var __publicField = (obj, key, value) => {
1269
1269
  )
1270
1270
  );
1271
1271
  const assetTypeAttachmentReducer = assetTypeAttachmentSlice.reducer;
1272
- const workspaceAdapter = createModelAdapter((workspace) => workspace.offline_id);
1273
- const initialState$t = workspaceAdapter.getInitialState({});
1274
- const workspaceSlice = toolkit.createSlice({
1275
- name: "workspace",
1276
- initialState: initialState$t,
1277
- reducers: {
1278
- initializeWorkspaces: workspaceAdapter.initialize,
1279
- setWorkspaces: workspaceAdapter.setMany,
1280
- addWorkspace: workspaceAdapter.addOne,
1281
- updateWorkspace: workspaceAdapter.updateOne,
1282
- deleteWorkspace: workspaceAdapter.deleteOne
1283
- }
1284
- });
1285
- const { initializeWorkspaces, setWorkspaces, addWorkspace, updateWorkspace, deleteWorkspace } = workspaceSlice.actions;
1286
- const selectWorkspaceMapping = (state) => state.workspaceReducer.instances;
1287
- const selectWorkspaces = toolkit.createSelector([selectWorkspaceMapping], (mapping) => Object.values(mapping));
1288
- const selectMainWorkspace = toolkit.createSelector(
1289
- [selectWorkspaces],
1290
- (workspaces) => {
1291
- return workspaces.find((workspace) => workspace.name.toLowerCase() === "main");
1292
- }
1293
- );
1294
- const selectWorkspaceById = (id) => (state) => {
1295
- return state.workspaceReducer.instances[id];
1296
- };
1297
- const selectPermittedWorkspaceIds = toolkit.createSelector(
1298
- [selectWorkspaceMapping],
1299
- (mapping) => {
1300
- return new Set(
1301
- Object.values(mapping).filter((workspace) => workspace.permitted).map((workspace) => workspace.offline_id)
1302
- );
1303
- }
1304
- );
1305
- const workspaceReducer = workspaceSlice.reducer;
1306
- const maxRecentIssues = 10;
1307
1272
  const issueAdapter = createModelAdapter((issue) => issue.offline_id);
1308
- const initialState$s = issueAdapter.getInitialState({
1309
- recentIssueIds: []
1310
- });
1273
+ const initialState$t = issueAdapter.getInitialState({});
1311
1274
  const issueSlice = toolkit.createSlice({
1312
1275
  name: "issues",
1313
- initialState: initialState$s,
1276
+ initialState: initialState$t,
1314
1277
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1315
- Object.assign(state, initialState$s);
1278
+ Object.assign(state, initialState$t);
1316
1279
  }),
1317
1280
  reducers: {
1318
1281
  initializeIssues: issueAdapter.initialize,
@@ -1320,104 +1283,14 @@ var __publicField = (obj, key, value) => {
1320
1283
  addIssues: issueAdapter.addMany,
1321
1284
  updateIssue: issueAdapter.updateOne,
1322
1285
  deleteIssue: issueAdapter.deleteOne,
1323
- deleteIssues: issueAdapter.deleteMany,
1324
- cleanRecentIssues: (state) => {
1325
- state.recentIssueIds = state.recentIssueIds.filter((recentIssue) => state.instances[recentIssue.offlineId]);
1326
- },
1327
- addToRecentIssues: (state, action) => {
1328
- state.recentIssueIds = state.recentIssueIds.filter(
1329
- (recentIssue) => recentIssue.offlineId !== action.payload
1330
- );
1331
- state.recentIssueIds.push({ offlineId: action.payload.toLowerCase(), lastOpenedEpochTime: Date.now() });
1332
- if (state.recentIssueIds.length > maxRecentIssues) {
1333
- state.recentIssueIds.shift();
1334
- }
1335
- },
1336
- resetRecentIssues: (state) => {
1337
- state.recentIssueIds = [];
1338
- },
1339
- removeRecentIssue: (state, action) => {
1340
- const indexToRemove = state.recentIssueIds.findIndex((item) => {
1341
- return item.offlineId == action.payload;
1342
- });
1343
- if (indexToRemove !== -1) {
1344
- state.recentIssueIds.splice(indexToRemove, 1);
1345
- }
1346
- }
1286
+ deleteIssues: issueAdapter.deleteMany
1347
1287
  }
1348
1288
  });
1349
- const {
1350
- initializeIssues,
1351
- addIssue,
1352
- addIssues,
1353
- updateIssue,
1354
- deleteIssue,
1355
- deleteIssues,
1356
- addToRecentIssues,
1357
- cleanRecentIssues,
1358
- removeRecentIssue,
1359
- resetRecentIssues
1360
- } = issueSlice.actions;
1289
+ const { initializeIssues, addIssue, addIssues, updateIssue, deleteIssue, deleteIssues } = issueSlice.actions;
1361
1290
  const selectIssueMapping = (state) => state.issueReducer.instances;
1362
- const selectRecentIssueIds = (state) => state.issueReducer.recentIssueIds;
1363
1291
  const selectIssueById = (id) => (state) => {
1364
1292
  return state.issueReducer.instances[id];
1365
1293
  };
1366
- const searchIssues = restructureCreateSelectorWithArgs(
1367
- toolkit.createSelector(
1368
- [selectIssueMapping, selectWorkspaceMapping, (_state, searchArgs) => searchArgs],
1369
- (mapping, workspaceMapping, searchArgs) => {
1370
- let searchTerm = searchArgs.searchTerm;
1371
- const maxResults = searchArgs.maxResults;
1372
- searchTerm = searchTerm.toLowerCase();
1373
- const ret = [];
1374
- const issues = Object.values(mapping);
1375
- let nbResults = 0;
1376
- for (const issue of issues) {
1377
- if (!issue.index_workspace) {
1378
- logOnlyOnce(
1379
- "issue-has-no-index-workspace",
1380
- issue.offline_id,
1381
- "warn",
1382
- `Issue ${issue.offline_id} has no index_workspace and cannot be searched.`
1383
- );
1384
- continue;
1385
- }
1386
- const workspace = workspaceMapping[issue.index_workspace];
1387
- if (!workspace) {
1388
- logOnlyOnce(
1389
- "issue-has-non-existent-index-workspace",
1390
- issue.offline_id,
1391
- "warn",
1392
- `Encountered issue with an index_workspace that doesn't exist. Issue ${issue.offline_id} has
1393
- index_workspace = ${issue.index_workspace}, which does not exist in:`,
1394
- Object.keys(workspaceMapping)
1395
- );
1396
- continue;
1397
- }
1398
- const workspaceAbbreviation = workspace.abbreviation;
1399
- if (!workspaceAbbreviation) {
1400
- logOnlyOnce(
1401
- "workspace-has-no-abbreviation",
1402
- workspace.offline_id,
1403
- "error",
1404
- `Workspace ${workspace.name} has no abbreviation. Not including any issues in search.`
1405
- );
1406
- continue;
1407
- }
1408
- const tag = "index" in issue ? `${workspaceAbbreviation.toUpperCase()}-${issue.index}` : null;
1409
- if ((issue.title || "").toLowerCase().includes(searchTerm) || tag && tag.toLowerCase().includes(searchTerm)) {
1410
- ret.push(issueToSearchResult(issue, tag));
1411
- nbResults++;
1412
- if (maxResults && nbResults >= maxResults) {
1413
- return ret;
1414
- }
1415
- }
1416
- }
1417
- return ret;
1418
- }
1419
- )
1420
- );
1421
1294
  const selectIssuesByIds = restructureCreateSelectorWithArgs(
1422
1295
  toolkit.createSelector([selectIssueMapping, (_, issueIds) => issueIds], (issuesMapping, issueIds) => {
1423
1296
  const issues = [];
@@ -1432,48 +1305,14 @@ var __publicField = (obj, key, value) => {
1432
1305
  return fallbackToEmptyArray(issues);
1433
1306
  })
1434
1307
  );
1435
- const selectRecentIssuesAsSearchResults = toolkit.createSelector(
1436
- [selectIssueMapping, selectRecentIssueIds, selectWorkspaceMapping],
1437
- (issueMapping, recentIssueIds, workspaceMapping) => {
1438
- const ret = [];
1439
- for (const recentIssueResult of recentIssueIds) {
1440
- const issue = issueMapping[recentIssueResult.offlineId];
1441
- if (!issue) {
1442
- console.info("Recent issue no longer exists");
1443
- continue;
1444
- }
1445
- if ("index" in issue && issue.index_workspace) {
1446
- const indexWorkspace = workspaceMapping[issue.index_workspace];
1447
- if (!indexWorkspace) {
1448
- logOnlyOnce(
1449
- "issue-has-index-but-not-index-workspace",
1450
- issue.offline_id,
1451
- "warn",
1452
- `Issue ${issue.offline_id} has an index but no index_workspace. This may be because the
1453
- workspace has been deleted, but the new index has not been returned by the server yet. It will not
1454
- be included in search results.`
1455
- );
1456
- continue;
1457
- }
1458
- const workspaceTag = `${indexWorkspace.abbreviation}-${issue.index}`;
1459
- const searchResult = {
1460
- ...issueToSearchResult(issue, workspaceTag),
1461
- lastOpenedEpochTime: recentIssueResult.lastOpenedEpochTime
1462
- };
1463
- ret.push(searchResult);
1464
- }
1465
- }
1466
- return ret;
1467
- }
1468
- );
1469
1308
  const issueReducer = issueSlice.reducer;
1470
1309
  const issueTypeAdapter = createModelAdapter((issueType) => issueType.offline_id);
1471
- const initialState$r = issueTypeAdapter.getInitialState({});
1310
+ const initialState$s = issueTypeAdapter.getInitialState({});
1472
1311
  const issueTypeSlice = toolkit.createSlice({
1473
1312
  name: "issueTypes",
1474
- initialState: initialState$r,
1313
+ initialState: initialState$s,
1475
1314
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1476
- Object.assign(state, initialState$r);
1315
+ Object.assign(state, initialState$s);
1477
1316
  }),
1478
1317
  reducers: {
1479
1318
  initializeIssueTypes: issueTypeAdapter.initialize,
@@ -1530,15 +1369,15 @@ var __publicField = (obj, key, value) => {
1530
1369
  return selectIssuesOfIssueType(issueTypeId)(state).length;
1531
1370
  };
1532
1371
  const issueTypeReducer = issueTypeSlice.reducer;
1533
- const initialState$q = {
1372
+ const initialState$r = {
1534
1373
  s3Urls: {}
1535
1374
  };
1536
1375
  const msPerHour = 1e3 * 60 * 60;
1537
1376
  const msPerWeek = msPerHour * 24 * 7;
1538
1377
  const fileSlice = toolkit.createSlice({
1539
1378
  name: "file",
1540
- initialState: initialState$q,
1541
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1379
+ initialState: initialState$r,
1380
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1542
1381
  reducers: {
1543
1382
  setUploadUrl: (state, action) => {
1544
1383
  const { url, fields, sha1 } = action.payload;
@@ -1619,19 +1458,14 @@ var __publicField = (obj, key, value) => {
1619
1458
  LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
1620
1459
  return LicenseStatus2;
1621
1460
  })(LicenseStatus || {});
1622
- const initialState$p = {
1461
+ const initialState$q = {
1623
1462
  users: {},
1624
- currentUser: {
1625
- id: 0,
1626
- username: "",
1627
- email: "",
1628
- profile: { file: null, file_sha1: null, favourite_project_ids: [], tour_step: -1 }
1629
- }
1463
+ currentUser: null
1630
1464
  };
1631
1465
  const userSlice = toolkit.createSlice({
1632
1466
  name: "users",
1633
- initialState: initialState$p,
1634
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1467
+ initialState: initialState$q,
1468
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1635
1469
  reducers: {
1636
1470
  setUsers: (state, action) => {
1637
1471
  const usersMapping = {};
@@ -1649,6 +1483,8 @@ var __publicField = (obj, key, value) => {
1649
1483
  state.currentUser = action.payload;
1650
1484
  },
1651
1485
  setProfilePicture: (state, action) => {
1486
+ if (!state.currentUser)
1487
+ return;
1652
1488
  state.currentUser.profile.file = action.payload.file ?? null;
1653
1489
  state.currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
1654
1490
  const currentUser = state.users[state.currentUser.id];
@@ -1658,32 +1494,12 @@ var __publicField = (obj, key, value) => {
1658
1494
  currentUser.profile.file = action.payload.file ?? null;
1659
1495
  currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
1660
1496
  },
1661
- addFavouriteProjectId: (state, action) => {
1662
- state.currentUser.profile.favourite_project_ids.push(action.payload);
1663
- },
1664
- removeFavouriteProjectId: (state, action) => {
1665
- state.currentUser.profile.favourite_project_ids = state.currentUser.profile.favourite_project_ids.filter(
1666
- (id) => id !== action.payload
1667
- );
1668
- },
1669
- setTourStep: (state, action) => {
1670
- state.currentUser.profile.tour_step = action.payload;
1671
- },
1672
1497
  removeUser: (state, action) => {
1673
1498
  delete state.users[action.payload];
1674
1499
  }
1675
1500
  }
1676
1501
  });
1677
- const {
1678
- setCurrentUser,
1679
- setProfilePicture,
1680
- setUsers,
1681
- addUsers,
1682
- addFavouriteProjectId,
1683
- removeFavouriteProjectId,
1684
- setTourStep,
1685
- removeUser
1686
- } = userSlice.actions;
1502
+ const { setCurrentUser, setProfilePicture, setUsers, addUsers, removeUser } = userSlice.actions;
1687
1503
  const userReducer = userSlice.reducer;
1688
1504
  const selectCurrentUser = (state) => state.userReducer.currentUser;
1689
1505
  const selectUsersMapping = (state) => state.userReducer.users;
@@ -1704,15 +1520,14 @@ var __publicField = (obj, key, value) => {
1704
1520
  return fallbackToEmptyArray(users);
1705
1521
  })
1706
1522
  );
1707
- const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
1708
1523
  const organizationAccessAdapter = createModelAdapter(
1709
1524
  (organizationAccess) => organizationAccess.offline_id
1710
1525
  );
1711
- const initialState$o = organizationAccessAdapter.getInitialState({});
1526
+ const initialState$p = organizationAccessAdapter.getInitialState({});
1712
1527
  const organizationAccessSlice = toolkit.createSlice({
1713
1528
  name: "organizationAccess",
1714
- initialState: initialState$o,
1715
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1529
+ initialState: initialState$p,
1530
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1716
1531
  reducers: {
1717
1532
  initializeOrganizationAccesses: organizationAccessAdapter.initialize,
1718
1533
  updateOrganizationAccess: organizationAccessAdapter.updateOne,
@@ -1730,7 +1545,7 @@ var __publicField = (obj, key, value) => {
1730
1545
  [selectCurrentUser, selectOrganizationAccesses],
1731
1546
  (currentUser, organizationAccesses) => {
1732
1547
  const activeOrganizationAccess = Object.values(organizationAccesses).find(
1733
- (organizationAccess) => organizationAccess.user === currentUser.id
1548
+ (organizationAccess) => organizationAccess.user === (currentUser == null ? void 0 : currentUser.id)
1734
1549
  );
1735
1550
  return activeOrganizationAccess ?? null;
1736
1551
  }
@@ -1749,11 +1564,11 @@ var __publicField = (obj, key, value) => {
1749
1564
  };
1750
1565
  const organizationAccessReducer = organizationAccessSlice.reducer;
1751
1566
  const licenseAdapter = createModelAdapter((license) => license.offline_id);
1752
- const initialState$n = licenseAdapter.getInitialState({});
1567
+ const initialState$o = licenseAdapter.getInitialState({});
1753
1568
  const licenseSlice = toolkit.createSlice({
1754
1569
  name: "license",
1755
- initialState: initialState$n,
1756
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1570
+ initialState: initialState$o,
1571
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1757
1572
  reducers: {
1758
1573
  initializeLicences: licenseAdapter.initialize,
1759
1574
  addLicenses: licenseAdapter.addMany,
@@ -1778,11 +1593,11 @@ var __publicField = (obj, key, value) => {
1778
1593
  );
1779
1594
  const licenseReducer = licenseSlice.reducer;
1780
1595
  const projectAccessAdapter = createModelAdapter((projectAccess) => projectAccess.offline_id);
1781
- const initialState$m = projectAccessAdapter.getInitialState({});
1596
+ const initialState$n = projectAccessAdapter.getInitialState({});
1782
1597
  const projectAccessSlice = toolkit.createSlice({
1783
1598
  name: "projectAccess",
1784
- initialState: initialState$m,
1785
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1599
+ initialState: initialState$n,
1600
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1786
1601
  reducers: {
1787
1602
  initializeProjectAccesses: projectAccessAdapter.initialize,
1788
1603
  updateProjectAccess: projectAccessAdapter.updateOne,
@@ -1807,7 +1622,7 @@ var __publicField = (obj, key, value) => {
1807
1622
  const currentUser = state.userReducer.currentUser;
1808
1623
  const activeProjectId = state.projectReducer.activeProjectId;
1809
1624
  return Object.values(state.projectAccessReducer.instances).find((projectAccess) => {
1810
- return projectAccess.user === currentUser.id && projectAccess.project === activeProjectId;
1625
+ return projectAccess.user === (currentUser == null ? void 0 : currentUser.id) && projectAccess.project === activeProjectId;
1811
1626
  }) ?? null;
1812
1627
  };
1813
1628
  const selectProjectAccessForUser = (user) => (state) => {
@@ -1823,14 +1638,14 @@ var __publicField = (obj, key, value) => {
1823
1638
  return projectAccesses;
1824
1639
  };
1825
1640
  const projectAccessReducer = projectAccessSlice.reducer;
1826
- const initialState$l = {
1641
+ const initialState$m = {
1827
1642
  projects: {},
1828
1643
  activeProjectId: null
1829
1644
  };
1830
1645
  const projectSlice = toolkit.createSlice({
1831
1646
  name: "projects",
1832
- initialState: initialState$l,
1833
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1647
+ initialState: initialState$m,
1648
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1834
1649
  reducers: {
1835
1650
  setProjects: (state, action) => {
1836
1651
  const projectsMap = {};
@@ -1920,9 +1735,9 @@ var __publicField = (obj, key, value) => {
1920
1735
  [selectCurrentUser, selectProjectUsersAsMapping, selectProjectAccessUserMapping],
1921
1736
  (currentUser, userMapping, projectAccessMapping) => {
1922
1737
  return Object.values(userMapping).sort((userA, userB) => {
1923
- if (userA.id === currentUser.id) {
1738
+ if (userA.id === (currentUser == null ? void 0 : currentUser.id)) {
1924
1739
  return -1;
1925
- } else if (userB.id === currentUser.id) {
1740
+ } else if (userB.id === (currentUser == null ? void 0 : currentUser.id)) {
1926
1741
  return 1;
1927
1742
  }
1928
1743
  const projectAccessesA = projectAccessMapping[userA.id];
@@ -1937,13 +1752,13 @@ var __publicField = (obj, key, value) => {
1937
1752
  });
1938
1753
  }
1939
1754
  );
1940
- const initialState$k = {
1755
+ const initialState$l = {
1941
1756
  organizations: {}
1942
1757
  };
1943
1758
  const organizationSlice = toolkit.createSlice({
1944
1759
  name: "organizations",
1945
- initialState: initialState$k,
1946
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1760
+ initialState: initialState$l,
1761
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1947
1762
  reducers: {
1948
1763
  setOrganizations: (state, action) => {
1949
1764
  for (const org of action.payload) {
@@ -1999,9 +1814,9 @@ var __publicField = (obj, key, value) => {
1999
1814
  [selectCurrentUser, selectOrganizationUsersAsMapping, selectOrganizationAccessUserMapping],
2000
1815
  (currentUser, userMapping, organizationAccessMapping) => {
2001
1816
  return Object.values(userMapping).sort((userA, userB) => {
2002
- if (userA.id === currentUser.id) {
1817
+ if (userA.id === (currentUser == null ? void 0 : currentUser.id)) {
2003
1818
  return -1;
2004
- } else if (userB.id === currentUser.id) {
1819
+ } else if (userB.id === (currentUser == null ? void 0 : currentUser.id)) {
2005
1820
  return 1;
2006
1821
  }
2007
1822
  const organizationAccessesA = organizationAccessMapping[userA.id];
@@ -2034,14 +1849,14 @@ var __publicField = (obj, key, value) => {
2034
1849
  }
2035
1850
  };
2036
1851
  };
2037
- const initialState$j = {
1852
+ const initialState$k = {
2038
1853
  deletedRequests: [],
2039
1854
  latestRetryTime: 0
2040
1855
  };
2041
1856
  const outboxSlice = toolkit.createSlice({
2042
1857
  name: "outbox",
2043
- initialState: initialState$j,
2044
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1858
+ initialState: initialState$k,
1859
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
2045
1860
  reducers: {
2046
1861
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
2047
1862
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -2073,15 +1888,15 @@ var __publicField = (obj, key, value) => {
2073
1888
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
2074
1889
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
2075
1890
  const outboxReducer = outboxSlice.reducer;
2076
- const initialState$i = {
1891
+ const initialState$j = {
2077
1892
  projectFiles: {},
2078
1893
  activeProjectFileId: null,
2079
1894
  isImportingProjectFile: false
2080
1895
  };
2081
1896
  const projectFileSlice = toolkit.createSlice({
2082
1897
  name: "projectFiles",
2083
- initialState: initialState$i,
2084
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1898
+ initialState: initialState$j,
1899
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
2085
1900
  reducers: {
2086
1901
  addOrReplaceProjectFiles: (state, action) => {
2087
1902
  for (let fileObj of action.payload) {
@@ -2168,11 +1983,11 @@ var __publicField = (obj, key, value) => {
2168
1983
  };
2169
1984
  const projectFileReducer = projectFileSlice.reducer;
2170
1985
  const projectAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2171
- const initialState$h = projectAttachmentAdapter.getInitialState({});
1986
+ const initialState$i = projectAttachmentAdapter.getInitialState({});
2172
1987
  const projectAttachmentSlice = toolkit.createSlice({
2173
1988
  name: "projectAttachments",
2174
- initialState: initialState$h,
2175
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
1989
+ initialState: initialState$i,
1990
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2176
1991
  reducers: {
2177
1992
  initializeProjectAttachments: projectAttachmentAdapter.initialize,
2178
1993
  addProjectAttachment: projectAttachmentAdapter.addOne,
@@ -2227,12 +2042,12 @@ var __publicField = (obj, key, value) => {
2227
2042
  )
2228
2043
  );
2229
2044
  const projectAttachmentReducer = projectAttachmentSlice.reducer;
2230
- const initialState$g = {
2045
+ const initialState$h = {
2231
2046
  isRehydrated: false
2232
2047
  };
2233
2048
  const rehydratedSlice = toolkit.createSlice({
2234
2049
  name: "rehydrated",
2235
- initialState: initialState$g,
2050
+ initialState: initialState$h,
2236
2051
  // The `reducers` field lets us define reducers and generate associated actions
2237
2052
  reducers: {
2238
2053
  setRehydrated: (state, action) => {
@@ -2257,11 +2072,11 @@ var __publicField = (obj, key, value) => {
2257
2072
  }
2258
2073
  };
2259
2074
  const formRevisionAdapter = createModelAdapter((revision) => revision.offline_id);
2260
- const initialState$f = formRevisionAdapter.getInitialState({});
2075
+ const initialState$g = formRevisionAdapter.getInitialState({});
2261
2076
  const formRevisionsSlice = toolkit.createSlice({
2262
2077
  name: "formRevisions",
2263
- initialState: initialState$f,
2264
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2078
+ initialState: initialState$g,
2079
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2265
2080
  reducers: {
2266
2081
  initializeFormRevisions: formRevisionAdapter.initialize,
2267
2082
  setFormRevision: formRevisionAdapter.setOne,
@@ -2333,11 +2148,11 @@ var __publicField = (obj, key, value) => {
2333
2148
  });
2334
2149
  const formRevisionReducer = formRevisionsSlice.reducer;
2335
2150
  const formAdapter = createModelAdapter((form) => form.offline_id);
2336
- const initialState$e = formAdapter.getInitialState({});
2151
+ const initialState$f = formAdapter.getInitialState({});
2337
2152
  const formSlice = toolkit.createSlice({
2338
2153
  name: "forms",
2339
- initialState: initialState$e,
2340
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2154
+ initialState: initialState$f,
2155
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2341
2156
  reducers: {
2342
2157
  initializeForms: formAdapter.initialize,
2343
2158
  setForm: formAdapter.setOne,
@@ -2371,7 +2186,7 @@ var __publicField = (obj, key, value) => {
2371
2186
  }
2372
2187
  const latestRevision = _selectLatestFormRevision(revisions, formId);
2373
2188
  if (latestRevision.title.toLowerCase().includes(searchTerm.toLowerCase())) {
2374
- regularMatches.push({ ...form, latestRevision });
2189
+ regularMatches.push(form);
2375
2190
  }
2376
2191
  }
2377
2192
  return [...regularMatches.slice(0, maxResults)];
@@ -2406,11 +2221,11 @@ var __publicField = (obj, key, value) => {
2406
2221
  return Object.values(formsMapping).filter((form) => !form.asset_type).length;
2407
2222
  });
2408
2223
  const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
2409
- const initialState$d = submissionAdapter.getInitialState({});
2224
+ const initialState$e = submissionAdapter.getInitialState({});
2410
2225
  const formSubmissionSlice = toolkit.createSlice({
2411
2226
  name: "formSubmissions",
2412
- initialState: initialState$d,
2413
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2227
+ initialState: initialState$e,
2228
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2414
2229
  reducers: {
2415
2230
  initializeFormSubmissions: submissionAdapter.initialize,
2416
2231
  setFormSubmission: submissionAdapter.setOne,
@@ -2622,11 +2437,11 @@ var __publicField = (obj, key, value) => {
2622
2437
  const formSubmissionAttachmentAdapter = createModelAdapter(
2623
2438
  (attachment) => attachment.offline_id
2624
2439
  );
2625
- const initialState$c = formSubmissionAttachmentAdapter.getInitialState({});
2440
+ const initialState$d = formSubmissionAttachmentAdapter.getInitialState({});
2626
2441
  const formSubmissionAttachmentSlice = toolkit.createSlice({
2627
2442
  name: "formSubmissionAttachments",
2628
- initialState: initialState$c,
2629
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2443
+ initialState: initialState$d,
2444
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2630
2445
  reducers: {
2631
2446
  initializeFormSubmissionAttachments: formSubmissionAttachmentAdapter.initialize,
2632
2447
  addFormSubmissionAttachment: formSubmissionAttachmentAdapter.addOne,
@@ -2678,11 +2493,11 @@ var __publicField = (obj, key, value) => {
2678
2493
  const formRevisionAttachmentAdapter = createModelAdapter(
2679
2494
  (attachment) => attachment.offline_id
2680
2495
  );
2681
- const initialState$b = formRevisionAttachmentAdapter.getInitialState({});
2496
+ const initialState$c = formRevisionAttachmentAdapter.getInitialState({});
2682
2497
  const formRevisionAttachmentSlice = toolkit.createSlice({
2683
2498
  name: "formRevisionAttachments",
2684
- initialState: initialState$b,
2685
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2499
+ initialState: initialState$c,
2500
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2686
2501
  reducers: {
2687
2502
  initializeFormRevisionAttachments: formRevisionAttachmentAdapter.initialize,
2688
2503
  addFormRevisionAttachment: formRevisionAttachmentAdapter.addOne,
@@ -2720,6 +2535,40 @@ var __publicField = (obj, key, value) => {
2720
2535
  )
2721
2536
  );
2722
2537
  const formRevisionAttachmentReducer = formRevisionAttachmentSlice.reducer;
2538
+ const workspaceAdapter = createModelAdapter((workspace) => workspace.offline_id);
2539
+ const initialState$b = workspaceAdapter.getInitialState({});
2540
+ const workspaceSlice = toolkit.createSlice({
2541
+ name: "workspace",
2542
+ initialState: initialState$b,
2543
+ reducers: {
2544
+ initializeWorkspaces: workspaceAdapter.initialize,
2545
+ setWorkspaces: workspaceAdapter.setMany,
2546
+ addWorkspace: workspaceAdapter.addOne,
2547
+ updateWorkspace: workspaceAdapter.updateOne,
2548
+ deleteWorkspace: workspaceAdapter.deleteOne
2549
+ }
2550
+ });
2551
+ const { initializeWorkspaces, setWorkspaces, addWorkspace, updateWorkspace, deleteWorkspace } = workspaceSlice.actions;
2552
+ const selectWorkspaceMapping = (state) => state.workspaceReducer.instances;
2553
+ const selectWorkspaces = toolkit.createSelector([selectWorkspaceMapping], (mapping) => Object.values(mapping));
2554
+ const selectMainWorkspace = toolkit.createSelector(
2555
+ [selectWorkspaces],
2556
+ (workspaces) => {
2557
+ return workspaces.find((workspace) => workspace.name.toLowerCase() === "main");
2558
+ }
2559
+ );
2560
+ const selectWorkspaceById = (id) => (state) => {
2561
+ return state.workspaceReducer.instances[id];
2562
+ };
2563
+ const selectPermittedWorkspaceIds = toolkit.createSelector(
2564
+ [selectWorkspaceMapping],
2565
+ (mapping) => {
2566
+ return new Set(
2567
+ Object.values(mapping).filter((workspace) => workspace.permitted).map((workspace) => workspace.offline_id)
2568
+ );
2569
+ }
2570
+ );
2571
+ const workspaceReducer = workspaceSlice.reducer;
2723
2572
  const emailDomainAdapter = createModelAdapter((emailDomain) => emailDomain.offline_id);
2724
2573
  const initialState$a = emailDomainAdapter.getInitialState({});
2725
2574
  const emailDomainsSlice = toolkit.createSlice({
@@ -3108,13 +2957,13 @@ var __publicField = (obj, key, value) => {
3108
2957
  deleteIssueComments
3109
2958
  } = issueCommentSlice.actions;
3110
2959
  const selectIssueCommentMapping = (state) => state.issueCommentReducer.instances;
2960
+ const selectIssueCommentById = (id) => (state) => {
2961
+ return state.issueCommentReducer.instances[id];
2962
+ };
3111
2963
  const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
3112
- toolkit.createSelector(
3113
- [selectIssueCommentMapping, (_state, issueId) => issueId],
3114
- (commentMapping, issueId) => {
3115
- return fallbackToEmptyArray(Object.values(commentMapping).filter((comment) => comment.issue === issueId));
3116
- }
3117
- )
2964
+ toolkit.createSelector([selectIssueCommentMapping, (_state, issueId) => issueId], (commentMapping, issueId) => {
2965
+ return fallbackToEmptyArray(Object.values(commentMapping).filter((comment) => comment.issue === issueId));
2966
+ })
3118
2967
  );
3119
2968
  const issueCommentReducer = issueCommentSlice.reducer;
3120
2969
  const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
@@ -4024,15 +3873,15 @@ var __publicField = (obj, key, value) => {
4024
3873
  }
4025
3874
  }
4026
3875
  class CategoryService extends BaseApiService {
4027
- add(payload, workspaceId) {
3876
+ add(payload) {
3877
+ var _a2;
4028
3878
  const { store } = this.client;
4029
- const createdBy = store.getState().userReducer.currentUser.id;
3879
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
4030
3880
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4031
3881
  const offlineCategory = offline({
4032
3882
  ...payload,
4033
3883
  created_by: createdBy,
4034
- submitted_at: submittedAt,
4035
- workspace: workspaceId
3884
+ submitted_at: submittedAt
4036
3885
  });
4037
3886
  this.dispatch(addCategory(offlineCategory));
4038
3887
  const promise = this.enqueueRequest({
@@ -4040,48 +3889,50 @@ var __publicField = (obj, key, value) => {
4040
3889
  method: HttpMethod.POST,
4041
3890
  url: "/categories/",
4042
3891
  queryParams: {
4043
- workspace_id: workspaceId.toString()
3892
+ workspace_id: payload.workspace.toString()
4044
3893
  },
4045
3894
  payload: offlineCategory,
4046
- blockers: [workspaceId],
3895
+ blockers: [payload.workspace],
4047
3896
  blocks: [offlineCategory.offline_id]
4048
3897
  });
4049
3898
  return [offlineCategory, promise];
4050
3899
  }
4051
- update(category, workspaceId) {
3900
+ update(payload) {
4052
3901
  const state = this.client.store.getState();
4053
- const existingCategory = selectCategoryById(category.offline_id)(state);
3902
+ const existingCategory = selectCategoryById(payload.offline_id)(state);
4054
3903
  if (!existingCategory) {
4055
- throw new Error(`Expected an existing category with offline_id ${category.offline_id}`);
3904
+ throw new Error(`Expected an existing category with offline_id ${payload.offline_id}`);
4056
3905
  }
4057
- const optimisticCategory = { ...existingCategory, ...category };
3906
+ const optimisticCategory = { ...existingCategory, ...payload };
4058
3907
  this.dispatch(updateCategory(optimisticCategory));
4059
3908
  const promise = this.enqueueRequest({
4060
3909
  description: "Edit Category",
4061
3910
  method: HttpMethod.PATCH,
4062
- url: `/categories/${category.offline_id}/`,
4063
- queryParams: {
4064
- workspace_id: workspaceId.toString()
4065
- },
4066
- payload: category,
4067
- blockers: [category.offline_id],
4068
- blocks: [category.offline_id]
3911
+ url: `/categories/${payload.offline_id}/`,
3912
+ payload,
3913
+ blockers: [payload.offline_id],
3914
+ blocks: [payload.offline_id]
4069
3915
  });
4070
3916
  return [optimisticCategory, promise];
4071
3917
  }
4072
- remove(category, workspaceId) {
4073
- this.dispatch(deleteCategory(category.offline_id));
4074
- return this.enqueueRequest({
3918
+ remove(id) {
3919
+ const { store } = this.client;
3920
+ const category = selectCategoryById(id)(store.getState());
3921
+ if (!category) {
3922
+ throw new Error(`No category with id ${id} found in the store`);
3923
+ }
3924
+ this.dispatch(deleteCategory(id));
3925
+ const promise = this.enqueueRequest({
4075
3926
  description: "Delete Category",
4076
3927
  method: HttpMethod.DELETE,
4077
3928
  url: `/categories/${category.offline_id}/`,
4078
- // TODO: Shouldn't be necessary to specify workspace_id here
4079
- queryParams: {
4080
- workspace_id: workspaceId.toString()
4081
- },
4082
3929
  blockers: [category.offline_id],
4083
3930
  blocks: []
4084
3931
  });
3932
+ promise.catch(() => {
3933
+ this.dispatch(addCategory(category));
3934
+ });
3935
+ return promise;
4085
3936
  }
4086
3937
  async refreshStore(projectId) {
4087
3938
  const result = await this.enqueueRequest({
@@ -4535,8 +4386,9 @@ var __publicField = (obj, key, value) => {
4535
4386
  };
4536
4387
  class BaseAttachmentService extends BaseUploadService {
4537
4388
  async attachFiles(files, modelId, buildOfflineAttachment) {
4389
+ var _a2;
4538
4390
  const { store } = this.client;
4539
- const currentUser = store.getState().userReducer.currentUser;
4391
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
4540
4392
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4541
4393
  const offlineAttachments = [];
4542
4394
  const attachmentPayloads = [];
@@ -4556,7 +4408,7 @@ var __publicField = (obj, key, value) => {
4556
4408
  file,
4557
4409
  sha1,
4558
4410
  submittedAt,
4559
- createdBy: currentUser.id,
4411
+ createdBy,
4560
4412
  description: "",
4561
4413
  modelId
4562
4414
  });
@@ -4760,21 +4612,21 @@ var __publicField = (obj, key, value) => {
4760
4612
  }
4761
4613
  }
4762
4614
  class IssueCommentService extends BaseApiService {
4763
- // Omit author and submitted_at since these will always be set internally
4764
- add(comment) {
4615
+ add(payload) {
4616
+ var _a2;
4765
4617
  const { store } = this.client;
4766
4618
  const offlineComment = offline({
4767
- ...comment,
4768
- author: store.getState().userReducer.currentUser.id,
4619
+ ...payload,
4620
+ author: (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id,
4769
4621
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
4770
4622
  });
4771
4623
  this.dispatch(addIssueComment(offlineComment));
4772
4624
  const promise = this.enqueueRequest({
4773
- description: `${truncate(comment.content, 80)}`,
4625
+ description: "Add issue comment",
4774
4626
  method: HttpMethod.POST,
4775
- url: `/issues/${comment.issue}/comment/`,
4627
+ url: `/issues/${payload.issue}/comment/`,
4776
4628
  payload: offlineComment,
4777
- blockers: [comment.issue],
4629
+ blockers: [payload.issue],
4778
4630
  blocks: [offlineComment.offline_id]
4779
4631
  });
4780
4632
  promise.catch(() => {
@@ -4782,37 +4634,41 @@ var __publicField = (obj, key, value) => {
4782
4634
  });
4783
4635
  return [offlineComment, promise];
4784
4636
  }
4785
- update(comment) {
4637
+ update(payload) {
4786
4638
  const { store } = this.client;
4787
- const commentToUpdate = store.getState().issueCommentReducer.instances[comment.offline_id];
4639
+ const commentToUpdate = selectIssueCommentById(payload.offline_id)(store.getState());
4788
4640
  if (!commentToUpdate) {
4789
- throw new Error(`Comment with offline_id ${comment.offline_id} not found in store`);
4641
+ throw new Error(`Comment with offline_id ${payload.offline_id} not found in store`);
4790
4642
  }
4791
- this.dispatch(setIssueComment(comment));
4643
+ const updatedComment = {
4644
+ ...commentToUpdate,
4645
+ ...payload
4646
+ };
4647
+ this.dispatch(setIssueComment(updatedComment));
4792
4648
  const promise = this.enqueueRequest({
4793
- description: `Edit comment: ${truncate(comment.content, 80)}`,
4649
+ description: "Edit issue comment",
4794
4650
  method: HttpMethod.PATCH,
4795
- url: `/issues/comments/${comment.offline_id}/`,
4796
- payload: comment,
4797
- blockers: [comment.issue],
4798
- blocks: [comment.offline_id]
4651
+ url: `/issues/comments/${payload.offline_id}/`,
4652
+ payload,
4653
+ blockers: [payload.offline_id],
4654
+ blocks: [payload.offline_id]
4799
4655
  });
4800
4656
  promise.catch(() => {
4801
4657
  this.dispatch(setIssueComment(commentToUpdate));
4802
4658
  });
4803
- return [comment, promise];
4659
+ return [updatedComment, promise];
4804
4660
  }
4805
- remove(offline_id) {
4806
- const commentToRemove = this.client.store.getState().issueCommentReducer.instances[offline_id];
4661
+ remove(id) {
4662
+ const commentToRemove = this.client.store.getState().issueCommentReducer.instances[id];
4807
4663
  if (!commentToRemove) {
4808
- throw new Error(`Comment with offline_id ${offline_id} not found in store`);
4664
+ throw new Error(`Comment with offline_id ${id} not found in store`);
4809
4665
  }
4810
- this.dispatch(deleteIssueComment(offline_id));
4666
+ this.dispatch(deleteIssueComment(id));
4811
4667
  const promise = this.enqueueRequest({
4812
4668
  description: "Delete comment",
4813
4669
  method: HttpMethod.DELETE,
4814
- url: `/issues/comments/${offline_id}/`,
4815
- blockers: [offline_id],
4670
+ url: `/issues/comments/${id}/`,
4671
+ blockers: [id],
4816
4672
  blocks: []
4817
4673
  });
4818
4674
  promise.catch(() => {
@@ -4885,67 +4741,59 @@ var __publicField = (obj, key, value) => {
4885
4741
  }
4886
4742
  class IssueService extends BaseApiService {
4887
4743
  // Basic CRUD functions
4888
- // TODO: Once all models are represented in `Created<TModel>`, use `Created` in `OptimisticModelResult`, so we don't
4889
- // have to repeat it for all optimistic model results (all optimistic results are created).
4890
- add(issue, workspaceId, issueType = null) {
4744
+ add(payload) {
4745
+ var _a2;
4891
4746
  const { store } = this.client;
4892
- const dateWithoutMilliseconds = /* @__PURE__ */ new Date();
4893
4747
  const state = store.getState();
4894
- const currentUserId = state.userReducer.currentUser.id;
4895
- dateWithoutMilliseconds.setMilliseconds(0);
4896
- if (!workspaceId) {
4897
- throw new Error("No active workspace ID while creating issue.");
4898
- }
4899
- const issuePayload = offline({
4900
- ...issue,
4901
- submitted_at: dateWithoutMilliseconds.toISOString(),
4902
- index_workspace: workspaceId,
4903
- created_by: currentUserId,
4904
- status: issue.status ?? DEFAULT_ISSUE_STATUS,
4905
- priority: issue.priority ?? DEFAULT_ISSUE_PRIORITY
4906
- });
4907
- this.dispatch(addIssue(issuePayload));
4908
- this.dispatch(addToRecentIssues(issuePayload.offline_id));
4748
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4749
+ const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
4750
+ const offlineIssue = offline({
4751
+ ...payload,
4752
+ submitted_at: submittedAt,
4753
+ created_by: createdBy
4754
+ });
4755
+ this.dispatch(addIssue(offlineIssue));
4909
4756
  this.dispatch(addActiveProjectIssuesCount(1));
4910
4757
  const promise = this.enqueueRequest({
4911
4758
  description: "Create issue",
4912
4759
  method: HttpMethod.POST,
4913
4760
  url: "/issues/",
4914
4761
  queryParams: {
4915
- workspace_id: workspaceId,
4916
- ...issueType ? { issue_type: issueType } : {}
4762
+ workspace_id: payload.index_workspace,
4763
+ ...payload.issue_type ? { issue_type: payload.issue_type } : {}
4917
4764
  },
4918
- payload: issuePayload,
4919
- blockers: ["add-issue", ...issuePayload.index_workspace ? [issuePayload.index_workspace] : []],
4920
- blocks: [issuePayload.offline_id]
4765
+ payload: offlineIssue,
4766
+ blockers: ["add-issue", ...offlineIssue.index_workspace ? [offlineIssue.index_workspace] : []],
4767
+ blocks: [offlineIssue.offline_id]
4921
4768
  });
4922
4769
  void promise.then((result) => {
4923
4770
  this.dispatch(updateIssue(result));
4924
4771
  }).catch((error) => {
4925
- var _a2;
4772
+ var _a3;
4926
4773
  console.error(error);
4927
4774
  if (error instanceof APIError) {
4928
- (_a2 = blocks.unsafeShowToast) == null ? void 0 : _a2.call(blocks, {
4775
+ (_a3 = blocks.unsafeShowToast) == null ? void 0 : _a3.call(blocks, {
4929
4776
  title: "Could not create issue",
4930
4777
  description: error.message,
4931
4778
  accentColor: "red"
4932
4779
  });
4933
4780
  }
4934
- this.dispatch(deleteIssue(issuePayload.offline_id));
4781
+ this.dispatch(deleteIssue(offlineIssue.offline_id));
4935
4782
  this.dispatch(addActiveProjectIssuesCount(-1));
4936
4783
  throw error;
4937
4784
  });
4938
- return [issuePayload, promise];
4785
+ return [offlineIssue, promise];
4939
4786
  }
4940
- update(issue) {
4787
+ update(payload) {
4788
+ var _a2;
4941
4789
  const state = this.client.store.getState();
4942
- const issueToBeUpdated = selectIssueById(issue.offline_id)(state);
4790
+ const issueToBeUpdated = selectIssueById(payload.offline_id)(state);
4943
4791
  if (!issueToBeUpdated) {
4944
4792
  throw new Error(
4945
- `Attempting to update an issue with offline_id ${issue.offline_id} that doesn't exist in the store`
4793
+ `Attempting to update an issue with offline_id ${payload.offline_id} that doesn't exist in the store`
4946
4794
  );
4947
4795
  }
4948
- const updatedIssue = { ...issueToBeUpdated, ...issue };
4796
+ const updatedIssue = { ...issueToBeUpdated, ...payload };
4949
4797
  this.dispatch(updateIssue(updatedIssue));
4950
4798
  const changes = {};
4951
4799
  for (const issueUpdateChange of [
@@ -4957,11 +4805,11 @@ var __publicField = (obj, key, value) => {
4957
4805
  IssueUpdateChange.ASSIGNED_TO,
4958
4806
  IssueUpdateChange.DUE_DATE
4959
4807
  ]) {
4960
- if (issueUpdateChange in issue && issue[issueUpdateChange] !== issueToBeUpdated[issueUpdateChange]) {
4808
+ if (issueUpdateChange in payload && payload[issueUpdateChange] !== issueToBeUpdated[issueUpdateChange]) {
4961
4809
  switch (issueUpdateChange) {
4962
4810
  case "category": {
4963
4811
  let categoryOrNull = null;
4964
- const categoryIdOrNull = issue[issueUpdateChange];
4812
+ const categoryIdOrNull = payload[issueUpdateChange];
4965
4813
  if (categoryIdOrNull) {
4966
4814
  categoryOrNull = state.categoryReducer.instances[categoryIdOrNull] ?? null;
4967
4815
  if (!categoryOrNull)
@@ -4978,7 +4826,7 @@ var __publicField = (obj, key, value) => {
4978
4826
  }
4979
4827
  case "assigned_to": {
4980
4828
  let userOrNull = null;
4981
- const userIdOrNull = issue[issueUpdateChange];
4829
+ const userIdOrNull = payload[issueUpdateChange];
4982
4830
  if (userIdOrNull) {
4983
4831
  userOrNull = state.userReducer.users[userIdOrNull] ?? null;
4984
4832
  if (!userOrNull)
@@ -4993,24 +4841,24 @@ var __publicField = (obj, key, value) => {
4993
4841
  break;
4994
4842
  }
4995
4843
  case "description":
4996
- changes[issueUpdateChange] = issue[issueUpdateChange] ?? null;
4844
+ changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
4997
4845
  break;
4998
4846
  case "title":
4999
- changes[issueUpdateChange] = issue[issueUpdateChange] ?? null;
4847
+ changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
5000
4848
  break;
5001
4849
  case "priority":
5002
- changes[issueUpdateChange] = issue[issueUpdateChange];
4850
+ changes[issueUpdateChange] = payload[issueUpdateChange];
5003
4851
  break;
5004
4852
  case "status":
5005
- changes[issueUpdateChange] = issue[issueUpdateChange];
4853
+ changes[issueUpdateChange] = payload[issueUpdateChange];
5006
4854
  break;
5007
4855
  case "due_date":
5008
- changes[issueUpdateChange] = issue[issueUpdateChange] ? issue[issueUpdateChange] : null;
4856
+ changes[issueUpdateChange] = payload[issueUpdateChange] ? payload[issueUpdateChange] : null;
5009
4857
  }
5010
4858
  }
5011
4859
  }
5012
4860
  const offlineIssueUpdate = offline({
5013
- created_by: state.userReducer.currentUser.id,
4861
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5014
4862
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5015
4863
  issue: issueToBeUpdated.offline_id,
5016
4864
  changes
@@ -5019,10 +4867,10 @@ var __publicField = (obj, key, value) => {
5019
4867
  const promise = this.enqueueRequest({
5020
4868
  description: "Edit issue",
5021
4869
  method: HttpMethod.PATCH,
5022
- url: `/issues/${issue.offline_id}/`,
5023
- payload: issue,
5024
- blockers: [issue.offline_id],
5025
- blocks: [issue.offline_id]
4870
+ url: `/issues/${payload.offline_id}/`,
4871
+ payload,
4872
+ blockers: [payload.offline_id],
4873
+ blocks: [payload.offline_id]
5026
4874
  });
5027
4875
  promise.catch(() => {
5028
4876
  this.dispatch(updateIssue(issueToBeUpdated));
@@ -5074,7 +4922,6 @@ var __publicField = (obj, key, value) => {
5074
4922
  throw e;
5075
4923
  }
5076
4924
  }
5077
- // Special functions
5078
4925
  async refreshStore(projectId) {
5079
4926
  const result = await this.enqueueRequest({
5080
4927
  description: "Get issues",
@@ -5082,33 +4929,24 @@ var __publicField = (obj, key, value) => {
5082
4929
  url: `/projects/${projectId}/issues/`,
5083
4930
  blockers: [],
5084
4931
  blocks: []
5085
- }).then((result2) => {
5086
- const filteredResult = result2.filter(onlyUniqueOfflineIds);
5087
- if (result2.length !== filteredResult.length) {
5088
- console.error(
5089
- `Received duplicate issues from the API (new length ${filteredResult.length});
5090
- filtered in browser.`
5091
- );
5092
- }
5093
- return filteredResult;
5094
4932
  });
5095
4933
  this.dispatch(initializeIssues(result));
5096
4934
  }
5097
4935
  }
5098
4936
  class IssueTypeService extends BaseApiService {
5099
- add(payload, organizationId) {
4937
+ add(payload) {
4938
+ var _a2;
5100
4939
  const { store } = this.client;
5101
4940
  const state = store.getState();
5102
4941
  const offlineIssueType = offline({
5103
4942
  ...payload,
5104
4943
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5105
- created_by: state.userReducer.currentUser.id,
5106
- organization: organizationId
4944
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id
5107
4945
  });
5108
4946
  this.dispatch(addIssueType(offlineIssueType));
5109
4947
  const promise = this.enqueueRequest({
5110
4948
  method: HttpMethod.POST,
5111
- url: `/organizations/${organizationId}/issue-types/`,
4949
+ url: `/organizations/${payload.organization}/issue-types/`,
5112
4950
  // Sending only whats needed here
5113
4951
  payload: {
5114
4952
  offline_id: offlineIssueType.offline_id,
@@ -5154,20 +4992,20 @@ var __publicField = (obj, key, value) => {
5154
4992
  });
5155
4993
  return [offlineUpdatedIssueType, promise];
5156
4994
  }
5157
- delete(issueTypeId) {
4995
+ delete(id) {
5158
4996
  const { store } = this.client;
5159
4997
  const state = store.getState();
5160
- const issueTypeToDelete = selectIssueTypeById(issueTypeId)(state);
4998
+ const issueTypeToDelete = selectIssueTypeById(id)(state);
5161
4999
  if (!issueTypeToDelete) {
5162
- throw new Error(`IssueType with offline_id ${issueTypeId} does not exist in the store.`);
5000
+ throw new Error(`IssueType with offline_id ${id} does not exist in the store.`);
5163
5001
  }
5164
- const issuesOfIssueType = selectIssuesOfIssueType(issueTypeId)(state);
5165
- this.dispatch(removeIssueType(issueTypeId));
5002
+ const issuesOfIssueType = selectIssuesOfIssueType(id)(state);
5003
+ this.dispatch(removeIssueType(id));
5166
5004
  this.dispatch(deleteIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
5167
5005
  const promise = this.enqueueRequest({
5168
5006
  method: HttpMethod.DELETE,
5169
- url: `/issues/types/${issueTypeId}/`,
5170
- blockers: [issueTypeId],
5007
+ url: `/issues/types/${id}/`,
5008
+ blockers: [id],
5171
5009
  blocks: []
5172
5010
  });
5173
5011
  promise.catch(() => {
@@ -5225,17 +5063,6 @@ var __publicField = (obj, key, value) => {
5225
5063
  }
5226
5064
  }
5227
5065
  class ProjectFileService extends BaseApiService {
5228
- async refreshStore(projectId) {
5229
- const result = await this.enqueueRequest({
5230
- description: "Get project files",
5231
- method: HttpMethod.GET,
5232
- url: `/projects/${projectId}/files/`,
5233
- blockers: [],
5234
- blocks: []
5235
- });
5236
- this.dispatch(addOrReplaceProjectFiles([]));
5237
- this.dispatch(addOrReplaceProjectFiles(result));
5238
- }
5239
5066
  async saveExisting(file) {
5240
5067
  if (!file.offline_id) {
5241
5068
  throw new Error(
@@ -5323,6 +5150,17 @@ var __publicField = (obj, key, value) => {
5323
5150
  blocks: []
5324
5151
  });
5325
5152
  }
5153
+ async refreshStore(projectId) {
5154
+ const result = await this.enqueueRequest({
5155
+ description: "Get project files",
5156
+ method: HttpMethod.GET,
5157
+ url: `/projects/${projectId}/files/`,
5158
+ blockers: [],
5159
+ blocks: []
5160
+ });
5161
+ this.dispatch(addOrReplaceProjectFiles([]));
5162
+ this.dispatch(addOrReplaceProjectFiles(result));
5163
+ }
5326
5164
  }
5327
5165
  class ProjectAttachmentService extends BaseAttachmentService {
5328
5166
  constructor() {
@@ -5508,8 +5346,9 @@ var __publicField = (obj, key, value) => {
5508
5346
  };
5509
5347
  class FormService extends BaseUploadService {
5510
5348
  async bulkAddRevisionAttachments(revisionId, files) {
5349
+ var _a2;
5511
5350
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5512
- const createdBy = this.client.store.getState().userReducer.currentUser.id;
5351
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5513
5352
  const filePayloads = {};
5514
5353
  const offlineFormRevisionAttachments = [];
5515
5354
  const attachmentPayloads = [];
@@ -5611,10 +5450,11 @@ var __publicField = (obj, key, value) => {
5611
5450
  return [form, offlineFormRevision, offlineFormRevisionAttachments, formPromise, attachmentsPromise];
5612
5451
  }
5613
5452
  addForOrganization(organizationId, initialRevision) {
5453
+ var _a2;
5614
5454
  const state = this.client.store.getState();
5615
5455
  const offlineForm = offline({
5616
5456
  favorite: false,
5617
- created_by: state.userReducer.currentUser.id,
5457
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5618
5458
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5619
5459
  organization: organizationId
5620
5460
  });
@@ -5626,45 +5466,49 @@ var __publicField = (obj, key, value) => {
5626
5466
  );
5627
5467
  }
5628
5468
  addForProject(projectId, initialRevision) {
5469
+ var _a2;
5629
5470
  const state = this.client.store.getState();
5630
5471
  const offlineForm = offline({
5631
5472
  favorite: false,
5632
- created_by: state.userReducer.currentUser.id,
5473
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5633
5474
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5634
5475
  project: projectId
5635
5476
  });
5636
5477
  return this.add(projectId.toString(), offlineForm, initialRevision, `/projects/${projectId}/create-form/`);
5637
5478
  }
5638
5479
  addForIssueType(issueTypeId, initialRevision) {
5480
+ var _a2;
5639
5481
  const state = this.client.store.getState();
5640
5482
  const offlineForm = offline({
5641
5483
  favorite: false,
5642
- created_by: state.userReducer.currentUser.id,
5484
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5643
5485
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5644
5486
  issue_type: issueTypeId
5645
5487
  });
5646
5488
  return this.add(issueTypeId, offlineForm, initialRevision, `/issues/types/${issueTypeId}/create-form/`);
5647
5489
  }
5648
5490
  addForAssetType(assetTypeId, initialRevision) {
5491
+ var _a2;
5649
5492
  const state = this.client.store.getState();
5650
5493
  const offlineForm = offline({
5651
5494
  favorite: false,
5652
- created_by: state.userReducer.currentUser.id,
5495
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5653
5496
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5654
5497
  asset_type: assetTypeId
5655
5498
  });
5656
5499
  return this.add(assetTypeId, offlineForm, initialRevision, `/assets/types/${assetTypeId}/create-form/`);
5657
5500
  }
5658
5501
  async createRevision(formId, revision) {
5502
+ var _a2;
5659
5503
  const offlineRevision = offline(revision);
5660
5504
  const { store } = this.client;
5661
5505
  const state = store.getState();
5662
- const currentUserId = state.userReducer.currentUser.id;
5506
+ const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
5663
5507
  const { fields, images } = await separateImageFromFields(offlineRevision.fields);
5664
5508
  const fullRevision = {
5665
5509
  ...offlineRevision,
5666
5510
  fields,
5667
- created_by: currentUserId,
5511
+ created_by: createdBy,
5668
5512
  revision: "Pending",
5669
5513
  form: formId,
5670
5514
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -5813,8 +5657,9 @@ var __publicField = (obj, key, value) => {
5813
5657
  };
5814
5658
  class FormSubmissionService extends BaseUploadService {
5815
5659
  async bulkAddSubmissionAttachments(submissionId, files) {
5660
+ var _a2;
5816
5661
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5817
- const createdBy = this.client.store.getState().userReducer.currentUser.id;
5662
+ const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
5818
5663
  const filePayloads = {};
5819
5664
  const offlineFormSubmissionAttachments = [];
5820
5665
  const attachmentPayloads = [];
@@ -5896,13 +5741,14 @@ var __publicField = (obj, key, value) => {
5896
5741
  }
5897
5742
  // Outer promise is for hashing and caching files for submission attachments
5898
5743
  async add(payload) {
5744
+ var _a2;
5899
5745
  const { store } = this.client;
5900
5746
  const state = store.getState();
5901
5747
  const { values, files } = separateFilesFromValues(payload.values);
5902
5748
  const offlineSubmission = offline({
5903
5749
  ...payload,
5904
5750
  values,
5905
- created_by: state.userReducer.currentUser.id,
5751
+ created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
5906
5752
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
5907
5753
  });
5908
5754
  const promise = this.enqueueRequest({
@@ -6158,8 +6004,9 @@ var __publicField = (obj, key, value) => {
6158
6004
  }
6159
6005
  class WorkspaceService extends BaseApiService {
6160
6006
  add(payload) {
6007
+ var _a2;
6161
6008
  const { store } = this.client;
6162
- const createdBy = store.getState().userReducer.currentUser.id;
6009
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6163
6010
  const offlineWorkspace = offline({
6164
6011
  ...payload,
6165
6012
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -6181,8 +6028,14 @@ var __publicField = (obj, key, value) => {
6181
6028
  });
6182
6029
  return [offlineWorkspace, promise];
6183
6030
  }
6184
- update(workspace) {
6185
- this.dispatch(addWorkspace(workspace));
6031
+ update(payload) {
6032
+ const { store } = this.client;
6033
+ const workspace = selectWorkspaceById(payload.offline_id)(store.getState());
6034
+ if (!workspace) {
6035
+ throw new Error(`Expected an existing workspace with offline_id ${payload.offline_id}`);
6036
+ }
6037
+ const updatedWorkspace = { ...workspace, ...payload };
6038
+ this.dispatch(updateWorkspace(updatedWorkspace));
6186
6039
  const promise = this.enqueueRequest({
6187
6040
  description: "Update Workspace",
6188
6041
  method: HttpMethod.PATCH,
@@ -6191,10 +6044,17 @@ var __publicField = (obj, key, value) => {
6191
6044
  blockers: [workspace.offline_id],
6192
6045
  blocks: [workspace.offline_id]
6193
6046
  });
6047
+ promise.then((result) => {
6048
+ this.dispatch(updateWorkspace(result));
6049
+ }).catch(() => {
6050
+ this.dispatch(updateWorkspace(workspace));
6051
+ });
6194
6052
  return [workspace, promise];
6195
6053
  }
6196
6054
  delete(workspaceId) {
6197
6055
  const { store } = this.client;
6056
+ const originalWorkspace = selectWorkspaceById(workspaceId)(store.getState());
6057
+ this.dispatch(deleteWorkspace(workspaceId));
6198
6058
  const promise = this.enqueueRequest({
6199
6059
  description: "Delete Workspace",
6200
6060
  method: HttpMethod.DELETE,
@@ -6202,8 +6062,6 @@ var __publicField = (obj, key, value) => {
6202
6062
  blockers: [workspaceId],
6203
6063
  blocks: []
6204
6064
  });
6205
- const originalWorkspace = store.getState().workspaceReducer.instances[workspaceId];
6206
- this.dispatch(deleteWorkspace(workspaceId));
6207
6065
  void promise.then(() => {
6208
6066
  }).catch((reason) => {
6209
6067
  if (originalWorkspace) {
@@ -6705,12 +6563,13 @@ var __publicField = (obj, key, value) => {
6705
6563
  }
6706
6564
  class DocumentService extends BaseApiService {
6707
6565
  add(payload) {
6566
+ var _a2;
6708
6567
  const { store } = this.client;
6709
- const currentUserId = store.getState().userReducer.currentUser.id;
6568
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6710
6569
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6711
6570
  const offlineDocument = offline({
6712
6571
  ...payload,
6713
- created_by: currentUserId,
6572
+ created_by: createdBy,
6714
6573
  submitted_at: submittedAt
6715
6574
  });
6716
6575
  this.dispatch(addDocuments([offlineDocument]));
@@ -6739,7 +6598,11 @@ var __publicField = (obj, key, value) => {
6739
6598
  `attempting to update a document with offline_id ${document2.offline_id} that does not exist in store.documents`
6740
6599
  );
6741
6600
  }
6742
- this.dispatch(updateDocuments([document2]));
6601
+ const updatedDocument = {
6602
+ ...documentToBeUpdated,
6603
+ ...document2
6604
+ };
6605
+ this.dispatch(updateDocuments([updatedDocument]));
6743
6606
  const promise = this.enqueueRequest({
6744
6607
  description: "Update Document",
6745
6608
  method: HttpMethod.PATCH,
@@ -6751,8 +6614,7 @@ var __publicField = (obj, key, value) => {
6751
6614
  promise.catch(() => {
6752
6615
  updateDocuments([documentToBeUpdated]);
6753
6616
  });
6754
- const fullDocument = store.getState().documentsReducer.documents[document2.offline_id];
6755
- return [fullDocument, promise];
6617
+ return [updatedDocument, promise];
6756
6618
  }
6757
6619
  move(documentId, targetDocumentId, position) {
6758
6620
  const { store } = this.client;
@@ -6799,22 +6661,22 @@ var __publicField = (obj, key, value) => {
6799
6661
  });
6800
6662
  return promise;
6801
6663
  }
6802
- delete(documentId) {
6664
+ delete(id) {
6803
6665
  const { store } = this.client;
6804
6666
  const documentsMapping = selectDocumentsMapping(store.getState());
6805
- const documentToBeDeleted = documentsMapping[documentId];
6667
+ const documentToBeDeleted = selectDocumentById(id)(store.getState());
6806
6668
  if (!documentToBeDeleted) {
6807
6669
  throw new Error(
6808
- `attempting to delete a document with offline_id ${documentId} that does not exist in store.documents`
6670
+ `attempting to delete a document with offline_id ${id} that does not exist in store.documents`
6809
6671
  );
6810
6672
  }
6811
6673
  const parentDocument = documentToBeDeleted.parent_document ? documentsMapping[documentToBeDeleted.parent_document] : void 0;
6812
- this.dispatch(removeDocuments([documentId]));
6674
+ this.dispatch(removeDocuments([id]));
6813
6675
  const promise = this.enqueueRequest({
6814
6676
  description: "Delete Document",
6815
6677
  method: HttpMethod.DELETE,
6816
- url: `/documents/${documentId}/`,
6817
- blockers: [documentId],
6678
+ url: `/documents/${id}/`,
6679
+ blockers: [id],
6818
6680
  blocks: []
6819
6681
  });
6820
6682
  promise.then((documentsToUpdate) => {
@@ -6872,8 +6734,9 @@ var __publicField = (obj, key, value) => {
6872
6734
  }
6873
6735
  // NOTE: overriding the method from BaseAttachmentService since document attachments get vectorized
6874
6736
  async attachFilesToDocument(files, documentId) {
6737
+ var _a2;
6875
6738
  const { store } = this.client;
6876
- const currentUser = store.getState().userReducer.currentUser;
6739
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
6877
6740
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6878
6741
  const offlineAttachments = [];
6879
6742
  const attachmentPayloads = [];
@@ -6895,7 +6758,7 @@ var __publicField = (obj, key, value) => {
6895
6758
  file,
6896
6759
  sha1,
6897
6760
  submittedAt,
6898
- createdBy: currentUser.id,
6761
+ createdBy,
6899
6762
  description: "",
6900
6763
  modelId: documentId
6901
6764
  });
@@ -7058,10 +6921,9 @@ var __publicField = (obj, key, value) => {
7058
6921
  }
7059
6922
  }
7060
6923
  class TeamService extends BaseApiService {
7061
- add(teamPayload, organizationId) {
6924
+ add(payload) {
7062
6925
  const offlineTeam = offline({
7063
- ...teamPayload,
7064
- organization: organizationId,
6926
+ ...payload,
7065
6927
  submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7066
6928
  // TODO: uncomment once supported
7067
6929
  // created_by: state.userReducer.currentUser.id,
@@ -7070,7 +6932,7 @@ var __publicField = (obj, key, value) => {
7070
6932
  const promise = this.enqueueRequest({
7071
6933
  description: "Create team",
7072
6934
  method: HttpMethod.POST,
7073
- url: `/organizations/${organizationId}/teams/`,
6935
+ url: `/organizations/${payload.organization}/teams/`,
7074
6936
  payload: offlineTeam,
7075
6937
  // No blocks since users and organizations are not offline
7076
6938
  blockers: [],
@@ -7083,25 +6945,24 @@ var __publicField = (obj, key, value) => {
7083
6945
  });
7084
6946
  return [offlineTeam, promise];
7085
6947
  }
7086
- // TODO: @Audiopolis / Magnus - should we pass a offline_id as one arg and a UpdatedTeamProps as a second arg instead of this set up?
7087
- update(team) {
6948
+ update(payload) {
7088
6949
  const { store } = this.client;
7089
- const teamToBeUpdated = selectTeamById(team.offline_id)(store.getState());
6950
+ const teamToBeUpdated = selectTeamById(payload.offline_id)(store.getState());
7090
6951
  if (!teamToBeUpdated) {
7091
- throw new Error(`Expected team with offline_id ${team.offline_id} to exist`);
6952
+ throw new Error(`Expected team with offline_id ${payload.offline_id} to exist`);
7092
6953
  }
7093
6954
  const offlineUpdatedTeam = {
7094
6955
  ...teamToBeUpdated,
7095
- ...team
6956
+ ...payload
7096
6957
  };
7097
6958
  this.dispatch(updateTeam(offlineUpdatedTeam));
7098
6959
  const promise = this.enqueueRequest({
7099
6960
  description: "Update team",
7100
6961
  method: HttpMethod.PATCH,
7101
- url: `/organizations/teams/${team.offline_id}/`,
6962
+ url: `/organizations/teams/${payload.offline_id}/`,
7102
6963
  payload: offlineUpdatedTeam,
7103
- blockers: [team.offline_id],
7104
- blocks: [team.offline_id]
6964
+ blockers: [payload.offline_id],
6965
+ blocks: [payload.offline_id]
7105
6966
  });
7106
6967
  promise.then((updatedTeam) => {
7107
6968
  this.dispatch(setTeam(updatedTeam));
@@ -7213,10 +7074,11 @@ var __publicField = (obj, key, value) => {
7213
7074
  }
7214
7075
  class GeoImageService extends BaseUploadService {
7215
7076
  async add(payload) {
7077
+ var _a2;
7216
7078
  const { store } = this.client;
7217
7079
  const { file, ...payloadWithoutFile } = payload;
7218
7080
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7219
- const currentUser = store.getState().userReducer.currentUser;
7081
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7220
7082
  const projectId = payloadWithoutFile.project;
7221
7083
  const sha1 = await hashFile(file);
7222
7084
  const filePayload = {
@@ -7231,9 +7093,9 @@ var __publicField = (obj, key, value) => {
7231
7093
  file_sha1: sha1,
7232
7094
  file: URL.createObjectURL(file),
7233
7095
  submitted_at: submittedAt,
7234
- created_by: currentUser.id
7096
+ created_by: createdBy
7235
7097
  });
7236
- store.dispatch(addGeoImage(offlineMapImage));
7098
+ this.dispatch(addGeoImage(offlineMapImage));
7237
7099
  const promise = this.enqueueRequest({
7238
7100
  description: "Add geo image",
7239
7101
  method: HttpMethod.POST,
@@ -7257,16 +7119,17 @@ var __publicField = (obj, key, value) => {
7257
7119
  });
7258
7120
  promise.then((result) => {
7259
7121
  this.processPresignedUrls(result.presigned_urls);
7260
- store.dispatch(setGeoImage(result.geo_image));
7122
+ this.dispatch(setGeoImage(result.geo_image));
7261
7123
  }).catch(() => {
7262
- store.dispatch(deleteGeoImage(offlineMapImage.offline_id));
7124
+ this.dispatch(deleteGeoImage(offlineMapImage.offline_id));
7263
7125
  });
7264
7126
  return [offlineMapImage, promise.then((result) => result.geo_image)];
7265
7127
  }
7266
7128
  async bulkAdd(payloads, projectId) {
7129
+ var _a2;
7267
7130
  const { store } = this.client;
7268
7131
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7269
- const currentUser = store.getState().userReducer.currentUser;
7132
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7270
7133
  const offlineGeoImages = [];
7271
7134
  const offlineIds = [];
7272
7135
  const geoImagePayloads = [];
@@ -7289,7 +7152,7 @@ var __publicField = (obj, key, value) => {
7289
7152
  file_sha1: sha1,
7290
7153
  file: URL.createObjectURL(file),
7291
7154
  submitted_at: submittedAt,
7292
- created_by: currentUser.id,
7155
+ created_by: createdBy,
7293
7156
  project: projectId
7294
7157
  });
7295
7158
  offlineGeoImages.push(offlineMapImage);
@@ -7306,7 +7169,7 @@ var __publicField = (obj, key, value) => {
7306
7169
  original_date: offlineMapImage.original_date
7307
7170
  });
7308
7171
  }
7309
- store.dispatch(addGeoImages(offlineGeoImages));
7172
+ this.dispatch(addGeoImages(offlineGeoImages));
7310
7173
  const promise = this.enqueueRequest({
7311
7174
  description: "Bulk add geo images",
7312
7175
  method: HttpMethod.POST,
@@ -7322,9 +7185,9 @@ var __publicField = (obj, key, value) => {
7322
7185
  });
7323
7186
  promise.then((result) => {
7324
7187
  this.processPresignedUrls(result.presigned_urls);
7325
- store.dispatch(setGeoImages(result.geo_images));
7188
+ this.dispatch(setGeoImages(result.geo_images));
7326
7189
  }).catch(() => {
7327
- store.dispatch(deleteGeoImages(offlineIds));
7190
+ this.dispatch(deleteGeoImages(offlineIds));
7328
7191
  });
7329
7192
  return [offlineGeoImages, promise.then((result) => result.geo_images)];
7330
7193
  }
@@ -7336,7 +7199,7 @@ var __publicField = (obj, key, value) => {
7336
7199
  throw new Error(`Map image with offline_id ${payload.offline_id} does not exist in the store`);
7337
7200
  }
7338
7201
  const updatedGeoImage = { ...geoImageToUpdate, ...payload };
7339
- store.dispatch(updateGeoImage(updatedGeoImage));
7202
+ this.dispatch(updateGeoImage(updatedGeoImage));
7340
7203
  const promise = this.enqueueRequest({
7341
7204
  description: "Update geo image",
7342
7205
  method: HttpMethod.PATCH,
@@ -7346,9 +7209,9 @@ var __publicField = (obj, key, value) => {
7346
7209
  blockers: [payload.offline_id]
7347
7210
  });
7348
7211
  promise.then((result) => {
7349
- store.dispatch(setGeoImage(result));
7212
+ this.dispatch(setGeoImage(result));
7350
7213
  }).catch(() => {
7351
- store.dispatch(setGeoImage(geoImageToUpdate));
7214
+ this.dispatch(setGeoImage(geoImageToUpdate));
7352
7215
  });
7353
7216
  return [updatedGeoImage, promise];
7354
7217
  }
@@ -7359,7 +7222,7 @@ var __publicField = (obj, key, value) => {
7359
7222
  if (!geoImageToDelete) {
7360
7223
  throw new Error(`Map image with offline_id ${geoImageId} does not exist in the store`);
7361
7224
  }
7362
- store.dispatch(deleteGeoImage(geoImageId));
7225
+ this.dispatch(deleteGeoImage(geoImageId));
7363
7226
  const promise = this.enqueueRequest({
7364
7227
  description: "Delete geo image",
7365
7228
  method: HttpMethod.DELETE,
@@ -7368,12 +7231,11 @@ var __publicField = (obj, key, value) => {
7368
7231
  blockers: [geoImageId]
7369
7232
  });
7370
7233
  promise.catch(() => {
7371
- store.dispatch(setGeoImage(geoImageToDelete));
7234
+ this.dispatch(setGeoImage(geoImageToDelete));
7372
7235
  });
7373
7236
  return promise;
7374
7237
  }
7375
7238
  async refreshStore(projectId) {
7376
- const { store } = this.client;
7377
7239
  const result = await this.enqueueRequest({
7378
7240
  description: "Get geo images",
7379
7241
  method: HttpMethod.GET,
@@ -7381,14 +7243,15 @@ var __publicField = (obj, key, value) => {
7381
7243
  blocks: [projectId.toString()],
7382
7244
  blockers: []
7383
7245
  });
7384
- store.dispatch(initializeGeoImages(result));
7246
+ this.dispatch(initializeGeoImages(result));
7385
7247
  }
7386
7248
  }
7387
7249
  class IssueAssociationService extends BaseUploadService {
7388
7250
  add(payload) {
7251
+ var _a2;
7389
7252
  const { store } = this.client;
7390
7253
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7391
- const createdBy = store.getState().userReducer.currentUser.id;
7254
+ const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
7392
7255
  const offlineIssueAssociation = offline({
7393
7256
  ...payload,
7394
7257
  submitted_at: submittedAt,
@@ -7402,7 +7265,6 @@ var __publicField = (obj, key, value) => {
7402
7265
  payload: {
7403
7266
  offline_id: offlineIssueAssociation.offline_id,
7404
7267
  submitted_at: submittedAt,
7405
- created_by: createdBy,
7406
7268
  ...payload
7407
7269
  },
7408
7270
  blockers: [
@@ -7526,7 +7388,6 @@ var __publicField = (obj, key, value) => {
7526
7388
  exports2.addDocumentAttachments = addDocumentAttachments;
7527
7389
  exports2.addDocuments = addDocuments;
7528
7390
  exports2.addEmailDomain = addEmailDomain;
7529
- exports2.addFavouriteProjectId = addFavouriteProjectId;
7530
7391
  exports2.addForm = addForm;
7531
7392
  exports2.addFormRevision = addFormRevision;
7532
7393
  exports2.addFormRevisionAttachment = addFormRevisionAttachment;
@@ -7560,7 +7421,6 @@ var __publicField = (obj, key, value) => {
7560
7421
  exports2.addStageCompletions = addStageCompletions;
7561
7422
  exports2.addStages = addStages;
7562
7423
  exports2.addTeam = addTeam;
7563
- exports2.addToRecentIssues = addToRecentIssues;
7564
7424
  exports2.addUsers = addUsers;
7565
7425
  exports2.addWorkspace = addWorkspace;
7566
7426
  exports2.agentsReducer = agentsReducer;
@@ -7585,7 +7445,6 @@ var __publicField = (obj, key, value) => {
7585
7445
  exports2.categoryReducer = categoryReducer;
7586
7446
  exports2.categorySlice = categorySlice;
7587
7447
  exports2.classNames = classNames;
7588
- exports2.cleanRecentIssues = cleanRecentIssues;
7589
7448
  exports2.clearTokens = clearTokens;
7590
7449
  exports2.constructUploadedFilePayloads = constructUploadedFilePayloads;
7591
7450
  exports2.coordinatesAreEqual = coordinatesAreEqual;
@@ -7756,20 +7615,16 @@ var __publicField = (obj, key, value) => {
7756
7615
  exports2.rehydratedReducer = rehydratedReducer;
7757
7616
  exports2.rehydratedSlice = rehydratedSlice;
7758
7617
  exports2.removeDocuments = removeDocuments;
7759
- exports2.removeFavouriteProjectId = removeFavouriteProjectId;
7760
7618
  exports2.removeIssueType = removeIssueType;
7761
7619
  exports2.removeProjectFile = removeProjectFile;
7762
7620
  exports2.removeProjectFilesOfProject = removeProjectFilesOfProject;
7763
- exports2.removeRecentIssue = removeRecentIssue;
7764
7621
  exports2.removeStageCompletions = removeStageCompletions;
7765
7622
  exports2.removeStages = removeStages;
7766
7623
  exports2.removeUser = removeUser;
7767
7624
  exports2.resetProjectFileObjectUrls = resetProjectFileObjectUrls;
7768
- exports2.resetRecentIssues = resetRecentIssues;
7769
7625
  exports2.resetStore = resetStore;
7770
7626
  exports2.restructureCreateSelectorWithArgs = restructureCreateSelectorWithArgs;
7771
7627
  exports2.saveActiveProjectFileBounds = saveActiveProjectFileBounds;
7772
- exports2.searchIssues = searchIssues;
7773
7628
  exports2.selectAccessToken = selectAccessToken;
7774
7629
  exports2.selectActiveOrganizationAccess = selectActiveOrganizationAccess;
7775
7630
  exports2.selectActiveProject = selectActiveProject;
@@ -7835,7 +7690,6 @@ var __publicField = (obj, key, value) => {
7835
7690
  exports2.selectEmailDomains = selectEmailDomains;
7836
7691
  exports2.selectEmailDomainsAsMapping = selectEmailDomainsAsMapping;
7837
7692
  exports2.selectEmailDomainsOfOrganization = selectEmailDomainsOfOrganization;
7838
- exports2.selectFavouriteProjects = selectFavouriteProjects;
7839
7693
  exports2.selectFilteredForms = selectFilteredForms;
7840
7694
  exports2.selectFormById = selectFormById;
7841
7695
  exports2.selectFormMapping = selectFormMapping;
@@ -7876,6 +7730,7 @@ var __publicField = (obj, key, value) => {
7876
7730
  exports2.selectIssueAttachmentMapping = selectIssueAttachmentMapping;
7877
7731
  exports2.selectIssueAttachments = selectIssueAttachments;
7878
7732
  exports2.selectIssueById = selectIssueById;
7733
+ exports2.selectIssueCommentById = selectIssueCommentById;
7879
7734
  exports2.selectIssueCommentMapping = selectIssueCommentMapping;
7880
7735
  exports2.selectIssueCountOfCategory = selectIssueCountOfCategory;
7881
7736
  exports2.selectIssueMapping = selectIssueMapping;
@@ -7925,8 +7780,6 @@ var __publicField = (obj, key, value) => {
7925
7780
  exports2.selectProjectUsersAsMapping = selectProjectUsersAsMapping;
7926
7781
  exports2.selectProjectUsersIds = selectProjectUsersIds;
7927
7782
  exports2.selectProjectsOfOrganization = selectProjectsOfOrganization;
7928
- exports2.selectRecentIssueIds = selectRecentIssueIds;
7929
- exports2.selectRecentIssuesAsSearchResults = selectRecentIssuesAsSearchResults;
7930
7783
  exports2.selectRehydrated = selectRehydrated;
7931
7784
  exports2.selectRootDocuments = selectRootDocuments;
7932
7785
  exports2.selectSortedFormSubmissionsOfForm = selectSortedFormSubmissionsOfForm;
@@ -7992,7 +7845,6 @@ var __publicField = (obj, key, value) => {
7992
7845
  exports2.setStageCompletions = setStageCompletions;
7993
7846
  exports2.setTeam = setTeam;
7994
7847
  exports2.setTokens = setTokens;
7995
- exports2.setTourStep = setTourStep;
7996
7848
  exports2.setUploadUrl = setUploadUrl;
7997
7849
  exports2.setUsers = setUsers;
7998
7850
  exports2.setWorkspaces = setWorkspaces;