@overmap-ai/core 1.0.63-form-submission-fix.4 → 1.0.63-form-submission-drafts.1

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,
@@ -2692,11 +2692,11 @@ const formSubmissionReducer = formSubmissionSlice.reducer;
2692
2692
  const formSubmissionAttachmentAdapter = createModelAdapter(
2693
2693
  (attachment) => attachment.offline_id
2694
2694
  );
2695
- const initialState$b = formSubmissionAttachmentAdapter.getInitialState({});
2695
+ const initialState$c = formSubmissionAttachmentAdapter.getInitialState({});
2696
2696
  const formSubmissionAttachmentSlice = createSlice({
2697
2697
  name: "formSubmissionAttachments",
2698
- initialState: initialState$b,
2699
- 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)),
2700
2700
  reducers: {
2701
2701
  initializeFormSubmissionAttachments: formSubmissionAttachmentAdapter.initialize,
2702
2702
  addFormSubmissionAttachment: formSubmissionAttachmentAdapter.addOne,
@@ -2723,6 +2723,15 @@ const {
2723
2723
  const selectFormSubmissionAttachmentsMapping = (state) => {
2724
2724
  return state.formSubmissionAttachmentReducer.instances;
2725
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
+ );
2726
2735
  const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
2727
2736
  createSelector(
2728
2737
  [selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
@@ -2735,11 +2744,11 @@ const formSubmissionAttachmentReducer = formSubmissionAttachmentSlice.reducer;
2735
2744
  const formRevisionAttachmentAdapter = createModelAdapter(
2736
2745
  (attachment) => attachment.offline_id
2737
2746
  );
2738
- const initialState$a = formRevisionAttachmentAdapter.getInitialState({});
2747
+ const initialState$b = formRevisionAttachmentAdapter.getInitialState({});
2739
2748
  const formRevisionAttachmentSlice = createSlice({
2740
2749
  name: "formRevisionAttachments",
2741
- initialState: initialState$a,
2742
- 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)),
2743
2752
  reducers: {
2744
2753
  initializeFormRevisionAttachments: formRevisionAttachmentAdapter.initialize,
2745
2754
  addFormRevisionAttachment: formRevisionAttachmentAdapter.addOne,
@@ -2776,10 +2785,10 @@ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
2776
2785
  );
2777
2786
  const formRevisionAttachmentReducer = formRevisionAttachmentSlice.reducer;
2778
2787
  const emailDomainAdapter = createModelAdapter((emailDomain) => emailDomain.offline_id);
2779
- const initialState$9 = emailDomainAdapter.getInitialState({});
2788
+ const initialState$a = emailDomainAdapter.getInitialState({});
2780
2789
  const emailDomainsSlice = createSlice({
2781
2790
  name: "emailDomains",
2782
- initialState: initialState$9,
2791
+ initialState: initialState$a,
2783
2792
  reducers: {
2784
2793
  initializeEmailDomains: emailDomainAdapter.initialize,
2785
2794
  addEmailDomain: emailDomainAdapter.addOne,
@@ -2798,14 +2807,14 @@ const selectEmailDomainsOfOrganization = restructureCreateSelectorWithArgs(
2798
2807
  )
2799
2808
  );
2800
2809
  const emailDomainsReducer = emailDomainsSlice.reducer;
2801
- const initialState$8 = {
2810
+ const initialState$9 = {
2802
2811
  documents: {}
2803
2812
  };
2804
2813
  const documentSlice = createSlice({
2805
2814
  name: "documents",
2806
- initialState: initialState$8,
2815
+ initialState: initialState$9,
2807
2816
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2808
- Object.assign(state, initialState$8);
2817
+ Object.assign(state, initialState$9);
2809
2818
  }),
2810
2819
  reducers: {
2811
2820
  setDocuments: (state, action) => {
@@ -2980,11 +2989,11 @@ const selectRootDocuments = createSelector(
2980
2989
  );
2981
2990
  const documentsReducer = documentSlice.reducer;
2982
2991
  const documentAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
2983
- const initialState$7 = documentAttachmentAdapter.getInitialState({});
2992
+ const initialState$8 = documentAttachmentAdapter.getInitialState({});
2984
2993
  const documentAttachmentSlice = createSlice({
2985
2994
  name: "documentAttachments",
2986
- initialState: initialState$7,
2987
- 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)),
2988
2997
  reducers: {
2989
2998
  initializeDocumentAttachments: documentAttachmentAdapter.initialize,
2990
2999
  addDocumentAttachment: documentAttachmentAdapter.addOne,
@@ -3043,11 +3052,11 @@ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
3043
3052
  );
3044
3053
  const documentAttachmentReducer = documentAttachmentSlice.reducer;
3045
3054
  const teamAdapter = createModelAdapter((team) => team.offline_id);
3046
- const initialState$6 = teamAdapter.getInitialState({});
3055
+ const initialState$7 = teamAdapter.getInitialState({});
3047
3056
  const teamSlice = createSlice({
3048
3057
  name: "teams",
3049
- initialState: initialState$6,
3050
- 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)),
3051
3060
  reducers: {
3052
3061
  setTeam: teamAdapter.setOne,
3053
3062
  initializeTeams: teamAdapter.initialize,
@@ -3081,11 +3090,11 @@ const teamReducer = teamSlice.reducer;
3081
3090
  const agentUserConversationAdapter = createModelAdapter(
3082
3091
  (conversation) => conversation.offline_id
3083
3092
  );
3084
- const initialState$5 = agentUserConversationAdapter.getInitialState({});
3093
+ const initialState$6 = agentUserConversationAdapter.getInitialState({});
3085
3094
  const agentsSlice = createSlice({
3086
3095
  name: "agents",
3087
- initialState: initialState$5,
3088
- 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)),
3089
3098
  reducers: {
3090
3099
  initializeConversations: agentUserConversationAdapter.initialize,
3091
3100
  addConversation: agentUserConversationAdapter.addOne,
@@ -3107,11 +3116,11 @@ const selectConversation = restructureCreateSelectorWithArgs(
3107
3116
  );
3108
3117
  const agentsReducer = agentsSlice.reducer;
3109
3118
  const issueCommentAdapter = createModelAdapter((comment) => comment.offline_id);
3110
- const initialState$4 = issueCommentAdapter.getInitialState({});
3119
+ const initialState$5 = issueCommentAdapter.getInitialState({});
3111
3120
  const issueCommentSlice = createSlice({
3112
3121
  name: "issueComments",
3113
- initialState: initialState$4,
3114
- 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)),
3115
3124
  reducers: {
3116
3125
  addIssueComment: issueCommentAdapter.addOne,
3117
3126
  addIssueComments: issueCommentAdapter.addMany,
@@ -3140,11 +3149,11 @@ const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
3140
3149
  );
3141
3150
  const issueCommentReducer = issueCommentSlice.reducer;
3142
3151
  const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
3143
- const initialState$3 = issueUpdateAdapter.getInitialState({});
3152
+ const initialState$4 = issueUpdateAdapter.getInitialState({});
3144
3153
  const issueUpdateSlice = createSlice({
3145
3154
  name: "issueUpdates",
3146
- initialState: initialState$3,
3147
- 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)),
3148
3157
  reducers: {
3149
3158
  initializeIssueUpdates: issueUpdateAdapter.setMany,
3150
3159
  setIssueUpdate: issueUpdateAdapter.setOne,
@@ -3173,11 +3182,11 @@ const selectIssueUpdatesOfIssue = restructureCreateSelectorWithArgs(
3173
3182
  );
3174
3183
  const issueUpdateReducer = issueUpdateSlice.reducer;
3175
3184
  const issueAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
3176
- const initialState$2 = issueAttachmentAdapter.getInitialState({});
3185
+ const initialState$3 = issueAttachmentAdapter.getInitialState({});
3177
3186
  const issueAttachmentSlice = createSlice({
3178
3187
  name: "issueAttachments",
3179
- initialState: initialState$2,
3180
- 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)),
3181
3190
  reducers: {
3182
3191
  initializeIssueAttachments: issueAttachmentAdapter.initialize,
3183
3192
  addIssueAttachment: issueAttachmentAdapter.addOne,
@@ -3235,23 +3244,23 @@ const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
3235
3244
  )
3236
3245
  );
3237
3246
  const issueAttachmentReducer = issueAttachmentSlice.reducer;
3238
- const initialState$1 = {
3247
+ const initialState$2 = {
3239
3248
  version: 0
3240
3249
  };
3241
3250
  const versioningSlice = createSlice({
3242
3251
  name: "versioning",
3243
- initialState: initialState$1,
3252
+ initialState: initialState$2,
3244
3253
  reducers: {}
3245
3254
  });
3246
3255
  const versioningReducer = versioningSlice.reducer;
3247
3256
  const geoImageAdapter = createModelAdapter((model) => model.offline_id);
3248
- const initialState = geoImageAdapter.getInitialState({});
3257
+ const initialState$1 = geoImageAdapter.getInitialState({});
3249
3258
  const geoImageSlice = createSlice({
3250
3259
  name: "geoImages",
3251
- initialState,
3260
+ initialState: initialState$1,
3252
3261
  extraReducers: (builder) => {
3253
3262
  builder.addCase("RESET", (state) => {
3254
- Object.assign(state, initialState);
3263
+ Object.assign(state, initialState$1);
3255
3264
  });
3256
3265
  },
3257
3266
  reducers: {
@@ -3288,6 +3297,64 @@ const selectGeoImagesOfProject = restructureCreateSelectorWithArgs(
3288
3297
  })
3289
3298
  );
3290
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;
3291
3358
  const fullAssetMarkerSize = 45;
3292
3359
  const DEFAULT_ISSUE_STATUS = IssueStatus.BACKLOG;
3293
3360
  const DEFAULT_ISSUE_PRIORITY = IssuePriority.MEDIUM;
@@ -3360,7 +3427,8 @@ const overmapReducers = {
3360
3427
  agentsReducer,
3361
3428
  issueCommentReducer,
3362
3429
  issueUpdateReducer,
3363
- geoImageReducer
3430
+ geoImageReducer,
3431
+ issueAssociationReducer
3364
3432
  };
3365
3433
  const overmapReducer = combineReducers(overmapReducers);
3366
3434
  const resetStore = "RESET";
@@ -4151,11 +4219,13 @@ class AssetService extends BaseApiService {
4151
4219
  }
4152
4220
  async remove(assetId) {
4153
4221
  const { store } = this.client;
4154
- const assetToBeDeleted = selectAsset(assetId)(store.getState());
4222
+ const state = store.getState();
4223
+ const assetToBeDeleted = selectAsset(assetId)(state);
4155
4224
  if (!assetToBeDeleted)
4156
4225
  throw new Error(`No asset with id ${assetId} found in the store`);
4157
- const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(store.getState());
4158
- const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(assetId)(store.getState());
4226
+ const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(state);
4227
+ const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(assetId)(state);
4228
+ const issueAssociations = selectIssueAssociationsOfAsset(assetId)(state);
4159
4229
  this.dispatch(deleteAsset(assetId));
4160
4230
  if (attachmentsOfAssets.length > 0) {
4161
4231
  const attachmentsOfAssetIds = attachmentsOfAssets.map(({ offline_id }) => offline_id);
@@ -4165,6 +4235,10 @@ class AssetService extends BaseApiService {
4165
4235
  const formSubmissionsOfAssetIds = formSubmissionsOfAssets.map(({ offline_id }) => offline_id);
4166
4236
  this.dispatch(deleteFormSubmissions(formSubmissionsOfAssetIds));
4167
4237
  }
4238
+ if (issueAssociations.length > 0) {
4239
+ const issueAssociationsIds = issueAssociations.map(({ offline_id }) => offline_id);
4240
+ this.dispatch(deleteIssueAssociations(issueAssociationsIds));
4241
+ }
4168
4242
  return this.enqueueRequest({
4169
4243
  description: "Delete asset",
4170
4244
  method: HttpMethod.DELETE,
@@ -4175,6 +4249,7 @@ class AssetService extends BaseApiService {
4175
4249
  this.dispatch(addAsset(assetToBeDeleted));
4176
4250
  this.dispatch(addAssetAttachments(attachmentsOfAssets));
4177
4251
  this.dispatch(addFormSubmissions(formSubmissionsOfAssets));
4252
+ this.dispatch(addIssueAssociations(issueAssociations));
4178
4253
  throw err;
4179
4254
  });
4180
4255
  }
@@ -4622,7 +4697,7 @@ class BaseAttachmentService extends BaseUploadService {
4622
4697
  }
4623
4698
  // Note that currently the fetching of attachments for all models dependds on the active projectId. This may change in the future. And
4624
4699
  // so for some attachment model services, this method will have to be overridden.
4625
- async refreshStore(projectId) {
4700
+ async refreshStore(projectId, _organizationId) {
4626
4701
  const meta = AttachmentModelMeta[this.attachmentModel];
4627
4702
  const result = await this.enqueueRequest({
4628
4703
  description: `Get ${meta.name} attachments`,
@@ -5050,6 +5125,12 @@ class IssueService extends BaseApiService {
5050
5125
  const attachmentsOfIssue = selectAttachmentsOfIssue(id)(state);
5051
5126
  const updatesOfIssue = selectIssueUpdatesOfIssue(id)(state);
5052
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);
5053
5134
  this.dispatch(deleteIssue(id));
5054
5135
  this.dispatch(addActiveProjectIssuesCount(-1));
5055
5136
  if (attachmentsOfIssue.length > 0)
@@ -5058,6 +5139,8 @@ class IssueService extends BaseApiService {
5058
5139
  this.dispatch(deleteIssueUpdates(updatesOfIssue.map(({ offline_id }) => offline_id)));
5059
5140
  if (formSubmissionsOfIssue.length > 0)
5060
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)));
5061
5144
  try {
5062
5145
  return await this.enqueueRequest({
5063
5146
  description: "Delete issue",
@@ -5072,6 +5155,7 @@ class IssueService extends BaseApiService {
5072
5155
  this.dispatch(addIssueUpdates(updatesOfIssue));
5073
5156
  this.dispatch(addActiveProjectIssuesCount(1));
5074
5157
  this.dispatch(addFormSubmissions(formSubmissionsOfIssue));
5158
+ this.dispatch(addIssueAssociations(issueAssociations));
5075
5159
  throw e;
5076
5160
  }
5077
5161
  }
@@ -5115,7 +5199,7 @@ class IssueTypeService extends BaseApiService {
5115
5199
  offline_id: offlineIssueType.offline_id,
5116
5200
  submitted_at: offlineIssueType.submitted_at,
5117
5201
  icon: offlineIssueType.icon,
5118
- icon_color: offlineIssueType.icon_color,
5202
+ icon_color: offlineIssueType.color,
5119
5203
  name: offlineIssueType.name,
5120
5204
  description: offlineIssueType.description
5121
5205
  },
@@ -5926,6 +6010,25 @@ class FormSubmissionService extends BaseUploadService {
5926
6010
  });
5927
6011
  return [offlineFormSubmissionAttachments, promise.then(({ attachments }) => attachments)];
5928
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
+ }
5929
6032
  // Outer promise is for hashing and caching files for submission attachments
5930
6033
  async add(payload) {
5931
6034
  const { store } = this.client;
@@ -6065,10 +6168,64 @@ class FormSubmissionService extends BaseUploadService {
6065
6168
  });
6066
6169
  return batchPromises;
6067
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 = {
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
+ }
6068
6225
  async delete(submissionId) {
6069
6226
  const { store } = this.client;
6070
6227
  const state = store.getState();
6071
- const submissionToBeDeleted = selectFormSubmission(submissionId)(store.getState());
6228
+ const submissionToBeDeleted = selectFormSubmission(submissionId)(state);
6072
6229
  if (!submissionToBeDeleted) {
6073
6230
  throw new Error(`Expected submission with offline_id ${submissionId} to exist`);
6074
6231
  }
@@ -6653,27 +6810,20 @@ class LicenseService extends BaseApiService {
6653
6810
  }
6654
6811
  }
6655
6812
  class DocumentService extends BaseApiService {
6656
- // TODO: Support adding for project or organization
6657
- add(document2) {
6813
+ add(payload) {
6658
6814
  const { store } = this.client;
6659
6815
  const currentUserId = store.getState().userReducer.currentUser.id;
6660
- const activeProjectId = store.getState().projectReducer.activeProjectId;
6661
- if (!activeProjectId) {
6662
- throw new Error("No active project ID while creating document.");
6663
- }
6664
- const offlineDocument = offline(document2);
6665
- const submittedDocument = {
6666
- ...offlineDocument,
6816
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6817
+ const offlineDocument = offline({
6818
+ ...payload,
6667
6819
  created_by: currentUserId,
6668
- project: activeProjectId,
6669
- organization: null,
6670
- children_documents: []
6671
- };
6672
- this.dispatch(addDocuments([submittedDocument]));
6820
+ submitted_at: submittedAt
6821
+ });
6822
+ this.dispatch(addDocuments([offlineDocument]));
6673
6823
  const promise = this.enqueueRequest({
6674
6824
  description: "Create Document",
6675
6825
  method: HttpMethod.POST,
6676
- url: `/projects/${activeProjectId}/documents/`,
6826
+ url: "/documents/",
6677
6827
  payload: offlineDocument,
6678
6828
  queryParams: {
6679
6829
  parent_document: offlineDocument.parent_document ?? void 0
@@ -6685,7 +6835,7 @@ class DocumentService extends BaseApiService {
6685
6835
  promise.catch(() => {
6686
6836
  this.dispatch(removeDocuments([offlineDocument.offline_id]));
6687
6837
  });
6688
- return [submittedDocument, promise];
6838
+ return [offlineDocument, promise];
6689
6839
  }
6690
6840
  update(document2) {
6691
6841
  const { store } = this.client;
@@ -6832,6 +6982,24 @@ class DocumentAttachmentService extends BaseAttachmentService {
6832
6982
  async deleteDocumentAttachment(attachmentId) {
6833
6983
  return this.deleteAttachment(attachmentId);
6834
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
+ }
6835
7003
  }
6836
7004
  class AgentService extends BaseApiService {
6837
7005
  async startConversation(prompt) {
@@ -7245,6 +7413,72 @@ class GeoImageService extends BaseUploadService {
7245
7413
  store.dispatch(initializeGeoImages(result));
7246
7414
  }
7247
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
+ }
7248
7482
  export {
7249
7483
  APIError,
7250
7484
  AgentService,
@@ -7273,6 +7507,7 @@ export {
7273
7507
  GREEN,
7274
7508
  GeoImageService,
7275
7509
  HttpMethod,
7510
+ IssueAssociationService,
7276
7511
  IssueAttachmentService,
7277
7512
  IssueCommentService,
7278
7513
  IssuePriority,
@@ -7334,6 +7569,8 @@ export {
7334
7569
  addGeoImage,
7335
7570
  addGeoImages,
7336
7571
  addIssue,
7572
+ addIssueAssociation,
7573
+ addIssueAssociations,
7337
7574
  addIssueAttachment,
7338
7575
  addIssueAttachments,
7339
7576
  addIssueComment,
@@ -7411,6 +7648,8 @@ export {
7411
7648
  deleteGeoImage,
7412
7649
  deleteGeoImages,
7413
7650
  deleteIssue,
7651
+ deleteIssueAssociation,
7652
+ deleteIssueAssociations,
7414
7653
  deleteIssueAttachment,
7415
7654
  deleteIssueAttachments,
7416
7655
  deleteIssueComment,
@@ -7483,6 +7722,7 @@ export {
7483
7722
  initializeFormSubmissions,
7484
7723
  initializeForms,
7485
7724
  initializeGeoImages,
7725
+ initializeIssueAssociations,
7486
7726
  initializeIssueAttachments,
7487
7727
  initializeIssueTypes,
7488
7728
  initializeIssueUpdates,
@@ -7495,6 +7735,8 @@ export {
7495
7735
  initializeTeams,
7496
7736
  initializeWorkspaces,
7497
7737
  isToday,
7738
+ issueAssociationReducer,
7739
+ issueAssociationSlice,
7498
7740
  issueAttachmentReducer,
7499
7741
  issueAttachmentSlice,
7500
7742
  issueCommentReducer,
@@ -7630,6 +7872,7 @@ export {
7630
7872
  selectFormRevisions,
7631
7873
  selectFormRevisionsOfForm,
7632
7874
  selectFormSubmission,
7875
+ selectFormSubmissionAttachemntsByIds,
7633
7876
  selectFormSubmissionAttachmentsMapping,
7634
7877
  selectFormSubmissions,
7635
7878
  selectFormSubmissionsByAssets,
@@ -7650,6 +7893,11 @@ export {
7650
7893
  selectIsImportingProjectFile,
7651
7894
  selectIsLoggedIn,
7652
7895
  selectIssue,
7896
+ selectIssueAssociationById,
7897
+ selectIssueAssociationMapping,
7898
+ selectIssueAssociationsOfAsset,
7899
+ selectIssueAssociationsOfIssue,
7900
+ selectIssueAssociationsToIssue,
7653
7901
  selectIssueAttachment,
7654
7902
  selectIssueAttachmentMapping,
7655
7903
  selectIssueAttachments,
@@ -7754,6 +8002,8 @@ export {
7754
8002
  setGeoImages,
7755
8003
  setIsFetchingInitialData,
7756
8004
  setIsImportingProjectFile,
8005
+ setIssueAssociation,
8006
+ setIssueAssociations,
7757
8007
  setIssueAttachment,
7758
8008
  setIssueAttachments,
7759
8009
  setIssueComment,
@@ -7807,6 +8057,8 @@ export {
7807
8057
  updateGeoImage,
7808
8058
  updateGeoImages,
7809
8059
  updateIssue,
8060
+ updateIssueAssociation,
8061
+ updateIssueAssociations,
7810
8062
  updateIssueAttachment,
7811
8063
  updateIssueAttachments,
7812
8064
  updateIssueType,