@overmap-ai/core 1.0.58-sign-up-hotfix.5 → 1.0.60-model-adapter.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/overmap-core.js +1074 -1590
  2. package/dist/overmap-core.js.map +1 -1
  3. package/dist/overmap-core.umd.cjs +1077 -1593
  4. package/dist/overmap-core.umd.cjs.map +1 -1
  5. package/dist/sdk/services/AssetAttachmentService.d.ts +9 -3
  6. package/dist/sdk/services/AssetTypeAttachmentService.d.ts +9 -3
  7. package/dist/sdk/services/BaseAttachmentService.d.ts +11 -15
  8. package/dist/sdk/services/CategoryService.d.ts +1 -20
  9. package/dist/sdk/services/DocumentAttachmentService.d.ts +9 -3
  10. package/dist/sdk/services/EmailDomainsService.d.ts +0 -1
  11. package/dist/sdk/services/IssueAttachmentService.d.ts +9 -3
  12. package/dist/sdk/services/IssueService.d.ts +1 -2
  13. package/dist/sdk/services/ProjectAttachmentService.d.ts +9 -3
  14. package/dist/store/adapter.d.ts +15 -0
  15. package/dist/store/slices/agentsSlice.d.ts +23 -12
  16. package/dist/store/slices/assetAttachmentSlice.d.ts +52 -0
  17. package/dist/store/slices/assetSlice.d.ts +10 -51
  18. package/dist/store/slices/assetStageSlice.d.ts +30 -22
  19. package/dist/store/slices/assetTypeAttachmentSlice.d.ts +52 -0
  20. package/dist/store/slices/assetTypeSlice.d.ts +11 -49
  21. package/dist/store/slices/categorySlice.d.ts +26 -25
  22. package/dist/store/slices/documentAttachmentSlice.d.ts +52 -0
  23. package/dist/store/slices/documentSlice.d.ts +11 -43
  24. package/dist/store/slices/emailDomainsSlice.d.ts +14 -11
  25. package/dist/store/slices/formRevisionAttachmentSlice.d.ts +46 -0
  26. package/dist/store/slices/formRevisionSlice.d.ts +39 -21
  27. package/dist/store/slices/formSlice.d.ts +27 -22
  28. package/dist/store/slices/formSubmissionAttachmentSlice.d.ts +46 -0
  29. package/dist/store/slices/formSubmissionSlice.d.ts +29 -29
  30. package/dist/store/slices/index.d.ts +9 -0
  31. package/dist/store/slices/issueAttachmentSlice.d.ts +52 -0
  32. package/dist/store/slices/issueCommentSlice.d.ts +34 -0
  33. package/dist/store/slices/issueSlice.d.ts +21 -127
  34. package/dist/store/slices/issueTypeSlice.d.ts +25 -11
  35. package/dist/store/slices/issueUpdateSlice.d.ts +34 -0
  36. package/dist/store/slices/licenseSlice.d.ts +9 -7
  37. package/dist/store/slices/organizationAccessSlice.d.ts +12 -10
  38. package/dist/store/slices/projectAccessSlice.d.ts +15 -11
  39. package/dist/store/slices/projectAttachmentSlice.d.ts +52 -0
  40. package/dist/store/slices/projectFileSlice.d.ts +9 -0
  41. package/dist/store/slices/projectSlice.d.ts +2 -43
  42. package/dist/store/slices/teamSlice.d.ts +24 -10
  43. package/dist/store/slices/workspaceSlice.d.ts +28 -16
  44. package/dist/store/store.d.ts +28 -1
  45. package/dist/store/typings.d.ts +3 -0
  46. package/package.json +1 -1
  47. package/dist/store/slices/utils.d.ts +0 -14
@@ -734,15 +734,15 @@ var __publicField = (obj, key, value) => {
734
734
  };
735
735
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
736
736
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
737
- const initialState$s = {
737
+ const initialState$B = {
738
738
  accessToken: "",
739
739
  refreshToken: "",
740
740
  isLoggedIn: false
741
741
  };
742
742
  const authSlice = toolkit.createSlice({
743
743
  name: "auth",
744
- initialState: initialState$s,
745
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$s)),
744
+ initialState: initialState$B,
745
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$B)),
746
746
  reducers: {
747
747
  setTokens: (state, action) => {
748
748
  state.accessToken = action.payload.accessToken;
@@ -1386,77 +1386,92 @@ var __publicField = (obj, key, value) => {
1386
1386
  return getLocalDateString(date);
1387
1387
  return relative.format(days, "days");
1388
1388
  });
1389
- const initialState$r = {
1390
- categories: {},
1391
- usedCategoryColors: [],
1389
+ function createModelAdapter(computeModelId) {
1390
+ const addOne = (state, action) => {
1391
+ const id = computeModelId(action.payload);
1392
+ state.instances[id] = action.payload;
1393
+ };
1394
+ const addMany = (state, action) => {
1395
+ for (const model of action.payload) {
1396
+ const id = computeModelId(model);
1397
+ state.instances[id] = model;
1398
+ }
1399
+ };
1400
+ const setOne = (state, action) => {
1401
+ const id = computeModelId(action.payload);
1402
+ state.instances[id] = action.payload;
1403
+ };
1404
+ const setMany = (state, action) => {
1405
+ for (const model of action.payload) {
1406
+ const id = computeModelId(model);
1407
+ state.instances[id] = model;
1408
+ }
1409
+ };
1410
+ const updateOne = (state, action) => {
1411
+ const id = computeModelId(action.payload);
1412
+ state.instances[id] = action.payload;
1413
+ };
1414
+ const updateMany = (state, action) => {
1415
+ for (const model of action.payload) {
1416
+ const id = computeModelId(model);
1417
+ state.instances[id] = model;
1418
+ }
1419
+ };
1420
+ const deleteOne = (state, action) => {
1421
+ delete state.instances[action.payload];
1422
+ };
1423
+ const deleteMany = (state, action) => {
1424
+ for (const id of action.payload) {
1425
+ delete state.instances[id];
1426
+ }
1427
+ };
1428
+ const initialize = (state, action) => {
1429
+ state.instances = {};
1430
+ for (const model of action.payload) {
1431
+ const id = computeModelId(model);
1432
+ state.instances[id] = model;
1433
+ }
1434
+ };
1435
+ const getInitialState = (state) => {
1436
+ return {
1437
+ ...state,
1438
+ instances: {}
1439
+ };
1440
+ };
1441
+ return {
1442
+ addOne,
1443
+ addMany,
1444
+ setOne,
1445
+ setMany,
1446
+ updateOne,
1447
+ updateMany,
1448
+ deleteOne,
1449
+ deleteMany,
1450
+ initialize,
1451
+ getInitialState
1452
+ };
1453
+ }
1454
+ const categoryAdapter = createModelAdapter((category) => category.offline_id);
1455
+ const initialState$A = categoryAdapter.getInitialState({
1392
1456
  categoryVisibility: {
1393
1457
  hiddenCategoryIds: [],
1394
1458
  isNullCategoryHidden: false
1395
1459
  }
1396
- };
1460
+ });
1397
1461
  const categorySlice = toolkit.createSlice({
1398
1462
  name: "categories",
1399
- initialState: initialState$r,
1400
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1463
+ initialState: initialState$A,
1464
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$A)),
1401
1465
  reducers: {
1402
- setCategories: (state, action) => {
1403
- if (!Array.isArray(action.payload))
1404
- throw new Error("Expected an array of Categories");
1405
- if (action.payload.filter(onlyUniqueOfflineIds).length !== action.payload.length) {
1406
- throw new Error("Tried to use setCategories reducer with duplicate ID's");
1407
- }
1408
- action.payload.forEach((category) => {
1409
- state.categories[category.offline_id] = category;
1410
- });
1466
+ initializeCategories: (state, action) => {
1467
+ categoryAdapter.initialize(state, action);
1411
1468
  state.categoryVisibility.hiddenCategoryIds = state.categoryVisibility.hiddenCategoryIds.filter(
1412
1469
  (categoryId) => action.payload.some((category) => category.offline_id === categoryId)
1413
1470
  );
1414
1471
  },
1415
- addOrReplaceCategories: (state, action) => {
1416
- action.payload.forEach((category) => {
1417
- state.categories[category.offline_id] = category;
1418
- });
1419
- },
1420
- addCategory: (state, action) => {
1421
- if (action.payload.offline_id in state.categories) {
1422
- throw new Error(`Tried to add duplicate category with ID: ${action.payload.offline_id}`);
1423
- }
1424
- state.categories[action.payload.offline_id] = action.payload;
1425
- state.usedCategoryColors.push(action.payload.color);
1426
- },
1427
- patchCategory: (state, action) => {
1428
- const existingData = state.categories[action.payload.offline_id];
1429
- if (existingData) {
1430
- state.categories[action.payload.offline_id] = { ...existingData, ...action.payload };
1431
- } else {
1432
- console.error(`Tried to patch category with ID that doesn't exist: ${action.payload.offline_id}`);
1433
- }
1434
- if (action.payload.color && !(action.payload.color in state.usedCategoryColors)) {
1435
- state.usedCategoryColors.push(action.payload.color);
1436
- }
1437
- },
1438
- replaceCategory: (state, action) => {
1439
- if (action.payload.offline_id in state.categories) {
1440
- state.categories[action.payload.offline_id] = action.payload;
1441
- } else {
1442
- console.error(`Tried to replace category with ID that doesn't exist: ${action.payload.offline_id}`);
1443
- }
1444
- if (!(action.payload.color in state.usedCategoryColors)) {
1445
- state.usedCategoryColors.push(action.payload.color);
1446
- }
1447
- },
1448
- removeCategory: (state, action) => {
1449
- if (!action.payload) {
1450
- throw new Error("Category is undefined");
1451
- }
1452
- const category = state.categories[action.payload];
1453
- if (category) {
1454
- categorySlice.caseReducers.removeColor(state, { payload: category.color });
1455
- delete state.categories[action.payload];
1456
- } else {
1457
- throw new Error(`Tried to remove category with ID that doesn't exist: ${action.payload}`);
1458
- }
1459
- },
1472
+ addCategory: categoryAdapter.addOne,
1473
+ updateCategory: categoryAdapter.updateOne,
1474
+ deleteCategory: categoryAdapter.deleteOne,
1460
1475
  // Pass in a null value to hide the "No category" category
1461
1476
  hideCategory: (state, action) => {
1462
1477
  const categoryId = action.payload;
@@ -1467,7 +1482,7 @@ var __publicField = (obj, key, value) => {
1467
1482
  }
1468
1483
  },
1469
1484
  hideAllCategories: (state) => {
1470
- state.categoryVisibility.hiddenCategoryIds = Object.keys(state.categories);
1485
+ state.categoryVisibility.hiddenCategoryIds = Object.keys(state.instances);
1471
1486
  state.categoryVisibility.isNullCategoryHidden = true;
1472
1487
  },
1473
1488
  // Pass in a null value to unhide the "No category" category
@@ -1484,26 +1499,20 @@ var __publicField = (obj, key, value) => {
1484
1499
  unhideAllCategories: (state) => {
1485
1500
  state.categoryVisibility.hiddenCategoryIds = [];
1486
1501
  state.categoryVisibility.isNullCategoryHidden = false;
1487
- },
1488
- removeColor: (state, action) => {
1489
- state.usedCategoryColors = state.usedCategoryColors.filter((color) => color !== action.payload);
1490
1502
  }
1491
1503
  }
1492
1504
  });
1493
1505
  const {
1494
- setCategories,
1506
+ initializeCategories,
1495
1507
  addCategory,
1496
- replaceCategory,
1497
- patchCategory,
1498
- removeCategory,
1508
+ updateCategory,
1509
+ deleteCategory,
1499
1510
  hideCategory,
1500
1511
  hideAllCategories,
1501
1512
  unhideCategory,
1502
- unhideAllCategories,
1503
- removeColor,
1504
- addOrReplaceCategories
1513
+ unhideAllCategories
1505
1514
  } = categorySlice.actions;
1506
- const selectCategoryMapping = (state) => state.categoryReducer.categories;
1515
+ const selectCategoryMapping = (state) => state.categoryReducer.instances;
1507
1516
  const _selectActiveWorkspaceId = (state) => state.workspaceReducer.activeWorkspaceId;
1508
1517
  const selectCategories = toolkit.createSelector(
1509
1518
  [selectCategoryMapping, _selectActiveWorkspaceId],
@@ -1515,12 +1524,12 @@ var __publicField = (obj, key, value) => {
1515
1524
  (categories, workspaceId) => categories.filter((category) => category.workspace === workspaceId)
1516
1525
  )
1517
1526
  );
1518
- const selectCategory = (offline_id) => (state) => {
1519
- if (!offline_id)
1520
- return void 0;
1521
- return state.categoryReducer.categories[offline_id];
1522
- };
1523
- const selectUsedColors = (state) => state.categoryReducer.usedCategoryColors;
1527
+ const selectCategoryById = restructureCreateSelectorWithArgs(
1528
+ toolkit.createSelector(
1529
+ [selectCategoryMapping, (_state, categoryId) => categoryId],
1530
+ (mapping, categoryId) => mapping[categoryId]
1531
+ )
1532
+ );
1524
1533
  const selectCategoryVisibility = (state) => state.categoryReducer.categoryVisibility;
1525
1534
  const selectHiddenCategoryCount = (state) => {
1526
1535
  const { hiddenCategoryIds, isNullCategoryHidden } = state.categoryReducer.categoryVisibility;
@@ -1530,106 +1539,28 @@ var __publicField = (obj, key, value) => {
1530
1539
  return hiddenCategoryCount;
1531
1540
  };
1532
1541
  const selectIssueCountOfCategory = (categoryId) => (state) => {
1533
- return Object.values(state.issueReducer.issues).filter((issue) => issue.category === categoryId).length;
1542
+ return Object.values(state.issueReducer.instances).filter((issue) => issue.category === categoryId).length;
1534
1543
  };
1535
1544
  const categoryReducer = categorySlice.reducer;
1536
- function setAttachment(state, action) {
1537
- state.attachments[action.payload.offline_id] = action.payload;
1538
- }
1539
- function setAttachments(state, action) {
1540
- state.attachments = {};
1541
- for (const attachment of action.payload) {
1542
- state.attachments[attachment.offline_id] = attachment;
1543
- }
1544
- }
1545
- function addAttachment(state, action) {
1546
- if (action.payload.offline_id in state.attachments) {
1547
- throw new Error(`Attachment ${action.payload.offline_id} already exists.`);
1548
- }
1549
- state.attachments[action.payload.offline_id] = action.payload;
1550
- }
1551
- function addAttachments(state, action) {
1552
- for (const attachment of action.payload) {
1553
- state.attachments[attachment.offline_id] = attachment;
1554
- }
1555
- }
1556
- function updateAttachment(state, action) {
1557
- if (action.payload.offline_id in state.attachments) {
1558
- state.attachments[action.payload.offline_id] = action.payload;
1559
- } else {
1560
- throw new Error(`Attachment ${action.payload.offline_id} does not exist.`);
1561
- }
1562
- }
1563
- function updateAttachments(state, action) {
1564
- for (const attachment of action.payload) {
1565
- if (attachment.offline_id in state.attachments) {
1566
- state.attachments[attachment.offline_id] = attachment;
1567
- } else {
1568
- throw new Error(`Attachment ${attachment.offline_id} does not exist.`);
1569
- }
1570
- }
1571
- }
1572
- function removeAttachment(state, action) {
1573
- if (action.payload in state.attachments) {
1574
- delete state.attachments[action.payload];
1575
- } else {
1576
- throw new Error(`Attachment ${action.payload} does not exist.`);
1577
- }
1578
- }
1579
- function removeAttachments(state, action) {
1580
- for (const attachmentId of action.payload) {
1581
- delete state.attachments[attachmentId];
1582
- }
1583
- }
1584
- const initialState$q = {
1585
- assetTypes: {},
1586
- hiddenAssetTypeIds: {},
1587
- attachments: {}
1588
- };
1545
+ const assetTypeAdapter = createModelAdapter((assetType) => assetType.offline_id);
1546
+ const initialState$z = assetTypeAdapter.getInitialState({
1547
+ hiddenAssetTypeIds: {}
1548
+ });
1589
1549
  const assetTypeSlice = toolkit.createSlice({
1590
1550
  name: "assetTypes",
1591
- initialState: initialState$q,
1592
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1551
+ initialState: initialState$z,
1552
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
1593
1553
  reducers: {
1594
- addAssetType: (state, action) => {
1595
- state.assetTypes[action.payload.offline_id] = action.payload;
1596
- },
1597
- setAssetTypes: (state, action) => {
1598
- state.assetTypes = toOfflineIdRecord(action.payload);
1599
- },
1554
+ initializeAssetTypes: assetTypeAdapter.initialize,
1555
+ addAssetType: assetTypeAdapter.addOne,
1556
+ deleteAssetType: assetTypeAdapter.deleteOne,
1600
1557
  toggleAssetTypeVisibility: (state, action) => {
1601
1558
  state.hiddenAssetTypeIds[action.payload] = !state.hiddenAssetTypeIds[action.payload];
1602
- },
1603
- deleteAssetType: (state, action) => {
1604
- delete state.assetTypes[action.payload];
1605
- },
1606
- // Attachments
1607
- setAssetTypeAttachment: setAttachment,
1608
- setAssetTypeAttachments: setAttachments,
1609
- addAssetTypeAttachment: addAttachment,
1610
- addAssetTypeAttachments: addAttachments,
1611
- updateAssetTypeAttachment: updateAttachment,
1612
- updateAssetTypeAttachments: updateAttachments,
1613
- removeAssetTypeAttachment: removeAttachment,
1614
- removeAssetTypeAttachments: removeAttachments
1559
+ }
1615
1560
  }
1616
1561
  });
1617
- const {
1618
- addAssetType,
1619
- setAssetTypes,
1620
- toggleAssetTypeVisibility,
1621
- deleteAssetType,
1622
- // Attachmet
1623
- setAssetTypeAttachment,
1624
- setAssetTypeAttachments,
1625
- addAssetTypeAttachment,
1626
- addAssetTypeAttachments,
1627
- updateAssetTypeAttachment,
1628
- updateAssetTypeAttachments,
1629
- removeAssetTypeAttachment,
1630
- removeAssetTypeAttachments
1631
- } = assetTypeSlice.actions;
1632
- const selectAssetTypesMapping = (state) => state.assetTypeReducer.assetTypes;
1562
+ const { addAssetType, initializeAssetTypes, deleteAssetType, toggleAssetTypeVisibility } = assetTypeSlice.actions;
1563
+ const selectAssetTypesMapping = (state) => state.assetTypeReducer.instances;
1633
1564
  const selectAssetTypes = toolkit.createSelector(
1634
1565
  [selectAssetTypesMapping],
1635
1566
  (mapping) => Object.values(mapping)
@@ -1665,151 +1596,78 @@ var __publicField = (obj, key, value) => {
1665
1596
  })
1666
1597
  );
1667
1598
  const selectHiddenAssetTypeIds = (state) => state.assetTypeReducer.hiddenAssetTypeIds;
1668
- const selectAssetTypeAttachmentMapping = (state) => state.assetTypeReducer.attachments;
1669
- const selectAssetTypeAttachments = toolkit.createSelector(
1670
- [selectAssetTypeAttachmentMapping],
1671
- (mapping) => Object.values(mapping)
1672
- );
1673
- const selectAssetTypeAttachment = (attachmentId) => (state) => {
1674
- return state.assetTypeReducer.attachments[attachmentId];
1675
- };
1676
- const selectAttachmentsOfAssetType = restructureCreateSelectorWithArgs(
1677
- toolkit.createSelector(
1678
- [selectAssetTypeAttachments, (_state, assetTypeId) => assetTypeId],
1679
- (attachments, assetTypeId) => {
1680
- return attachments.filter(({ asset_type }) => assetTypeId === asset_type);
1681
- }
1682
- )
1683
- );
1684
- const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
1685
- toolkit.createSelector(
1686
- [selectAssetTypeAttachments, (_state, assetTypeId) => assetTypeId],
1687
- (attachments, assetTypeId) => {
1688
- const attachmentsOfAssetType = attachments.filter(({ asset_type }) => asset_type === assetTypeId);
1689
- const fileAttachments = attachmentsOfAssetType.filter(
1690
- // this null check here is necessary, there are cases where file_type is null or undefined
1691
- ({ file_type }) => !file_type || !file_type.startsWith("image/")
1692
- );
1693
- const imageAttachments = attachmentsOfAssetType.filter(
1694
- // this null check here is necessary, there are cases where file_type is null or undefined
1695
- ({ file_type }) => file_type && file_type.startsWith("image/")
1696
- );
1697
- return { fileAttachments, imageAttachments };
1698
- }
1699
- )
1700
- );
1701
1599
  const assetTypeReducer = assetTypeSlice.reducer;
