@overmap-ai/core 1.0.63-form-submission-fix.3 → 1.0.63-form-submission-drafts.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.
@@ -379,15 +379,15 @@ const wrapMigration = (migrator) => (state) => {
379
379
  };
380
380
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
381
381
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
382
- const initialState$B = {
382
+ const initialState$C = {
383
383
  accessToken: "",
384
384
  refreshToken: "",
385
385
  isLoggedIn: false
386
386
  };
387
387
  const authSlice = createSlice({
388
388
  name: "auth",
389
- initialState: initialState$B,
390
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$B)),
389
+ initialState: initialState$C,
390
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$C)),
391
391
  reducers: {
392
392
  setTokens: (state, action) => {
393
393
  state.accessToken = action.payload.accessToken;
@@ -857,11 +857,11 @@ function createModelAdapter(computeModelId) {
857
857
  };
858
858
  }
859
859
  const categoryAdapter = createModelAdapter((category) => category.offline_id);
860
- const initialState$A = categoryAdapter.getInitialState({});
860
+ const initialState$B = categoryAdapter.getInitialState({});
861
861
  const categorySlice = createSlice({
862
862
  name: "categories",
863
- initialState: initialState$A,
864
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$A)),
863
+ initialState: initialState$B,
864
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$B)),
865
865
  reducers: {
866
866
  initializeCategories: categoryAdapter.initialize,
867
867
  addCategory: categoryAdapter.addOne,
@@ -891,11 +891,11 @@ const selectIssueCountOfCategory = (categoryId) => (state) => {
891
891
  };
892
892
  const categoryReducer = categorySlice.reducer;
893
893
  const assetTypeAdapter = createModelAdapter((assetType) => assetType.offline_id);
894
- const initialState$z = assetTypeAdapter.getInitialState({});
894
+ const initialState$A = assetTypeAdapter.getInitialState({});
895
895
  const assetTypeSlice = createSlice({
896
896
  name: "assetTypes",
897
- initialState: initialState$z,
898
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
897
+ initialState: initialState$A,
898
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$A)),
899
899
  reducers: {
900
900
  initializeAssetTypes: assetTypeAdapter.initialize,
901
901
  addAssetType: assetTypeAdapter.addOne,
@@ -940,11 +940,11 @@ const selectAssetTypesByName = restructureCreateSelectorWithArgs(
940
940
  );
941
941
  const assetTypeReducer = assetTypeSlice.reducer;
942
942
  const assetAdapter = createModelAdapter((asset) => asset.offline_id);
943
- const initialState$y = assetAdapter.getInitialState({});
943
+ const initialState$z = assetAdapter.getInitialState({});
944
944
  const assetSlice = createSlice({
945
945
  name: "assets",
946
- initialState: initialState$y,
947
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
946
+ initialState: initialState$z,
947
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
948
948
  reducers: {
949
949
  initializeAssets: (state, action) => {
950
950
  assetAdapter.initialize(state, action);
@@ -1047,11 +1047,11 @@ const selectAssetTypesFromIds = (assetTypeIds) => (state) => {
1047
1047
  };
1048
1048
  const assetReducer = assetSlice.reducer;
1049
1049
  const assetAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
1050
- const initialState$x = assetAttachmentAdapter.getInitialState({});
1050
+ const initialState$y = assetAttachmentAdapter.getInitialState({});
1051
1051
  const assetAttachmentSlice = createSlice({
1052
1052
  name: "assetAttachments",
1053
- initialState: initialState$x,
1054
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
1053
+ initialState: initialState$y,
1054
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
1055
1055
  reducers: {
1056
1056
  initializeAssetAttachments: assetAttachmentAdapter.initialize,
1057
1057
  addAssetAttachment: assetAttachmentAdapter.addOne,
@@ -1109,13 +1109,13 @@ const selectAttachmentsOfAssetByType = restructureCreateSelectorWithArgs(
1109
1109
  )
1110
1110
  );
1111
1111
  const assetAttachmentReducer = assetAttachmentSlice.reducer;
1112
- const initialState$w = {
1112
+ const initialState$x = {
1113
1113
  completionsByAssetId: {}
1114
1114
  };
1115
1115
  const assetStageCompletionSlice = createSlice({
1116
1116
  name: "assetStageCompletions",
1117
- initialState: initialState$w,
1118
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1117
+ initialState: initialState$x,
1118
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
1119
1119
  reducers: {
1120
1120
  addStageCompletion: (state, action) => {
1121
1121
  let stageToCompletionDateMapping = state.completionsByAssetId[action.payload.asset];
@@ -1167,11 +1167,11 @@ const selectCompletedStageIdsForAsset = restructureCreateSelectorWithArgs(
1167
1167
  );
1168
1168
  const assetStageCompletionReducer = assetStageCompletionSlice.reducer;
1169
1169
  const assetStageAdapter = createModelAdapter((assetStage) => assetStage.offline_id);
1170
- const initialState$v = assetStageAdapter.getInitialState({});
1170
+ const initialState$w = assetStageAdapter.getInitialState({});
1171
1171
  const assetStageSlice = createSlice({
1172
1172
  name: "assetStages",
1173
- initialState: initialState$v,
1174
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1173
+ initialState: initialState$w,
1174
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
1175
1175
  reducers: {
1176
1176
  initializeStages: assetStageAdapter.initialize,
1177
1177
  setStage: assetStageAdapter.setOne,
@@ -1252,11 +1252,11 @@ const assetStageReducer = assetStageSlice.reducer;
1252
1252
  const assetTypeAttachmentAdapter = createModelAdapter(
1253
1253
  (attachment) => attachment.offline_id
1254
1254
  );
1255
- const initialState$u = assetTypeAttachmentAdapter.getInitialState({});
1255
+ const initialState$v = assetTypeAttachmentAdapter.getInitialState({});
1256
1256
  const assetTypeAttachmentSlice = createSlice({
1257
1257
  name: "assetTypeAttachments",
1258
- initialState: initialState$u,
1259
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$u)),
1258
+ initialState: initialState$v,
1259
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
1260
1260
  reducers: {
1261
1261
  initializeAssetTypeAttachments: assetTypeAttachmentAdapter.initialize,
1262
1262
  addAssetTypeAttachment: assetTypeAttachmentAdapter.addOne,
@@ -1315,10 +1315,10 @@ const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
1315
1315
  );
1316
1316
  const assetTypeAttachmentReducer = assetTypeAttachmentSlice.reducer;
1317
1317
  const workspaceAdapter = createModelAdapter((workspace) => workspace.offline_id);
1318
- const initialState$t = workspaceAdapter.getInitialState({});
1318
+ const initialState$u = workspaceAdapter.getInitialState({});
1319
1319
  const workspaceSlice = createSlice({
1320
1320
  name: "workspace",
1321
- initialState: initialState$t,
1321
+ initialState: initialState$u,
1322
1322
  reducers: {
1323
1323
  initializeWorkspaces: workspaceAdapter.initialize,
1324
1324
  setWorkspaces: workspaceAdapter.setMany,
@@ -1350,14 +1350,14 @@ const selectPermittedWorkspaceIds = createSelector(
1350
1350
  const workspaceReducer = workspaceSlice.reducer;
1351
1351
  const maxRecentIssues = 10;
1352
1352
  const issueAdapter = createModelAdapter((issue) => issue.offline_id);
1353
- const initialState$s = issueAdapter.getInitialState({
1353
+ const initialState$t = issueAdapter.getInitialState({
1354
1354
  recentIssueIds: []
1355
1355
  });
1356
1356
  const issueSlice = createSlice({
1357
1357
  name: "issues",
1358
- initialState: initialState$s,
1358
+ initialState: initialState$t,
1359
1359
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1360
- Object.assign(state, initialState$s);
1360
+ Object.assign(state, initialState$t);
1361
1361
  }),
1362
1362
  reducers: {
1363
1363
  initializeIssues: issueAdapter.initialize,
@@ -1501,12 +1501,12 @@ const selectRecentIssuesAsSearchResults = createSelector(
1501
1501
  );
1502
1502
  const issueReducer = issueSlice.reducer;
1503
1503
  const issueTypeAdapter = createModelAdapter((issueType) => issueType.offline_id);
1504
- const initialState$r = issueTypeAdapter.getInitialState({});
1504
+ const initialState$s = issueTypeAdapter.getInitialState({});
1505
1505
  const issueTypeSlice = createSlice({
1506
1506
  name: "issueTypes",
1507
- initialState: initialState$r,
1507
+ initialState: initialState$s,
1508
1508
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
1509
- Object.assign(state, initialState$r);
1509
+ Object.assign(state, initialState$s);
1510
1510
  }),
1511
1511
  reducers: {
1512
1512
  initializeIssueTypes: issueTypeAdapter.initialize,
@@ -1555,15 +1555,15 @@ const selectIssuesOfIssueTypeCount = (issueTypeId) => (state) => {
1555
1555
  return ((_a2 = selectIssuesOfIssueType(issueTypeId)(state)) == null ? void 0 : _a2.length) ?? 0;
1556
1556
  };
1557
1557
  const issueTypeReducer = issueTypeSlice.reducer;
1558
- const initialState$q = {
1558
+ const initialState$r = {
1559
1559
  s3Urls: {}
1560
1560
  };
1561
1561
  const msPerHour = 1e3 * 60 * 60;
1562
1562
  const msPerWeek = msPerHour * 24 * 7;
1563
1563
  const fileSlice = createSlice({
1564
1564
  name: "file",
1565
- initialState: initialState$q,
1566
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1565
+ initialState: initialState$r,
1566
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1567
1567
  reducers: {
1568
1568
  setUploadUrl: (state, action) => {
1569
1569
  const { url, fields, sha1 } = action.payload;
@@ -1644,7 +1644,7 @@ var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
1644
1644
  LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
1645
1645
  return LicenseStatus2;
1646
1646
  })(LicenseStatus || {});
1647
- const initialState$p = {
1647
+ const initialState$q = {
1648
1648
  users: {},
1649
1649
  currentUser: {
1650
1650
  id: 0,
@@ -1655,8 +1655,8 @@ const initialState$p = {
1655
1655
  };
1656
1656
  const userSlice = createSlice({
1657
1657
  name: "users",
1658
- initialState: initialState$p,
1659
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1658
+ initialState: initialState$q,
1659
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1660
1660
  reducers: {
1661
1661
  setUsers: (state, action) => {
1662
1662
  const usersMapping = {};
@@ -1721,11 +1721,11 @@ const userReducer = userSlice.reducer;
1721
1721
  const organizationAccessAdapter = createModelAdapter(
1722
1722
  (organizationAccess) => organizationAccess.offline_id
1723
1723
  );
1724
- const initialState$o = organizationAccessAdapter.getInitialState({});
1724
+ const initialState$p = organizationAccessAdapter.getInitialState({});
1725
1725
  const organizationAccessSlice = createSlice({
1726
1726
  name: "organizationAccess",
1727
- initialState: initialState$o,
1728
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1727
+ initialState: initialState$p,
1728
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1729
1729
  reducers: {
1730
1730
  initializeOrganizationAccesses: organizationAccessAdapter.initialize,
1731
1731
  updateOrganizationAccess: organizationAccessAdapter.updateOne,
@@ -1762,11 +1762,11 @@ const selectOrganizationAccessUserMapping = (state) => {
1762
1762
  };
1763
1763
  const organizationAccessReducer = organizationAccessSlice.reducer;
1764
1764
  const licenseAdapter = createModelAdapter((license) => license.offline_id);
1765
- const initialState$n = licenseAdapter.getInitialState({});
1765
+ const initialState$o = licenseAdapter.getInitialState({});
1766
1766
  const licenseSlice = createSlice({
1767
1767
  name: "license",
1768
- initialState: initialState$n,
1769
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1768
+ initialState: initialState$o,
1769
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1770
1770
  reducers: {
1771
1771
  initializeLicences: licenseAdapter.initialize,
1772
1772
  addLicenses: licenseAdapter.addMany,
@@ -1792,11 +1792,11 @@ const selectLicensesForProjectsMapping = createSelector(
1792
1792
  );
1793
1793
  const licenseReducer = licenseSlice.reducer;
1794
1794
  const projectAccessAdapter = createModelAdapter((projectAccess) => projectAccess.offline_id);
1795
- const initialState$m = projectAccessAdapter.getInitialState({});
1795
+ const initialState$n = projectAccessAdapter.getInitialState({});
1796
1796
  const projectAccessSlice = createSlice({
1797
1797
  name: "projectAccess",
1798
- initialState: initialState$m,
1799
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1798
+ initialState: initialState$n,
1799
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1800
1800
  reducers: {
1801
1801
  initializeProjectAccesses: projectAccessAdapter.initialize,
1802
1802
  updateProjectAccess: projectAccessAdapter.updateOne,
@@ -1842,14 +1842,14 @@ const selectProjectAccessUserMapping = (state) => {
1842
1842
  return projectAccesses;
1843
1843
  };
1844
1844
  const projectAccessReducer = projectAccessSlice.reducer;
1845
- const initialState$l = {
1845
+ const initialState$m = {
1846
1846
  projects: {},
1847
1847
  activeProjectId: null
1848
1848
  };
1849
1849
  const projectSlice = createSlice({
1850
1850
  name: "projects",
1851
- initialState: initialState$l,
1852
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1851
+ initialState: initialState$m,
1852
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1853
1853
  reducers: {
1854
1854
  setProjects: (state, action) => {
1855
1855
  const projectsMap = {};
@@ -1963,13 +1963,13 @@ const selectSortedProjectUsers = createSelector(
1963
1963
  });
1964
1964
  }
1965
1965
  );
1966
- const initialState$k = {
1966
+ const initialState$l = {
1967
1967
  organizations: {}
1968
1968
  };
1969
1969
  const organizationSlice = createSlice({
1970
1970
  name: "organizations",
1971
- initialState: initialState$k,
1972
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1971
+ initialState: initialState$l,
1972
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1973
1973
  reducers: {
1974
1974
  setOrganizations: (state, action) => {
1975
1975
  for (const org of action.payload) {
@@ -2052,14 +2052,14 @@ const createOfflineAction = (request2, baseUrl, serviceName) => {
2052
2052
  }
2053
2053
  };
2054
2054
  };
2055
- const initialState$j = {
2055
+ const initialState$k = {
2056
2056
  deletedRequests: [],
2057
2057
  latestRetryTime: 0
2058
2058
  };
2059
2059
  const outboxSlice = createSlice({
2060
2060
  name: "outbox",
2061
- initialState: initialState$j,
2062
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
2061
+ initialState: initialState$k,
2062
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
2063
2063
  reducers: {
2064
2064
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
2065
2065
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -2091,15 +2091,15 @@ const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
2091
2091
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
2092
2092
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
2093
2093
  const outboxReducer = outboxSlice.reducer;
2094
- const initialState$i = {
2094
+ const initialState$j = {
2095
2095
  projectFiles: {},
2096
2096
  activeProjectFileId: null,
2097
2097
  isImportingProjectFile: false
2098
2098
  };
2099
2099
  const projectFileSlice = createSlice({
2100
2100
  name: "projectFiles",
2101
- initialState: initialState$i,
2102
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2101
+ initialState: initialState$j,
2102
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
2103
2103
  reducers: {
2104
2104
  addOrReplaceProjectFiles: (state, action) => {
2105
2105
  for (let fileObj of action.payload) {
@@ -2184,11 +2184,11 @@ const selectProjectFileById = (id) => (state) => {
2184
2184
  };
2185
2185
  const projectFileReducer = projectFileSlice.reducer;
2186
2186
  const projectAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2187
- const initialState$h = projectAttachmentAdapter.getInitialState({});
2187
+ const initialState$i = projectAttachmentAdapter.getInitialState({});
2188
2188
  const projectAttachmentSlice = createSlice({
2189
2189
  name: "projectAttachments",
2190
- initialState: initialState$h,
2191
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2190
+ initialState: initialState$i,
2191
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2192
2192
  reducers: {
2193
2193
  initializeProjectAttachments: projectAttachmentAdapter.initialize,
2194
2194
  addProjectAttachment: projectAttachmentAdapter.addOne,
@@ -2246,12 +2246,12 @@ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
2246
2246
  )
2247
2247
  );
2248
2248
  const projectAttachmentReducer = projectAttachmentSlice.reducer;
2249
- const initialState$g = {
2249
+ const initialState$h = {
2250
2250
  isRehydrated: false
2251
2251
  };
2252
2252
  const rehydratedSlice = createSlice({
2253
2253
  name: "rehydrated",
2254
- initialState: initialState$g,
2254
+ initialState: initialState$h,
2255
2255
  // The `reducers` field lets us define reducers and generate associated actions
2256
2256
  reducers: {
2257
2257
  setRehydrated: (state, action) => {
@@ -2262,13 +2262,13 @@ const rehydratedSlice = createSlice({
2262
2262
  const { setRehydrated } = rehydratedSlice.actions;
2263
2263
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
2264
2264
  const rehydratedReducer = rehydratedSlice.reducer;
2265
- const initialState$f = {
2265
+ const initialState$g = {
2266
2266
  isFetchingInitialData: false
2267
2267
  };
2268
2268
  const settingSlice = createSlice({
2269
2269
  name: "settings",
2270
- initialState: initialState$f,
2271
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2270
+ initialState: initialState$g,
2271
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2272
2272
  reducers: {
2273
2273
  setIsFetchingInitialData: (state, action) => {
2274
2274
  state.isFetchingInitialData = action.payload;
@@ -2292,11 +2292,11 @@ const formRevisionSortFn = (formRevisionA, formRevisionB) => {
2292
2292
  }
2293
2293
  };
2294
2294
  const formRevisionAdapter = createModelAdapter((revision) => revision.offline_id);
2295
- const initialState$e = formRevisionAdapter.getInitialState({});
2295
+ const initialState$f = formRevisionAdapter.getInitialState({});
2296
2296
  const formRevisionsSlice = createSlice({
2297
2297
  name: "formRevisions",
2298
- initialState: initialState$e,
2299
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2298
+ initialState: initialState$f,
2299
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2300
2300
  reducers: {
2301
2301
  initializeFormRevisions: formRevisionAdapter.initialize,
2302
2302
  setFormRevision: formRevisionAdapter.setOne,
@@ -2396,11 +2396,11 @@ const selectLatestFormRevisionByForm = createSelector([selectFormRevisionMapping
2396
2396
  });
2397
2397
  const formRevisionReducer = formRevisionsSlice.reducer;
2398
2398
  const formAdapter = createModelAdapter((form) => form.offline_id);
2399
- const initialState$d = formAdapter.getInitialState({});
2399
+ const initialState$e = formAdapter.getInitialState({});
2400
2400
  const formSlice = createSlice({
2401
2401
  name: "forms",
2402
- initialState: initialState$d,
2403
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2402
+ initialState: initialState$e,
2403
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2404
2404
  reducers: {
2405
2405
  initializeForms: formAdapter.initialize,
2406
2406
  setForm: formAdapter.setOne,
@@ -2480,11 +2480,11 @@ const selectGeneralFormCount = createSelector([selectFormMapping], (formsMapping
2480
2480
  });
2481
2481
  const formReducer = formSlice.reducer;
2482
2482
  const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
2483
- const initialState$c = submissionAdapter.getInitialState({});
2483
+ const initialState$d = submissionAdapter.getInitialState({});
2484
2484
  const formSubmissionSlice = createSlice({
2485
2485
  name: "formSubmissions",
2486
- initialState: initialState$c,
2487
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2486
+ initialState: initialState$d,
2487
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2488
2488
  reducers: {
2489
2489
  initializeFormSubmissions: submissionAdapter.initialize,
2490
2490
  setFormSubmission: submissionAdapter.setOne,
@@ -2594,8 +2594,10 @@ const selectAttachedFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
2594
2594
  ],
2595
2595
  (issues, forms, formRevisions, submissions, issueId) => {
2596
2596
  const issue = issues[issueId];
2597
- if (!issue || !issue.issue_type) {
2597
+ if (!issue)
2598
2598
  return [];
2599
+ if (!issue.issue_type) {
2600
+ return Object.values(submissions).filter((submission) => submission.issue === issueId);
2599
2601
  }
2600
2602
  const issueTypeForms = new Set(
2601
2603
  Object.keys(forms).filter((formId) => forms[formId].issue_type === issue.issue_type)
@@ -2650,8 +2652,10 @@ const selectAttachedFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
2650
2652
  ],
2651
2653
  (assets, forms, formRevisions, submissions, assetId) => {
2652
2654
  const asset = assets[assetId];
2653
- if (!asset || !asset.asset_type) {
2655
+ if (!asset)
2654
2656
  return [];
2657
+ if (!asset.asset_type) {
2658
+ return Object.values(submissions).filter((submission) => submission.asset === assetId);
2655
2659
  }
2656
2660
  const issueTypeForms = new Set(
2657
2661
  Object.keys(forms).filter((formId) => forms[formId].asset_type === asset.asset_type)
@@ -2688,11 +2692,11 @@ const formSubmissionReducer = formSubmissionSlice.reducer;
2688
2692
  const formSubmissionAttachmentAdapter = createModelAdapter(
2689
2693
  (attachment) => attachment.offline_id
2690
2694
  );
2691
- const initialState$b = formSubmissionAttachmentAdapter.getInitialState({});
2695
+ const initialState$c = formSubmissionAttachmentAdapter.getInitialState({});
2692
2696
  const formSubmissionAttachmentSlice = createSlice({
2693
2697
  name: "formSubmissionAttachments",
2694
- initialState: initialState$b,
2695
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2698
+ initialState: initialState$c,
2699
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2696
2700
  reducers: {
2697
2701
  initializeFormSubmissionAttachments: formSubmissionAttachmentAdapter.initialize,
2698
2702
  addFormSubmissionAttachment: formSubmissionAttachmentAdapter.addOne,
@@ -2719,6 +2723,15 @@ const {
2719
2723
  const selectFormSubmissionAttachmentsMapping = (state) => {
2720
2724
  return state.formSubmissionAttachmentReducer.instances;
2721
2725
  };
2726
+ const selectFormSubmissionAttachemntsByIds = restructureCreateSelectorWithArgs(
2727
+ createSelector(
2728
+ [selectFormSubmissionAttachmentsMapping, (_, attachmentIds) => attachmentIds],
2729
+ (mapping, attachmentIds) => {
2730
+ const attachmentIdsSet = new Set(attachmentIds);
2731
+ return Object.values(mapping).filter((attachment) => attachmentIdsSet.has(attachment.offline_id));
2732
+ }
2733
+ )
2734
+ );
2722
2735
  const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
2723
2736
  createSelector(
2724
2737
  [selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
@@ -2731,11 +2744,11 @@ const formSubmissionAttachmentReducer = formSubmissionAttachmentSlice.reducer;
2731
2744
  const formRevisionAttachmentAdapter = createModelAdapter(
2732
2745
  (attachment) => attachment.offline_id
2733
2746
  );
2734
- const initialState$a = formRevisionAttachmentAdapter.getInitialState({});
2747
+ const initialState$b = formRevisionAttachmentAdapter.getInitialState({});
2735
2748
  const formRevisionAttachmentSlice = createSlice({
2736
2749
  name: "formRevisionAttachments",
2737
- initialState: initialState$a,
2738
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2750
+ initialState: initialState$b,
2751
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2739
2752
  reducers: {
2740
2753
  initializeFormRevisionAttachments: formRevisionAttachmentAdapter.initialize,
2741
2754
  addFormRevisionAttachment: formRevisionAttachmentAdapter.addOne,
@@ -2772,10 +2785,10 @@ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
2772
2785
  );
2773
2786
  const formRevisionAttachmentReducer = formRevisionAttachmentSlice.reducer;
2774
2787
  const emailDomainAdapter = createModelAdapter((emailDomain) => emailDomain.offline_id);
2775
- const initialState$9 = emailDomainAdapter.getInitialState({});
2788
+ const initialState$a = emailDomainAdapter.getInitialState({});
2776
2789
  const emailDomainsSlice = createSlice({
2777
2790
  name: "emailDomains",
2778
- initialState: initialState$9,
2791
+ initialState: initialState$a,
2779
2792
  reducers: {
2780
2793
  initializeEmailDomains: emailDomainAdapter.initialize,
2781
2794
  addEmailDomain: emailDomainAdapter.addOne,
@@ -2794,14 +2807,14 @@ const selectEmailDomainsOfOrganization = restructureCreateSelectorWithArgs(
2794
2807
  )
2795
2808
  );
2796
2809
  const emailDomainsReducer = emailDomainsSlice.reducer;
2797
- const initialState$8 = {
2810
+ const initialState$9 = {
2798
2811
  documents: {}
2799
2812
  };
2800
2813
  const documentSlice = createSlice({
2801
2814
  name: "documents",
2802
- initialState: initialState$8,
2815
+ initialState: initialState$9,
2803
2816
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2804
- Object.assign(state, initialState$8);
2817
+ Object.assign(state, initialState$9);
2805
2818
  }),
2806
2819
  reducers: {
2807
2820
  setDocuments: (state, action) => {
@@ -2976,11 +2989,11 @@ const selectRootDocuments = createSelector(
2976
2989
  );
2977
2990
  const documentsReducer = documentSlice.reducer;
2978
2991
  const documentAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2979
- const initialState$7 = documentAttachmentAdapter.getInitialState({});
2992
+ const initialState$8 = documentAttachmentAdapter.getInitialState({});
2980
2993
  const documentAttachmentSlice = createSlice({
2981
2994
  name: "documentAttachments",
2982
- initialState: initialState$7,
2983
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
2995
+ initialState: initialState$8,
2996
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
2984
2997
  reducers: {
2985
2998
  initializeDocumentAttachments: documentAttachmentAdapter.initialize,
2986
2999
  addDocumentAttachment: documentAttachmentAdapter.addOne,
@@ -3039,11 +3052,11 @@ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
3039
3052
  );
3040
3053
  const documentAttachmentReducer = documentAttachmentSlice.reducer;
3041
3054
  const teamAdapter = createModelAdapter((team) => team.offline_id);
3042
- const initialState$6 = teamAdapter.getInitialState({});
3055
+ const initialState$7 = teamAdapter.getInitialState({});
3043
3056
  const teamSlice = createSlice({
3044
3057
  name: "teams",
3045
- initialState: initialState$6,
3046
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3058
+ initialState: initialState$7,
3059
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
3047
3060
  reducers: {
3048
3061
  setTeam: teamAdapter.setOne,
3049
3062
  initializeTeams: teamAdapter.initialize,
@@ -3077,11 +3090,11 @@ const teamReducer = teamSlice.reducer;
3077
3090
  const agentUserConversationAdapter = createModelAdapter(
3078
3091
  (conversation) => conversation.offline_id
3079
3092
  );
3080
- const initialState$5 = agentUserConversationAdapter.getInitialState({});
3093
+ const initialState$6 = agentUserConversationAdapter.getInitialState({});
3081
3094
  const agentsSlice = createSlice({
3082
3095
  name: "agents",
3083
- initialState: initialState$5,
3084
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3096
+ initialState: initialState$6,
3097
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3085
3098
  reducers: {
3086
3099
  initializeConversations: agentUserConversationAdapter.initialize,
3087
3100
  addConversation: agentUserConversationAdapter.addOne,
@@ -3103,11 +3116,11 @@ const selectConversation = restructureCreateSelectorWithArgs(
3103
3116
  );
3104
3117
  const agentsReducer = agentsSlice.reducer;
3105
3118
  const issueCommentAdapter = createModelAdapter((comment) => comment.offline_id);
3106
- const initialState$4 = issueCommentAdapter.getInitialState({});
3119
+ const initialState$5 = issueCommentAdapter.getInitialState({});
3107
3120
  const issueCommentSlice = createSlice({
3108
3121
  name: "issueComments",
3109
- initialState: initialState$4,
3110
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3122
+ initialState: initialState$5,
3123
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3111
3124
  reducers: {
3112
3125
  addIssueComment: issueCommentAdapter.addOne,
3113
3126
  addIssueComments: issueCommentAdapter.addMany,
@@ -3136,11 +3149,11 @@ const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
3136
3149
  );
3137
3150
  const issueCommentReducer = issueCommentSlice.reducer;
3138
3151
  const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
3139
- const initialState$3 = issueUpdateAdapter.getInitialState({});
3152
+ const initialState$4 = issueUpdateAdapter.getInitialState({});
3140
3153
  const issueUpdateSlice = createSlice({
3141
3154
  name: "issueUpdates",
3142
- initialState: initialState$3,
3143
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3155
+ initialState: initialState$4,
3156
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3144
3157
  reducers: {
3145
3158
  initializeIssueUpdates: issueUpdateAdapter.setMany,
3146
3159
  setIssueUpdate: issueUpdateAdapter.setOne,
@@ -3169,11 +3182,11 @@ const selectIssueUpdatesOfIssue = restructureCreateSelectorWithArgs(
3169
3182
  );
3170
3183
  const issueUpdateReducer = issueUpdateSlice.reducer;
3171
3184
  const issueAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
3172
- const initialState$2 = issueAttachmentAdapter.getInitialState({});
3185
+ const initialState$3 = issueAttachmentAdapter.getInitialState({});
3173
3186
  const issueAttachmentSlice = createSlice({
3174
3187
  name: "issueAttachments",
3175
- initialState: initialState$2,
3176
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$2)),
3188
+ initialState: initialState$3,
3189
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3177
3190
  reducers: {
3178
3191
  initializeIssueAttachments: issueAttachmentAdapter.initialize,
3179
3192
  addIssueAttachment: issueAttachmentAdapter.addOne,
@@ -3231,23 +3244,23 @@ const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
3231
3244
  )
3232
3245
  );
3233
3246
  const issueAttachmentReducer = issueAttachmentSlice.reducer;
3234
- const initialState$1 = {
3247
+ const initialState$2 = {
3235
3248
  version: 0
3236
3249
  };
3237
3250
  const versioningSlice = createSlice({
3238
3251
  name: "versioning",
3239
- initialState: initialState$1,
3252
+ initialState: initialState$2,
3240
3253
  reducers: {}
3241
3254
  });
3242
3255
  const versioningReducer = versioningSlice.reducer;
3243
3256
  const geoImageAdapter = createModelAdapter((model) => model.offline_id);
3244
- const initialState = geoImageAdapter.getInitialState({});
3257
+ const initialState$1 = geoImageAdapter.getInitialState({});
3245
3258
  const geoImageSlice = createSlice({
3246
3259
  name: "geoImages",
3247
- initialState,
3260
+ initialState: initialState$1,
3248
3261
  extraReducers: (builder) => {
3249
3262
  builder.addCase("RESET", (state) => {
3250
- Object.assign(state, initialState);
3263
+ Object.assign(state, initialState$1);
3251
3264
  });
3252
3265
  },
3253
3266
  reducers: {
@@ -3284,6 +3297,64 @@ const selectGeoImagesOfProject = restructureCreateSelectorWithArgs(
3284
3297
  })
3285
3298
  );
3286
3299
  const geoImageReducer = geoImageSlice.reducer;
3300
+ const issueAssociationAdapter = createModelAdapter((assoc) => assoc.offline_id);
3301
+ const initialState = issueAssociationAdapter.getInitialState({});
3302
+ const issueAssociationSlice = createSlice({
3303
+ name: "issueAssociations",
3304
+ initialState,
3305
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState)),
3306
+ reducers: {
3307
+ initializeIssueAssociations: issueAssociationAdapter.initialize,
3308
+ addIssueAssociation: issueAssociationAdapter.addOne,
3309
+ addIssueAssociations: issueAssociationAdapter.addMany,
3310
+ setIssueAssociation: issueAssociationAdapter.setOne,
3311
+ setIssueAssociations: issueAssociationAdapter.setMany,
3312
+ updateIssueAssociation: issueAssociationAdapter.updateOne,
3313
+ updateIssueAssociations: issueAssociationAdapter.updateMany,
3314
+ deleteIssueAssociation: issueAssociationAdapter.deleteOne,
3315
+ deleteIssueAssociations: issueAssociationAdapter.deleteMany
3316
+ }
3317
+ });
3318
+ const {
3319
+ initializeIssueAssociations,
3320
+ setIssueAssociations,
3321
+ setIssueAssociation,
3322
+ updateIssueAssociation,
3323
+ updateIssueAssociations,
3324
+ addIssueAssociation,
3325
+ addIssueAssociations,
3326
+ deleteIssueAssociation,
3327
+ deleteIssueAssociations
3328
+ } = issueAssociationSlice.actions;
3329
+ const selectIssueAssociationMapping = (state) => state.issueAssociationReducer.instances;
3330
+ const selectIssueAssociationById = (id) => (state) => {
3331
+ return state.issueAssociationReducer.instances[id];
3332
+ };
3333
+ const selectIssueAssociationsToIssue = restructureCreateSelectorWithArgs(
3334
+ createSelector(
3335
+ [selectIssueAssociationMapping, (_state, issueId) => issueId],
3336
+ (associationMapping, issueId) => {
3337
+ return Object.values(associationMapping).filter((assoc) => assoc.associated_issue === issueId);
3338
+ }
3339
+ )
3340
+ );
3341
+ const selectIssueAssociationsOfIssue = restructureCreateSelectorWithArgs(
3342
+ createSelector(
3343
+ [selectIssueAssociationMapping, (_state, issueId) => issueId],
3344
+ (associationMapping, issueId) => {
3345
+ return Object.values(associationMapping).filter((assoc) => assoc.issue === issueId);
3346
+ }
3347
+ )
3348
+ );
3349
+ const selectIssueAssociationsOfAsset = restructureCreateSelectorWithArgs(
3350
+ createSelector(
3351
+ [selectIssueAssociationMapping, (_state, assetId) => assetId],
3352
+ (associationMapping, assetId) => {
3353
+ return Object.values(associationMapping).filter((assoc) => assoc.asset === assetId);
3354
+ }
3355
+ )
3356
+ );
3357
+ const issueAssociationReducer = issueAssociationSlice.reducer;
3287
3358
  const fullAssetMarkerSize = 45;
3288
3359
  const DEFAULT_ISSUE_STATUS = IssueStatus.BACKLOG;
3289
3360
  const DEFAULT_ISSUE_PRIORITY = IssuePriority.MEDIUM;
@@ -3356,7 +3427,8 @@ const overmapReducers = {
3356
3427
  agentsReducer,
3357
3428
  issueCommentReducer,
3358
3429
  issueUpdateReducer,
3359
- geoImageReducer
3430
+ geoImageReducer,
3431
+ issueAssociationReducer
3360
3432
  };
3361
3433
  const overmapReducer = combineReducers(overmapReducers);
3362
3434
  const resetStore = "RESET";
@@ -4147,11 +4219,13 @@ class AssetService extends BaseApiService {
4147
4219
  }
4148
4220
  async remove(assetId) {
4149
4221
  const { store } = this.client;
4150
- const assetToBeDeleted = selectAsset(assetId)(store.getState());
4222
+ const state = store.getState();
4223
+ const assetToBeDeleted = selectAsset(assetId)(state);
4151
4224
  if (!assetToBeDeleted)
4152
4225
  throw new Error(`No asset with id ${assetId} found in the store`);
4153
- const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(store.getState());
4154
- const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(assetId)(store.getState());
4226
+ const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(state);
4227
+ const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(assetId)(state);
4228
+ const issueAssociations = selectIssueAssociationsOfAsset(assetId)(state);
4155
4229
  this.dispatch(deleteAsset(assetId));
4156
4230
  if (attachmentsOfAssets.length > 0) {
4157
4231
  const attachmentsOfAssetIds = attachmentsOfAssets.map(({ offline_id }) => offline_id);
@@ -4161,6 +4235,10 @@ class AssetService extends BaseApiService {
4161
4235
  const formSubmissionsOfAssetIds = formSubmissionsOfAssets.map(({ offline_id }) => offline_id);
4162
4236
  this.dispatch(deleteFormSubmissions(formSubmissionsOfAssetIds));
4163
4237
  }
4238
+ if (issueAssociations.length > 0) {
4239
+ const issueAssociationsIds = issueAssociations.map(({ offline_id }) => offline_id);
4240
+ this.dispatch(deleteIssueAssociations(issueAssociationsIds));
4241
+ }
4164
4242
  return this.enqueueRequest({
4165
4243
  description: "Delete asset",
4166
4244
  method: HttpMethod.DELETE,
@@ -4171,6 +4249,7 @@ class AssetService extends BaseApiService {
4171
4249
  this.dispatch(addAsset(assetToBeDeleted));
4172
4250
  this.dispatch(addAssetAttachments(attachmentsOfAssets));
4173
4251
  this.dispatch(addFormSubmissions(formSubmissionsOfAssets));
4252
+ this.dispatch(addIssueAssociations(issueAssociations));
4174
4253
  throw err;
4175
4254
  });
4176
4255
  }
@@ -4618,7 +4697,7 @@ class BaseAttachmentService extends BaseUploadService {
4618
4697
  }
4619
4698
  // Note that currently the fetching of attachments for all models dependds on the active projectId. This may change in the future. And
4620
4699
  // so for some attachment model services, this method will have to be overridden.
4621
- async refreshStore(projectId) {
4700
+ async refreshStore(projectId, _organizationId) {
4622
4701
  const meta = AttachmentModelMeta[this.attachmentModel];
4623
4702
  const result = await this.enqueueRequest({
4624
4703
  description: `Get ${meta.name} attachments`,
@@ -5046,6 +5125,12 @@ class IssueService extends BaseApiService {
5046
5125
  const attachmentsOfIssue = selectAttachmentsOfIssue(id)(state);
5047
5126
  const updatesOfIssue = selectIssueUpdatesOfIssue(id)(state);
5048
5127
  const formSubmissionsOfIssue = selectFormSubmissionsOfIssue(id)(state);
5128
+ const issueAssociationsRecord = {};
5129
+ for (const issueAssociation of selectIssueAssociationsToIssue(id)(state))
5130
+ issueAssociationsRecord[issueAssociation.offline_id] = issueAssociation;
5131
+ for (const issueAssociation of selectIssueAssociationsOfIssue(id)(state))
5132
+ issueAssociationsRecord[issueAssociation.offline_id] = issueAssociation;
5133
+ const issueAssociations = Object.values(issueAssociationsRecord);
5049
5134
  this.dispatch(deleteIssue(id));
5050
5135
  this.dispatch(addActiveProjectIssuesCount(-1));
5051
5136
  if (attachmentsOfIssue.length > 0)
@@ -5054,6 +5139,8 @@ class IssueService extends BaseApiService {
5054
5139
  this.dispatch(deleteIssueUpdates(updatesOfIssue.map(({ offline_id }) => offline_id)));
5055
5140
  if (formSubmissionsOfIssue.length > 0)
5056
5141
  this.dispatch(deleteFormSubmissions(formSubmissionsOfIssue.map(({ offline_id }) => offline_id)));
5142
+ if (issueAssociations.length > 0)
5143
+ this.dispatch(deleteIssueAssociations(issueAssociations.map(({ offline_id }) => offline_id)));
5057
5144
  try {
5058
5145
  return await this.enqueueRequest({
5059
5146
  description: "Delete issue",
@@ -5068,6 +5155,7 @@ class IssueService extends BaseApiService {
5068
5155
  this.dispatch(addIssueUpdates(updatesOfIssue));
5069
5156
  this.dispatch(addActiveProjectIssuesCount(1));
5070
5157
  this.dispatch(addFormSubmissions(formSubmissionsOfIssue));
5158
+ this.dispatch(addIssueAssociations(issueAssociations));
5071
5159
  throw e;
5072
5160
  }
5073
5161
  }
@@ -5111,7 +5199,7 @@ class IssueTypeService extends BaseApiService {
5111
5199
  offline_id: offlineIssueType.offline_id,
5112
5200
  submitted_at: offlineIssueType.submitted_at,
5113
5201
  icon: offlineIssueType.icon,
5114
- icon_color: offlineIssueType.icon_color,
5202
+ icon_color: offlineIssueType.color,
5115
5203
  name: offlineIssueType.name,
5116
5204
  description: offlineIssueType.description
5117
5205
  },
@@ -5922,6 +6010,25 @@ class FormSubmissionService extends BaseUploadService {
5922
6010
  });
5923
6011
  return [offlineFormSubmissionAttachments, promise.then(({ attachments }) => attachments)];
5924
6012
  }
6013
+ async bulkDeleteSubmissionAttachments(submissionId, attachmentsIds) {
6014
+ const { store } = this.client;
6015
+ const state = store.getState();
6016
+ const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
6017
+ this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
6018
+ try {
6019
+ await this.enqueueRequest({
6020
+ description: "Delete form submission attachments",
6021
+ method: HttpMethod.DELETE,
6022
+ url: `/forms/submissions/${submissionId}/attachments/bulk/`,
6023
+ payload: { attachments: attachmentsIds },
6024
+ blockers: [submissionId, ...attachmentsIds],
6025
+ blocks: []
6026
+ });
6027
+ } catch (e) {
6028
+ this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
6029
+ throw e;
6030
+ }
6031
+ }
5925
6032
  // Outer promise is for hashing and caching files for submission attachments
5926
6033
  async add(payload) {
5927
6034
  const { store } = this.client;
@@ -6061,10 +6168,64 @@ class FormSubmissionService extends BaseUploadService {
6061
6168
  });
6062
6169
  return batchPromises;
6063
6170
  }
6171
+ async update(payload) {
6172
+ const { store } = this.client;
6173
+ const state = store.getState();
6174
+ const submissionToBeUpdated = selectFormSubmission(payload.offline_id)(state);
6175
+ if (!submissionToBeUpdated) {
6176
+ throw new Error(`Expected submission with offline_id ${payload.offline_id} to exist`);
6177
+ }
6178
+ const { values, files } = separateFilesFromValues(payload.values ?? {});
6179
+ const updatedSubmission = offline({
6180
+ ...submissionToBeUpdated,
6181
+ ...payload,
6182
+ // values could also have a partial update
6183
+ values: {
6184
+ ...submissionToBeUpdated.values,
6185
+ ...values
6186
+ }
6187
+ });
6188
+ this.dispatch(updateFormSubmission(updatedSubmission));
6189
+ const promise = this.enqueueRequest({
6190
+ description: "Delete user form submissions",
6191
+ method: HttpMethod.PATCH,
6192
+ url: `/forms/submissions/${updatedSubmission.offline_id}/`,
6193
+ payload: updatedSubmission,
6194
+ blockers: [updatedSubmission.offline_id],
6195
+ blocks: [updatedSubmission.offline_id]
6196
+ });
6197
+ const formSubmissionAttachments = selectAttachmentsOfFormSubmission(payload.offline_id)(state);
6198
+ const formSubmissionAttachmentIdsToBeDeleted = [];
6199
+ for (const attachment of formSubmissionAttachments) {
6200
+ if (attachment.field_identifier in files) {
6201
+ formSubmissionAttachmentIdsToBeDeleted.push(attachment.offline_id);
6202
+ }
6203
+ }
6204
+ const [offlineFormSubmissionAttachments, attachmentsPromise] = await this.bulkAddSubmissionAttachments(
6205
+ payload.offline_id,
6206
+ files
6207
+ );
6208
+ const deleteAttachmentsPromise = this.bulkDeleteSubmissionAttachments(
6209
+ payload.offline_id,
6210
+ formSubmissionAttachmentIdsToBeDeleted
6211
+ );
6212
+ promise.then((result) => {
6213
+ this.dispatch(setFormSubmission(result));
6214
+ }).catch(() => {
6215
+ this.dispatch(setFormSubmission(submissionToBeUpdated));
6216
+ });
6217
+ return [
6218
+ updatedSubmission,
6219
+ offlineFormSubmissionAttachments,
6220
+ promise,
6221
+ attachmentsPromise,
6222
+ deleteAttachmentsPromise
6223
+ ];
6224
+ }
6064
6225
  async delete(submissionId) {
6065
6226
  const { store } = this.client;
6066
6227
  const state = store.getState();
6067
- const submissionToBeDeleted = selectFormSubmission(submissionId)(store.getState());
6228
+ const submissionToBeDeleted = selectFormSubmission(submissionId)(state);
6068
6229
  if (!submissionToBeDeleted) {
6069
6230
  throw new Error(`Expected submission with offline_id ${submissionId} to exist`);
6070
6231
  }
@@ -6649,27 +6810,20 @@ class LicenseService extends BaseApiService {
6649
6810
  }
6650
6811
  }
6651
6812
  class DocumentService extends BaseApiService {
6652
- // TODO: Support adding for project or organization
6653
- add(document2) {
6813
+ add(payload) {
6654
6814
  const { store } = this.client;
6655
6815
  const currentUserId = store.getState().userReducer.currentUser.id;
6656
- const activeProjectId = store.getState().projectReducer.activeProjectId;
6657
- if (!activeProjectId) {
6658
- throw new Error("No active project ID while creating document.");
6659
- }
6660
- const offlineDocument = offline(document2);
6661
- const submittedDocument = {
6662
- ...offlineDocument,
6816
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6817
+ const offlineDocument = offline({
6818
+ ...payload,
6663
6819
  created_by: currentUserId,
6664
- project: activeProjectId,
6665
- organization: null,
6666
- children_documents: []
6667
- };
6668
- this.dispatch(addDocuments([submittedDocument]));
6820
+ submitted_at: submittedAt
6821
+ });
6822
+ this.dispatch(addDocuments([offlineDocument]));
6669
6823
  const promise = this.enqueueRequest({
6670
6824
  description: "Create Document",
6671
6825
  method: HttpMethod.POST,
6672
- url: `/projects/${activeProjectId}/documents/`,
6826
+ url: "/documents/",
6673
6827
  payload: offlineDocument,
6674
6828
  queryParams: {
6675
6829
  parent_document: offlineDocument.parent_document ?? void 0
@@ -6681,7 +6835,7 @@ class DocumentService extends BaseApiService {
6681
6835
  promise.catch(() => {
6682
6836
  this.dispatch(removeDocuments([offlineDocument.offline_id]));
6683
6837
  });
6684
- return [submittedDocument, promise];
6838
+ return [offlineDocument, promise];
6685
6839
  }
6686
6840
  update(document2) {
6687
6841
  const { store } = this.client;
@@ -6828,6 +6982,24 @@ class DocumentAttachmentService extends BaseAttachmentService {
6828
6982
  async deleteDocumentAttachment(attachmentId) {
6829
6983
  return this.deleteAttachment(attachmentId);
6830
6984
  }
6985
+ async refreshStore(projectId, organizationId) {
6986
+ const projectDocumentAttachments = await this.enqueueRequest({
6987
+ description: "Get document attachments",
6988
+ method: HttpMethod.GET,
6989
+ url: `/projects/${projectId}/document-attachments/`,
6990
+ blocks: [],
6991
+ blockers: []
6992
+ });
6993
+ this.dispatch(this.initializeAttachments(projectDocumentAttachments));
6994
+ const organizationDocumentAttachments = await this.enqueueRequest({
6995
+ description: "Get document attachments",
6996
+ method: HttpMethod.GET,
6997
+ url: `/organizations/${organizationId}/document-attachments/`,
6998
+ blocks: [],
6999
+ blockers: []
7000
+ });
7001
+ this.dispatch(this.addAttachments(organizationDocumentAttachments));
7002
+ }
6831
7003
  }
6832
7004
  class AgentService extends BaseApiService {
6833
7005
  async startConversation(prompt) {
@@ -7241,6 +7413,72 @@ class GeoImageService extends BaseUploadService {
7241
7413
  store.dispatch(initializeGeoImages(result));
7242
7414
  }
7243
7415
  }
7416
+ class IssueAssociationService extends BaseUploadService {
7417
+ add(payload) {
7418
+ const { store } = this.client;
7419
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7420
+ const createdBy = store.getState().userReducer.currentUser.id;
7421
+ const offlineIssueAssociation = offline({
7422
+ ...payload,
7423
+ submitted_at: submittedAt,
7424
+ created_by: createdBy
7425
+ });
7426
+ this.dispatch(addIssueAssociation(offlineIssueAssociation));
7427
+ const promise = this.enqueueRequest({
7428
+ description: "Add issue association",
7429
+ method: HttpMethod.POST,
7430
+ url: "/issues/associations/",
7431
+ payload: {
7432
+ offline_id: offlineIssueAssociation.offline_id,
7433
+ submitted_at: submittedAt,
7434
+ created_by: createdBy,
7435
+ ...payload
7436
+ },
7437
+ blockers: [
7438
+ payload.associated_issue,
7439
+ ...payload.issue ? [payload.issue] : [],
7440
+ ...payload.asset ? [payload.asset] : []
7441
+ ],
7442
+ blocks: [offlineIssueAssociation.offline_id]
7443
+ });
7444
+ promise.then((issueAssociation) => {
7445
+ this.dispatch(updateIssueAssociation(issueAssociation));
7446
+ }).catch(() => {
7447
+ this.dispatch(deleteIssueAssociation(offlineIssueAssociation.offline_id));
7448
+ });
7449
+ return [offlineIssueAssociation, promise];
7450
+ }
7451
+ async delete(id) {
7452
+ const { store } = this.client;
7453
+ const issueAssociation = selectIssueAssociationById(id)(store.getState());
7454
+ if (!issueAssociation) {
7455
+ throw new Error(`Issue association with id ${id} not found in store.`);
7456
+ }
7457
+ this.dispatch(deleteIssueAssociation(id));
7458
+ const promise = this.enqueueRequest({
7459
+ description: "Delete issue association",
7460
+ method: HttpMethod.DELETE,
7461
+ url: `/issues/associations/${id}/`,
7462
+ blockers: [id],
7463
+ blocks: []
7464
+ });
7465
+ promise.catch(() => {
7466
+ this.dispatch(addIssueAssociation(issueAssociation));
7467
+ });
7468
+ return promise;
7469
+ }
7470
+ async refreshStore(projectId) {
7471
+ const issueAssociations = await this.enqueueRequest({
7472
+ description: "Fetch issue associations",
7473
+ method: HttpMethod.GET,
7474
+ url: "/issues/associations/",
7475
+ queryParams: { project_id: projectId.toString() },
7476
+ blockers: [],
7477
+ blocks: []
7478
+ });
7479
+ this.dispatch(initializeIssueAssociations(issueAssociations));
7480
+ }
7481
+ }
7244
7482
  export {
7245
7483
  APIError,
7246
7484
  AgentService,
@@ -7269,6 +7507,7 @@ export {
7269
7507
  GREEN,
7270
7508
  GeoImageService,
7271
7509
  HttpMethod,
7510
+ IssueAssociationService,
7272
7511
  IssueAttachmentService,
7273
7512
  IssueCommentService,
7274
7513
  IssuePriority,
@@ -7330,6 +7569,8 @@ export {
7330
7569
  addGeoImage,
7331
7570
  addGeoImages,
7332
7571
  addIssue,
7572
+ addIssueAssociation,
7573
+ addIssueAssociations,
7333
7574
  addIssueAttachment,
7334
7575
  addIssueAttachments,
7335
7576
  addIssueComment,
@@ -7407,6 +7648,8 @@ export {
7407
7648
  deleteGeoImage,
7408
7649
  deleteGeoImages,
7409
7650
  deleteIssue,
7651
+ deleteIssueAssociation,
7652
+ deleteIssueAssociations,
7410
7653
  deleteIssueAttachment,
7411
7654
  deleteIssueAttachments,
7412
7655
  deleteIssueComment,
@@ -7479,6 +7722,7 @@ export {
7479
7722
  initializeFormSubmissions,
7480
7723
  initializeForms,
7481
7724
  initializeGeoImages,
7725
+ initializeIssueAssociations,
7482
7726
  initializeIssueAttachments,
7483
7727
  initializeIssueTypes,
7484
7728
  initializeIssueUpdates,
@@ -7491,6 +7735,8 @@ export {
7491
7735
  initializeTeams,
7492
7736
  initializeWorkspaces,
7493
7737
  isToday,
7738
+ issueAssociationReducer,
7739
+ issueAssociationSlice,
7494
7740
  issueAttachmentReducer,
7495
7741
  issueAttachmentSlice,
7496
7742
  issueCommentReducer,
@@ -7626,6 +7872,7 @@ export {
7626
7872
  selectFormRevisions,
7627
7873
  selectFormRevisionsOfForm,
7628
7874
  selectFormSubmission,
7875
+ selectFormSubmissionAttachemntsByIds,
7629
7876
  selectFormSubmissionAttachmentsMapping,
7630
7877
  selectFormSubmissions,
7631
7878
  selectFormSubmissionsByAssets,
@@ -7646,6 +7893,11 @@ export {
7646
7893
  selectIsImportingProjectFile,
7647
7894
  selectIsLoggedIn,
7648
7895
  selectIssue,
7896
+ selectIssueAssociationById,
7897
+ selectIssueAssociationMapping,
7898
+ selectIssueAssociationsOfAsset,
7899
+ selectIssueAssociationsOfIssue,
7900
+ selectIssueAssociationsToIssue,
7649
7901
  selectIssueAttachment,
7650
7902
  selectIssueAttachmentMapping,
7651
7903
  selectIssueAttachments,
@@ -7750,6 +8002,8 @@ export {
7750
8002
  setGeoImages,
7751
8003
  setIsFetchingInitialData,
7752
8004
  setIsImportingProjectFile,
8005
+ setIssueAssociation,
8006
+ setIssueAssociations,
7753
8007
  setIssueAttachment,
7754
8008
  setIssueAttachments,
7755
8009
  setIssueComment,
@@ -7803,6 +8057,8 @@ export {
7803
8057
  updateGeoImage,
7804
8058
  updateGeoImages,
7805
8059
  updateIssue,
8060
+ updateIssueAssociation,
8061
+ updateIssueAssociations,
7806
8062
  updateIssueAttachment,
7807
8063
  updateIssueAttachments,
7808
8064
  updateIssueType,