1702
- const initialState$p = {
1703
- assets: {},
1704
- attachments: {}
1705
- };
1600
+ const assetAdapter = createModelAdapter((asset) => asset.offline_id);
1601
+ const initialState$y = assetAdapter.getInitialState({});
1706
1602
  const assetSlice = toolkit.createSlice({
1707
1603
  name: "assets",
1708
- initialState: initialState$p,
1709
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1604
+ initialState: initialState$y,
1605
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
1710
1606
  reducers: {
1607
+ initializeAssets: (state, action) => {
1608
+ assetAdapter.initialize(state, action);
1609
+ prevAssets = null;
1610
+ },
1711
1611
  addAsset: (state, action) => {
1712
- state.assets[action.payload.offline_id] = action.payload;
1612
+ assetAdapter.addOne(state, action);
1613
+ prevAssets = null;
1614
+ },
1615
+ addAssets: (state, action) => {
1616
+ assetAdapter.addMany(state, action);
1713
1617
  prevAssets = null;
1714
1618
  },
1715
- addAssetsInBatches: (state, action) => {
1716
- Object.assign(state.assets, toOfflineIdRecord(action.payload));
1619
+ setAsset: (state, action) => {
1620
+ assetAdapter.setOne(state, action);
1717
1621
  prevAssets = null;
1718
1622
  },
1719
1623
  setAssets: (state, action) => {
1720
- state.assets = toOfflineIdRecord(action.payload);
1624
+ assetAdapter.setMany(state, action);
1721
1625
  prevAssets = null;
1722
1626
  },
1723
1627
  updateAsset: (state, action) => {
1724
- if (action.payload.offline_id in state.assets) {
1725
- state.assets[action.payload.offline_id] = action.payload;
1726
- } else {
1727
- throw new Error(`Tried to update asset with ID that doesn't exist: ${action.payload.offline_id}`);
1728
- }
1628
+ assetAdapter.updateOne(state, action);
1729
1629
  prevAssets = null;
1730
1630
  },
1731
1631
  updateAssets: (state, action) => {
1732
- for (const asset of action.payload) {
1733
- if (asset.offline_id in state.assets) {
1734
- state.assets[asset.offline_id] = asset;
1735
- } else {
1736
- throw new Error(`Tried to update asset with ID that doesn't exist: ${asset.offline_id}`);
1737
- }
1738
- }
1739
- prevAssets = null;
1740
- },
1741
- removeAsset: (state, action) => {
1742
- if (action.payload in state.assets) {
1743
- delete state.assets[action.payload];
1744
- } else {
1745
- throw new Error(`Failed to remove asset because ID doesn't exist: ${action.payload}`);
1746
- }
1632
+ assetAdapter.updateMany(state, action);
1747
1633
  prevAssets = null;
1748
1634
  },
1749
- removeAssets: (state, action) => {
1750
- for (const assetId of action.payload) {
1751
- if (assetId in state.assets) {
1752
- delete state.assets[assetId];
1753
- } else {
1754
- throw new Error(`Failed to remove asset because ID doesn't exist: ${assetId}`);
1755
- }
1756
- }
1635
+ deleteAsset: (state, action) => {
1636
+ assetAdapter.deleteOne(state, action);
1757
1637
  prevAssets = null;
1758
1638
  },
1759
- removeAllAssetsOfType: (state, action) => {
1760
- var _a2;
1761
- for (const componentId in state.assets) {
1762
- if (((_a2 = state.assets[componentId]) == null ? void 0 : _a2.asset_type) === action.payload) {
1763
- delete state.assets[componentId];
1764
- }
1765
- }
1639
+ deleteAssets: (state, action) => {
1640
+ assetAdapter.deleteMany(state, action);
1766
1641
  prevAssets = null;
1767
- },
1768
- // Attachments
1769
- setAssetAttachment: setAttachment,
1770
- setAssetAttachments: setAttachments,
1771
- addAssetAttachment: addAttachment,
1772
- addAssetAttachments: addAttachments,
1773
- updateAssetAttachment: updateAttachment,
1774
- updateAssetAttachments: updateAttachments,
1775
- removeAssetAttachment: removeAttachment,
1776
- removeAssetAttachments: removeAttachments
1642
+ }
1777
1643
  }
1778
1644
  });
1779
1645
  const {
1646
+ initializeAssets,
1780
1647
  addAsset,
1648
+ addAssets,
1781
1649
  updateAsset,
1782
1650
  updateAssets,
1783
- removeAsset,
1784
- removeAssets,
1785
- addAssetsInBatches,
1786
- setAssets,
1787
- removeAllAssetsOfType,
1788
- // Attachments
1789
- setAssetAttachment,
1790
- setAssetAttachments,
1791
- addAssetAttachment,
1792
- addAssetAttachments,
1793
- updateAssetAttachment,
1794
- updateAssetAttachments,
1795
- removeAssetAttachment,
1796
- removeAssetAttachments
1651
+ deleteAsset,
1652
+ deleteAssets,
1653
+ setAsset,
1654
+ setAssets
1797
1655
  } = assetSlice.actions;
1798
1656
  let prevAssets = null;
1799
1657
  const selectAssets = (state) => {
1800
1658
  if (!prevAssets) {
1801
- prevAssets = Object.values(state.assetReducer.assets);
1659
+ prevAssets = Object.values(state.assetReducer.instances);
1802
1660
  }
1803
1661
  return prevAssets;
1804
1662
  };
1805
- const selectAssetsMapping = (state) => state.assetReducer.assets;
1663
+ const selectAssetsMapping = (state) => state.assetReducer.instances;
1806
1664
  const selectAssetsOfAssetType = restructureCreateSelectorWithArgs(
1807
1665
  toolkit.createSelector([selectAssets, (_state, assetTypeId) => assetTypeId], (components, assetTypeId) => {
1808
1666
  return components.filter((asset) => asset.asset_type === assetTypeId);
1809
1667
  })
1810
1668
  );
1811
1669
  const selectAsset = (assetId) => (state) => {
1812
- return state.assetReducer.assets[assetId];
1670
+ return state.assetReducer.instances[assetId];
1813
1671
  };
1814
1672
  const selectAssetToAssetTypeMapping = toolkit.createSelector(
1815
1673
  [selectAssets, selectAssetTypesMapping],
@@ -1838,20 +1696,50 @@ var __publicField = (obj, key, value) => {
1838
1696
  };
1839
1697
  const selectAssetTypesFromIds = (assetTypeIds) => (state) => {
1840
1698
  return assetTypeIds.reduce((acc, assetTypeId) => {
1841
- const assetType = state.assetTypeReducer.assetTypes[assetTypeId];
1699
+ const assetType = state.assetTypeReducer.instances[assetTypeId];
1842
1700
  if (assetType) {
1843
1701
  acc.push(assetType);
1844
1702
  }
1845
1703
  return acc;
1846
1704
  }, []);
1847
1705
  };
1848
- const selectAssetAttachmentMapping = (state) => state.assetReducer.attachments;
1706
+ const assetReducer = assetSlice.reducer;
1707
+ const assetAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
1708
+ const initialState$x = assetAttachmentAdapter.getInitialState({});
1709
+ const assetAttachmentSlice = toolkit.createSlice({
1710
+ name: "assetAttachments",
1711
+ initialState: initialState$x,
1712
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
1713
+ reducers: {
1714
+ initializeAssetAttachments: assetAttachmentAdapter.initialize,
1715
+ addAssetAttachment: assetAttachmentAdapter.addOne,
1716
+ addAssetAttachments: assetAttachmentAdapter.addMany,
1717
+ setAssetAttachment: assetAttachmentAdapter.setOne,
1718
+ setAssetAttachments: assetAttachmentAdapter.setMany,
1719
+ updateAssetAttachment: assetAttachmentAdapter.updateOne,
1720
+ updateAssetAttachments: assetAttachmentAdapter.updateMany,
1721
+ deleteAssetAttachment: assetAttachmentAdapter.deleteOne,
1722
+ deleteAssetAttachments: assetAttachmentAdapter.deleteMany
1723
+ }
1724
+ });
1725
+ const {
1726
+ initializeAssetAttachments,
1727
+ addAssetAttachment,
1728
+ addAssetAttachments,
1729
+ setAssetAttachment,
1730
+ setAssetAttachments,
1731
+ updateAssetAttachment,
1732
+ updateAssetAttachments,
1733
+ deleteAssetAttachment,
1734
+ deleteAssetAttachments
1735
+ } = assetAttachmentSlice.actions;
1736
+ const selectAssetAttachmentMapping = (state) => state.assetAttachmentReducer.instances;
1849
1737
  const selectAssetAttachments = toolkit.createSelector(
1850
1738
  [selectAssetAttachmentMapping],
1851
1739
  (mapping) => Object.values(mapping)
1852
1740
  );
1853
1741
  const selectAssetAttachment = (attachmentId) => (state) => {
1854
- return state.assetReducer.attachments[attachmentId];
1742
+ return state.assetAttachmentReducer.instances[attachmentId];
1855
1743
  };
1856
1744
  const selectAttachmentsOfAsset = restructureCreateSelectorWithArgs(
1857
1745
  toolkit.createSelector(
@@ -1878,14 +1766,14 @@ var __publicField = (obj, key, value) => {
1878
1766
  }
1879
1767
  )
1880
1768
  );
1881
- const assetReducer = assetSlice.reducer;
1882
- const initialState$o = {
1769
+ const assetAttachmentReducer = assetAttachmentSlice.reducer;
1770
+ const initialState$w = {
1883
1771
  completionsByAssetId: {}
1884
1772
  };
1885
1773
  const assetStageCompletionSlice = toolkit.createSlice({
1886
1774
  name: "assetStageCompletions",
1887
- initialState: initialState$o,
1888
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1775
+ initialState: initialState$w,
1776
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1889
1777
  reducers: {
1890
1778
  addStageCompletion: (state, action) => {
1891
1779
  let stageToCompletionDateMapping = state.completionsByAssetId[action.payload.asset];
@@ -1934,46 +1822,22 @@ var __publicField = (obj, key, value) => {
1934
1822
  return Object.keys(state.assetStageCompletionReducer.completionsByAssetId[asset.offline_id] ?? {});
1935
1823
  };
1936
1824
  const assetStageCompletionReducer = assetStageCompletionSlice.reducer;
1937
- const initialState$n = {
1938
- stages: {}
1939
- };
1825
+ const assetStageAdapter = createModelAdapter((assetStage) => assetStage.offline_id);
1826
+ const initialState$v = assetStageAdapter.getInitialState({});
1940
1827
  const assetStageSlice = toolkit.createSlice({
1941
1828
  name: "assetStages",
1942
- initialState: initialState$n,
1943
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1829
+ initialState: initialState$v,
1830
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1944
1831
  reducers: {
1945
- addStages: (state, action) => {
1946
- Object.assign(state.stages, toOfflineIdRecord(action.payload));
1947
- },
1948
- updateStages: (state, action) => {
1949
- for (const stage of action.payload) {
1950
- state.stages[stage.offline_id] = stage;
1951
- }
1952
- },
1953
- removeStages: (state, action) => {
1954
- action.payload.forEach((id) => {
1955
- delete state.stages[id];
1956
- });
1957
- },
1958
- linkStageToForm: (state, action) => {
1959
- const { stageId, formId: formId2 } = action.payload;
1960
- const stage = state.stages[stageId];
1961
- if (!stage) {
1962
- throw new Error("No stage exists with the id " + stageId);
1963
- }
1964
- stage.user_form = formId2;
1965
- },
1966
- unlinkStageToForm: (state, action) => {
1967
- const { stageId } = action.payload;
1968
- const stage = state.stages[stageId];
1969
- if (!stage) {
1970
- throw new Error("No stage exists with the id " + stageId);
1971
- }
1972
- delete stage.user_form;
1973
- }
1832
+ initializeStages: assetStageAdapter.initialize,
1833
+ setStage: assetStageAdapter.setOne,
1834
+ addStages: assetStageAdapter.addMany,
1835
+ updateStage: assetStageAdapter.updateOne,
1836
+ updateStages: assetStageAdapter.updateMany,
1837
+ removeStages: assetStageAdapter.deleteMany
1974
1838
  }
1975
1839
  });
1976
- const selectStageMapping = (state) => state.assetStageReducer.stages;
1840
+ const selectStageMapping = (state) => state.assetStageReducer.instances;
1977
1841
  const selectStage = restructureCreateSelectorWithArgs(
1978
1842
  toolkit.createSelector([selectStageMapping, (_state, stageId) => stageId], (stageMapping, stageId) => {
1979
1843
  return stageMapping[stageId];
@@ -2036,43 +1900,100 @@ var __publicField = (obj, key, value) => {
2036
1900
  return ret;
2037
1901
  })
2038
1902
  );
2039
- const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = assetStageSlice.actions;
1903
+ const { initializeStages, setStage, addStages, updateStages, removeStages, updateStage } = assetStageSlice.actions;
2040
1904
  const assetStageReducer = assetStageSlice.reducer;
2041
- const initialState$m = {
2042
- workspaces: {},
2043
- activeWorkspaceId: null
1905
+ const assetTypeAttachmentAdapter = createModelAdapter(
1906
+ (attachment) => attachment.offline_id
1907
+ );
1908
+ const initialState$u = assetTypeAttachmentAdapter.getInitialState({});
1909
+ const assetTypeAttachmentSlice = toolkit.createSlice({
1910
+ name: "assetTypeAttachments",
1911
+ initialState: initialState$u,
1912
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$u)),
1913
+ reducers: {
1914
+ initializeAssetTypeAttachments: assetTypeAttachmentAdapter.initialize,
1915
+ addAssetTypeAttachment: assetTypeAttachmentAdapter.addOne,
1916
+ addAssetTypeAttachments: assetTypeAttachmentAdapter.addMany,
1917
+ setAssetTypeAttachment: assetTypeAttachmentAdapter.setOne,
1918
+ setAssetTypeAttachments: assetTypeAttachmentAdapter.setMany,
1919
+ updateAssetTypeAttachment: assetTypeAttachmentAdapter.updateOne,
1920
+ updateAssetTypeAttachments: assetTypeAttachmentAdapter.updateMany,
1921
+ deleteAssetTypeAttachment: assetTypeAttachmentAdapter.deleteOne,
1922
+ deleteAssetTypeAttachments: assetTypeAttachmentAdapter.deleteMany
1923
+ }
1924
+ });
1925
+ const {
1926
+ initializeAssetTypeAttachments,
1927
+ addAssetTypeAttachment,
1928
+ addAssetTypeAttachments,
1929
+ setAssetTypeAttachment,
1930
+ setAssetTypeAttachments,
1931
+ updateAssetTypeAttachment,
1932
+ updateAssetTypeAttachments,
1933
+ deleteAssetTypeAttachment,
1934
+ deleteAssetTypeAttachments
1935
+ } = assetTypeAttachmentSlice.actions;
1936
+ const selectAssetTypeAttachmentMapping = (state) => state.assetTypeAttachmentReducer.instances;
1937
+ const selectAssetTypeAttachments = toolkit.createSelector(
1938
+ [selectAssetTypeAttachmentMapping],
1939
+ (mapping) => Object.values(mapping)
1940
+ );
1941
+ const selectAssetTypeAttachment = (attachmentId) => (state) => {
1942
+ return state.assetTypeAttachmentReducer.instances[attachmentId];
2044
1943
  };
1944
+ const selectAttachmentsOfAssetType = restructureCreateSelectorWithArgs(
1945
+ toolkit.createSelector(
1946
+ [selectAssetTypeAttachments, (_state, assetTypeId) => assetTypeId],
1947
+ (attachments, assetTypeId) => {
1948
+ return attachments.filter(({ asset_type }) => assetTypeId === asset_type);
1949
+ }
1950
+ )
1951
+ );
1952
+ const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
1953
+ toolkit.createSelector(
1954
+ [selectAssetTypeAttachments, (_state, assetTypeId) => assetTypeId],
1955
+ (attachments, assetTypeId) => {
1956
+ const attachmentsOfAssetType = attachments.filter(({ asset_type }) => asset_type === assetTypeId);
1957
+ const fileAttachments = attachmentsOfAssetType.filter(
1958
+ // this null check here is necessary, there are cases where file_type is null or undefined
1959
+ ({ file_type }) => !file_type || !file_type.startsWith("image/")
1960
+ );
1961
+ const imageAttachments = attachmentsOfAssetType.filter(
1962
+ // this null check here is necessary, there are cases where file_type is null or undefined
1963
+ ({ file_type }) => file_type && file_type.startsWith("image/")
1964
+ );
1965
+ return { fileAttachments, imageAttachments };
1966
+ }
1967
+ )
1968
+ );
1969
+ const assetTypeAttachmentReducer = assetTypeAttachmentSlice.reducer;
1970
+ const workspaceAdapter = createModelAdapter((workspace) => workspace.offline_id);
1971
+ const initialState$t = workspaceAdapter.getInitialState({
1972
+ activeWorkspaceId: null
1973
+ });
2045
1974
  const workspaceSlice = toolkit.createSlice({
2046
1975
  name: "workspace",
2047
- initialState: initialState$m,
2048
- // The `reducers` field lets us define reducers and generate associated actions
1976
+ initialState: initialState$t,
2049
1977
  reducers: {
2050
- setWorkspaces: (state, action) => {
2051
- state.workspaces = action.payload;
2052
- },
2053
- // Takes a list of Workspaces and updates existing ones to match the payload, or adds them
2054
- // to the store if they are not already present
2055
- addOrReplaceWorkspaces: (state, action) => {
2056
- Object.values(action.payload).forEach((workspace) => {
2057
- state.workspaces[workspace.offline_id] = workspace;
2058
- });
2059
- },
2060
- addWorkspace: (state, action) => {
2061
- if (action.payload.offline_id in state.workspaces) {
2062
- throw new Error(`Tried to add duplicate workspace with name: ${action.payload.offline_id}`);
2063
- }
2064
- state.workspaces[action.payload.offline_id] = action.payload;
2065
- },
2066
- removeWorkspace: (state, action) => {
2067
- delete state.workspaces[action.payload];
2068
- },
1978
+ initializeWorkspaces: workspaceAdapter.initialize,
1979
+ setWorkspaces: workspaceAdapter.setMany,
1980
+ addWorkspace: workspaceAdapter.addOne,
1981
+ updateWorkspace: workspaceAdapter.updateOne,
1982
+ deleteWorkspace: workspaceAdapter.deleteOne,
2069
1983
  setActiveWorkspaceId: (state, action) => {
2070
1984
  state.activeWorkspaceId = action.payload;
2071
1985
  }
2072
1986
  }
2073
1987
  });
2074
- const { setWorkspaces, addOrReplaceWorkspaces, addWorkspace, setActiveWorkspaceId, removeWorkspace } = workspaceSlice.actions;
2075
- const selectWorkspaceMapping = (state) => state.workspaceReducer.workspaces;
1988
+ const {
1989
+ initializeWorkspaces,
1990
+ setWorkspaces,
1991
+ addWorkspace,
1992
+ updateWorkspace,
1993
+ setActiveWorkspaceId,
1994
+ deleteWorkspace
1995
+ } = workspaceSlice.actions;
1996
+ const selectWorkspaceMapping = (state) => state.workspaceReducer.instances;
2076
1997
  const selectWorkspaces = toolkit.createSelector([selectWorkspaceMapping], (mapping) => Object.values(mapping));
2077
1998
  const selectMainWorkspace = toolkit.createSelector([selectWorkspaces], (workspaces) => {
2078
1999
  return workspaces.find((workspace) => workspace.name.toLowerCase() === "main");
@@ -2101,169 +2022,33 @@ var __publicField = (obj, key, value) => {
2101
2022
  );
2102
2023
  const workspaceReducer = workspaceSlice.reducer;
2103
2024
  const maxRecentIssues = 10;
2104
- const initialState$l = {
2105
- issues: {},
2106
- attachments: {},
2107
- comments: {},
2108
- updates: {},
2025
+ const issueAdapter = createModelAdapter((issue) => issue.offline_id);
2026
+ const initialState$s = issueAdapter.getInitialState({
2109
2027
  visibleStatuses: [IssueStatus.BACKLOG, IssueStatus.SELECTED],
2110
2028
  visibleUserIds: null,
2111
- recentIssueIds: [],
2112
- activeIssueId: null
2113
- };
2029
+ recentIssueIds: []
2030
+ });
2114
2031
  const issueSlice = toolkit.createSlice({
2115
2032
  name: "issues",
2116
- initialState: initialState$l,
2033
+ initialState: initialState$s,
2117
2034
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2118
- Object.assign(state, initialState$l);
2035
+ Object.assign(state, initialState$s);
2119
2036
  }),
2120
2037
  reducers: {
2121
- setIssues: (state, action) => {
2122
- if (action.payload.filter(onlyUniqueOfflineIds).length !== action.payload.length) {
2123
- throw new Error("Tried to use setIssues reducer with duplicate ID's");
2124
- }
2125
- action.payload.forEach((issue) => {
2126
- state.issues[issue.offline_id] = issue;
2127
- });
2128
- },
2129
- setIssueUpdates: (state, action) => {
2130
- if (action.payload.filter(onlyUniqueOfflineIds).length !== action.payload.length) {
2131
- throw new Error("Tried to use setIssues reducer with duplicate ID's");
2132
- }
2133
- const newUpdates = {};
2134
- for (const update of action.payload) {
2135
- newUpdates[update.offline_id] = update;
2136
- }
2137
- state.updates = newUpdates;
2138
- },
2139
- setActiveIssueId: (state, action) => {
2140
- state.activeIssueId = action.payload;
2038
+ initializeIssues: issueAdapter.initialize,
2039
+ addIssue: issueAdapter.addOne,
2040
+ addIssues: issueAdapter.addMany,
2041
+ updateIssue: issueAdapter.updateOne,
2042
+ deleteIssue: issueAdapter.deleteOne,
2043
+ deleteIssues: issueAdapter.deleteMany,
2044
+ setVisibleStatuses: (state, action) => {
2045
+ state.visibleStatuses = action.payload;
2141
2046
  },
2142
- addIssue: (state, action) => {
2143
- if (action.payload.offline_id in state.issues) {
2144
- throw new Error(`Tried to add duplicate issue with ID: ${action.payload.offline_id}`);
2145
- }
2146
- state.issues[action.payload.offline_id] = action.payload;
2047
+ setVisibleUserIds: (state, action) => {
2048
+ state.visibleUserIds = [...new Set(action.payload)];
2147
2049
  },
2148
- addIssues: (state, action) => {
2149
- for (const issue of action.payload) {
2150
- if (issue.offline_id in state.issues) {
2151
- throw new Error(`Tried to add duplicate issue with ID: ${issue.offline_id}`);
2152
- }
2153
- }
2154
- for (const issue of action.payload) {
2155
- state.issues[issue.offline_id] = issue;
2156
- }
2157
- },
2158
- addIssueUpdate: (state, action) => {
2159
- if (action.payload.offline_id in state.updates) {
2160
- throw new Error(`Tried to add duplicate issue update with offline_id: ${action.payload.offline_id}`);
2161
- }
2162
- state.updates[action.payload.offline_id] = action.payload;
2163
- },
2164
- addIssueUpdates: (state, action) => {
2165
- for (const update of action.payload) {
2166
- state.updates[update.offline_id] = update;
2167
- }
2168
- },
2169
- updateIssue: (state, action) => {
2170
- if (action.payload.offline_id in state.issues) {
2171
- state.issues[action.payload.offline_id] = {
2172
- ...state.issues[action.payload.offline_id],
2173
- ...action.payload
2174
- };
2175
- } else {
2176
- throw new Error(`Tried to update issue with ID that doesn't exist: ${action.payload.offline_id}`);
2177
- }
2178
- },
2179
- removeIssue: (state, action) => {
2180
- if (action.payload in state.issues) {
2181
- delete state.issues[action.payload];
2182
- } else {
2183
- throw new Error(`Failed to remove issue because ID doesn't exist: ${action.payload}`);
2184
- }
2185
- },
2186
- removeIssues: (state, action) => {
2187
- for (const issueId of action.payload) {
2188
- delete state.issues[issueId];
2189
- }
2190
- },
2191
- removeIssueUpdate: (state, action) => {
2192
- if (action.payload in state.updates) {
2193
- delete state.updates[action.payload];
2194
- } else {
2195
- throw new Error(`Failed to remove issue update because offline_id doesn't exist: ${action.payload}`);
2196
- }
2197
- },
2198
- removeIssueUpdates: (state, action) => {
2199
- for (const updateId of action.payload) {
2200
- delete state.updates[updateId];
2201
- }
2202
- },
2203
- removeAttachmentsOfIssue: (state, action) => {
2204
- const attachments = Object.values(state.attachments).filter((a) => a.issue === action.payload);
2205
- for (const attachment of attachments) {
2206
- delete state.attachments[attachment.offline_id];
2207
- }
2208
- },
2209
- setVisibleStatuses: (state, action) => {
2210
- state.visibleStatuses = action.payload;
2211
- },
2212
- setVisibleUserIds: (state, action) => {
2213
- state.visibleUserIds = [...new Set(action.payload)];
2214
- },
2215
- // Comments
2216
- addIssueComment: (state, action) => {
2217
- if (action.payload.offline_id in state.comments) {
2218
- throw new Error(
2219
- `Tried to add issue comment with offline_id: ${action.payload.offline_id} that already exists`
2220
- );
2221
- }
2222
- state.comments[action.payload.offline_id] = action.payload;
2223
- },
2224
- addIssueComments: (state, action) => {
2225
- for (const comment of action.payload) {
2226
- if (comment.offline_id in state.comments) {
2227
- throw new Error(
2228
- `Tried to add issue comment with offline_id: ${comment.offline_id} that already exists`
2229
- );
2230
- }
2231
- }
2232
- for (const comment of action.payload) {
2233
- state.comments[comment.offline_id] = comment;
2234
- }
2235
- },
2236
- setIssueComment: (state, action) => {
2237
- state.comments[action.payload.offline_id] = action.payload;
2238
- },
2239
- setIssueComments: (state, action) => {
2240
- const newComments = {};
2241
- for (const comment of action.payload) {
2242
- newComments[comment.offline_id] = comment;
2243
- }
2244
- state.comments = newComments;
2245
- },
2246
- addOrReplaceIssueComment: (state, action) => {
2247
- state.comments[action.payload.offline_id] = action.payload;
2248
- },
2249
- removeIssueComment: (state, action) => {
2250
- if (!(action.payload in state.comments)) {
2251
- throw new Error(`Failed to remove issue comment because ID doesn't exist: ${action.payload}`);
2252
- }
2253
- delete state.comments[action.payload];
2254
- },
2255
- removeIssueComments: (state, action) => {
2256
- for (const commentId of action.payload) {
2257
- if (!(commentId in state.comments)) {
2258
- throw new Error(`Failed to remove issue comment because ID doesn't exist: ${commentId}`);
2259
- }
2260
- }
2261
- for (const commentId of action.payload) {
2262
- delete state.comments[commentId];
2263
- }
2264
- },
2265
- cleanRecentIssues: (state) => {
2266
- state.recentIssueIds = state.recentIssueIds.filter((recentIssue) => state.issues[recentIssue.offlineId]);
2050
+ cleanRecentIssues: (state) => {
2051
+ state.recentIssueIds = state.recentIssueIds.filter((recentIssue) => state.instances[recentIssue.offlineId]);
2267
2052
  },
2268
2053
  addToRecentIssues: (state, action) => {
2269
2054
  state.recentIssueIds = state.recentIssueIds.filter(
@@ -2284,57 +2069,24 @@ var __publicField = (obj, key, value) => {
2284
2069
  if (indexToRemove !== -1) {
2285
2070
  state.recentIssueIds.splice(indexToRemove, 1);
2286
2071
  }
2287
- },
2288
- // Attachments
2289
- setIssueAttachment: setAttachment,
2290
- setIssueAttachments: setAttachments,
2291
- addIssueAttachment: addAttachment,
2292
- addIssueAttachments: addAttachments,
2293
- updateIssueAttachment: updateAttachment,
2294
- updateIssueAttachments: updateAttachments,
2295
- removeIssueAttachment: removeAttachment,
2296
- removeIssueAttachments: removeAttachments
2072
+ }
2297
2073
  }
2298
2074
  });
2299
2075
  const {
2076
+ initializeIssues,
2300
2077
  addIssue,
2301
2078
  addIssues,
2302
- addIssueUpdate,
2303
- addIssueUpdates,
2304
- addOrReplaceIssueComment,
2079
+ updateIssue,
2080
+ deleteIssue,
2081
+ deleteIssues,
2082
+ setVisibleStatuses,
2083
+ setVisibleUserIds,
2305
2084
  addToRecentIssues,
2306
2085
  cleanRecentIssues,
2307
- removeAttachmentsOfIssue,
2308
- removeIssue,
2309
- removeIssues,
2310
- removeIssueUpdate,
2311
- removeIssueUpdates,
2312
2086
  removeRecentIssue,
2313
- resetRecentIssues,
2314
- setActiveIssueId,
2315
- setIssueUpdates,
2316
- setIssues,
2317
- setVisibleStatuses,
2318
- setVisibleUserIds,
2319
- updateIssue,
2320
- // Attachments
2321
- setIssueAttachment,
2322
- setIssueAttachments,
2323
- addIssueAttachment,
2324
- addIssueAttachments,
2325
- updateIssueAttachment,
2326
- updateIssueAttachments,
2327
- removeIssueAttachment,
2328
- removeIssueAttachments,
2329
- // Commments
2330
- addIssueComment,
2331
- addIssueComments,
2332
- setIssueComment,
2333
- setIssueComments,
2334
- removeIssueComment,
2335
- removeIssueComments
2087
+ resetRecentIssues
2336
2088
  } = issueSlice.actions;
2337
- const selectIssueMapping = (state) => state.issueReducer.issues;
2089
+ const selectIssueMapping = (state) => state.issueReducer.instances;
2338
2090
  const selectRecentIssueIds = (state) => state.issueReducer.recentIssueIds;
2339
2091
  const selectVisibleUserIds = (state) => state.issueReducer.visibleUserIds;
2340
2092
  const selectVisibleStatuses = (state) => state.issueReducer.visibleStatuses;
@@ -2381,83 +2133,11 @@ var __publicField = (obj, key, value) => {
2381
2133
  }
2382
2134
  )
2383
2135
  );
2384
- const selectActiveIssueId = (state) => state.issueReducer.activeIssueId;
2385
- const selectIssueAttachmentMapping = (state) => state.issueReducer.attachments;
2386
- const selectIssueAttachments = toolkit.createSelector(
2387
- [selectIssueAttachmentMapping],
2388
- (mapping) => Object.values(mapping)
2389
- );
2390
- const selectPhotoAttachmentsOfIssue = restructureCreateSelectorWithArgs(
2391
- toolkit.createSelector(
2392
- [selectIssueAttachmentMapping, (_state, issueId) => issueId],
2393
- (attachmentMapping, issueId) => {
2394
- return Object.values(attachmentMapping).filter(
2395
- (attachment) => attachment.issue === issueId && attachment.file_type && attachment.file_type.startsWith("image/")
2396
- );
2397
- }
2398
- )
2399
- );
2400
- const selectCommentMapping = (state) => state.issueReducer.comments;
2401
- const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
2402
- toolkit.createSelector([selectCommentMapping, (_state, issueId) => issueId], (commentMapping, issueId) => {
2403
- return Object.values(commentMapping).filter((comment) => comment.issue === issueId);
2404
- })
2405
- );
2406
- const selectIssueUpdateMapping = (state) => state.issueReducer.updates;
2407
- const selectIssueUpdatesOfIssue = restructureCreateSelectorWithArgs(
2408
- toolkit.createSelector([selectIssueUpdateMapping, (_state, issueId) => issueId], (updates, issueId) => {
2409
- return Object.values(updates).filter((update) => update.issue === issueId);
2410
- })
2411
- );
2412
- const selectAttachmentsOfIssue = restructureCreateSelectorWithArgs(
2413
- toolkit.createSelector(
2414
- [selectIssueAttachments, (_state, issueId) => issueId],
2415
- (attachments, issueId) => {
2416
- return attachments.filter(({ issue }) => issueId === issue);
2417
- }
2418
- )
2419
- );
2420
- const selectIssueAttachment = (attachmentId) => (root) => {
2421
- return root.issueReducer.attachments[attachmentId];
2422
- };
2423
- const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
2424
- toolkit.createSelector(
2425
- [selectIssueAttachments, (_state, issueId) => issueId],
2426
- (attachments, issueId) => {
2427
- const attachmentsOfIssue = attachments.filter(({ issue }) => issue === issueId);
2428
- const fileAttachments = attachmentsOfIssue.filter(
2429
- // this null check here is necessary, there are cases where file_type is null or undefined
2430
- ({ file_type }) => !file_type || !file_type.startsWith("image/")
2431
- );
2432
- const imageAttachments = attachmentsOfIssue.filter(
2433
- // this null check here is necessary, there are cases where file_type is null or undefined
2434
- ({ file_type }) => file_type && file_type.startsWith("image/")
2435
- );
2436
- return { fileAttachments, imageAttachments };
2437
- }
2438
- )
2439
- );
2440
- const selectFileAttachmentsOfIssue = restructureCreateSelectorWithArgs(
2441
- toolkit.createSelector(
2442
- [selectIssueAttachmentMapping, (_state, issueId) => issueId],
2443
- (attachmentMapping, issueId) => {
2444
- if (!issueId)
2445
- return void 0;
2446
- return Object.values(attachmentMapping).filter(
2447
- (attachment) => (
2448
- // Files with file_type that is null or not an image file
2449
- attachment.issue === issueId && (!attachment.file_type || !attachment.file_type.startsWith("image/"))
2450
- )
2451
- );
2452
- }
2453
- )
2454
- );
2455
2136
  const selectIssue = restructureCreateSelectorWithArgs(
2456
2137
  toolkit.createSelector([selectIssueMapping, (_state, id) => id], (mapping, id) => {
2457
2138
  return mapping[id];
2458
2139
  })
2459
2140
  );
2460
- const selectAllAttachments = toolkit.createSelector([selectIssueAttachmentMapping], (mapping) => Object.values(mapping));
2461
2141
  const searchIssues = restructureCreateSelectorWithArgs(
2462
2142
  toolkit.createSelector(
2463
2143
  [selectIssueMapping, selectWorkspaceMapping, (_state, searchArgs) => searchArgs],
@@ -2548,47 +2228,25 @@ var __publicField = (obj, key, value) => {
2548
2228
  }
2549
2229
  );
2550
2230
  const issueReducer = issueSlice.reducer;
2551
- const initialState$k = {
2552
- issueTypes: {}
2553
- };
2231
+ const issueTypeAdapter = createModelAdapter((issueType) => issueType.offline_id);
2232
+ const initialState$r = issueTypeAdapter.getInitialState({});
2554
2233
  const issueTypeSlice = toolkit.createSlice({
2555
2234
  name: "issueTypes",
2556
- initialState: initialState$k,
2235
+ initialState: initialState$r,
2557
2236
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2558
- Object.assign(state, initialState$k);
2237
+ Object.assign(state, initialState$r);
2559
2238
  }),
2560
2239
  reducers: {
2561
- setIssueTypes: (state, action) => {
2562
- for (const issueType of action.payload) {
2563
- state.issueTypes[issueType.offline_id] = issueType;
2564
- }
2565
- },
2566
- setIssueType: (state, action) => {
2567
- state.issueTypes[action.payload.offline_id] = action.payload;
2568
- },
2569
- addIssueType: (state, action) => {
2570
- if (action.payload.offline_id in state.issueTypes) {
2571
- throw new Error(`IssueType with offline_id ${action.payload.offline_id} already exists in the store.`);
2572
- }
2573
- state.issueTypes[action.payload.offline_id] = action.payload;
2574
- },
2575
- updateIssueType: (state, action) => {
2576
- if (!(action.payload.offline_id in state.issueTypes)) {
2577
- throw new Error(`IssueType with offline_id ${action.payload.offline_id} does not exist in the store.`);
2578
- }
2579
- state.issueTypes[action.payload.offline_id] = action.payload;
2580
- },
2581
- removeIssueType: (state, action) => {
2582
- if (!(action.payload in state.issueTypes)) {
2583
- throw new Error(`IssueType with offline_id ${action.payload} does not exist in the store.`);
2584
- }
2585
- delete state.issueTypes[action.payload];
2586
- }
2240
+ initializeIssueTypes: issueTypeAdapter.initialize,
2241
+ setIssueType: issueTypeAdapter.setOne,
2242
+ addIssueType: issueTypeAdapter.addOne,
2243
+ updateIssueType: issueTypeAdapter.updateOne,
2244
+ removeIssueType: issueTypeAdapter.deleteOne
2587
2245
  }
2588
2246
  });
2589
- const { setIssueTypes, setIssueType, addIssueType, updateIssueType, removeIssueType } = issueTypeSlice.actions;
2247
+ const { initializeIssueTypes, setIssueType, addIssueType, updateIssueType, removeIssueType } = issueTypeSlice.actions;
2590
2248
  const selectIssueTypeMapping = (state) => {
2591
- return state.issueTypeReducer.issueTypes;
2249
+ return state.issueTypeReducer.instances;
2592
2250
  };
2593
2251
  const selectIssueTypes = toolkit.createSelector(selectIssueTypeMapping, (issueTypes) => {
2594
2252
  return Object.values(issueTypes);
@@ -2611,7 +2269,7 @@ var __publicField = (obj, key, value) => {
2611
2269
  );
2612
2270
  const selectIssuesOfIssueType = restructureCreateSelectorWithArgs(
2613
2271
  toolkit.createSelector(
2614
- [(state) => state.issueReducer.issues, (_, issueTypeId) => issueTypeId],
2272
+ [(state) => state.issueReducer.instances, (_, issueTypeId) => issueTypeId],
2615
2273
  (issuesMapping, issueTypeId) => {
2616
2274
  return Object.values(issuesMapping).filter((issue) => issue.issue_type === issueTypeId);
2617
2275
  }
@@ -2622,15 +2280,15 @@ var __publicField = (obj, key, value) => {
2622
2280
  return ((_a2 = selectIssuesOfIssueType(issueTypeId)(state)) == null ? void 0 : _a2.length) ?? 0;
2623
2281
  };
2624
2282
  const issueTypeReducer = issueTypeSlice.reducer;
2625
- const initialState$j = {
2283
+ const initialState$q = {
2626
2284
  s3Urls: {}
2627
2285
  };
2628
2286
  const msPerHour = 1e3 * 60 * 60;
2629
2287
  const msPerWeek = msPerHour * 24 * 7;
2630
2288
  const fileSlice = toolkit.createSlice({
2631
2289
  name: "file",
2632
- initialState: initialState$j,
2633
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
2290
+ initialState: initialState$q,
2291
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
2634
2292
  reducers: {
2635
2293
  setUploadUrl: (state, action) => {
2636
2294
  const { url, fields, sha1 } = action.payload;
@@ -2657,7 +2315,7 @@ var __publicField = (obj, key, value) => {
2657
2315
  return url;
2658
2316
  };
2659
2317
  const fileReducer = fileSlice.reducer;
2660
- const initialState$i = {
2318
+ const initialState$p = {
2661
2319
  // TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
2662
2320
  mapStyle: MapStyle.SATELLITE,
2663
2321
  showTooltips: false,
@@ -2665,8 +2323,8 @@ var __publicField = (obj, key, value) => {
2665
2323
  };
2666
2324
  const mapSlice = toolkit.createSlice({
2667
2325
  name: "map",
2668
- initialState: initialState$i,
2669
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2326
+ initialState: initialState$p,
2327
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
2670
2328
  reducers: {
2671
2329
  setMapStyle: (state, action) => {
2672
2330
  state.mapStyle = action.payload;
@@ -2738,7 +2396,7 @@ var __publicField = (obj, key, value) => {
2738
2396
  LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
2739
2397
  return LicenseStatus2;
2740
2398
  })(LicenseStatus || {});
2741
- const initialState$h = {
2399
+ const initialState$o = {
2742
2400
  users: {},
2743
2401
  currentUser: {
2744
2402
  id: 0,
@@ -2749,8 +2407,8 @@ var __publicField = (obj, key, value) => {
2749
2407
  };
2750
2408
  const userSlice = toolkit.createSlice({
2751
2409
  name: "users",
2752
- initialState: initialState$h,
2753
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2410
+ initialState: initialState$o,
2411
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
2754
2412
  reducers: {
2755
2413
  setUsers: (state, action) => {
2756
2414
  const usersMapping = {};
@@ -2812,52 +2470,26 @@ var __publicField = (obj, key, value) => {
2812
2470
  const selectUsersAsMapping = (state) => state.userReducer.users;
2813
2471
  const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
2814
2472
  const userReducer = userSlice.reducer;
2815
- const initialState$g = {
2816
- organizationAccesses: {}
2817
- };
2473
+ const organizationAccessAdapter = createModelAdapter(
2474
+ (organizationAccess) => organizationAccess.offline_id
2475
+ );
2476
+ const initialState$n = organizationAccessAdapter.getInitialState({});
2818
2477
  const organizationAccessSlice = toolkit.createSlice({
2819
2478
  name: "organizationAccess",
2820
- initialState: initialState$g,
2821
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2479
+ initialState: initialState$n,
2480
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
2822
2481
  reducers: {
2823
- setOrganizationAccesses: (state, action) => {
2824
- if (!Array.isArray(action.payload))
2825
- throw new Error("Expected an array of OrganizationAccess");
2826
- if (action.payload.filter(onlyUniqueOfflineIds).length !== action.payload.length) {
2827
- throw new Error("Tried to use setOrganizationAccesses reducer with duplicate ID's");
2828
- }
2829
- const organizationAccesses = {};
2830
- for (const organizationAccess of action.payload) {
2831
- organizationAccesses[organizationAccess.offline_id] = organizationAccess;
2832
- }
2833
- state.organizationAccesses = organizationAccesses;
2834
- },
2835
- updateOrganizationAccess: (state, action) => {
2836
- if (action.payload.offline_id in state.organizationAccesses) {
2837
- state.organizationAccesses[action.payload.offline_id] = action.payload;
2838
- } else {
2839
- throw new Error(
2840
- `Tried to update organization access with ID that doesn't exist: ${action.payload.offline_id}`
2841
- );
2842
- }
2843
- },
2844
- removeOrganizationAccess: (state, action) => {
2845
- if (action.payload.offline_id in state.organizationAccesses) {
2846
- delete state.organizationAccesses[action.payload.offline_id];
2847
- } else {
2848
- throw new Error(
2849
- `Tried to remove organization access with ID that doesn't exist: ${action.payload.offline_id}`
2850
- );
2851
- }
2852
- }
2482
+ initializeOrganizationAccesses: organizationAccessAdapter.initialize,
2483
+ updateOrganizationAccess: organizationAccessAdapter.updateOne,
2484
+ deleteOrganizationAccess: organizationAccessAdapter.deleteOne
2853
2485
  }
2854
2486
  });
2855
- const { setOrganizationAccesses, updateOrganizationAccess, removeOrganizationAccess } = organizationAccessSlice.actions;
2487
+ const { initializeOrganizationAccesses, updateOrganizationAccess, deleteOrganizationAccess } = organizationAccessSlice.actions;
2856
2488
  const selectOrganizationAccesses = (state) => {
2857
- return state.organizationAccessReducer.organizationAccesses;
2489
+ return state.organizationAccessReducer.instances;
2858
2490
  };
2859
2491
  const selectOrganizationAccess = (organizationAccessId) => (state) => {
2860
- return state.organizationAccessReducer.organizationAccesses[organizationAccessId];
2492
+ return state.organizationAccessReducer.instances[organizationAccessId];
2861
2493
  };
2862
2494
  const selectActiveOrganizationAccess = toolkit.createSelector(
2863
2495
  [selectCurrentUser, selectOrganizationAccesses],
@@ -2869,60 +2501,39 @@ var __publicField = (obj, key, value) => {
2869
2501
  }
2870
2502
  );
2871
2503
  const selectOrganizationAccessForUser = (user) => (state) => {
2872
- return Object.values(state.organizationAccessReducer.organizationAccesses).find(
2504
+ return Object.values(state.organizationAccessReducer.instances).find(
2873
2505
  (organizationAccess) => organizationAccess.user === user.id
2874
2506
  );
2875
2507
  };
2876
2508
  const selectOrganizationAccessUserMapping = (state) => {
2877
2509
  const organizationAccesses = {};
2878
- for (const organizationAccess of Object.values(state.organizationAccessReducer.organizationAccesses)) {
2510
+ for (const organizationAccess of Object.values(state.organizationAccessReducer.instances)) {
2879
2511
  organizationAccesses[organizationAccess.user] = organizationAccess;
2880
2512
  }
2881
2513
  return organizationAccesses;
2882
2514
  };
2883
2515
  const organizationAccessReducer = organizationAccessSlice.reducer;
2884
- const initialState$f = {
2885
- licenses: {}
2886
- };
2516
+ const licenseAdapter = createModelAdapter((license) => license.offline_id);
2517
+ const initialState$m = licenseAdapter.getInitialState({});
2887
2518
  const licenseSlice = toolkit.createSlice({
2888
2519
  name: "license",
2889
- initialState: initialState$f,
2890
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2520
+ initialState: initialState$m,
2521
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
2891
2522
  reducers: {
2892
- setLicenses: (state, action) => {
2893
- if (!Array.isArray(action.payload))
2894
- throw new Error("Expected an array of Licenses");
2895
- if (action.payload.filter(onlyUniqueOfflineIds).length !== action.payload.length) {
2896
- throw new Error("Tried to use setLicenses reducer with duplicate ID's");
2897
- }
2898
- const licenses = {};
2899
- for (const license of action.payload) {
2900
- licenses[license.offline_id] = license;
2901
- }
2902
- state.licenses = licenses;
2903
- },
2904
- addLicenses: (state, action) => {
2905
- for (const license of action.payload) {
2906
- state.licenses[license.offline_id] = license;
2907
- }
2908
- },
2909
- updateLicense: (state, action) => {
2910
- if (!(action.payload.offline_id in state.licenses)) {
2911
- throw new Error("Tried to update license that does not exist.");
2912
- }
2913
- state.licenses[action.payload.offline_id] = action.payload;
2914
- }
2523
+ setLicenses: licenseAdapter.initialize,
2524
+ addLicenses: licenseAdapter.addMany,
2525
+ updateLicense: licenseAdapter.updateOne
2915
2526
  }
2916
2527
  });
2917
2528
  const { setLicenses, addLicenses, updateLicense } = licenseSlice.actions;
2918
2529
  const selectLicenses = (state) => {
2919
- return state.licenseReducer.licenses;
2530
+ return state.licenseReducer.instances;
2920
2531
  };
2921
- const selectLicense = (licenseId) => (state) => state.licenseReducer.licenses[licenseId];
2922
- const selectActiveLicense = (state) => Object.values(state.licenseReducer.licenses).find(
2532
+ const selectLicense = (licenseId) => (state) => state.licenseReducer.instances[licenseId];
2533
+ const selectActiveLicense = (state) => Object.values(state.licenseReducer.instances).find(
2923
2534
  (license) => license.project === state.projectReducer.activeProjectId
2924
2535
  ) ?? null;
2925
- const selectLicenseForProject = (projectId) => (state) => Object.values(state.licenseReducer.licenses).find((license) => license.project === projectId);
2536
+ const selectLicenseForProject = (projectId) => (state) => Object.values(state.licenseReducer.instances).find((license) => license.project === projectId);
2926
2537
  const selectActiveStatusLicenses = toolkit.createSelector(
2927
2538
  [selectLicenses],
2928
2539
  (licenses) => Object.values(licenses).filter((license) => license.is_active)
@@ -2932,90 +2543,58 @@ var __publicField = (obj, key, value) => {
2932
2543
  (licenses) => Object.values(licenses).filter((license) => license.project).reduce((accum, license) => ({ ...accum, [license.project]: license }), {})
2933
2544
  );
2934
2545
  const licenseReducer = licenseSlice.reducer;
2935
- const initialState$e = {
2936
- projectAccesses: {}
2937
- };
2546
+ const projectAccessAdapter = createModelAdapter((projectAccess) => projectAccess.offline_id);
2547
+ const initialState$l = projectAccessAdapter.getInitialState({});
2938
2548
  const projectAccessSlice = toolkit.createSlice({
2939
2549
  name: "projectAccess",
2940
- initialState: initialState$e,
2941
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2550
+ initialState: initialState$l,
2551
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
2942
2552
  reducers: {
2943
- setProjectAccesses: (state, action) => {
2944
- if (!Array.isArray(action.payload))
2945
- throw new Error("Expected an array of ProjectAccess");
2946
- if (action.payload.filter(onlyUniqueOfflineIds).length !== action.payload.length) {
2947
- throw new Error("Tried to use setProjectAccesses reducer with duplicate ID's");
2948
- }
2949
- const projectAccesses = {};
2950
- for (const projectAccess of action.payload) {
2951
- projectAccesses[projectAccess.offline_id] = projectAccess;
2952
- }
2953
- state.projectAccesses = projectAccesses;
2954
- },
2955
- updateProjectAccess: (state, action) => {
2956
- if (action.payload.offline_id in state.projectAccesses) {
2957
- state.projectAccesses[action.payload.offline_id] = action.payload;
2958
- } else {
2959
- throw new Error(
2960
- `Tried to update project access with ID that doesn't exist: ${action.payload.offline_id}`
2961
- );
2962
- }
2963
- },
2964
- removeProjectAccess: (state, action) => {
2965
- if (action.payload.offline_id in state.projectAccesses) {
2966
- delete state.projectAccesses[action.payload.offline_id];
2967
- } else {
2968
- throw new Error(
2969
- `Tried to remove project access with ID that doesn't exist: ${action.payload.offline_id}`
2970
- );
2971
- }
2972
- },
2973
- removeProjectAccessesOfProject: (state, action) => {
2974
- for (const projectAccess of Object.values(state.projectAccesses)) {
2975
- if (projectAccess.project === action.payload) {
2976
- delete state.projectAccesses[projectAccess.offline_id];
2977
- }
2978
- }
2979
- }
2553
+ setProjectAccesses: projectAccessAdapter.initialize,
2554
+ updateProjectAccess: projectAccessAdapter.updateOne,
2555
+ deleteProjectAccess: projectAccessAdapter.deleteOne,
2556
+ deleteProjectAccesses: projectAccessAdapter.deleteMany
2980
2557
  }
2981
2558
  });
2982
- const { setProjectAccesses, updateProjectAccess, removeProjectAccess, removeProjectAccessesOfProject } = projectAccessSlice.actions;
2559
+ const { setProjectAccesses, updateProjectAccess, deleteProjectAccess, deleteProjectAccesses } = projectAccessSlice.actions;
2560
+ const selectProjectAccessMapping = (state) => {
2561
+ return state.projectAccessReducer.instances;
2562
+ };
2983
2563
  const selectProjectAccesses = (state) => {
2984
- return state.projectAccessReducer.projectAccesses;
2564
+ return Object.values(state.projectAccessReducer.instances);
2985
2565
  };
2986
2566
  const selectProjectAccess = (projectAccessId) => (state) => {
2987
- return state.projectAccessReducer.projectAccesses[projectAccessId];
2567
+ return state.projectAccessReducer.instances[projectAccessId];
2988
2568
  };
2989
2569
  const selectActiveProjectAccess = (state) => {
2990
2570
  const currentUser = state.userReducer.currentUser;
2991
2571
  const activeProjectId = state.projectReducer.activeProjectId;
2992
- return Object.values(state.projectAccessReducer.projectAccesses).find((projectAccess) => {
2572
+ return Object.values(state.projectAccessReducer.instances).find((projectAccess) => {
2993
2573
  return projectAccess.user === currentUser.id && projectAccess.project === activeProjectId;
2994
2574
  }) ?? null;
2995
2575
  };
2996
2576
  const selectProjectAccessForUser = (user) => (state) => {
2997
- return Object.values(state.projectAccessReducer.projectAccesses).find(
2577
+ return Object.values(state.projectAccessReducer.instances).find(
2998
2578
  (projectAccess) => projectAccess.user === user.id
2999
2579
  );
3000
2580
  };
3001
2581
  const selectProjectAccessUserMapping = (state) => {
3002
2582
  const projectAccesses = {};
3003
- for (const projectAccess of Object.values(state.projectAccessReducer.projectAccesses)) {
2583
+ for (const projectAccess of Object.values(state.projectAccessReducer.instances)) {
3004
2584
  projectAccesses[projectAccess.user] = projectAccess;
3005
2585
  }
3006
2586
  return projectAccesses;
3007
2587
  };
3008
2588
  const projectAccessReducer = projectAccessSlice.reducer;
3009
- const initialState$d = {
2589
+ const initialState$k = {
3010
2590
  projects: {},
3011
2591
  activeProjectId: null,
3012
2592
  recentProjectIds: [],
3013
- recentSearchableQueries: [],
3014
- attachments: {}
2593
+ recentSearchableQueries: []
3015
2594
  };
3016
2595
  const projectSlice = toolkit.createSlice({
3017
2596
  name: "projects",
3018
- initialState: initialState$d,
2597
+ initialState: initialState$k,
3019
2598
  reducers: {
3020
2599
  setProjects: (state, action) => {
3021
2600
  const projectsMap = {};
@@ -3079,16 +2658,7 @@ var __publicField = (obj, key, value) => {
3079
2658
  } else {
3080
2659
  throw new Error("Update form submissions count: no active project");
3081
2660
  }
3082
- },
3083
- // Attachments
3084
- setProjectAttachment: setAttachment,
3085
- setProjectAttachments: setAttachments,
3086
- addProjectAttachment: addAttachment,
3087
- addProjectAttachments: addAttachments,
3088
- updateProjectAttachment: updateAttachment,
3089
- updateProjectAttachments: updateAttachments,
3090
- removeProjectAttachment: removeAttachment,
3091
- removeProjectAttachments: removeAttachments
2661
+ }
3092
2662
  }
3093
2663
  });
3094
2664
  const {
@@ -3099,16 +2669,7 @@ var __publicField = (obj, key, value) => {
3099
2669
  deleteProject,
3100
2670
  acceptProjectInvite,
3101
2671
  addActiveProjectIssuesCount,
3102
- addActiveProjectFormSubmissionsCount,
3103
- // Attachments
3104
- setProjectAttachment,
3105
- setProjectAttachments,
3106
- addProjectAttachment,
3107
- addProjectAttachments,
3108
- updateProjectAttachment,
3109
- updateProjectAttachments,
3110
- removeProjectAttachment,
3111
- removeProjectAttachments
2672
+ addActiveProjectFormSubmissionsCount
3112
2673
  } = projectSlice.actions;
3113
2674
  const selectProjects = (state) => state.projectReducer.projects;
3114
2675
  const selectActiveProjectId = (state) => state.projectReducer.activeProjectId;
@@ -3139,7 +2700,7 @@ var __publicField = (obj, key, value) => {
3139
2700
  );
3140
2701
  const projectReducer = projectSlice.reducer;
3141
2702
  const selectProjectUsersIds = toolkit.createSelector(
3142
- [selectProjectAccesses],
2703
+ [selectProjectAccessMapping],
3143
2704
  (projectAccesses) => Object.values(projectAccesses).map((projectAccess) => projectAccess.user)
3144
2705
  );
3145
2706
  const selectProjectUsersAsMapping = toolkit.createSelector(
@@ -3171,47 +2732,14 @@ var __publicField = (obj, key, value) => {
3171
2732
  });
3172
2733
  }
3173
2734
  );
3174
- const selectProjectAttachmentMapping = (state) => state.projectReducer.attachments;
3175
- const selectAllProjectAttachments = toolkit.createSelector(
3176
- [selectProjectAttachmentMapping],
3177
- (mapping) => Object.values(mapping)
3178
- );
3179
- const selectProjectAttachment = (attachmentId) => (state) => {
3180
- return state.projectReducer.attachments[attachmentId];
3181
- };
3182
- const selectAttachmentsOfProject = restructureCreateSelectorWithArgs(
3183
- toolkit.createSelector(
3184
- [selectAllProjectAttachments, (_state, projectId) => projectId],
3185
- (attachments, projectId) => {
3186
- return attachments.filter(({ project }) => projectId === project);
3187
- }
3188
- )
3189
- );
3190
- const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
3191
- toolkit.createSelector(
3192
- [selectAllProjectAttachments, (_state, projectId) => projectId],
3193
- (attachments, projectId) => {
3194
- const attachmentsOfProject = attachments.filter(({ project }) => projectId === project);
3195
- const fileAttachments = attachmentsOfProject.filter(
3196
- // this null check here is necessary, there are cases where file_type is null or undefined
3197
- ({ file_type }) => !file_type || !file_type.startsWith("image/")
3198
- );
3199
- const imageAttachments = attachmentsOfProject.filter(
3200
- // this null check here is necessary, there are cases where file_type is null or undefined
3201
- ({ file_type }) => file_type && file_type.startsWith("image/")
3202
- );
3203
- return { fileAttachments, imageAttachments };
3204
- }
3205
- )
3206
- );
3207
- const initialState$c = {
2735
+ const initialState$j = {
3208
2736
  organizations: {},
3209
2737
  activeOrganizationId: null
3210
2738
  };
3211
2739
  const organizationSlice = toolkit.createSlice({
3212
2740
  name: "organizations",
3213
- initialState: initialState$c,
3214
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2741
+ initialState: initialState$j,
2742
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
3215
2743
  reducers: {
3216
2744
  setOrganizations: (state, action) => {
3217
2745
  for (const org of action.payload) {
@@ -3330,14 +2858,14 @@ var __publicField = (obj, key, value) => {
3330
2858
  }
3331
2859
  };
3332
2860
  };
3333
- const initialState$b = {
2861
+ const initialState$i = {
3334
2862
  deletedRequests: [],
3335
2863
  latestRetryTime: 0
3336
2864
  };
3337
2865
  const outboxSlice = toolkit.createSlice({
3338
2866
  name: "outbox",
3339
- initialState: initialState$b,
3340
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2867
+ initialState: initialState$i,
2868
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
3341
2869
  reducers: {
3342
2870
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
3343
2871
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -3369,7 +2897,7 @@ var __publicField = (obj, key, value) => {
3369
2897
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
3370
2898
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
3371
2899
  const outboxReducer = outboxSlice.reducer;
3372
- const initialState$a = {
2900
+ const initialState$h = {
3373
2901
  projectFiles: {},
3374
2902
  activeProjectFileId: null,
3375
2903
  isImportingProjectFile: false,
@@ -3377,8 +2905,8 @@ var __publicField = (obj, key, value) => {
3377
2905
  };
3378
2906
  const projectFileSlice = toolkit.createSlice({
3379
2907
  name: "projectFiles",
3380
- initialState: initialState$a,
3381
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2908
+ initialState: initialState$h,
2909
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
3382
2910
  reducers: {
3383
2911
  addOrReplaceProjectFiles: (state, action) => {
3384
2912
  for (let fileObj of action.payload) {
@@ -3479,12 +3007,75 @@ var __publicField = (obj, key, value) => {
3479
3007
  const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProjectFileId;
3480
3008
  const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
3481
3009
  const projectFileReducer = projectFileSlice.reducer;
3482
- const initialState$9 = {
3010
+ const projectAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
3011
+ const initialState$g = projectAttachmentAdapter.getInitialState({});
3012
+ const projectAttachmentSlice = toolkit.createSlice({
3013
+ name: "projectAttachments",
3014
+ initialState: initialState$g,
3015
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
3016
+ reducers: {
3017
+ initializeProjectAttachments: projectAttachmentAdapter.initialize,
3018
+ addProjectAttachment: projectAttachmentAdapter.addOne,
3019
+ addProjectAttachments: projectAttachmentAdapter.addMany,
3020
+ setProjectAttachment: projectAttachmentAdapter.setOne,
3021
+ setProjectAttachments: projectAttachmentAdapter.setMany,
3022
+ updateProjectAttachment: projectAttachmentAdapter.updateOne,
3023
+ updateProjectAttachments: projectAttachmentAdapter.updateMany,
3024
+ deleteProjectAttachment: projectAttachmentAdapter.deleteOne,
3025
+ deleteProjectAttachments: projectAttachmentAdapter.deleteMany
3026
+ }
3027
+ });
3028
+ const {
3029
+ initializeProjectAttachments,
3030
+ addProjectAttachment,
3031
+ addProjectAttachments,
3032
+ setProjectAttachment,
3033
+ setProjectAttachments,
3034
+ updateProjectAttachment,
3035
+ updateProjectAttachments,
3036
+ deleteProjectAttachment,
3037
+ deleteProjectAttachments
3038
+ } = projectAttachmentSlice.actions;
3039
+ const selectProjectAttachmentMapping = (state) => state.projectAttachmentReducer.instances;
3040
+ const selectAllProjectAttachments = toolkit.createSelector(
3041
+ [selectProjectAttachmentMapping],
3042
+ (mapping) => Object.values(mapping)
3043
+ );
3044
+ const selectProjectAttachment = (attachmentId) => (state) => {
3045
+ return state.projectAttachmentReducer.instances[attachmentId];
3046
+ };
3047
+ const selectAttachmentsOfProject = restructureCreateSelectorWithArgs(
3048
+ toolkit.createSelector(
3049
+ [selectAllProjectAttachments, (_state, projectId) => projectId],
3050
+ (attachments, projectId) => {
3051
+ return attachments.filter(({ project }) => projectId === project);
3052
+ }
3053
+ )
3054
+ );
3055
+ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
3056
+ toolkit.createSelector(
3057
+ [selectAllProjectAttachments, (_state, projectId) => projectId],
3058
+ (attachments, projectId) => {
3059
+ const attachmentsOfProject = attachments.filter(({ project }) => projectId === project);
3060
+ const fileAttachments = attachmentsOfProject.filter(
3061
+ // this null check here is necessary, there are cases where file_type is null or undefined
3062
+ ({ file_type }) => !file_type || !file_type.startsWith("image/")
3063
+ );
3064
+ const imageAttachments = attachmentsOfProject.filter(
3065
+ // this null check here is necessary, there are cases where file_type is null or undefined
3066
+ ({ file_type }) => file_type && file_type.startsWith("image/")
3067
+ );
3068
+ return { fileAttachments, imageAttachments };
3069
+ }
3070
+ )
3071
+ );
3072
+ const projectAttachmentReducer = projectAttachmentSlice.reducer;
3073
+ const initialState$f = {
3483
3074
  isRehydrated: false
3484
3075
  };
3485
3076
  const rehydratedSlice = toolkit.createSlice({
3486
3077
  name: "rehydrated",
3487
- initialState: initialState$9,
3078
+ initialState: initialState$f,
3488
3079
  // The `reducers` field lets us define reducers and generate associated actions
3489
3080
  reducers: {
3490
3081
  setRehydrated: (state, action) => {
@@ -3494,7 +3085,7 @@ var __publicField = (obj, key, value) => {
3494
3085
  });
3495
3086
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
3496
3087
  const rehydratedReducer = rehydratedSlice.reducer;
3497
- const initialState$8 = {
3088
+ const initialState$e = {
3498
3089
  useIssueTemplate: false,
3499
3090
  placementMode: false,
3500
3091
  enableClustering: false,
@@ -3512,8 +3103,8 @@ var __publicField = (obj, key, value) => {
3512
3103
  };
3513
3104
  const settingSlice = toolkit.createSlice({
3514
3105
  name: "settings",
3515
- initialState: initialState$8,
3516
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3106
+ initialState: initialState$e,
3107
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
3517
3108
  reducers: {
3518
3109
  setEnableDuplicateIssues: (state, action) => {
3519
3110
  state.useIssueTemplate = action.payload;
@@ -3572,119 +3163,36 @@ var __publicField = (obj, key, value) => {
3572
3163
  return revisionA < revisionB ? -1 : 1;
3573
3164
  }
3574
3165
  };
3575
- const initialState$7 = {
3576
- formRevisions: {},
3577
- attachments: {}
3578
- };
3166
+ const formRevisionAdapter = createModelAdapter((revision) => revision.offline_id);
3167
+ const initialState$d = formRevisionAdapter.getInitialState({});
3579
3168
  const formRevisionsSlice = toolkit.createSlice({
3580
3169
  name: "formRevisions",
3581
- initialState: initialState$7,
3582
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
3170
+ initialState: initialState$d,
3171
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
3583
3172
  reducers: {
3584
- // revision related actions
3585
- setFormRevision: (state, action) => {
3586
- state.formRevisions[action.payload.offline_id] = action.payload;
3587
- },
3588
- setFormRevisions: (state, action) => {
3589
- state.formRevisions = {};
3590
- for (const revision of action.payload) {
3591
- state.formRevisions[revision.offline_id] = revision;
3592
- }
3593
- },
3594
- addFormRevision: (state, action) => {
3595
- if (state.formRevisions[action.payload.offline_id] !== void 0) {
3596
- throw new Error(`Revision with offline_id ${action.payload.offline_id} already exists`);
3597
- }
3598
- state.formRevisions[action.payload.offline_id] = action.payload;
3599
- },
3600
- addFormRevisions: (state, action) => {
3601
- for (const userFormRevision of action.payload) {
3602
- if (state.formRevisions[userFormRevision.offline_id] !== void 0) {
3603
- throw new Error(`Revision with offline_id ${userFormRevision.offline_id} already exists`);
3604
- }
3605
- }
3606
- for (const userFormRevision of action.payload) {
3607
- state.formRevisions[userFormRevision.offline_id] = userFormRevision;
3608
- }
3609
- },
3610
- // UserFormRevisions do not get updated
3611
- deleteFormRevision: (state, action) => {
3612
- if (state.formRevisions[action.payload] === void 0) {
3613
- throw new Error(`Revision with offline_id ${action.payload} does not exist`);
3614
- }
3615
- delete state.formRevisions[action.payload];
3616
- },
3617
- deleteFormRevisions: (state, action) => {
3618
- for (const offlineId of action.payload) {
3619
- if (state.formRevisions[offlineId] === void 0) {
3620
- throw new Error(`Revision with offline_id ${offlineId} does not exist`);
3621
- }
3622
- }
3623
- for (const offlineId of action.payload) {
3624
- delete state.formRevisions[offlineId];
3625
- }
3626
- },
3627
- // attachment related actions
3628
- setFormRevisionAttachments: (state, action) => {
3629
- state.attachments = {};
3630
- for (const attachment of action.payload) {
3631
- state.attachments[attachment.offline_id] = attachment;
3632
- }
3633
- },
3634
- addFormRevisionAttachment: (state, action) => {
3635
- if (state.attachments[action.payload.offline_id] !== void 0) {
3636
- throw new Error(`Attachment with offline_id ${action.payload.offline_id} already exists`);
3637
- }
3638
- state.attachments[action.payload.offline_id] = action.payload;
3639
- },
3640
- addFormRevisionAttachments: (state, action) => {
3641
- for (const attachment of action.payload) {
3642
- if (state.attachments[attachment.offline_id] !== void 0) {
3643
- throw new Error(`Attachment with offline_id ${attachment.offline_id} already exists`);
3644
- }
3645
- }
3646
- for (const attachment of action.payload) {
3647
- state.attachments[attachment.offline_id] = attachment;
3648
- }
3649
- },
3650
- deleteFormRevisionAttachment: (state, action) => {
3651
- if (state.attachments[action.payload] === void 0) {
3652
- throw new Error(`Attachment with offline_id ${action.payload} does not exist`);
3653
- }
3654
- delete state.attachments[action.payload];
3655
- },
3656
- deleteFormRevisionAttachments: (state, action) => {
3657
- for (const offlineId of action.payload) {
3658
- if (state.attachments[offlineId] === void 0) {
3659
- throw new Error(`Attachment with offline_id ${offlineId} does not exist`);
3660
- }
3661
- }
3662
- for (const offlineId of action.payload) {
3663
- delete state.attachments[offlineId];
3664
- }
3665
- }
3173
+ initializeFormRevisions: formRevisionAdapter.initialize,
3174
+ setFormRevision: formRevisionAdapter.setOne,
3175
+ addFormRevision: formRevisionAdapter.addOne,
3176
+ addFormRevisions: formRevisionAdapter.addMany,
3177
+ deleteFormRevision: formRevisionAdapter.deleteOne,
3178
+ deleteFormRevisions: formRevisionAdapter.deleteMany
3666
3179
  }
3667
3180
  });
3668
3181
  const {
3669
3182
  setFormRevision,
3670
- setFormRevisions,
3183
+ initializeFormRevisions,
3671
3184
  addFormRevision,
3672
3185
  addFormRevisions,
3673
3186
  deleteFormRevision,
3674
- deleteFormRevisions,
3675
- setFormRevisionAttachments,
3676
- addFormRevisionAttachment,
3677
- addFormRevisionAttachments,
3678
- deleteFormRevisionAttachment,
3679
- deleteFormRevisionAttachments
3187
+ deleteFormRevisions
3680
3188
  } = formRevisionsSlice.actions;
3681
- const selectFormRevisionMapping = (state) => state.formRevisionReducer.formRevisions;
3189
+ const selectFormRevisionMapping = (state) => state.formRevisionReducer.instances;
3682
3190
  const selectFormRevisions = toolkit.createSelector(
3683
3191
  [selectFormRevisionMapping],
3684
3192
  (formRevisions) => Object.values(formRevisions)
3685
3193
  );
3686
3194
  const selectFormRevision = (formRevisionId) => (state) => {
3687
- return state.formRevisionReducer.formRevisions[formRevisionId];
3195
+ return state.formRevisionReducer.instances[formRevisionId];
3688
3196
  };
3689
3197
  const _selectLatestFormRevision = (formRevisions, formId2) => {
3690
3198
  let ret = null;
@@ -3713,7 +3221,7 @@ var __publicField = (obj, key, value) => {
3713
3221
  const selectLatestFormRevisionsOfAssetTypes = restructureCreateSelectorWithArgs(
3714
3222
  toolkit.createSelector(
3715
3223
  [
3716
- (state) => state.formReducer.forms,
3224
+ (state) => state.formReducer.instances,
3717
3225
  selectFormRevisionMapping,
3718
3226
  (_state, assetTypeIds) => assetTypeIds
3719
3227
  ],
@@ -3747,67 +3255,28 @@ var __publicField = (obj, key, value) => {
3747
3255
  }
3748
3256
  return latestRevisions;
3749
3257
  });
3750
- const selectUserFormRevisionAttachmentsMapping = (state) => {
3751
- return state.formRevisionReducer.attachments;
3752
- };
3753
- const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
3754
- toolkit.createSelector(
3755
- [selectUserFormRevisionAttachmentsMapping, (_state, revisionId) => revisionId],
3756
- (attachments, revisionId) => {
3757
- return Object.values(attachments).filter((attachment) => attachment.revision === revisionId);
3758
- }
3759
- )
3760
- );
3761
3258
  const formRevisionReducer = formRevisionsSlice.reducer;
3762
- const initialState$6 = {
3763
- forms: {}
3764
- };
3259
+ const formAdapter = createModelAdapter((form) => form.offline_id);
3260
+ const initialState$c = formAdapter.getInitialState({});
3765
3261
  const formSlice = toolkit.createSlice({
3766
3262
  name: "forms",
3767
- initialState: initialState$6,
3768
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3263
+ initialState: initialState$c,
3264
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
3769
3265
  reducers: {
3770
- setForms: (state, action) => {
3771
- state.forms = {};
3772
- action.payload.forEach((userForm) => {
3773
- state.forms[userForm.offline_id] = userForm;
3774
- });
3775
- },
3776
- addForm: (state, action) => {
3777
- state.forms[action.payload.offline_id] = action.payload;
3778
- },
3779
- addForms: (state, action) => {
3780
- for (const userForm of action.payload) {
3781
- state.forms[userForm.offline_id] = userForm;
3782
- }
3783
- },
3784
- favoriteForm: (state, action) => {
3785
- const { formId: formId2 } = action.payload;
3786
- const form = state.forms[formId2];
3787
- if (!form) {
3788
- throw new Error("No form exists with the id " + formId2);
3789
- }
3790
- form.favorite = true;
3791
- },
3792
- unfavoriteForm: (state, action) => {
3793
- const { formId: formId2 } = action.payload;
3794
- const form = state.forms[formId2];
3795
- if (!form) {
3796
- throw new Error("No form exists with the id " + formId2);
3797
- }
3798
- form.favorite = false;
3799
- },
3800
- deleteForm: (state, action) => {
3801
- delete state.forms[action.payload];
3802
- }
3266
+ setForms: formAdapter.initialize,
3267
+ setForm: formAdapter.setOne,
3268
+ addForm: formAdapter.addOne,
3269
+ addForms: formAdapter.addMany,
3270
+ updateForm: formAdapter.updateOne,
3271
+ deleteForm: formAdapter.deleteOne
3803
3272
  }
3804
3273
  });
3805
- const { setForms, addForm, addForms, favoriteForm, unfavoriteForm, deleteForm } = formSlice.actions;
3274
+ const { setForms, setForm, addForm, addForms, updateForm, deleteForm } = formSlice.actions;
3806
3275
  const selectFilteredForms = restructureCreateSelectorWithArgs(
3807
3276
  toolkit.createSelector(
3808
3277
  [
3809
- (state) => state.formReducer.forms,
3810
- (state) => state.formRevisionReducer.formRevisions,
3278
+ (state) => state.formReducer.instances,
3279
+ (state) => state.formRevisionReducer.instances,
3811
3280
  (_state, search) => search
3812
3281
  ],
3813
3282
  (userForms, revisions, search) => {
@@ -3840,10 +3309,10 @@ var __publicField = (obj, key, value) => {
3840
3309
  )
3841
3310
  );
3842
3311
  const selectForm = (formId2) => (state) => {
3843
- return state.formReducer.forms[formId2];
3312
+ return state.formReducer.instances[formId2];
3844
3313
  };
3845
3314
  const selectFormMapping = (state) => {
3846
- return state.formReducer.forms;
3315
+ return state.formReducer.instances;
3847
3316
  };
3848
3317
  const selectFormOfAssetType = restructureCreateSelectorWithArgs(
3849
3318
  toolkit.createSelector(
@@ -3868,123 +3337,21 @@ var __publicField = (obj, key, value) => {
3868
3337
  return Object.values(userForms).filter((form) => !form.asset_type).length;
3869
3338
  });
3870
3339
  const formReducer = formSlice.reducer;
3871
- const initialState$5 = {
3872
- formSubmissions: {},
3873
- attachments: {}
3874
- };
3340
+ const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
3341
+ const initialState$b = submissionAdapter.getInitialState({});
3875
3342
  const formSubmissionSlice = toolkit.createSlice({
3876
3343
  name: "formSubmissions",
3877
- initialState: initialState$5,
3878
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3344
+ initialState: initialState$b,
3345
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
3879
3346
  reducers: {
3880
- setFormSubmission: (state, action) => {
3881
- state.formSubmissions[action.payload.offline_id] = action.payload;
3882
- },
3883
- setFormSubmissions: (state, action) => {
3884
- state.formSubmissions = {};
3885
- for (const submission of action.payload) {
3886
- state.formSubmissions[submission.offline_id] = submission;
3887
- }
3888
- },
3889
- addFormSubmission: (state, action) => {
3890
- if (action.payload.offline_id in state.formSubmissions) {
3891
- throw new Error(`Submission with offline_id ${action.payload.offline_id} already exists`);
3892
- }
3893
- state.formSubmissions[action.payload.offline_id] = action.payload;
3894
- },
3895
- addFormSubmissions: (state, action) => {
3896
- for (const submission of action.payload) {
3897
- if (state.formSubmissions[submission.offline_id] !== void 0) {
3898
- throw new Error(`Submission with offline_id ${submission.offline_id} already exists`);
3899
- }
3900
- }
3901
- for (const submission of action.payload) {
3902
- state.formSubmissions[submission.offline_id] = submission;
3903
- }
3904
- },
3905
- updateFormSubmission: (state, action) => {
3906
- if (state.formSubmissions[action.payload.offline_id] === void 0) {
3907
- throw new Error(`Submission with offline_id ${action.payload.offline_id} does not exist`);
3908
- }
3909
- state.formSubmissions[action.payload.offline_id] = action.payload;
3910
- },
3911
- updateFormSubmissions: (state, action) => {
3912
- for (const submission of action.payload) {
3913
- if (state.formSubmissions[submission.offline_id] === void 0) {
3914
- throw new Error(`Submission with offline_id ${submission.offline_id} does not exist`);
3915
- }
3916
- }
3917
- for (const submission of action.payload) {
3918
- state.formSubmissions[submission.offline_id] = submission;
3919
- }
3920
- },
3921
- deleteFormSubmission: (state, action) => {
3922
- if (state.formSubmissions[action.payload] === void 0) {
3923
- throw new Error(`Submission with offline_id ${action.payload} does not exist`);
3924
- }
3925
- delete state.formSubmissions[action.payload];
3926
- },
3927
- deleteFormSubmissions: (state, action) => {
3928
- for (const offlineId of action.payload) {
3929
- if (state.formSubmissions[offlineId] === void 0) {
3930
- throw new Error(`Submission with offline_id ${offlineId} does not exist`);
3931
- }
3932
- delete state.formSubmissions[offlineId];
3933
- }
3934
- for (const offlineId of action.payload) {
3935
- delete state.formSubmissions[offlineId];
3936
- }
3937
- },
3938
- // Attachments
3939
- addFormSubmissionAttachment: (state, action) => {
3940
- if (state.attachments[action.payload.offline_id] !== void 0) {
3941
- throw new Error(`Attachment with offline_id ${action.payload.offline_id} already exists`);
3942
- }
3943
- state.attachments[action.payload.offline_id] = action.payload;
3944
- },
3945
- addFormSubmissionAttachments: (state, action) => {
3946
- for (const attachment of action.payload) {
3947
- if (state.attachments[attachment.offline_id] !== void 0) {
3948
- throw new Error(`Attachment with offline_id ${attachment.offline_id} already exists`);
3949
- }
3950
- }
3951
- for (const attachment of action.payload) {
3952
- state.attachments[attachment.offline_id] = attachment;
3953
- }
3954
- },
3955
- // We only need a multi set for attachments because they are not updated, only added and deleted
3956
- setFormSubmissionAttachments: (state, action) => {
3957
- state.attachments = {};
3958
- for (const attachment of action.payload) {
3959
- state.attachments[attachment.offline_id] = attachment;
3960
- }
3961
- },
3962
- updateFormSubmissionAttachments: (state, action) => {
3963
- for (const attachment of action.payload) {
3964
- if (state.attachments[attachment.offline_id] === void 0) {
3965
- throw new Error(`Attachment with offline_id ${attachment.offline_id} does not exist`);
3966
- }
3967
- }
3968
- for (const attachment of action.payload) {
3969
- state.attachments[attachment.offline_id] = attachment;
3970
- }
3971
- },
3972
- // The delete actions for UserFormSubmissionAttachments are not used in the app, but are included for completeness
3973
- // Could be used if editing a submission is ever supported, will be applicable for supporting tip tap content in submissions
3974
- deleteFormSubmissionAttachment: (state, action) => {
3975
- if (state.attachments[action.payload] === void 0) {
3976
- throw new Error(`Attachment with offline_id ${action.payload} does not exist`);
3977
- }
3978
- delete state.attachments[action.payload];
3979
- },
3980
- deleteFormSubmissionAttachments: (state, action) => {
3981
- for (const offlineId of action.payload) {
3982
- if (state.attachments[offlineId] === void 0) {
3983
- throw new Error(`Attachment with offline_id ${offlineId} does not exist`);
3984
- }
3985
- delete state.attachments[offlineId];
3986
- }
3987
- }
3347
+ setFormSubmission: submissionAdapter.setOne,
3348
+ setFormSubmissions: submissionAdapter.setMany,
3349
+ addFormSubmission: submissionAdapter.addOne,
3350
+ addFormSubmissions: submissionAdapter.addMany,
3351
+ updateFormSubmission: submissionAdapter.updateOne,
3352
+ updateFormSubmissions: submissionAdapter.updateMany,
3353
+ deleteFormSubmission: submissionAdapter.deleteOne,
3354
+ deleteFormSubmissions: submissionAdapter.deleteMany
3988
3355
  }
3989
3356
  });
3990
3357
  const {
@@ -3995,16 +3362,10 @@ var __publicField = (obj, key, value) => {
3995
3362
  updateFormSubmission,
3996
3363
  updateFormSubmissions,
3997
3364
  deleteFormSubmission,
3998
- deleteFormSubmissions,
3999
- addFormSubmissionAttachment,
4000
- addFormSubmissionAttachments,
4001
- setFormSubmissionAttachments,
4002
- updateFormSubmissionAttachments,
4003
- deleteFormSubmissionAttachment,
4004
- deleteFormSubmissionAttachments
3365
+ deleteFormSubmissions
4005
3366
  } = formSubmissionSlice.actions;
4006
3367
  const selectFormSubmissionsMapping = (state) => {
4007
- return state.formSubmissionReducer.formSubmissions;
3368
+ return state.formSubmissionReducer.instances;
4008
3369
  };
4009
3370
  const selectFormSubmissions = toolkit.createSelector(
4010
3371
  [selectFormSubmissionsMapping],
@@ -4013,7 +3374,7 @@ var __publicField = (obj, key, value) => {
4013
3374
  }
4014
3375
  );
4015
3376
  const selectFormSubmission = (submissionId) => (state) => {
4016
- return state.formSubmissionReducer.formSubmissions[submissionId];
3377
+ return state.formSubmissionReducer.instances[submissionId];
4017
3378
  };
4018
3379
  const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
4019
3380
  toolkit.createSelector(
@@ -4118,8 +3479,40 @@ var __publicField = (obj, key, value) => {
4118
3479
  return assetSubmissionMapping;
4119
3480
  }
4120
3481
  );
3482
+ const formSubmissionReducer = formSubmissionSlice.reducer;
3483
+ const formSubmissionAttachmentAdapter = createModelAdapter(
3484
+ (attachment) => attachment.offline_id
3485
+ );
3486
+ const initialState$a = formSubmissionAttachmentAdapter.getInitialState({});
3487
+ const formSubmissionAttachmentSlice = toolkit.createSlice({
3488
+ name: "formSubmissionAttachments",
3489
+ initialState: initialState$a,
3490
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
3491
+ reducers: {
3492
+ initializeFormSubmissionAttachments: formSubmissionAttachmentAdapter.initialize,
3493
+ addFormSubmissionAttachment: formSubmissionAttachmentAdapter.addOne,
3494
+ addFormSubmissionAttachments: formSubmissionAttachmentAdapter.addMany,
3495
+ setFormSubmissionAttachment: formSubmissionAttachmentAdapter.setOne,
3496
+ setFormSubmissionAttachments: formSubmissionAttachmentAdapter.setMany,
3497
+ updateFormSubmissionAttachment: formSubmissionAttachmentAdapter.updateOne,
3498
+ updateFormSubmissionAttachments: formSubmissionAttachmentAdapter.updateMany,
3499
+ deleteFormSubmissionAttachment: formSubmissionAttachmentAdapter.deleteOne,
3500
+ deleteFormSubmissionAttachments: formSubmissionAttachmentAdapter.deleteMany
3501
+ }
3502
+ });
3503
+ const {
3504
+ initializeFormSubmissionAttachments,
3505
+ addFormSubmissionAttachment,
3506
+ addFormSubmissionAttachments,
3507
+ setFormSubmissionAttachment,
3508
+ setFormSubmissionAttachments,
3509
+ updateFormSubmissionAttachment,
3510
+ updateFormSubmissionAttachments,
3511
+ deleteFormSubmissionAttachment,
3512
+ deleteFormSubmissionAttachments
3513
+ } = formSubmissionAttachmentSlice.actions;
4121
3514
  const selectFormSubmissionAttachmentsMapping = (state) => {
4122
- return state.formSubmissionReducer.attachments;
3515
+ return state.formSubmissionAttachmentReducer.instances;
4123
3516
  };
4124
3517
  const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
4125
3518
  toolkit.createSelector(
@@ -4129,48 +3522,81 @@ var __publicField = (obj, key, value) => {
4129
3522
  }
4130
3523
  )
4131
3524
  );
4132
- const formSubmissionReducer = formSubmissionSlice.reducer;
4133
- const initialState$4 = {
4134
- emailDomains: {}
3525
+ const formSubmissionAttachmentReducer = formSubmissionAttachmentSlice.reducer;
3526
+ const formRevisionAttachmentAdapter = createModelAdapter(
3527
+ (attachment) => attachment.offline_id
3528
+ );
3529
+ const initialState$9 = formRevisionAttachmentAdapter.getInitialState({});
3530
+ const formRevisionAttachmentSlice = toolkit.createSlice({
3531
+ name: "formRevisionAttachments",
3532
+ initialState: initialState$9,
3533
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
3534
+ reducers: {
3535
+ initializeFormRevisionAttachments: formRevisionAttachmentAdapter.initialize,
3536
+ addFormRevisionAttachment: formRevisionAttachmentAdapter.addOne,
3537
+ addFormRevisionAttachments: formRevisionAttachmentAdapter.addMany,
3538
+ setFormRevisionAttachment: formRevisionAttachmentAdapter.setOne,
3539
+ setFormRevisionAttachments: formRevisionAttachmentAdapter.setMany,
3540
+ updateFormRevisionAttachment: formRevisionAttachmentAdapter.updateOne,
3541
+ updateFormRevisionAttachments: formRevisionAttachmentAdapter.updateMany,
3542
+ deleteFormRevisionAttachment: formRevisionAttachmentAdapter.deleteOne,
3543
+ deleteFormRevisionAttachments: formRevisionAttachmentAdapter.deleteMany
3544
+ }
3545
+ });
3546
+ const {
3547
+ initializeFormRevisionAttachments,
3548
+ addFormRevisionAttachment,
3549
+ addFormRevisionAttachments,
3550
+ setFormRevisionAttachment,
3551
+ setFormRevisionAttachments,
3552
+ updateFormRevisionAttachment,
3553
+ updateFormRevisionAttachments,
3554
+ deleteFormRevisionAttachment,
3555
+ deleteFormRevisionAttachments
3556
+ } = formRevisionAttachmentSlice.actions;
3557
+ const selectUserFormRevisionAttachmentsMapping = (state) => {
3558
+ return state.formRevisionAttachmentReducer.instances;
4135
3559
  };
3560
+ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
3561
+ toolkit.createSelector(
3562
+ [selectUserFormRevisionAttachmentsMapping, (_state, revisionId) => revisionId],
3563
+ (attachments, revisionId) => {
3564
+ return Object.values(attachments).filter((attachment) => attachment.revision === revisionId);
3565
+ }
3566
+ )
3567
+ );
3568
+ const formRevisionAttachmentReducer = formRevisionAttachmentSlice.reducer;
3569
+ const emailDomainAdapter = createModelAdapter((emailDomain) => emailDomain.offline_id);
3570
+ const initialState$8 = emailDomainAdapter.getInitialState({});
4136
3571
  const emailDomainsSlice = toolkit.createSlice({
4137
3572
  name: "emailDomains",
4138
- initialState: initialState$4,
3573
+ initialState: initialState$8,
4139
3574
  reducers: {
4140
- setEmailDomains: (state, action) => {
4141
- const emailDomains = {};
4142
- action.payload.forEach((emailDomain) => {
4143
- emailDomains[emailDomain.offline_id] = emailDomain;
4144
- });
4145
- state.emailDomains = emailDomains;
4146
- },
4147
- addEmailDomain: (state, action) => {
4148
- state.emailDomains[action.payload.offline_id] = action.payload;
4149
- },
4150
- removeEmailDomain: (state, action) => {
4151
- if (action.payload.offline_id in state.emailDomains) {
4152
- delete state.emailDomains[action.payload.offline_id];
4153
- } else {
4154
- throw new Error(`Tried to remove email domain with ID that doesn't exist: ${action.payload.offline_id}`);
4155
- }
4156
- }
3575
+ initializeEmailDomains: emailDomainAdapter.initialize,
3576
+ addEmailDomain: emailDomainAdapter.addOne,
3577
+ deleteEmailDomain: emailDomainAdapter.deleteOne
4157
3578
  }
4158
3579
  });
4159
- const { setEmailDomains, addEmailDomain, removeEmailDomain } = emailDomainsSlice.actions;
4160
- const selectEmailDomainsAsMapping = (state) => state.emailDomainsReducer.emailDomains;
4161
- const selectSortedEmailDomains = (state) => Object.values(state.emailDomainsReducer.emailDomains).sort(
4162
- (ed1, ed2) => ed1.domain.localeCompare(ed2.domain)
3580
+ const { initializeEmailDomains, addEmailDomain, deleteEmailDomain } = emailDomainsSlice.actions;
3581
+ const selectEmailDomainsAsMapping = (state) => state.emailDomainsReducer.instances;
3582
+ const selectEmailDomains = (state) => Object.values(state.emailDomainsReducer.instances);
3583
+ const selectEmailDomainsOfOrganization = restructureCreateSelectorWithArgs(
3584
+ toolkit.createSelector(
3585
+ [selectEmailDomains, (_, organizationId) => organizationId],
3586
+ (emailDomains, organizationId) => {
3587
+ return emailDomains.filter((emailDomain) => emailDomain.organization === organizationId);
3588
+ }
3589
+ )
4163
3590
  );
4164
3591
  const emailDomainsReducer = emailDomainsSlice.reducer;
4165
- const initialState$3 = {
4166
- documents: {},
4167
- attachments: {}
3592
+ const initialState$7 = {
3593
+ documents: {}
4168
3594
  };
4169
3595
  const documentSlice = toolkit.createSlice({
4170
3596
  name: "documents",
4171
- initialState: initialState$3,
3597
+ initialState: initialState$7,
4172
3598
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
4173
- Object.assign(state, initialState$3);
3599
+ Object.assign(state, initialState$7);
4174
3600
  }),
4175
3601
  reducers: {
4176
3602
  setDocuments: (state, action) => {
@@ -4310,34 +3736,10 @@ var __publicField = (obj, key, value) => {
4310
3736
  }
4311
3737
  delete state.documents[documentId];
4312
3738
  }
4313
- },
4314
- // Attachments
4315
- setDocumentAttachment: setAttachment,
4316
- setDocumentAttachments: setAttachments,
4317
- addDocumentAttachment: addAttachment,
4318
- addDocumentAttachments: addAttachments,
4319
- updateDocumentAttachment: updateAttachment,
4320
- updateDocumentAttachments: updateAttachments,
4321
- removeDocumentAttachment: removeAttachment,
4322
- removeDocumentAttachments: removeAttachments
3739
+ }
4323
3740
  }
4324
3741
  });
4325
- const {
4326
- setDocuments,
4327
- addDocuments,
4328
- updateDocuments,
4329
- moveDocument,
4330
- removeDocuments,
4331
- // Attachments
4332
- setDocumentAttachment,
4333
- setDocumentAttachments,
4334
- addDocumentAttachment,
4335
- addDocumentAttachments,
4336
- updateDocumentAttachment,
4337
- updateDocumentAttachments,
4338
- removeDocumentAttachment,
4339
- removeDocumentAttachments
4340
- } = documentSlice.actions;
3742
+ const { setDocuments, addDocuments, updateDocuments, moveDocument, removeDocuments } = documentSlice.actions;
4341
3743
  const selectDocumentsMapping = (state) => state.documentsReducer.documents;
4342
3744
  const selectDocuments = toolkit.createSelector(
4343
3745
  [selectDocumentsMapping],
@@ -4367,13 +3769,43 @@ var __publicField = (obj, key, value) => {
4367
3769
  [selectDocuments],
4368
3770
  (documents) => documents.filter((document2) => !document2.parent_document)
4369
3771
  );
4370
- const selectDocumentAttachmentMapping = (state) => state.documentsReducer.attachments;
3772
+ const documentsReducer = documentSlice.reducer;
3773
+ const documentAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
3774
+ const initialState$6 = documentAttachmentAdapter.getInitialState({});
3775
+ const documentAttachmentSlice = toolkit.createSlice({
3776
+ name: "documentAttachments",
3777
+ initialState: initialState$6,
3778
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3779
+ reducers: {
3780
+ initializeDocumentAttachments: documentAttachmentAdapter.initialize,
3781
+ addDocumentAttachment: documentAttachmentAdapter.addOne,
3782
+ addDocumentAttachments: documentAttachmentAdapter.addMany,
3783
+ setDocumentAttachment: documentAttachmentAdapter.setOne,
3784
+ setDocumentAttachments: documentAttachmentAdapter.setMany,
3785
+ updateDocumentAttachment: documentAttachmentAdapter.updateOne,
3786
+ updateDocumentAttachments: documentAttachmentAdapter.updateMany,
3787
+ deleteDocumentAttachment: documentAttachmentAdapter.deleteOne,
3788
+ deleteDocumentAttachments: documentAttachmentAdapter.deleteMany
3789
+ }
3790
+ });
3791
+ const {
3792
+ initializeDocumentAttachments,
3793
+ addDocumentAttachment,
3794
+ addDocumentAttachments,
3795
+ setDocumentAttachment,
3796
+ setDocumentAttachments,
3797
+ updateDocumentAttachment,
3798
+ updateDocumentAttachments,
3799
+ deleteDocumentAttachment,
3800
+ deleteDocumentAttachments
3801
+ } = documentAttachmentSlice.actions;
3802
+ const selectDocumentAttachmentMapping = (state) => state.documentAttachmentReducer.instances;
4371
3803
  const selectAllDocumentAttachments = toolkit.createSelector(
4372
3804
  [selectDocumentAttachmentMapping],
4373
3805
  (mapping) => Object.values(mapping)
4374
3806
  );
4375
3807
  const selectDocumentAttachment = (attachmentId) => (state) => {
4376
- return state.documentsReducer.attachments[attachmentId];
3808
+ return state.documentAttachmentReducer.instances[attachmentId];
4377
3809
  };
4378
3810
  const selectAttachmentsOfDocument = restructureCreateSelectorWithArgs(
4379
3811
  toolkit.createSelector(
@@ -4400,48 +3832,28 @@ var __publicField = (obj, key, value) => {
4400
3832
  }
4401
3833
  )
4402
3834
  );
4403
- const documentsReducer = documentSlice.reducer;
4404
- const initialState$2 = {
4405
- teams: {}
4406
- };
3835
+ const documentAttachmentReducer = documentAttachmentSlice.reducer;
3836
+ const teamAdapter = createModelAdapter((team) => team.offline_id);
3837
+ const initialState$5 = teamAdapter.getInitialState({});
4407
3838
  const teamSlice = toolkit.createSlice({
4408
3839
  name: "teams",
4409
- initialState: initialState$2,
4410
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$2)),
3840
+ initialState: initialState$5,
3841
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
4411
3842
  reducers: {
4412
- setTeam: (state, action) => {
4413
- state.teams[action.payload.offline_id] = action.payload;
4414
- },
4415
- setTeams: (state, action) => {
4416
- state.teams = {};
4417
- for (const team of action.payload) {
4418
- state.teams[team.offline_id] = team;
4419
- }
4420
- },
4421
- addTeam: (state, action) => {
4422
- if (state.teams[action.payload.offline_id]) {
4423
- throw new Error(`Team with offline_id ${action.payload.offline_id} already exists`);
4424
- }
4425
- state.teams[action.payload.offline_id] = action.payload;
4426
- },
4427
- updateTeam: (state, action) => {
4428
- if (!state.teams[action.payload.offline_id]) {
4429
- throw new Error(`Team with offline_id ${action.payload.offline_id} does not exist`);
4430
- }
4431
- state.teams[action.payload.offline_id] = action.payload;
4432
- },
4433
- deleteTeam: (state, action) => {
4434
- delete state.teams[action.payload];
4435
- }
3843
+ setTeam: teamAdapter.setOne,
3844
+ setTeams: teamAdapter.initialize,
3845
+ addTeam: teamAdapter.addOne,
3846
+ updateTeam: teamAdapter.updateOne,
3847
+ deleteTeam: teamAdapter.deleteOne
4436
3848
  }
4437
3849
  });
4438
3850
  const { setTeam, setTeams, addTeam, updateTeam, deleteTeam } = teamSlice.actions;
4439
- const selectTeamsMapping = (state) => state.teamReducer.teams;
3851
+ const selectTeamsMapping = (state) => state.teamReducer.instances;
4440
3852
  const selectTeams = toolkit.createSelector([selectTeamsMapping], (teams) => {
4441
3853
  return Object.values(teams);
4442
3854
  });
4443
3855
  const selectTeam = (teamId) => (state) => {
4444
- return state.teamReducer.teams[teamId];
3856
+ return state.teamReducer.instances[teamId];
4445
3857
  };
4446
3858
  const selectTeamsOfOrganization = restructureCreateSelectorWithArgs(
4447
3859
  toolkit.createSelector(
@@ -4457,43 +3869,23 @@ var __publicField = (obj, key, value) => {
4457
3869
  })
4458
3870
  );
4459
3871
  const teamReducer = teamSlice.reducer;
4460
- const initialState$1 = {
4461
- conversations: {}
4462
- };
3872
+ const agentUserConversationAdapter = createModelAdapter(
3873
+ (conversation) => conversation.offline_id
3874
+ );
3875
+ const initialState$4 = agentUserConversationAdapter.getInitialState({});
4463
3876
  const agentsSlice = toolkit.createSlice({
4464
3877
  name: "agents",
4465
- initialState: initialState$1,
4466
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$1)),
3878
+ initialState: initialState$4,
3879
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
4467
3880
  reducers: {
4468
- setConversations: (state, action) => {
4469
- state.conversations = {};
4470
- for (const conversation of action.payload) {
4471
- state.conversations[conversation.offline_id] = conversation;
4472
- }
4473
- },
4474
- addConversation: (state, action) => {
4475
- if (action.payload.offline_id in state.conversations) {
4476
- throw new Error("Conversation already exists in history");
4477
- }
4478
- state.conversations[action.payload.offline_id] = action.payload;
4479
- },
4480
- setConversation: (state, action) => {
4481
- if (!(action.payload.offline_id in state.conversations)) {
4482
- throw new Error("Conversation does not exist in history");
4483
- }
4484
- state.conversations[action.payload.offline_id] = action.payload;
4485
- },
4486
- updateConversation: (state, action) => {
4487
- const existing = state.conversations[action.payload.offline_id];
4488
- if (!existing) {
4489
- throw new Error("Conversation does not exist in history");
4490
- }
4491
- state.conversations[action.payload.offline_id] = { ...existing, ...action.payload };
4492
- }
3881
+ initializeConversations: agentUserConversationAdapter.initialize,
3882
+ addConversation: agentUserConversationAdapter.addOne,
3883
+ setConversation: agentUserConversationAdapter.setOne,
3884
+ updateConversation: agentUserConversationAdapter.updateOne
4493
3885
  }
4494
3886
  });
4495
- const { setConversations, addConversation, setConversation, updateConversation } = agentsSlice.actions;
4496
- const selectConversationMapping = (state) => state.agentsReducer.conversations;
3887
+ const { initializeConversations, addConversation, setConversation, updateConversation } = agentsSlice.actions;
3888
+ const selectConversationMapping = (state) => state.agentsReducer.instances;
4497
3889
  const selectConversations = toolkit.createSelector(
4498
3890
  [selectConversationMapping],
4499
3891
  (conversationMapping) => Object.values(conversationMapping)
@@ -4505,6 +3897,132 @@ var __publicField = (obj, key, value) => {
4505
3897
  )
4506
3898
  );
4507
3899
  const agentsReducer = agentsSlice.reducer;
3900
+ const issueCommentAdapter = createModelAdapter((comment) => comment.offline_id);
3901
+ const initialState$3 = issueCommentAdapter.getInitialState({});
3902
+ const issueCommentSlice = toolkit.createSlice({
3903
+ name: "issueComments",
3904
+ initialState: initialState$3,
3905
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3906
+ reducers: {
3907
+ addIssueComment: issueCommentAdapter.addOne,
3908
+ addIssueComments: issueCommentAdapter.addMany,
3909
+ setIssueComment: issueCommentAdapter.setOne,
3910
+ setIssueComments: issueCommentAdapter.setMany,
3911
+ deleteIssueComment: issueCommentAdapter.deleteOne,
3912
+ deleteIssueComments: issueCommentAdapter.deleteMany
3913
+ }
3914
+ });
3915
+ const {
3916
+ setIssueComments,
3917
+ setIssueComment,
3918
+ addIssueComment,
3919
+ addIssueComments,
3920
+ deleteIssueComment,
3921
+ deleteIssueComments
3922
+ } = issueCommentSlice.actions;
3923
+ const selectIssueCommentMapping = (state) => state.issueCommentReducer.instances;
3924
+ const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
3925
+ toolkit.createSelector(
3926
+ [selectIssueCommentMapping, (_state, issueId) => issueId],
3927
+ (commentMapping, issueId) => {
3928
+ return Object.values(commentMapping).filter((comment) => comment.issue === issueId);
3929
+ }
3930
+ )
3931
+ );
3932
+ const issueCommentReducer = issueCommentSlice.reducer;
3933
+ const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
3934
+ const initialState$2 = issueUpdateAdapter.getInitialState({});
3935
+ const issueUpdateSlice = toolkit.createSlice({
3936
+ name: "issueUpdates",
3937
+ initialState: initialState$2,
3938
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$2)),
3939
+ reducers: {
3940
+ initializeIssueUpdates: issueUpdateAdapter.setMany,
3941
+ setIssueUpdate: issueUpdateAdapter.setOne,
3942
+ addIssueUpdate: issueUpdateAdapter.addOne,
3943
+ addIssueUpdates: issueUpdateAdapter.addMany,
3944
+ deleteIssueUpdate: issueUpdateAdapter.deleteOne,
3945
+ deleteIssueUpdates: issueUpdateAdapter.deleteMany
3946
+ }
3947
+ });
3948
+ const {
3949
+ initializeIssueUpdates,
3950
+ setIssueUpdate,
3951
+ addIssueUpdate,
3952
+ addIssueUpdates,
3953
+ deleteIssueUpdate,
3954
+ deleteIssueUpdates
3955
+ } = issueUpdateSlice.actions;
3956
+ const selectIssueUpdateMapping = (state) => state.issueUpdateReducer.instances;
3957
+ const selectIssueUpdatesOfIssue = restructureCreateSelectorWithArgs(
3958
+ toolkit.createSelector([selectIssueUpdateMapping, (_state, issueId) => issueId], (updates, issueId) => {
3959
+ return Object.values(updates).filter((update) => update.issue === issueId);
3960
+ })
3961
+ );
3962
+ const issueUpdateReducer = issueUpdateSlice.reducer;
3963
+ const issueAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
3964
+ const initialState$1 = issueAttachmentAdapter.getInitialState({});
3965
+ const issueAttachmentSlice = toolkit.createSlice({
3966
+ name: "issueAttachments",
3967
+ initialState: initialState$1,
3968
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$1)),
3969
+ reducers: {
3970
+ initializeIssueAttachments: issueAttachmentAdapter.initialize,
3971
+ addIssueAttachment: issueAttachmentAdapter.addOne,
3972
+ addIssueAttachments: issueAttachmentAdapter.addMany,
3973
+ setIssueAttachment: issueAttachmentAdapter.setOne,
3974
+ setIssueAttachments: issueAttachmentAdapter.setMany,
3975
+ updateIssueAttachment: issueAttachmentAdapter.updateOne,
3976
+ updateIssueAttachments: issueAttachmentAdapter.updateMany,
3977
+ deleteIssueAttachment: issueAttachmentAdapter.deleteOne,
3978
+ deleteIssueAttachments: issueAttachmentAdapter.deleteMany
3979
+ }
3980
+ });
3981
+ const {
3982
+ initializeIssueAttachments,
3983
+ addIssueAttachment,
3984
+ addIssueAttachments,
3985
+ setIssueAttachment,
3986
+ setIssueAttachments,
3987
+ updateIssueAttachment,
3988
+ updateIssueAttachments,
3989
+ deleteIssueAttachment,
3990
+ deleteIssueAttachments
3991
+ } = issueAttachmentSlice.actions;
3992
+ const selectIssueAttachmentMapping = (state) => state.issueAttachmentReducer.instances;
3993
+ const selectIssueAttachments = toolkit.createSelector(
3994
+ [selectIssueAttachmentMapping],
3995
+ (mapping) => Object.values(mapping)
3996
+ );
3997
+ const selectAttachmentsOfIssue = restructureCreateSelectorWithArgs(
3998
+ toolkit.createSelector(
3999
+ [selectIssueAttachments, (_state, issueId) => issueId],
4000
+ (attachments, issueId) => {
4001
+ return attachments.filter(({ issue }) => issueId === issue);
4002
+ }
4003
+ )
4004
+ );
4005
+ const selectIssueAttachment = (attachmentId) => (root) => {
4006
+ return root.issueAttachmentReducer.instances[attachmentId];
4007
+ };
4008
+ const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
4009
+ toolkit.createSelector(
4010
+ [selectIssueAttachments, (_state, issueId) => issueId],
4011
+ (attachments, issueId) => {
4012
+ const attachmentsOfIssue = attachments.filter(({ issue }) => issue === issueId);
4013
+ const fileAttachments = attachmentsOfIssue.filter(
4014
+ // this null check here is necessary, there are cases where file_type is null or undefined
4015
+ ({ file_type }) => !file_type || !file_type.startsWith("image/")
4016
+ );
4017
+ const imageAttachments = attachmentsOfIssue.filter(
4018
+ // this null check here is necessary, there are cases where file_type is null or undefined
4019
+ ({ file_type }) => file_type && file_type.startsWith("image/")
4020
+ );
4021
+ return { fileAttachments, imageAttachments };
4022
+ }
4023
+ )
4024
+ );
4025
+ const issueAttachmentReducer = issueAttachmentSlice.reducer;
4508
4026
  const initialState = {
4509
4027
  version: 0
4510
4028
  };
@@ -4533,15 +4051,19 @@ var __publicField = (obj, key, value) => {
4533
4051
  authReducer,
4534
4052
  categoryReducer,
4535
4053
  assetReducer,
4054
+ assetAttachmentReducer,
4536
4055
  assetStageCompletionReducer,
4537
4056
  assetStageReducer,
4538
4057
  assetTypeReducer,
4058
+ assetTypeAttachmentReducer,
4539
4059
  issueReducer,
4060
+ issueAttachmentReducer,
4540
4061
  issueTypeReducer,
4541
4062
  mapReducer,
4542
4063
  organizationReducer,
4543
4064
  outboxReducer,
4544
4065
  projectReducer,
4066
+ projectAttachmentReducer,
4545
4067
  projectAccessReducer,
4546
4068
  organizationAccessReducer,
4547
4069
  projectFileReducer,
@@ -4549,20 +4071,25 @@ var __publicField = (obj, key, value) => {
4549
4071
  settingReducer,
4550
4072
  formReducer,
4551
4073
  formRevisionReducer,
4074
+ formRevisionAttachmentReducer,
4075
+ formSubmissionAttachmentReducer,
4552
4076
  formSubmissionReducer,
4553
4077
  userReducer,
4554
4078
  workspaceReducer,
4555
4079
  emailDomainsReducer,
4556
4080
  licenseReducer,
4557
4081
  documentsReducer,
4082
+ documentAttachmentReducer,
4558
4083
  teamReducer,
4559
- agentsReducer
4084
+ agentsReducer,
4085
+ issueCommentReducer,
4086
+ issueUpdateReducer
4560
4087
  };
4561
4088
  const overmapReducer = toolkit.combineReducers(overmapReducers);
4562
4089
  const resetStore = "RESET";
4563
4090
  function handleWorkspaceRemoval(draft, action) {
4564
4091
  const workspaceId = action.payload;
4565
- const issuesVisibleInWorkspace = Object.values(draft.issueReducer.issues).filter(
4092
+ const issuesVisibleInWorkspace = Object.values(draft.issueReducer.instances).filter(
4566
4093
  (issue) => issue.visible_in_workspaces.includes(workspaceId)
4567
4094
  );
4568
4095
  const mainWorkspace = selectMainWorkspace(draft);
@@ -5288,24 +4815,14 @@ var __publicField = (obj, key, value) => {
5288
4815
  });
5289
4816
  return [categoryWithWorkspace, promise];
5290
4817
  }
5291
- fetchAll(projectId) {
5292
- const promise = this.client.enqueueRequest({
5293
- description: "Get categories",
5294
- method: HttpMethod.GET,
5295
- url: `/projects/${projectId}/categories/`,
5296
- blocks: [],
5297
- blockers: []
5298
- });
5299
- const offlineCategories = Object.values(this.client.store.getState().categoryReducer.categories);
5300
- return [offlineCategories, promise];
5301
- }
5302
4818
  update(category, workspaceId) {
5303
- const existingCategory = this.client.store.getState().categoryReducer.categories[category.offline_id];
4819
+ const state = this.client.store.getState();
4820
+ const existingCategory = selectCategoryById(category.offline_id)(state);
5304
4821
  if (!existingCategory) {
5305
4822
  throw new Error(`Expected an existing category with offline_id ${category.offline_id}`);
5306
4823
  }
5307
- this.client.store.dispatch(patchCategory(category));
5308
4824
  const optimisticCategory = { ...existingCategory, ...category };
4825
+ this.client.store.dispatch(updateCategory(optimisticCategory));
5309
4826
  const promise = this.client.enqueueRequest({
5310
4827
  description: "Edit Category",
5311
4828
  method: HttpMethod.PATCH,
@@ -5320,7 +4837,7 @@ var __publicField = (obj, key, value) => {
5320
4837
  return [optimisticCategory, promise];
5321
4838
  }
5322
4839
  remove(category, workspaceId) {
5323
- this.client.store.dispatch(removeCategory(category.offline_id));
4840
+ this.client.store.dispatch(deleteCategory(category.offline_id));
5324
4841
  return this.client.enqueueRequest({
5325
4842
  description: "Delete Category",
5326
4843
  method: HttpMethod.DELETE,
@@ -5333,33 +4850,20 @@ var __publicField = (obj, key, value) => {
5333
4850
  blocks: []
5334
4851
  });
5335
4852
  }
5336
- /**
5337
- * Overwrites the store with whatever categories are on the server.
5338
- * @returns A promise that resolves to an empty result.
5339
- * @throws An APIError if the request fails.
5340
- * @throws An Error if there is no active project, or for any other unexpected error.
5341
- * @example
5342
- * ```typescript
5343
- * try {
5344
- * await sdk.category.refreshStore()
5345
- * } catch (e) {
5346
- * if (e instanceof APIError) {
5347
- * // handle error
5348
- * return
5349
- * }
5350
- * throw e
5351
- * }
5352
- * ```
5353
- */
5354
4853
  async refreshStore() {
5355
4854
  const { store } = this.client;
5356
4855
  const projectId = store.getState().projectReducer.activeProjectId;
5357
4856
  if (!projectId) {
5358
4857
  throw new Error("No active project");
5359
4858
  }
5360
- const [_offlineCategories, promise] = this.fetchAll(projectId);
5361
- const result = await promise;
5362
- store.dispatch(setCategories(result));
4859
+ const result = await this.client.enqueueRequest({
4860
+ description: "Get categories",
4861
+ method: HttpMethod.GET,
4862
+ url: `/projects/${projectId}/categories/`,
4863
+ blocks: [],
4864
+ blockers: []
4865
+ });
4866
+ store.dispatch(initializeCategories(result));
5363
4867
  }
5364
4868
  }
5365
4869
  function chunkArray(arr, chunkSize) {
@@ -5410,10 +4914,10 @@ var __publicField = (obj, key, value) => {
5410
4914
  if (!assetToBeDeleted)
5411
4915
  throw new Error(`No asset with id ${assetId} found in the store`);
5412
4916
  const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(store.getState());
5413
- store.dispatch(removeAsset(assetId));
4917
+ store.dispatch(deleteAsset(assetId));
5414
4918
  if (attachmentsOfAssets.length > 0) {
5415
4919
  const attachmentsOfAssetIds = attachmentsOfAssets.map(({ offline_id }) => offline_id);
5416
- store.dispatch(removeAssetAttachments(attachmentsOfAssetIds));
4920
+ store.dispatch(deleteAssetAttachments(attachmentsOfAssetIds));
5417
4921
  }
5418
4922
  return this.client.enqueueRequest({
5419
4923
  description: "Delete asset",
@@ -5430,10 +4934,10 @@ var __publicField = (obj, key, value) => {
5430
4934
  async deleteAllAssetsOfAssetType(assetTypeId) {
5431
4935
  const { store } = this.client;
5432
4936
  const state = store.getState();
5433
- const allAssetsOfAssetType = selectAssetsOfAssetType(assetTypeId)(state);
5434
- const allAssetsOfAssetTypeIds = (allAssetsOfAssetType || []).map((c) => c.offline_id);
4937
+ const allAssetsOfAssetType = selectAssetsOfAssetType(assetTypeId)(state) ?? [];
4938
+ const allAssetsOfAssetTypeIds = allAssetsOfAssetType.map((c) => c.offline_id);
5435
4939
  const affectedOfflineIds = [assetTypeId, ...allAssetsOfAssetTypeIds];
5436
- store.dispatch(removeAllAssetsOfType(assetTypeId));
4940
+ store.dispatch(deleteAssets(allAssetsOfAssetTypeIds));
5437
4941
  return this.client.enqueueRequest({
5438
4942
  description: "Delete all assets of asset type",
5439
4943
  method: HttpMethod.DELETE,
@@ -5441,9 +4945,7 @@ var __publicField = (obj, key, value) => {
5441
4945
  blockers: affectedOfflineIds,
5442
4946
  blocks: affectedOfflineIds
5443
4947
  }).catch((err) => {
5444
- if (allAssetsOfAssetType) {
5445
- store.dispatch(addAssetsInBatches(allAssetsOfAssetType));
5446
- }
4948
+ store.dispatch(addAssets(allAssetsOfAssetType));
5447
4949
  throw err;
5448
4950
  });
5449
4951
  }
@@ -5493,7 +4995,7 @@ var __publicField = (obj, key, value) => {
5493
4995
  }
5494
4996
  void Promise.all(batchPromises).then((result) => {
5495
4997
  const allCreatedAssets = result.flat();
5496
- store.dispatch(addAssetsInBatches(allCreatedAssets));
4998
+ store.dispatch(addAssets(allCreatedAssets));
5497
4999
  });
5498
5000
  return batchPromises;
5499
5001
  }
@@ -5506,14 +5008,14 @@ var __publicField = (obj, key, value) => {
5506
5008
  blockers: [],
5507
5009
  blocks: []
5508
5010
  });
5509
- store.dispatch(setAssets(result));
5011
+ store.dispatch(initializeAssets(result));
5510
5012
  }
5511
5013
  }
5512
5014
  class AssetStageCompletionService extends BaseApiService {
5513
5015
  add(assetId, stageId) {
5514
5016
  var _a2;
5515
5017
  const { store } = this.client;
5516
- const assetTypeId = (_a2 = store.getState().assetReducer.assets[assetId]) == null ? void 0 : _a2.asset_type;
5018
+ const assetTypeId = (_a2 = selectAsset(assetId)(store.getState())) == null ? void 0 : _a2.asset_type;
5517
5019
  if (!assetTypeId) {
5518
5020
  throw new Error(`Asset with offline_id ${assetId} not found`);
5519
5021
  }
@@ -5667,7 +5169,11 @@ var __publicField = (obj, key, value) => {
5667
5169
  }
5668
5170
  async linkForm(stageId, formId2) {
5669
5171
  const { store } = this.client;
5670
- store.dispatch(linkStageToForm({ stageId, formId: formId2 }));
5172
+ const stage = store.getState().assetStageReducer.instances[stageId];
5173
+ if (!stage) {
5174
+ throw new Error(`No asset stage with id ${stageId} found in the store`);
5175
+ }
5176
+ store.dispatch(updateStage({ ...stage, user_form: formId2 }));
5671
5177
  try {
5672
5178
  await this.client.enqueueRequest({
5673
5179
  description: "Link asset stage to form",
@@ -5678,13 +5184,17 @@ var __publicField = (obj, key, value) => {
5678
5184
  blocks: [stageId]
5679
5185
  });
5680
5186
  } catch (e) {
5681
- store.dispatch(unlinkStageToForm({ stageId }));
5187
+ store.dispatch(setStage(stage));
5682
5188
  throw e;
5683
5189
  }
5684
5190
  }
5685
5191
  async unlinkForm(stageId, formId2) {
5686
5192
  const { store } = this.client;
5687
- store.dispatch(unlinkStageToForm({ stageId }));
5193
+ const stage = store.getState().assetStageReducer.instances[stageId];
5194
+ if (!stage) {
5195
+ throw new Error(`No asset stage with id ${stageId} found in the store`);
5196
+ }
5197
+ store.dispatch(updateStage({ ...stage, user_form: void 0 }));
5688
5198
  try {
5689
5199
  await this.client.enqueueRequest({
5690
5200
  description: "Unlink asset stage from form",
@@ -5694,7 +5204,7 @@ var __publicField = (obj, key, value) => {
5694
5204
  blocks: [stageId]
5695
5205
  });
5696
5206
  } catch (e) {
5697
- store.dispatch(linkStageToForm({ stageId, formId: formId2 }));
5207
+ store.dispatch(setStage(stage));
5698
5208
  throw e;
5699
5209
  }
5700
5210
  }
@@ -5707,7 +5217,7 @@ var __publicField = (obj, key, value) => {
5707
5217
  blockers: [],
5708
5218
  blocks: []
5709
5219
  });
5710
- store.dispatch(addStages(result));
5220
+ store.dispatch(initializeStages(result));
5711
5221
  }
5712
5222
  }
5713
5223
  const AttachmentModelMeta = {
@@ -5745,22 +5255,22 @@ var __publicField = (obj, key, value) => {
5745
5255
  class BaseAttachmentService extends BaseApiService {
5746
5256
  getNumberOfAttachmentsWithSha1(sha1) {
5747
5257
  const {
5748
- issueReducer: issueReducer2,
5749
- assetReducer: assetReducer2,
5750
- assetTypeReducer: assetTypeReducer2,
5751
- documentsReducer: documentsReducer2,
5752
- projectReducer: projectReducer2,
5753
- formSubmissionReducer: formSubmissionReducer2,
5754
- formRevisionReducer: formRevisionReducer2
5258
+ issueAttachmentReducer: issueAttachmentReducer2,
5259
+ assetAttachmentReducer: assetAttachmentReducer2,
5260
+ assetTypeAttachmentReducer: assetTypeAttachmentReducer2,
5261
+ documentAttachmentReducer: documentAttachmentReducer2,
5262
+ projectAttachmentReducer: projectAttachmentReducer2,
5263
+ formSubmissionAttachmentReducer: formSubmissionAttachmentReducer2,
5264
+ formRevisionAttachmentReducer: formRevisionAttachmentReducer2
5755
5265
  } = this.client.store.getState();
5756
5266
  const objectsWithSha1 = [].concat(
5757
- Object.values(issueReducer2.attachments),
5758
- Object.values(assetReducer2.attachments),
5759
- Object.values(assetTypeReducer2.attachments),
5760
- Object.values(documentsReducer2.attachments),
5761
- Object.values(projectReducer2.attachments),
5762
- Object.values(formRevisionReducer2.attachments),
5763
- Object.values(formSubmissionReducer2.attachments)
5267
+ Object.values(issueAttachmentReducer2.instances),
5268
+ Object.values(assetAttachmentReducer2.instances),
5269
+ Object.values(assetTypeAttachmentReducer2.instances),
5270
+ Object.values(documentAttachmentReducer2.instances),
5271
+ Object.values(projectAttachmentReducer2.instances),
5272
+ Object.values(formRevisionAttachmentReducer2.instances),
5273
+ Object.values(formSubmissionAttachmentReducer2.instances)
5764
5274
  );
5765
5275
  return objectsWithSha1.filter((object) => object.file_sha1 === sha1).length;
5766
5276
  }
@@ -5780,22 +5290,7 @@ var __publicField = (obj, key, value) => {
5780
5290
  });
5781
5291
  }
5782
5292
  }
5783
- // Note that currently the fetching of attachments for all models dependds on the active projectId. This may change in the future. And
5784
- // so for some attachment model services, this method will have to be overridden.
5785
- async getAttachments(actions) {
5786
- const { store } = this.client;
5787
- const activeProjectId = store.getState().projectReducer.activeProjectId;
5788
- const meta = AttachmentModelMeta[this.attachmentModel];
5789
- const result = await this.client.enqueueRequest({
5790
- description: `Get ${meta.name} attachments`,
5791
- method: HttpMethod.GET,
5792
- url: `/projects/${activeProjectId}${meta.fetchUrlPostfix}/`,
5793
- blocks: [],
5794
- blockers: []
5795
- });
5796
- store.dispatch(actions.setAttachments(result));
5797
- }
5798
- async attachFiles(files, modelId, buildOfflineAttachment, actions) {
5293
+ async attachFiles(files, modelId, buildOfflineAttachment) {
5799
5294
  const { store } = this.client;
5800
5295
  const currentUser = store.getState().userReducer.currentUser;
5801
5296
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -5829,7 +5324,7 @@ var __publicField = (obj, key, value) => {
5829
5324
  description: offlineAttachment.description
5830
5325
  });
5831
5326
  }
5832
- store.dispatch(actions.addAttachments(offlineAttachments));
5327
+ store.dispatch(this.addAttachments(offlineAttachments));
5833
5328
  const meta = AttachmentModelMeta[this.attachmentModel];
5834
5329
  const promise = this.client.enqueueRequest({
5835
5330
  description: `Attach files to ${meta.name}`,
@@ -5844,22 +5339,22 @@ var __publicField = (obj, key, value) => {
5844
5339
  blockers: offlineAttachments.map((attachment) => attachment.file_sha1)
5845
5340
  });
5846
5341
  promise.then(({ attachments, presigned_urls }) => {
5847
- store.dispatch(actions.updateAttachments(attachments));
5342
+ store.dispatch(this.updateAttachments(attachments));
5848
5343
  this.processPresignedUrls(presigned_urls);
5849
5344
  }).catch(() => {
5850
- store.dispatch(actions.removeAttachments(offlineAttachments.map((attachment) => attachment.offline_id)));
5345
+ store.dispatch(this.removeAttachments(offlineAttachments.map((attachment) => attachment.offline_id)));
5851
5346
  });
5852
5347
  return [offlineAttachments, promise.then(({ attachments }) => attachments)];
5853
5348
  }
5854
- async deleteAttachment(attachmendId, actions, selectors) {
5349
+ async deleteAttachment(attachmendId) {
5855
5350
  const { store } = this.client;
5856
- const attachment = selectors.selectAttachment(attachmendId)(store.getState());
5351
+ const attachment = this.selectAttachment(attachmendId)(store.getState());
5857
5352
  if (!attachment) {
5858
5353
  throw new Error(
5859
5354
  `Attempting to delete attachment with offline_id ${attachmendId} that does not exist in the store`
5860
5355
  );
5861
5356
  }
5862
- store.dispatch(actions.removeAttachment(attachment.offline_id));
5357
+ store.dispatch(this.removeAttachment(attachment.offline_id));
5863
5358
  const meta = AttachmentModelMeta[this.attachmentModel];
5864
5359
  const promise = this.client.enqueueRequest({
5865
5360
  description: "Delete attachment",
@@ -5873,15 +5368,37 @@ var __publicField = (obj, key, value) => {
5873
5368
  void this.client.files.removeCache(attachment.file_sha1);
5874
5369
  }
5875
5370
  }).catch(() => {
5876
- store.dispatch(actions.setAttachment(attachment));
5371
+ store.dispatch(this.setAttachment(attachment));
5877
5372
  });
5878
5373
  return promise;
5879
5374
  }
5375
+ // Note that currently the fetching of attachments for all models dependds on the active projectId. This may change in the future. And
5376
+ // so for some attachment model services, this method will have to be overridden.
5377
+ async refreshStore() {
5378
+ const { store } = this.client;
5379
+ const activeProjectId = store.getState().projectReducer.activeProjectId;
5380
+ const meta = AttachmentModelMeta[this.attachmentModel];
5381
+ const result = await this.client.enqueueRequest({
5382
+ description: `Get ${meta.name} attachments`,
5383
+ method: HttpMethod.GET,
5384
+ url: `/projects/${activeProjectId}${meta.fetchUrlPostfix}/`,
5385
+ blocks: [],
5386
+ blockers: []
5387
+ });
5388
+ store.dispatch(this.initializeAttachments(result));
5389
+ }
5880
5390
  }
5881
5391
  class AssetAttachmentService extends BaseAttachmentService {
5882
5392
  constructor() {
5883
5393
  super(...arguments);
5884
5394
  __publicField(this, "attachmentModel", AttachmentModel.Asset);
5395
+ __publicField(this, "initializeAttachments", initializeAssetAttachments);
5396
+ __publicField(this, "addAttachments", addAssetAttachments);
5397
+ __publicField(this, "updateAttachments", updateAssetAttachments);
5398
+ __publicField(this, "removeAttachments", deleteAssetAttachments);
5399
+ __publicField(this, "removeAttachment", deleteAssetAttachment);
5400
+ __publicField(this, "setAttachment", setAssetAttachment);
5401
+ __publicField(this, "selectAttachment", selectAssetAttachment);
5885
5402
  }
5886
5403
  buildOfflineAttachment(data) {
5887
5404
  return offline({
@@ -5896,28 +5413,10 @@ var __publicField = (obj, key, value) => {
5896
5413
  });
5897
5414
  }
5898
5415
  async attachFilesToAsset(files, assetId) {
5899
- return this.attachFiles(files, assetId, this.buildOfflineAttachment.bind(this), {
5900
- addAttachments: addAssetAttachments,
5901
- updateAttachments: updateAssetAttachments,
5902
- removeAttachments: removeAssetAttachments
5903
- });
5904
- }
5905
- deleteAssetAttachment(attachmentId) {
5906
- return this.deleteAttachment(
5907
- attachmentId,
5908
- {
5909
- setAttachment: setAssetAttachment,
5910
- removeAttachment: removeAssetAttachment
5911
- },
5912
- {
5913
- selectAttachment: selectAssetAttachment
5914
- }
5915
- );
5416
+ return this.attachFiles(files, assetId, this.buildOfflineAttachment.bind(this));
5916
5417
  }
5917
- async refreshStore() {
5918
- return this.getAttachments({
5919
- setAttachments: setAssetAttachments
5920
- });
5418
+ async deleteAssetAttachment(attachmentId) {
5419
+ return this.deleteAttachment(attachmentId);
5921
5420
  }
5922
5421
  }
5923
5422
  class AssetTypeService extends BaseApiService {
@@ -5963,7 +5462,7 @@ var __publicField = (obj, key, value) => {
5963
5462
  }
5964
5463
  if (attachmentsOfAssetType.length > 0) {
5965
5464
  const attachmentsOfAssetTypeIds = attachmentsOfAssetType.map(({ offline_id }) => offline_id);
5966
- store.dispatch(removeAssetTypeAttachments(attachmentsOfAssetTypeIds));
5465
+ store.dispatch(deleteAssetTypeAttachments(attachmentsOfAssetTypeIds));
5967
5466
  }
5968
5467
  return this.client.enqueueRequest({
5969
5468
  description: "Delete asset type",
@@ -5987,13 +5486,20 @@ var __publicField = (obj, key, value) => {
5987
5486
  blockers: [],
5988
5487
  blocks: []
5989
5488
  });
5990
- store.dispatch(setAssetTypes(result));
5489
+ store.dispatch(initializeAssetTypes(result));
5991
5490
  }
5992
5491
  }
5993
5492
  class AssetTypeAttachmentService extends BaseAttachmentService {
5994
5493
  constructor() {
5995
5494
  super(...arguments);
5996
5495
  __publicField(this, "attachmentModel", AttachmentModel.AssetType);
5496
+ __publicField(this, "initializeAttachments", initializeAssetTypeAttachments);
5497
+ __publicField(this, "addAttachments", addAssetTypeAttachments);
5498
+ __publicField(this, "updateAttachments", updateAssetTypeAttachments);
5499
+ __publicField(this, "removeAttachments", deleteAssetTypeAttachments);
5500
+ __publicField(this, "removeAttachment", deleteAssetTypeAttachment);
5501
+ __publicField(this, "setAttachment", setAssetTypeAttachment);
5502
+ __publicField(this, "selectAttachment", selectAssetTypeAttachment);
5997
5503
  }
5998
5504
  buildOfflineAttachment(data) {
5999
5505
  return offline({
@@ -6008,33 +5514,10 @@ var __publicField = (obj, key, value) => {
6008
5514
  });
6009
5515
  }
6010
5516
  async attachFilesToAssetType(files, assetTypeId) {
6011
- return this.attachFiles(
6012
- files,
6013
- assetTypeId,
6014
- this.buildOfflineAttachment.bind(this),
6015
- {
6016
- addAttachments: addAssetTypeAttachments,
6017
- updateAttachments: updateAssetTypeAttachments,
6018
- removeAttachments: removeAssetTypeAttachments
6019
- }
6020
- );
6021
- }
6022
- deleteAssetTypeAttachment(attachmentId) {
6023
- return this.deleteAttachment(
6024
- attachmentId,
6025
- {
6026
- setAttachment: setAssetTypeAttachment,
6027
- removeAttachment: removeAssetTypeAttachment
6028
- },
6029
- {
6030
- selectAttachment: selectAssetTypeAttachment
6031
- }
6032
- );
5517
+ return this.attachFiles(files, assetTypeId, this.buildOfflineAttachment.bind(this));
6033
5518
  }
6034
- async refreshStore() {
6035
- return this.getAttachments({
6036
- setAttachments: setAssetTypeAttachments
6037
- });
5519
+ async deleteAssetTypeAttachment(attachmentId) {
5520
+ return this.deleteAttachment(attachmentId);
6038
5521
  }
6039
5522
  }
6040
5523
  class IssueCommentService extends BaseApiService {
@@ -6056,13 +5539,13 @@ var __publicField = (obj, key, value) => {
6056
5539
  blocks: [offlineComment.offline_id]
6057
5540
  });
6058
5541
  promise.catch(() => {
6059
- store.dispatch(removeIssueComment(offlineComment.offline_id));
5542
+ store.dispatch(deleteIssueComment(offlineComment.offline_id));
6060
5543
  });
6061
5544
  return [offlineComment, promise];
6062
5545
  }
6063
5546
  update(comment) {
6064
5547
  const { store } = this.client;
6065
- const commentToUpdate = store.getState().issueReducer.comments[comment.offline_id];
5548
+ const commentToUpdate = store.getState().issueCommentReducer.instances[comment.offline_id];
6066
5549
  if (!commentToUpdate) {
6067
5550
  throw new Error(`Comment with offline_id ${comment.offline_id} not found in store`);
6068
5551
  }
@@ -6081,11 +5564,11 @@ var __publicField = (obj, key, value) => {
6081
5564
  return [comment, promise];
6082
5565
  }
6083
5566
  remove(offline_id) {
6084
- const commentToRemove = this.client.store.getState().issueReducer.comments[offline_id];
5567
+ const commentToRemove = this.client.store.getState().issueCommentReducer.instances[offline_id];
6085
5568
  if (!commentToRemove) {
6086
5569
  throw new Error(`Comment with offline_id ${offline_id} not found in store`);
6087
5570
  }
6088
- this.client.store.dispatch(removeIssueComment(offline_id));
5571
+ this.client.store.dispatch(deleteIssueComment(offline_id));
6089
5572
  const promise = this.client.enqueueRequest({
6090
5573
  description: "Delete comment",
6091
5574
  method: HttpMethod.DELETE,
@@ -6130,13 +5613,20 @@ var __publicField = (obj, key, value) => {
6130
5613
  `Received duplicate comments from the API (new length ${filteredResult.length}); filtered in browser.`
6131
5614
  );
6132
5615
  }
6133
- store.dispatch(setIssueUpdates(filteredResult));
5616
+ store.dispatch(initializeIssueUpdates(filteredResult));
6134
5617
  }
6135
5618
  }
6136
5619
  class IssueAttachmentService extends BaseAttachmentService {
6137
5620
  constructor() {
6138
5621
  super(...arguments);
6139
5622
  __publicField(this, "attachmentModel", AttachmentModel.Issue);
5623
+ __publicField(this, "initializeAttachments", initializeIssueAttachments);
5624
+ __publicField(this, "addAttachments", addIssueAttachments);
5625
+ __publicField(this, "updateAttachments", updateIssueAttachments);
5626
+ __publicField(this, "removeAttachments", deleteIssueAttachments);
5627
+ __publicField(this, "removeAttachment", deleteIssueAttachment);
5628
+ __publicField(this, "setAttachment", setIssueAttachment);
5629
+ __publicField(this, "selectAttachment", selectIssueAttachment);
6140
5630
  }
6141
5631
  buildOfflineAttachment(data) {
6142
5632
  return offline({
@@ -6151,28 +5641,10 @@ var __publicField = (obj, key, value) => {
6151
5641
  });
6152
5642
  }
6153
5643
  async attachFilesToIssue(files, issueId) {
6154
- return this.attachFiles(files, issueId, this.buildOfflineAttachment.bind(this), {
6155
- addAttachments: addIssueAttachments,
6156
- updateAttachments: updateIssueAttachments,
6157
- removeAttachments: removeIssueAttachments
6158
- });
6159
- }
6160
- deleteIssueAttachment(attachmentId) {
6161
- return this.deleteAttachment(
6162
- attachmentId,
6163
- {
6164
- setAttachment: setIssueAttachment,
6165
- removeAttachment: removeIssueAttachment
6166
- },
6167
- {
6168
- selectAttachment: selectIssueAttachment
6169
- }
6170
- );
5644
+ return this.attachFiles(files, issueId, this.buildOfflineAttachment.bind(this));
6171
5645
  }
6172
- async refreshStore() {
6173
- return this.getAttachments({
6174
- setAttachments: setIssueAttachments
6175
- });
5646
+ async deleteIssueAttachment(attachmentId) {
5647
+ return this.deleteAttachment(attachmentId);
6176
5648
  }
6177
5649
  }
6178
5650
  class IssueService extends BaseApiService {
@@ -6228,41 +5700,22 @@ var __publicField = (obj, key, value) => {
6228
5700
  severity: "danger"
6229
5701
  });
6230
5702
  }
6231
- store.dispatch(removeIssue(issuePayload.offline_id));
5703
+ store.dispatch(deleteIssue(issuePayload.offline_id));
6232
5704
  store.dispatch(addActiveProjectIssuesCount(-1));
6233
5705
  throw error2;
6234
5706
  });
6235
5707
  return [issuePayload, promise];
6236
5708
  }
6237
- fetchAll(projectId) {
6238
- const promise = this.client.enqueueRequest({
6239
- description: "Get issues",
6240
- method: HttpMethod.GET,
6241
- url: `/projects/${projectId}/issues/`,
6242
- blockers: [],
6243
- blocks: []
6244
- }).then((result) => {
6245
- const filteredResult = result.filter(onlyUniqueOfflineIds);
6246
- if (result.length !== filteredResult.length) {
6247
- console.error(
6248
- `Received duplicate issues from the API (new length ${filteredResult.length});
6249
- filtered in browser.`
6250
- );
6251
- }
6252
- return filteredResult;
6253
- });
6254
- const offlineIssues = Object.values(this.client.store.getState().issueReducer.issues);
6255
- return [offlineIssues, promise];
6256
- }
6257
5709
  update(issue) {
6258
5710
  const state = this.client.store.getState();
6259
- const issueToBeUpdated = state.issueReducer.issues[issue.offline_id];
5711
+ const issueToBeUpdated = selectIssue(issue.offline_id)(state);
6260
5712
  if (!issueToBeUpdated) {
6261
5713
  throw new Error(
6262
5714
  `Attempting to update an issue with offline_id ${issue.offline_id} that doesn't exist in the store`
6263
5715
  );
6264
5716
  }
6265
- this.client.store.dispatch(updateIssue(issue));
5717
+ const updatedIssue = { ...issueToBeUpdated, ...issue };
5718
+ this.client.store.dispatch(updateIssue(updatedIssue));
6266
5719
  const changes = {};
6267
5720
  for (const issueUpdateChange of [
6268
5721
  IssueUpdateChange.TITLE,
@@ -6279,7 +5732,7 @@ var __publicField = (obj, key, value) => {
6279
5732
  let categoryOrNull = null;
6280
5733
  const categoryIdOrNull = issue[issueUpdateChange];
6281
5734
  if (categoryIdOrNull) {
6282
- categoryOrNull = state.categoryReducer.categories[categoryIdOrNull] ?? null;
5735
+ categoryOrNull = state.categoryReducer.instances[categoryIdOrNull] ?? null;
6283
5736
  if (!categoryOrNull)
6284
5737
  throw new Error(
6285
5738
  `Trying to update issue category to ${categoryIdOrNull} which does not exist in store`
@@ -6342,28 +5795,26 @@ var __publicField = (obj, key, value) => {
6342
5795
  });
6343
5796
  promise.catch(() => {
6344
5797
  this.client.store.dispatch(updateIssue(issueToBeUpdated));
6345
- this.client.store.dispatch(removeIssueUpdate(offlineIssueUpdate.offline_id));
5798
+ this.client.store.dispatch(deleteIssueUpdate(offlineIssueUpdate.offline_id));
6346
5799
  });
6347
- const fullIssue = state.issueReducer.issues[issue.offline_id];
6348
- return [fullIssue, promise];
5800
+ return [updatedIssue, promise];
6349
5801
  }
6350
5802
  async remove(id) {
6351
5803
  const { store } = this.client;
6352
5804
  const state = store.getState();
6353
5805
  const dispatch = store.dispatch;
6354
- const backup = state.issueReducer.issues[id];
5806
+ const backup = selectIssue(id)(state);
6355
5807
  if (!backup) {
6356
5808
  throw new Error(`No issue with id ${id} found in the store`);
6357
5809
  }
6358
- const attachments = Object.values(state.issueReducer.attachments).filter((a) => a.issue === id);
6359
5810
  const attachmentsOfIssue = selectAttachmentsOfIssue(id)(state);
6360
5811
  const updatesOfIssue = selectIssueUpdatesOfIssue(id)(state);
6361
- dispatch(removeIssue(id));
5812
+ dispatch(deleteIssue(id));
6362
5813
  dispatch(addActiveProjectIssuesCount(-1));
6363
5814
  if (attachmentsOfIssue.length > 0)
6364
- dispatch(removeAttachmentsOfIssue(id));
5815
+ dispatch(deleteIssueAttachments(attachmentsOfIssue.map(({ offline_id }) => offline_id)));
6365
5816
  if (updatesOfIssue.length > 0)
6366
- dispatch(removeIssueUpdates(updatesOfIssue.map(({ offline_id }) => offline_id)));
5817
+ dispatch(deleteIssueUpdates(updatesOfIssue.map(({ offline_id }) => offline_id)));
6367
5818
  try {
6368
5819
  return await this.client.enqueueRequest({
6369
5820
  description: "Delete issue",
@@ -6374,7 +5825,7 @@ var __publicField = (obj, key, value) => {
6374
5825
  });
6375
5826
  } catch (e) {
6376
5827
  dispatch(addIssue(backup));
6377
- dispatch(addIssueAttachments(attachments));
5828
+ dispatch(addIssueAttachments(attachmentsOfIssue));
6378
5829
  dispatch(addIssueUpdates(updatesOfIssue));
6379
5830
  dispatch(addActiveProjectIssuesCount(1));
6380
5831
  throw e;
@@ -6387,9 +5838,23 @@ var __publicField = (obj, key, value) => {
6387
5838
  if (!projectId) {
6388
5839
  throw new Error("No active project");
6389
5840
  }
6390
- const [_offlineIssues, promise] = this.fetchAll(projectId);
6391
- const result = await promise;
6392
- store.dispatch(setIssues(result));
5841
+ const result = await this.client.enqueueRequest({
5842
+ description: "Get issues",
5843
+ method: HttpMethod.GET,
5844
+ url: `/projects/${projectId}/issues/`,
5845
+ blockers: [],
5846
+ blocks: []
5847
+ }).then((result2) => {
5848
+ const filteredResult = result2.filter(onlyUniqueOfflineIds);
5849
+ if (result2.length !== filteredResult.length) {
5850
+ console.error(
5851
+ `Received duplicate issues from the API (new length ${filteredResult.length});
5852
+ filtered in browser.`
5853
+ );
5854
+ }
5855
+ return filteredResult;
5856
+ });
5857
+ store.dispatch(initializeIssues(result));
6393
5858
  }
6394
5859
  }
6395
5860
  class IssueTypeService extends BaseApiService {
@@ -6431,7 +5896,8 @@ var __publicField = (obj, key, value) => {
6431
5896
  }
6432
5897
  update(issueTypeFields) {
6433
5898
  const { store } = this.client;
6434
- const issueTypeToBeUpdated = store.getState().issueTypeReducer.issueTypes[issueTypeFields.offline_id];
5899
+ const state = store.getState();
5900
+ const issueTypeToBeUpdated = selectIssueType(issueTypeFields.offline_id)(state);
6435
5901
  if (!issueTypeToBeUpdated) {
6436
5902
  throw new Error(`IssueType with offline_id ${issueTypeFields.offline_id} does not exist in the store.`);
6437
5903
  }
@@ -6457,13 +5923,13 @@ var __publicField = (obj, key, value) => {
6457
5923
  delete(issueTypeId) {
6458
5924
  const { store } = this.client;
6459
5925
  const state = store.getState();
6460
- const issueTypeToDelete = state.issueTypeReducer.issueTypes[issueTypeId];
5926
+ const issueTypeToDelete = selectIssueType(issueTypeId)(state);
6461
5927
  if (!issueTypeToDelete) {
6462
5928
  throw new Error(`IssueType with offline_id ${issueTypeId} does not exist in the store.`);
6463
5929
  }
6464
5930
  const issuesOfIssueType = selectIssuesOfIssueType(issueTypeId)(state) ?? [];
6465
5931
  store.dispatch(removeIssueType(issueTypeId));
6466
- store.dispatch(removeIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
5932
+ store.dispatch(deleteIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
6467
5933
  const promise = this.client.enqueueRequest({
6468
5934
  method: HttpMethod.DELETE,
6469
5935
  url: `/issues/types/${issueTypeId}/`,
@@ -6488,7 +5954,7 @@ var __publicField = (obj, key, value) => {
6488
5954
  blockers: [],
6489
5955
  blocks: []
6490
5956
  });
6491
- store.dispatch(setIssueTypes(result));
5957
+ store.dispatch(initializeIssueTypes(result));
6492
5958
  }
6493
5959
  }
6494
5960
  class MainService extends BaseApiService {
@@ -6622,12 +6088,12 @@ var __publicField = (obj, key, value) => {
6622
6088
  if (overwrite) {
6623
6089
  console.log("Overwriting data");
6624
6090
  store.dispatch(setProjects(projects));
6625
- store.dispatch(setWorkspaces(workspaces));
6091
+ store.dispatch(initializeWorkspaces(Object.values(workspaces)));
6626
6092
  store.dispatch(resetRecentIssues());
6627
6093
  } else {
6628
6094
  console.log("Updating data (collisions will be replaced)");
6629
6095
  store.dispatch(addOrReplaceProjects(projects));
6630
- store.dispatch(addOrReplaceWorkspaces(workspaces));
6096
+ store.dispatch(setWorkspaces(Object.values(workspaces)));
6631
6097
  }
6632
6098
  if (!currentProjectId) {
6633
6099
  store.dispatch(setIsFetchingInitialData(false));
@@ -6685,7 +6151,7 @@ var __publicField = (obj, key, value) => {
6685
6151
  // TODO: Re-add user to project if removal fails
6686
6152
  async remove(projectAccess) {
6687
6153
  const { store } = this.client;
6688
- store.dispatch(removeProjectAccess(projectAccess));
6154
+ store.dispatch(deleteProjectAccess(projectAccess.offline_id));
6689
6155
  return this.client.enqueueRequest({
6690
6156
  description: "Delete project access",
6691
6157
  method: HttpMethod.DELETE,
@@ -6808,6 +6274,13 @@ var __publicField = (obj, key, value) => {
6808
6274
  constructor() {
6809
6275
  super(...arguments);
6810
6276
  __publicField(this, "attachmentModel", AttachmentModel.Project);
6277
+ __publicField(this, "initializeAttachments", initializeProjectAttachments);
6278
+ __publicField(this, "addAttachments", addProjectAttachments);
6279
+ __publicField(this, "updateAttachments", updateProjectAttachments);
6280
+ __publicField(this, "removeAttachments", deleteProjectAttachments);
6281
+ __publicField(this, "removeAttachment", deleteProjectAttachment);
6282
+ __publicField(this, "setAttachment", setProjectAttachment);
6283
+ __publicField(this, "selectAttachment", selectProjectAttachment);
6811
6284
  }
6812
6285
  buildOfflineAttachment(data) {
6813
6286
  return offline({
@@ -6822,28 +6295,10 @@ var __publicField = (obj, key, value) => {
6822
6295
  });
6823
6296
  }
6824
6297
  async attachFilesToProject(files, projectId) {
6825
- return this.attachFiles(files, projectId, this.buildOfflineAttachment.bind(this), {
6826
- addAttachments: addProjectAttachments,
6827
- updateAttachments: updateProjectAttachments,
6828
- removeAttachments: removeProjectAttachments
6829
- });
6830
- }
6831
- deleteProjectAttachment(attachmentId) {
6832
- return this.deleteAttachment(
6833
- attachmentId,
6834
- {
6835
- setAttachment: setProjectAttachment,
6836
- removeAttachment: removeProjectAttachment
6837
- },
6838
- {
6839
- selectAttachment: selectProjectAttachment
6840
- }
6841
- );
6298
+ return this.attachFiles(files, projectId, this.buildOfflineAttachment.bind(this));
6842
6299
  }
6843
- async refreshStore() {
6844
- return this.getAttachments({
6845
- setAttachments: setProjectAttachments
6846
- });
6300
+ async deleteProjectAttachment(attachmentId) {
6301
+ return this.deleteAttachment(attachmentId);
6847
6302
  }
6848
6303
  }
6849
6304
  class ProjectService extends BaseApiService {
@@ -6921,9 +6376,9 @@ var __publicField = (obj, key, value) => {
6921
6376
  const filesToDelete = selectProjectFiles(state).filter((file) => file.project === projectId);
6922
6377
  store.dispatch(removeProjectFilesOfProject(project.id));
6923
6378
  const attachmentsOfProject = selectAttachmentsOfProject(project.id)(state);
6924
- store.dispatch(removeProjectAttachments(attachmentsOfProject.map(({ offline_id }) => offline_id)));
6379
+ store.dispatch(deleteProjectAttachments(attachmentsOfProject.map(({ offline_id }) => offline_id)));
6925
6380
  const projectAccesses = selectProjectAccesses(state);
6926
- store.dispatch(removeProjectAccessesOfProject(project.id));
6381
+ store.dispatch(deleteProjectAccesses(projectAccesses.map(({ offline_id }) => offline_id)));
6927
6382
  store.dispatch({ type: "rehydrated/setRehydrated", payload: false });
6928
6383
  store.dispatch(deleteProject(project));
6929
6384
  const license = selectLicenseForProject(project.id)(state);
@@ -7178,8 +6633,13 @@ var __publicField = (obj, key, value) => {
7178
6633
  }
7179
6634
  async favorite(formId2) {
7180
6635
  const { store } = this.client;
7181
- const activeProjectId = store.getState().projectReducer.activeProjectId;
7182
- store.dispatch(favoriteForm({ formId: formId2 }));
6636
+ const state = store.getState();
6637
+ const activeProjectId = state.projectReducer.activeProjectId;
6638
+ const form = state.formReducer.instances[formId2];
6639
+ if (!form) {
6640
+ throw new Error(`Expected form to exist, got ${form}`);
6641
+ }
6642
+ store.dispatch(updateForm({ ...form, favorite: true }));
7183
6643
  try {
7184
6644
  await this.client.enqueueRequest({
7185
6645
  description: "Favorite form",
@@ -7189,14 +6649,19 @@ var __publicField = (obj, key, value) => {
7189
6649
  blocks: [`favorite-${formId2}`]
7190
6650
  });
7191
6651
  } catch (e) {
7192
- store.dispatch(unfavoriteForm({ formId: formId2 }));
6652
+ store.dispatch(updateForm(form));
7193
6653
  throw e;
7194
6654
  }
7195
6655
  }
7196
6656
  async unfavorite(formId2) {
7197
6657
  const { store } = this.client;
7198
- const activeProjectId = store.getState().projectReducer.activeProjectId;
7199
- store.dispatch(unfavoriteForm({ formId: formId2 }));
6658
+ const state = store.getState();
6659
+ const activeProjectId = state.projectReducer.activeProjectId;
6660
+ const form = state.formReducer.instances[formId2];
6661
+ if (!form) {
6662
+ throw new Error(`Expected form to exist, got ${form}`);
6663
+ }
6664
+ store.dispatch(updateForm({ ...form, favorite: false }));
7200
6665
  try {
7201
6666
  return await this.client.enqueueRequest({
7202
6667
  description: "Unfavorite form",
@@ -7206,7 +6671,7 @@ var __publicField = (obj, key, value) => {
7206
6671
  blocks: [`favorite-${formId2}`]
7207
6672
  });
7208
6673
  } catch (e) {
7209
- store.dispatch(favoriteForm({ formId: formId2 }));
6674
+ store.dispatch(updateForm(form));
7210
6675
  throw e;
7211
6676
  }
7212
6677
  }
@@ -7307,7 +6772,7 @@ var __publicField = (obj, key, value) => {
7307
6772
  for (const attachment of issueTypeFormsResult.attachments)
7308
6773
  attachments.push(attachment);
7309
6774
  store.dispatch(setForms(forms));
7310
- store.dispatch(setFormRevisions(revisions));
6775
+ store.dispatch(initializeFormRevisions(revisions));
7311
6776
  store.dispatch(setFormRevisionAttachments(attachments));
7312
6777
  }
7313
6778
  }
@@ -7534,7 +6999,10 @@ var __publicField = (obj, key, value) => {
7534
6999
  ...submission,
7535
7000
  values
7536
7001
  };
7537
- const submissionToBeUpdated = store.getState().formSubmissionReducer.formSubmissions[submission.offline_id];
7002
+ const submissionToBeUpdated = selectFormSubmission(submission.offline_id)(store.getState());
7003
+ if (!submissionToBeUpdated) {
7004
+ throw new Error(`Expected submission with offline_id ${submission.offline_id} to exist`);
7005
+ }
7538
7006
  store.dispatch(updateFormSubmission(offlineSubmission));
7539
7007
  const promise = this.client.enqueueRequest({
7540
7008
  description: "Patch form submission",
@@ -7556,7 +7024,10 @@ var __publicField = (obj, key, value) => {
7556
7024
  async delete(submissionId) {
7557
7025
  const { store } = this.client;
7558
7026
  const state = store.getState();
7559
- const submission = state.formSubmissionReducer.formSubmissions[submissionId];
7027
+ const submissionToBeDeleted = selectFormSubmission(submissionId)(store.getState());
7028
+ if (!submissionToBeDeleted) {
7029
+ throw new Error(`Expected submission with offline_id ${submissionId} to exist`);
7030
+ }
7560
7031
  const submissionAttachments = selectAttachmentsOfFormSubmission(submissionId)(state);
7561
7032
  store.dispatch(deleteFormSubmission(submissionId));
7562
7033
  store.dispatch(addActiveProjectFormSubmissionsCount(-1));
@@ -7571,7 +7042,7 @@ var __publicField = (obj, key, value) => {
7571
7042
  });
7572
7043
  } catch (e) {
7573
7044
  store.dispatch(addActiveProjectFormSubmissionsCount(1));
7574
- store.dispatch(addFormSubmission(submission));
7045
+ store.dispatch(addFormSubmission(submissionToBeDeleted));
7575
7046
  store.dispatch(addFormSubmissionAttachments(submissionAttachments));
7576
7047
  throw e;
7577
7048
  }
@@ -7611,15 +7082,15 @@ var __publicField = (obj, key, value) => {
7611
7082
  blocks: [offlineWorkspace.offline_id]
7612
7083
  });
7613
7084
  void promise.then((result) => {
7614
- store.dispatch(addOrReplaceWorkspaces({ [offlineWorkspace.offline_id]: result }));
7085
+ store.dispatch(updateWorkspace(result));
7615
7086
  }).catch(() => {
7616
- store.dispatch(removeWorkspace(offlineWorkspace.offline_id));
7087
+ store.dispatch(deleteWorkspace(offlineWorkspace.offline_id));
7617
7088
  });
7618
7089
  return [offlineWorkspace, promise];
7619
7090
  }
7620
7091
  update(workspace) {
7621
7092
  const { store } = this.client;
7622
- store.dispatch(addOrReplaceWorkspaces({ [workspace.offline_id]: workspace }));
7093
+ store.dispatch(addWorkspace(workspace));
7623
7094
  const promise = this.client.enqueueRequest({
7624
7095
  description: "Update Workspace",
7625
7096
  method: HttpMethod.PATCH,
@@ -7639,8 +7110,8 @@ var __publicField = (obj, key, value) => {
7639
7110
  blockers: [workspaceId],
7640
7111
  blocks: []
7641
7112
  });
7642
- const originalWorkspace = store.getState().workspaceReducer.workspaces[workspaceId];
7643
- store.dispatch(removeWorkspace(workspaceId));
7113
+ const originalWorkspace = store.getState().workspaceReducer.instances[workspaceId];
7114
+ store.dispatch(deleteWorkspace(workspaceId));
7644
7115
  void promise.then(() => {
7645
7116
  void this.client.main.fetchInitialData(true).then();
7646
7117
  }).catch((reason) => {
@@ -7668,7 +7139,7 @@ var __publicField = (obj, key, value) => {
7668
7139
  return promise;
7669
7140
  }
7670
7141
  async remove(organizationAccess) {
7671
- this.client.store.dispatch(removeOrganizationAccess(organizationAccess));
7142
+ this.client.store.dispatch(deleteOrganizationAccess(organizationAccess.offline_id));
7672
7143
  this.client.store.dispatch(removeUser(organizationAccess.user));
7673
7144
  return this.client.enqueueRequest({
7674
7145
  description: "Remove organization access",
@@ -7692,7 +7163,7 @@ var __publicField = (obj, key, value) => {
7692
7163
  blockers: [],
7693
7164
  blocks: []
7694
7165
  });
7695
- store.dispatch(setOrganizationAccesses(result));
7166
+ store.dispatch(initializeOrganizationAccesses(result));
7696
7167
  }
7697
7168
  }
7698
7169
  const cachedRequestPromises = {};
@@ -7927,15 +7398,6 @@ var __publicField = (obj, key, value) => {
7927
7398
  }
7928
7399
  }
7929
7400
  class EmailDomainsService extends BaseApiService {
7930
- async fetchAll(orgId) {
7931
- return this.client.enqueueRequest({
7932
- description: "Fetch email domains for organization",
7933
- method: HttpMethod.GET,
7934
- url: `/organizations/${orgId}/email-domains/`,
7935
- blockers: [orgId.toString()],
7936
- blocks: []
7937
- });
7938
- }
7939
7401
  async add(orgId, email) {
7940
7402
  return this.client.enqueueRequest({
7941
7403
  description: "Add email domain to organization",
@@ -7947,7 +7409,7 @@ var __publicField = (obj, key, value) => {
7947
7409
  });
7948
7410
  }
7949
7411
  async remove(emailDomain) {
7950
- this.client.store.dispatch(removeEmailDomain(emailDomain));
7412
+ this.client.store.dispatch(deleteEmailDomain(emailDomain.offline_id));
7951
7413
  return this.client.enqueueRequest({
7952
7414
  description: "Remove email domain from organization",
7953
7415
  method: HttpMethod.DELETE,
@@ -7964,9 +7426,14 @@ var __publicField = (obj, key, value) => {
7964
7426
  if (!organizationId) {
7965
7427
  throw new Error("No active organization");
7966
7428
  }
7967
- const promise = this.fetchAll(organizationId);
7968
- const result = await promise;
7969
- this.client.store.dispatch(setEmailDomains(result));
7429
+ const result = await this.client.enqueueRequest({
7430
+ description: "Fetch email domains for organization",
7431
+ method: HttpMethod.GET,
7432
+ url: `/organizations/${organizationId}/email-domains/`,
7433
+ blockers: [organizationId.toString()],
7434
+ blocks: []
7435
+ });
7436
+ this.client.store.dispatch(initializeEmailDomains(result));
7970
7437
  }
7971
7438
  }
7972
7439
  class OrganizationService extends BaseApiService {
@@ -7995,8 +7462,8 @@ var __publicField = (obj, key, value) => {
7995
7462
  const users = data.users;
7996
7463
  store.dispatch(addUsers(users));
7997
7464
  store.dispatch(setActiveOrganizationId(activeOrganization.id));
7998
- store.dispatch(setOrganizationAccesses(organizationAccesses));
7999
- store.dispatch(setEmailDomains(emailDomains));
7465
+ store.dispatch(initializeOrganizationAccesses(organizationAccesses));
7466
+ store.dispatch(initializeEmailDomains(emailDomains));
8000
7467
  if (showLoading) {
8001
7468
  store.dispatch(setIsFetchingInitialData(false));
8002
7469
  }
@@ -8309,6 +7776,13 @@ var __publicField = (obj, key, value) => {
8309
7776
  constructor() {
8310
7777
  super(...arguments);
8311
7778
  __publicField(this, "attachmentModel", AttachmentModel.Document);
7779
+ __publicField(this, "initializeAttachments", initializeDocumentAttachments);
7780
+ __publicField(this, "addAttachments", addDocumentAttachments);
7781
+ __publicField(this, "updateAttachments", updateDocumentAttachments);
7782
+ __publicField(this, "removeAttachments", deleteDocumentAttachments);
7783
+ __publicField(this, "removeAttachment", deleteDocumentAttachment);
7784
+ __publicField(this, "setAttachment", setDocumentAttachment);
7785
+ __publicField(this, "selectAttachment", selectDocumentAttachment);
8312
7786
  }
8313
7787
  buildOfflineAttachment(data) {
8314
7788
  return offline({
@@ -8323,28 +7797,10 @@ var __publicField = (obj, key, value) => {
8323
7797
  });
8324
7798
  }
8325
7799
  async attachFilesToDocument(files, documentId) {
8326
- return this.attachFiles(files, documentId, this.buildOfflineAttachment.bind(this), {
8327
- addAttachments: addDocumentAttachments,
8328
- updateAttachments: updateDocumentAttachments,
8329
- removeAttachments: removeDocumentAttachments
8330
- });
8331
- }
8332
- deleteDocumentAttachment(attachmentId) {
8333
- return this.deleteAttachment(
8334
- attachmentId,
8335
- {
8336
- setAttachment: setDocumentAttachment,
8337
- removeAttachment: removeDocumentAttachment
8338
- },
8339
- {
8340
- selectAttachment: selectDocumentAttachment
8341
- }
8342
- );
7800
+ return this.attachFiles(files, documentId, this.buildOfflineAttachment.bind(this));
8343
7801
  }
8344
- async refreshStore() {
8345
- return this.getAttachments({
8346
- setAttachments: setDocumentAttachments
8347
- });
7802
+ async deleteDocumentAttachment(attachmentId) {
7803
+ return this.deleteAttachment(attachmentId);
8348
7804
  }
8349
7805
  }
8350
7806
  class AgentService extends BaseApiService {
@@ -8385,7 +7841,7 @@ var __publicField = (obj, key, value) => {
8385
7841
  blocks: ["prompt"],
8386
7842
  queryParams: { conversation_id: conversationId }
8387
7843
  }).then((response) => {
8388
- const conversation = store.getState().agentsReducer.conversations[conversationId];
7844
+ const conversation = store.getState().agentsReducer.instances[conversationId];
8389
7845
  if (!(conversation == null ? void 0 : conversation.offline_id)) {
8390
7846
  throw new Error("Conversation not found");
8391
7847
  }
@@ -8431,7 +7887,7 @@ var __publicField = (obj, key, value) => {
8431
7887
  blockers: ["agent-conversations"],
8432
7888
  blocks: ["agent-conversations"]
8433
7889
  });
8434
- store.dispatch(setConversations(result));
7890
+ store.dispatch(initializeConversations(result));
8435
7891
  }
8436
7892
  }
8437
7893
  class TeamService extends BaseApiService {
@@ -8469,7 +7925,10 @@ var __publicField = (obj, key, value) => {
8469
7925
  // TODO: @Audiopolis / Magnus - should we pass a offline_id as one arg and a UpdatedTeamProps as a second arg instead of this set up?
8470
7926
  update(team) {
8471
7927
  const { store } = this.client;
8472
- const teamToBeUpdated = store.getState().teamReducer.teams[team.offline_id];
7928
+ const teamToBeUpdated = selectTeam(team.offline_id)(store.getState());
7929
+ if (!teamToBeUpdated) {
7930
+ throw new Error(`Expected team with offline_id ${team.offline_id} to exist`);
7931
+ }
8473
7932
  const offlineUpdatedTeam = {
8474
7933
  ...teamToBeUpdated,
8475
7934
  ...team
@@ -8493,7 +7952,7 @@ var __publicField = (obj, key, value) => {
8493
7952
  async delete(teamId) {
8494
7953
  const { store } = this.client;
8495
7954
  const state = store.getState();
8496
- const team = state.teamReducer.teams[teamId];
7955
+ const team = selectTeam(teamId)(state);
8497
7956
  if (!team) {
8498
7957
  throw new Error(`Expected team with id ${teamId} to exist`);
8499
7958
  }
@@ -8513,7 +7972,7 @@ var __publicField = (obj, key, value) => {
8513
7972
  }
8514
7973
  async setMembers(teamId, members) {
8515
7974
  const { store } = this.client;
8516
- const team = store.getState().teamReducer.teams[teamId];
7975
+ const team = selectTeam(teamId)(store.getState());
8517
7976
  if (!team) {
8518
7977
  throw new Error(`Expected team with id ${teamId} to exist`);
8519
7978
  }
@@ -8538,7 +7997,7 @@ var __publicField = (obj, key, value) => {
8538
7997
  }
8539
7998
  async addMembers(teamId, members) {
8540
7999
  const { store } = this.client;
8541
- const team = store.getState().teamReducer.teams[teamId];
8000
+ const team = selectTeam(teamId)(store.getState());
8542
8001
  if (!team) {
8543
8002
  throw new Error(`Expected team with id ${teamId} to exist`);
8544
8003
  }
@@ -8547,7 +8006,7 @@ var __publicField = (obj, key, value) => {
8547
8006
  }
8548
8007
  async removeMembers(teamId, members) {
8549
8008
  const { store } = this.client;
8550
- const team = store.getState().teamReducer.teams[teamId];
8009
+ const team = selectTeam(teamId)(store.getState());
8551
8010
  if (!team) {
8552
8011
  throw new Error(`Expected team with id ${teamId} to exist`);
8553
8012
  }
@@ -16903,7 +16362,7 @@ var __publicField = (obj, key, value) => {
16903
16362
  exports2.addAssetType = addAssetType;
16904
16363
  exports2.addAssetTypeAttachment = addAssetTypeAttachment;
16905
16364
  exports2.addAssetTypeAttachments = addAssetTypeAttachments;
16906
- exports2.addAssetsInBatches = addAssetsInBatches;
16365
+ exports2.addAssets = addAssets;
16907
16366
  exports2.addCategory = addCategory;
16908
16367
  exports2.addConversation = addConversation;
16909
16368
  exports2.addDocumentAttachment = addDocumentAttachment;
@@ -16931,12 +16390,9 @@ var __publicField = (obj, key, value) => {
16931
16390
  exports2.addIssueUpdates = addIssueUpdates;
16932
16391
  exports2.addIssues = addIssues;
16933
16392
  exports2.addLicenses = addLicenses;
16934
- exports2.addOrReplaceCategories = addOrReplaceCategories;
16935
- exports2.addOrReplaceIssueComment = addOrReplaceIssueComment;
16936
16393
  exports2.addOrReplaceProjectFile = addOrReplaceProjectFile;
16937
16394
  exports2.addOrReplaceProjectFiles = addOrReplaceProjectFiles;
16938
16395
  exports2.addOrReplaceProjects = addOrReplaceProjects;
16939
- exports2.addOrReplaceWorkspaces = addOrReplaceWorkspaces;
16940
16396
  exports2.addProjectAttachment = addProjectAttachment;
16941
16397
  exports2.addProjectAttachments = addProjectAttachments;
16942
16398
  exports2.addStageCompletion = addStageCompletion;
@@ -16949,12 +16405,16 @@ var __publicField = (obj, key, value) => {
16949
16405
  exports2.agentsReducer = agentsReducer;
16950
16406
  exports2.agentsSlice = agentsSlice;
16951
16407
  exports2.areArraysEqual = areArraysEqual;
16408
+ exports2.assetAttachmentReducer = assetAttachmentReducer;
16409
+ exports2.assetAttachmentSlice = assetAttachmentSlice;
16952
16410
  exports2.assetReducer = assetReducer;
16953
16411
  exports2.assetSlice = assetSlice;
16954
16412
  exports2.assetStageCompletionReducer = assetStageCompletionReducer;
16955
16413
  exports2.assetStageCompletionSlice = assetStageCompletionSlice;
16956
16414
  exports2.assetStageReducer = assetStageReducer;
16957
16415
  exports2.assetStageSlice = assetStageSlice;
16416
+ exports2.assetTypeAttachmentReducer = assetTypeAttachmentReducer;
16417
+ exports2.assetTypeAttachmentSlice = assetTypeAttachmentSlice;
16958
16418
  exports2.assetTypeReducer = assetTypeReducer;
16959
16419
  exports2.assetTypeSlice = assetTypeSlice;
16960
16420
  exports2.authReducer = authReducer;
@@ -16977,7 +16437,17 @@ var __publicField = (obj, key, value) => {
16977
16437
  exports2.decodeFormValues = decodeFormValues;
16978
16438
  exports2.defaultBadgeColor = defaultBadgeColor;
16979
16439
  exports2.defaultStore = defaultStore;
16440
+ exports2.deleteAsset = deleteAsset;
16441
+ exports2.deleteAssetAttachment = deleteAssetAttachment;
16442
+ exports2.deleteAssetAttachments = deleteAssetAttachments;
16980
16443
  exports2.deleteAssetType = deleteAssetType;
16444
+ exports2.deleteAssetTypeAttachment = deleteAssetTypeAttachment;
16445
+ exports2.deleteAssetTypeAttachments = deleteAssetTypeAttachments;
16446
+ exports2.deleteAssets = deleteAssets;
16447
+ exports2.deleteCategory = deleteCategory;
16448
+ exports2.deleteDocumentAttachment = deleteDocumentAttachment;
16449
+ exports2.deleteDocumentAttachments = deleteDocumentAttachments;
16450
+ exports2.deleteEmailDomain = deleteEmailDomain;
16981
16451
  exports2.deleteForm = deleteForm;
16982
16452
  exports2.deleteFormRevision = deleteFormRevision;
16983
16453
  exports2.deleteFormRevisionAttachment = deleteFormRevisionAttachment;
@@ -16987,12 +16457,28 @@ var __publicField = (obj, key, value) => {
16987
16457
  exports2.deleteFormSubmissionAttachment = deleteFormSubmissionAttachment;
16988
16458
  exports2.deleteFormSubmissionAttachments = deleteFormSubmissionAttachments;
16989
16459
  exports2.deleteFormSubmissions = deleteFormSubmissions;
16460
+ exports2.deleteIssue = deleteIssue;
16461
+ exports2.deleteIssueAttachment = deleteIssueAttachment;
16462
+ exports2.deleteIssueAttachments = deleteIssueAttachments;
16463
+ exports2.deleteIssueComment = deleteIssueComment;
16464
+ exports2.deleteIssueComments = deleteIssueComments;
16465
+ exports2.deleteIssueUpdate = deleteIssueUpdate;
16466
+ exports2.deleteIssueUpdates = deleteIssueUpdates;
16467
+ exports2.deleteIssues = deleteIssues;
16468
+ exports2.deleteOrganizationAccess = deleteOrganizationAccess;
16990
16469
  exports2.deleteProject = deleteProject;
16470
+ exports2.deleteProjectAccess = deleteProjectAccess;
16471
+ exports2.deleteProjectAccesses = deleteProjectAccesses;
16472
+ exports2.deleteProjectAttachment = deleteProjectAttachment;
16473
+ exports2.deleteProjectAttachments = deleteProjectAttachments;
16991
16474
  exports2.deleteTeam = deleteTeam;
16475
+ exports2.deleteWorkspace = deleteWorkspace;
16992
16476
  exports2.dequeue = dequeue;
16993
16477
  exports2.deserialize = deserialize;
16994
16478
  exports2.deserializeField = deserializeField;
16995
16479
  exports2.discard = discard;
16480
+ exports2.documentAttachmentReducer = documentAttachmentReducer;
16481
+ exports2.documentAttachmentSlice = documentAttachmentSlice;
16996
16482
  exports2.documentSlice = documentSlice;
16997
16483
  exports2.documentsReducer = documentsReducer;
16998
16484
  exports2.downloadFile = downloadFile;
@@ -17014,17 +16500,20 @@ var __publicField = (obj, key, value) => {
17014
16500
  exports2.enqueue = enqueue;
17015
16501
  exports2.enqueueRequest = enqueueRequest;
17016
16502
  exports2.errorColor = errorColor;
17017
- exports2.favoriteForm = favoriteForm;
17018
16503
  exports2.fileReducer = fileReducer;
17019
16504
  exports2.fileSlice = fileSlice;
17020
16505
  exports2.fileToBlob = fileToBlob;
17021
16506
  exports2.flattenFields = flattenFields;
17022
16507
  exports2.flipCoordinates = flipCoordinates;
17023
16508
  exports2.formReducer = formReducer;
16509
+ exports2.formRevisionAttachmentReducer = formRevisionAttachmentReducer;
16510
+ exports2.formRevisionAttachmentSlice = formRevisionAttachmentSlice;
17024
16511
  exports2.formRevisionReducer = formRevisionReducer;
17025
16512
  exports2.formRevisionToSchema = formRevisionToSchema;
17026
16513
  exports2.formRevisionsSlice = formRevisionsSlice;
17027
16514
  exports2.formSlice = formSlice;
16515
+ exports2.formSubmissionAttachmentReducer = formSubmissionAttachmentReducer;
16516
+ exports2.formSubmissionAttachmentSlice = formSubmissionAttachmentSlice;
17028
16517
  exports2.formSubmissionReducer = formSubmissionReducer;
17029
16518
  exports2.formSubmissionSlice = formSubmissionSlice;
17030
16519
  exports2.forms = index;
@@ -17043,16 +16532,40 @@ var __publicField = (obj, key, value) => {
17043
16532
  exports2.hideAllCategories = hideAllCategories;
17044
16533
  exports2.hideCategory = hideCategory;
17045
16534
  exports2.initialFormValues = initialFormValues;
16535
+ exports2.initializeAssetAttachments = initializeAssetAttachments;
16536
+ exports2.initializeAssetTypeAttachments = initializeAssetTypeAttachments;
16537
+ exports2.initializeAssetTypes = initializeAssetTypes;
16538
+ exports2.initializeAssets = initializeAssets;
16539
+ exports2.initializeCategories = initializeCategories;
16540
+ exports2.initializeConversations = initializeConversations;
16541
+ exports2.initializeDocumentAttachments = initializeDocumentAttachments;
16542
+ exports2.initializeEmailDomains = initializeEmailDomains;
16543
+ exports2.initializeFormRevisionAttachments = initializeFormRevisionAttachments;
16544
+ exports2.initializeFormRevisions = initializeFormRevisions;
16545
+ exports2.initializeFormSubmissionAttachments = initializeFormSubmissionAttachments;
16546
+ exports2.initializeIssueAttachments = initializeIssueAttachments;
16547
+ exports2.initializeIssueTypes = initializeIssueTypes;
16548
+ exports2.initializeIssueUpdates = initializeIssueUpdates;
16549
+ exports2.initializeIssues = initializeIssues;
16550
+ exports2.initializeOrganizationAccesses = initializeOrganizationAccesses;
16551
+ exports2.initializeProjectAttachments = initializeProjectAttachments;
16552
+ exports2.initializeStages = initializeStages;
16553
+ exports2.initializeWorkspaces = initializeWorkspaces;
17046
16554
  exports2.isConditionMet = isConditionMet;
17047
16555
  exports2.isToday = isToday;
16556
+ exports2.issueAttachmentReducer = issueAttachmentReducer;
16557
+ exports2.issueAttachmentSlice = issueAttachmentSlice;
16558
+ exports2.issueCommentReducer = issueCommentReducer;
16559
+ exports2.issueCommentSlice = issueCommentSlice;
17048
16560
  exports2.issueReducer = issueReducer;
17049
16561
  exports2.issueSlice = issueSlice;
17050
16562
  exports2.issueToSearchResult = issueToSearchResult;
17051
16563
  exports2.issueTypeReducer = issueTypeReducer;
17052
16564
  exports2.issueTypeSlice = issueTypeSlice;
16565
+ exports2.issueUpdateReducer = issueUpdateReducer;
16566
+ exports2.issueUpdateSlice = issueUpdateSlice;
17053
16567
  exports2.licenseReducer = licenseReducer;
17054
16568
  exports2.licenseSlice = licenseSlice;
17055
- exports2.linkStageToForm = linkStageToForm;
17056
16569
  exports2.literalToCoordinates = literalToCoordinates;
17057
16570
  exports2.logOnlyOnce = logOnlyOnce;
17058
16571
  exports2.makeClient = makeClient;
@@ -17079,54 +16592,27 @@ var __publicField = (obj, key, value) => {
17079
16592
  exports2.overmapEnhancer = overmapEnhancer;
17080
16593
  exports2.overmapReducer = overmapReducer;
17081
16594
  exports2.overmapReducers = overmapReducers;
17082
- exports2.patchCategory = patchCategory;
17083
16595
  exports2.performRequest = performRequest;
17084
16596
  exports2.primaryColor = primaryColor;
17085
16597
  exports2.projectAccessReducer = projectAccessReducer;
17086
16598
  exports2.projectAccessSlice = projectAccessSlice;
16599
+ exports2.projectAttachmentReducer = projectAttachmentReducer;
16600
+ exports2.projectAttachmentSlice = projectAttachmentSlice;
17087
16601
  exports2.projectFileReducer = projectFileReducer;
17088
16602
  exports2.projectFileSlice = projectFileSlice;
17089
16603
  exports2.projectReducer = projectReducer;
17090
16604
  exports2.projectSlice = projectSlice;
17091
16605
  exports2.rehydratedReducer = rehydratedReducer;
17092
16606
  exports2.rehydratedSlice = rehydratedSlice;
17093
- exports2.removeAllAssetsOfType = removeAllAssetsOfType;
17094
- exports2.removeAsset = removeAsset;
17095
- exports2.removeAssetAttachment = removeAssetAttachment;
17096
- exports2.removeAssetAttachments = removeAssetAttachments;
17097
- exports2.removeAssetTypeAttachment = removeAssetTypeAttachment;
17098
- exports2.removeAssetTypeAttachments = removeAssetTypeAttachments;
17099
- exports2.removeAssets = removeAssets;
17100
- exports2.removeAttachmentsOfIssue = removeAttachmentsOfIssue;
17101
- exports2.removeCategory = removeCategory;
17102
- exports2.removeColor = removeColor;
17103
- exports2.removeDocumentAttachment = removeDocumentAttachment;
17104
- exports2.removeDocumentAttachments = removeDocumentAttachments;
17105
16607
  exports2.removeDocuments = removeDocuments;
17106
- exports2.removeEmailDomain = removeEmailDomain;
17107
16608
  exports2.removeFavouriteProjectId = removeFavouriteProjectId;
17108
- exports2.removeIssue = removeIssue;
17109
- exports2.removeIssueAttachment = removeIssueAttachment;
17110
- exports2.removeIssueAttachments = removeIssueAttachments;
17111
- exports2.removeIssueComment = removeIssueComment;
17112
- exports2.removeIssueComments = removeIssueComments;
17113
16609
  exports2.removeIssueType = removeIssueType;
17114
- exports2.removeIssueUpdate = removeIssueUpdate;
17115
- exports2.removeIssueUpdates = removeIssueUpdates;
17116
- exports2.removeIssues = removeIssues;
17117
- exports2.removeOrganizationAccess = removeOrganizationAccess;
17118
- exports2.removeProjectAccess = removeProjectAccess;
17119
- exports2.removeProjectAccessesOfProject = removeProjectAccessesOfProject;
17120
- exports2.removeProjectAttachment = removeProjectAttachment;
17121
- exports2.removeProjectAttachments = removeProjectAttachments;
17122
16610
  exports2.removeProjectFile = removeProjectFile;
17123
16611
  exports2.removeProjectFilesOfProject = removeProjectFilesOfProject;
17124
16612
  exports2.removeRecentIssue = removeRecentIssue;
17125
16613
  exports2.removeStageCompletions = removeStageCompletions;
17126
16614
  exports2.removeStages = removeStages;
17127
16615
  exports2.removeUser = removeUser;
17128
- exports2.removeWorkspace = removeWorkspace;
17129
- exports2.replaceCategory = replaceCategory;
17130
16616
  exports2.resetProjectFileObjectUrls = resetProjectFileObjectUrls;
17131
16617
  exports2.resetRecentIssues = resetRecentIssues;
17132
16618
  exports2.resetStore = resetStore;
@@ -17135,7 +16621,6 @@ var __publicField = (obj, key, value) => {
17135
16621
  exports2.saveActiveProjectFileBounds = saveActiveProjectFileBounds;
17136
16622
  exports2.searchIssues = searchIssues;
17137
16623
  exports2.selectAccessToken = selectAccessToken;
17138
- exports2.selectActiveIssueId = selectActiveIssueId;
17139
16624
  exports2.selectActiveLicense = selectActiveLicense;
17140
16625
  exports2.selectActiveOrganization = selectActiveOrganization;
17141
16626
  exports2.selectActiveOrganizationAccess = selectActiveOrganizationAccess;
@@ -17149,7 +16634,6 @@ var __publicField = (obj, key, value) => {
17149
16634
  exports2.selectActiveStatusLicenses = selectActiveStatusLicenses;
17150
16635
  exports2.selectActiveWorkspace = selectActiveWorkspace;
17151
16636
  exports2.selectActiveWorkspaceId = selectActiveWorkspaceId;
17152
- exports2.selectAllAttachments = selectAllAttachments;
17153
16637
  exports2.selectAllDocumentAttachments = selectAllDocumentAttachments;
17154
16638
  exports2.selectAllProjectAttachments = selectAllProjectAttachments;
17155
16639
  exports2.selectAncestorIdsOfDocument = selectAncestorIdsOfDocument;
@@ -17185,11 +16669,10 @@ var __publicField = (obj, key, value) => {
17185
16669
  exports2.selectAttachmentsOfProjectByType = selectAttachmentsOfProjectByType;
17186
16670
  exports2.selectCategories = selectCategories;
17187
16671
  exports2.selectCategoriesOfWorkspace = selectCategoriesOfWorkspace;
17188
- exports2.selectCategory = selectCategory;
16672
+ exports2.selectCategoryById = selectCategoryById;
17189
16673
  exports2.selectCategoryMapping = selectCategoryMapping;
17190
16674
  exports2.selectCategoryVisibility = selectCategoryVisibility;
17191
16675
  exports2.selectCenterMapToProject = selectCenterMapToProject;
17192
- exports2.selectCommentMapping = selectCommentMapping;
17193
16676
  exports2.selectCommentsOfIssue = selectCommentsOfIssue;
17194
16677
  exports2.selectCompletedStageIdsForAsset = selectCompletedStageIdsForAsset;
17195
16678
  exports2.selectCompletedStages = selectCompletedStages;
@@ -17203,7 +16686,9 @@ var __publicField = (obj, key, value) => {
17203
16686
  exports2.selectDocumentAttachmentMapping = selectDocumentAttachmentMapping;
17204
16687
  exports2.selectDocuments = selectDocuments;
17205
16688
  exports2.selectDocumentsMapping = selectDocumentsMapping;
16689
+ exports2.selectEmailDomains = selectEmailDomains;
17206
16690
  exports2.selectEmailDomainsAsMapping = selectEmailDomainsAsMapping;
16691
+ exports2.selectEmailDomainsOfOrganization = selectEmailDomainsOfOrganization;
17207
16692
  exports2.selectEnableClustering = selectEnableClustering;
17208
16693
  exports2.selectEnableDuplicateIssues = selectEnableDuplicateIssues;
17209
16694
  exports2.selectEnablePlacementMode = selectEnablePlacementMode;
@@ -17212,7 +16697,6 @@ var __publicField = (obj, key, value) => {
17212
16697
  exports2.selectEnabledProjectFiles = selectEnabledProjectFiles;
17213
16698
  exports2.selectExpandedSections = selectExpandedSections;
17214
16699
  exports2.selectFavouriteProjects = selectFavouriteProjects;
17215
- exports2.selectFileAttachmentsOfIssue = selectFileAttachmentsOfIssue;
17216
16700
  exports2.selectFilteredForms = selectFilteredForms;
17217
16701
  exports2.selectForm = selectForm;
17218
16702
  exports2.selectFormMapping = selectFormMapping;
@@ -17244,6 +16728,7 @@ var __publicField = (obj, key, value) => {
17244
16728
  exports2.selectIssueAttachment = selectIssueAttachment;
17245
16729
  exports2.selectIssueAttachmentMapping = selectIssueAttachmentMapping;
17246
16730
  exports2.selectIssueAttachments = selectIssueAttachments;
16731
+ exports2.selectIssueCommentMapping = selectIssueCommentMapping;
17247
16732
  exports2.selectIssueCountOfCategory = selectIssueCountOfCategory;
17248
16733
  exports2.selectIssueMapping = selectIssueMapping;
17249
16734
  exports2.selectIssueType = selectIssueType;
@@ -17278,9 +16763,9 @@ var __publicField = (obj, key, value) => {
17278
16763
  exports2.selectOrganizationsMapping = selectOrganizationsMapping;
17279
16764
  exports2.selectOrganizationsWithAccess = selectOrganizationsWithAccess;
17280
16765
  exports2.selectPermittedWorkspaceIds = selectPermittedWorkspaceIds;
17281
- exports2.selectPhotoAttachmentsOfIssue = selectPhotoAttachmentsOfIssue;
17282
16766
  exports2.selectProjectAccess = selectProjectAccess;
17283
16767
  exports2.selectProjectAccessForUser = selectProjectAccessForUser;
16768
+ exports2.selectProjectAccessMapping = selectProjectAccessMapping;
17284
16769
  exports2.selectProjectAccessUserMapping = selectProjectAccessUserMapping;
17285
16770
  exports2.selectProjectAccesses = selectProjectAccesses;
17286
16771
  exports2.selectProjectAttachment = selectProjectAttachment;
@@ -17297,7 +16782,6 @@ var __publicField = (obj, key, value) => {
17297
16782
  exports2.selectRehydrated = selectRehydrated;
17298
16783
  exports2.selectRootDocuments = selectRootDocuments;
17299
16784
  exports2.selectShowTooltips = selectShowTooltips;
17300
- exports2.selectSortedEmailDomains = selectSortedEmailDomains;
17301
16785
  exports2.selectSortedFormSubmissionsOfForm = selectSortedFormSubmissionsOfForm;
17302
16786
  exports2.selectSortedOrganizationLicenses = selectSortedOrganizationLicenses;
17303
16787
  exports2.selectSortedOrganizationUsers = selectSortedOrganizationUsers;
@@ -17316,7 +16800,6 @@ var __publicField = (obj, key, value) => {
17316
16800
  exports2.selectTeamsOfOrganization = selectTeamsOfOrganization;
17317
16801
  exports2.selectTeamsOfUser = selectTeamsOfUser;
17318
16802
  exports2.selectUploadUrl = selectUploadUrl;
17319
- exports2.selectUsedColors = selectUsedColors;
17320
16803
  exports2.selectUser = selectUser;
17321
16804
  exports2.selectUserFormRevisionAttachmentsMapping = selectUserFormRevisionAttachmentsMapping;
17322
16805
  exports2.selectUsersAsMapping = selectUsersAsMapping;
@@ -17325,34 +16808,32 @@ var __publicField = (obj, key, value) => {
17325
16808
  exports2.selectWorkspace = selectWorkspace;
17326
16809
  exports2.selectWorkspaceMapping = selectWorkspaceMapping;
17327
16810
  exports2.selectWorkspaces = selectWorkspaces;
17328
- exports2.setActiveIssueId = setActiveIssueId;
17329
16811
  exports2.setActiveOrganizationId = setActiveOrganizationId;
17330
16812
  exports2.setActiveProjectFileId = setActiveProjectFileId;
17331
16813
  exports2.setActiveProjectId = setActiveProjectId;
17332
16814
  exports2.setActiveWorkspaceId = setActiveWorkspaceId;
17333
16815
  exports2.setAppearance = setAppearance;
16816
+ exports2.setAsset = setAsset;
17334
16817
  exports2.setAssetAttachment = setAssetAttachment;
17335
16818
  exports2.setAssetAttachments = setAssetAttachments;
17336
16819
  exports2.setAssetTypeAttachment = setAssetTypeAttachment;
17337
16820
  exports2.setAssetTypeAttachments = setAssetTypeAttachments;
17338
- exports2.setAssetTypes = setAssetTypes;
17339
16821
  exports2.setAssets = setAssets;
17340
- exports2.setCategories = setCategories;
17341
16822
  exports2.setCenterMapToProject = setCenterMapToProject;
17342
16823
  exports2.setConversation = setConversation;
17343
- exports2.setConversations = setConversations;
17344
16824
  exports2.setCurrentUser = setCurrentUser;
17345
16825
  exports2.setDocumentAttachment = setDocumentAttachment;
17346
16826
  exports2.setDocumentAttachments = setDocumentAttachments;
17347
16827
  exports2.setDocuments = setDocuments;
17348
- exports2.setEmailDomains = setEmailDomains;
17349
16828
  exports2.setEnableClustering = setEnableClustering;
17350
16829
  exports2.setEnableDuplicateIssues = setEnableDuplicateIssues;
17351
16830
  exports2.setEnablePlacementMode = setEnablePlacementMode;
16831
+ exports2.setForm = setForm;
17352
16832
  exports2.setFormRevision = setFormRevision;
16833
+ exports2.setFormRevisionAttachment = setFormRevisionAttachment;
17353
16834
  exports2.setFormRevisionAttachments = setFormRevisionAttachments;
17354
- exports2.setFormRevisions = setFormRevisions;
17355
16835
  exports2.setFormSubmission = setFormSubmission;
16836
+ exports2.setFormSubmissionAttachment = setFormSubmissionAttachment;
17356
16837
  exports2.setFormSubmissionAttachments = setFormSubmissionAttachments;
17357
16838
  exports2.setFormSubmissions = setFormSubmissions;
17358
16839
  exports2.setForms = setForms;
@@ -17364,13 +16845,10 @@ var __publicField = (obj, key, value) => {
17364
16845
  exports2.setIssueComment = setIssueComment;
17365
16846
  exports2.setIssueComments = setIssueComments;
17366
16847
  exports2.setIssueType = setIssueType;
17367
- exports2.setIssueTypes = setIssueTypes;
17368
- exports2.setIssueUpdates = setIssueUpdates;
17369
- exports2.setIssues = setIssues;
16848
+ exports2.setIssueUpdate = setIssueUpdate;
17370
16849
  exports2.setLicenses = setLicenses;
17371
16850
  exports2.setLoggedIn = setLoggedIn;
17372
16851
  exports2.setMapStyle = setMapStyle;
17373
- exports2.setOrganizationAccesses = setOrganizationAccesses;
17374
16852
  exports2.setOrganizations = setOrganizations;
17375
16853
  exports2.setProfilePicture = setProfilePicture;
17376
16854
  exports2.setProjectAccesses = setProjectAccesses;
@@ -17380,6 +16858,7 @@ var __publicField = (obj, key, value) => {
17380
16858
  exports2.setProjects = setProjects;
17381
16859
  exports2.setSectionExpanded = setSectionExpanded;
17382
16860
  exports2.setShowTooltips = setShowTooltips;
16861
+ exports2.setStage = setStage;
17383
16862
  exports2.setStageCompletions = setStageCompletions;
17384
16863
  exports2.setTeam = setTeam;
17385
16864
  exports2.setTeams = setTeams;
@@ -17402,10 +16881,8 @@ var __publicField = (obj, key, value) => {
17402
16881
  exports2.toOfflineIdRecord = toOfflineIdRecord;
17403
16882
  exports2.toggleAssetTypeVisibility = toggleAssetTypeVisibility;
17404
16883
  exports2.truncate = truncate;
17405
- exports2.unfavoriteForm = unfavoriteForm;
17406
16884
  exports2.unhideAllCategories = unhideAllCategories;
17407
16885
  exports2.unhideCategory = unhideCategory;
17408
- exports2.unlinkStageToForm = unlinkStageToForm;
17409
16886
  exports2.updateActiveOrganization = updateActiveOrganization;
17410
16887
  exports2.updateAsset = updateAsset;
17411
16888
  exports2.updateAssetAttachment = updateAssetAttachment;
@@ -17413,11 +16890,16 @@ var __publicField = (obj, key, value) => {
17413
16890
  exports2.updateAssetTypeAttachment = updateAssetTypeAttachment;
17414
16891
  exports2.updateAssetTypeAttachments = updateAssetTypeAttachments;
17415
16892
  exports2.updateAssets = updateAssets;
16893
+ exports2.updateCategory = updateCategory;
17416
16894
  exports2.updateConversation = updateConversation;
17417
16895
  exports2.updateDocumentAttachment = updateDocumentAttachment;
17418
16896
  exports2.updateDocumentAttachments = updateDocumentAttachments;
17419
16897
  exports2.updateDocuments = updateDocuments;
16898
+ exports2.updateForm = updateForm;
16899
+ exports2.updateFormRevisionAttachment = updateFormRevisionAttachment;
16900
+ exports2.updateFormRevisionAttachments = updateFormRevisionAttachments;
17420
16901
  exports2.updateFormSubmission = updateFormSubmission;
16902
+ exports2.updateFormSubmissionAttachment = updateFormSubmissionAttachment;
17421
16903
  exports2.updateFormSubmissionAttachments = updateFormSubmissionAttachments;
17422
16904
  exports2.updateFormSubmissions = updateFormSubmissions;
17423
16905
  exports2.updateIssue = updateIssue;
@@ -17430,8 +16912,10 @@ var __publicField = (obj, key, value) => {
17430
16912
  exports2.updateProjectAccess = updateProjectAccess;
17431
16913
  exports2.updateProjectAttachment = updateProjectAttachment;
17432
16914
  exports2.updateProjectAttachments = updateProjectAttachments;
16915
+ exports2.updateStage = updateStage;
17433
16916
  exports2.updateStages = updateStages;
17434
16917
  exports2.updateTeam = updateTeam;
16918
+ exports2.updateWorkspace = updateWorkspace;
17435
16919
  exports2.useAppDispatch = useAppDispatch;
17436
16920
  exports2.useAppSelector = useAppSelector;
17437
16921
  exports2.useFieldInput = useFieldInput;