@overmap-ai/core 1.0.50-bulk-form-submission.2 → 1.0.50-document-attachments.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.
@@ -622,15 +622,15 @@ var __publicField = (obj, key, value) => {
622
622
  };
623
623
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
624
624
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
625
- const initialState$p = {
625
+ const initialState$n = {
626
626
  accessToken: "",
627
627
  refreshToken: "",
628
628
  isLoggedIn: false
629
629
  };
630
630
  const authSlice = toolkit.createSlice({
631
631
  name: "auth",
632
- initialState: initialState$p,
633
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
632
+ initialState: initialState$n,
633
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
634
634
  reducers: {
635
635
  setTokens: (state, action) => {
636
636
  state.accessToken = action.payload.accessToken;
@@ -795,19 +795,6 @@ var __publicField = (obj, key, value) => {
795
795
  element.click();
796
796
  document.body.removeChild(element);
797
797
  }
798
- const constructUploadedFilePayloads = async (files) => {
799
- const filePayloads = {};
800
- for (const file of files) {
801
- const sha1 = await hashFile(file);
802
- filePayloads[sha1] = {
803
- sha1,
804
- extension: file.name.split(".").pop() || "",
805
- file_type: file.type,
806
- size: file.size
807
- };
808
- }
809
- return Object.values(filePayloads);
810
- };
811
798
  const fileToBlob = async (dataUrl) => {
812
799
  return (await fetch(dataUrl)).blob();
813
800
  };
@@ -1374,7 +1361,7 @@ var __publicField = (obj, key, value) => {
1374
1361
  return getLocalDateString(date);
1375
1362
  return relative.format(days, "days");
1376
1363
  });
1377
- const initialState$o = {
1364
+ const initialState$m = {
1378
1365
  categories: {},
1379
1366
  usedCategoryColors: [],
1380
1367
  categoryVisibility: {
@@ -1384,8 +1371,8 @@ var __publicField = (obj, key, value) => {
1384
1371
  };
1385
1372
  const categorySlice = toolkit.createSlice({
1386
1373
  name: "categories",
1387
- initialState: initialState$o,
1388
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1374
+ initialState: initialState$m,
1375
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1389
1376
  reducers: {
1390
1377
  setCategories: (state, action) => {
1391
1378
  if (!Array.isArray(action.payload))
@@ -1542,15 +1529,6 @@ var __publicField = (obj, key, value) => {
1542
1529
  throw new Error(`Attachment ${action.payload.offline_id} does not exist.`);
1543
1530
  }
1544
1531
  }
1545
- function updateAttachments(state, action) {
1546
- for (const attachment of action.payload) {
1547
- if (attachment.offline_id in state.attachments) {
1548
- state.attachments[attachment.offline_id] = attachment;
1549
- } else {
1550
- throw new Error(`Attachment ${attachment.offline_id} does not exist.`);
1551
- }
1552
- }
1553
- }
1554
1532
  function removeAttachment(state, action) {
1555
1533
  if (action.payload in state.attachments) {
1556
1534
  delete state.attachments[action.payload];
@@ -1563,14 +1541,14 @@ var __publicField = (obj, key, value) => {
1563
1541
  delete state.attachments[attachmentId];
1564
1542
  }
1565
1543
  }
1566
- const initialState$n = {
1544
+ const initialState$l = {
1567
1545
  components: {},
1568
1546
  attachments: {}
1569
1547
  };
1570
1548
  const componentSlice = toolkit.createSlice({
1571
1549
  name: "components",
1572
- initialState: initialState$n,
1573
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1550
+ initialState: initialState$l,
1551
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1574
1552
  reducers: {
1575
1553
  addComponent: (state, action) => {
1576
1554
  state.components[action.payload.offline_id] = action.payload;
@@ -1683,9 +1661,6 @@ var __publicField = (obj, key, value) => {
1683
1661
  [selectComponentAttachmentMapping],
1684
1662
  (mapping) => Object.values(mapping)
1685
1663
  );
1686
- const selectComponentAttachment = (attachmentId) => (state) => {
1687
- return state.componentReducer.attachments[attachmentId];
1688
- };
1689
1664
  const selectAttachmentsOfComponent = restructureCreateSelectorWithArgs(
1690
1665
  toolkit.createSelector(
1691
1666
  [selectAllComponentAttachments, (_state, componentId) => componentId],
@@ -1726,13 +1701,13 @@ var __publicField = (obj, key, value) => {
1726
1701
  removeAllComponentsOfType
1727
1702
  } = componentSlice.actions;
1728
1703
  const componentReducer = componentSlice.reducer;
1729
- const initialState$m = {
1704
+ const initialState$k = {
1730
1705
  completionsByComponentId: {}
1731
1706
  };
1732
1707
  const componentStageCompletionSlice = toolkit.createSlice({
1733
1708
  name: "componentStageCompletions",
1734
- initialState: initialState$m,
1735
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1709
+ initialState: initialState$k,
1710
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1736
1711
  reducers: {
1737
1712
  addStageCompletion: (state, action) => {
1738
1713
  let stageToCompletionDateMapping = state.completionsByComponentId[action.payload.component];
@@ -1783,13 +1758,13 @@ var __publicField = (obj, key, value) => {
1783
1758
  return Object.keys(state.componentStageCompletionReducer.completionsByComponentId[component.offline_id] ?? {});
1784
1759
  };
1785
1760
  const componentStageCompletionReducer = componentStageCompletionSlice.reducer;
1786
- const initialState$l = {
1761
+ const initialState$j = {
1787
1762
  stages: {}
1788
1763
  };
1789
1764
  const componentStageSlice = toolkit.createSlice({
1790
1765
  name: "componentStages",
1791
- initialState: initialState$l,
1792
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1766
+ initialState: initialState$j,
1767
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1793
1768
  reducers: {
1794
1769
  addStages: (state, action) => {
1795
1770
  Object.assign(state.stages, toOfflineIdRecord(action.payload));
@@ -1899,15 +1874,15 @@ var __publicField = (obj, key, value) => {
1899
1874
  );
1900
1875
  const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = componentStageSlice.actions;
1901
1876
  const componentStageReducer = componentStageSlice.reducer;
1902
- const initialState$k = {
1877
+ const initialState$i = {
1903
1878
  componentTypes: {},
1904
1879
  hiddenComponentTypeIds: {},
1905
1880
  attachments: {}
1906
1881
  };
1907
1882
  const componentTypeSlice = toolkit.createSlice({
1908
1883
  name: "componentTypes",
1909
- initialState: initialState$k,
1910
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1884
+ initialState: initialState$i,
1885
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1911
1886
  reducers: {
1912
1887
  addComponentType: (state, action) => {
1913
1888
  state.componentTypes[action.payload.offline_id] = action.payload;
@@ -1975,9 +1950,6 @@ var __publicField = (obj, key, value) => {
1975
1950
  [selectComponentTypeAttachmentMapping],
1976
1951
  (mapping) => Object.values(mapping)
1977
1952
  );
1978
- const selectComponentTypeAttachment = (attachmentId) => (state) => {
1979
- return state.componentTypeReducer.attachments[attachmentId];
1980
- };
1981
1953
  const selectAttachmentsOfComponentType = restructureCreateSelectorWithArgs(
1982
1954
  toolkit.createSelector(
1983
1955
  [selectAllComponentTypeAttachments, (_state, componentTypeId) => componentTypeId],
@@ -2018,13 +1990,13 @@ var __publicField = (obj, key, value) => {
2018
1990
  deleteComponentType
2019
1991
  } = componentTypeSlice.actions;
2020
1992
  const componentTypeReducer = componentTypeSlice.reducer;
2021
- const initialState$j = {
1993
+ const initialState$h = {
2022
1994
  workspaces: {},
2023
1995
  activeWorkspaceId: null
2024
1996
  };
2025
1997
  const workspaceSlice = toolkit.createSlice({
2026
1998
  name: "workspace",
2027
- initialState: initialState$j,
1999
+ initialState: initialState$h,
2028
2000
  // The `reducers` field lets us define reducers and generate associated actions
2029
2001
  reducers: {
2030
2002
  setWorkspaces: (state, action) => {
@@ -2081,7 +2053,7 @@ var __publicField = (obj, key, value) => {
2081
2053
  );
2082
2054
  const workspaceReducer = workspaceSlice.reducer;
2083
2055
  const maxRecentIssues = 10;
2084
- const initialState$i = {
2056
+ const initialState$g = {
2085
2057
  issues: {},
2086
2058
  attachments: {},
2087
2059
  comments: {},
@@ -2093,9 +2065,9 @@ var __publicField = (obj, key, value) => {
2093
2065
  };
2094
2066
  const issueSlice = toolkit.createSlice({
2095
2067
  name: "issues",
2096
- initialState: initialState$i,
2068
+ initialState: initialState$g,
2097
2069
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2098
- Object.assign(state, initialState$i);
2070
+ Object.assign(state, initialState$g);
2099
2071
  }),
2100
2072
  reducers: {
2101
2073
  setIssues: (state, action) => {
@@ -2150,7 +2122,6 @@ var __publicField = (obj, key, value) => {
2150
2122
  }
2151
2123
  },
2152
2124
  updateIssueAttachment: updateAttachment,
2153
- updateIssueAttachments: updateAttachments,
2154
2125
  removeIssue: (state, action) => {
2155
2126
  if (action.payload in state.issues) {
2156
2127
  delete state.issues[action.payload];
@@ -2159,7 +2130,6 @@ var __publicField = (obj, key, value) => {
2159
2130
  }
2160
2131
  },
2161
2132
  removeIssueAttachment: removeAttachment,
2162
- removeIssueAttachments: removeAttachments,
2163
2133
  removeIssueUpdate: (state, action) => {
2164
2134
  if (action.payload in state.updates) {
2165
2135
  delete state.updates[action.payload];
@@ -2269,7 +2239,6 @@ var __publicField = (obj, key, value) => {
2269
2239
  addToRecentIssues,
2270
2240
  cleanRecentIssues,
2271
2241
  removeIssueAttachment,
2272
- removeIssueAttachments,
2273
2242
  removeAttachmentsOfIssue,
2274
2243
  removeIssue,
2275
2244
  removeIssueUpdate,
@@ -2283,7 +2252,6 @@ var __publicField = (obj, key, value) => {
2283
2252
  setVisibleStatuses,
2284
2253
  setVisibleUserIds,
2285
2254
  updateIssueAttachment,
2286
- updateIssueAttachments,
2287
2255
  updateIssue,
2288
2256
  // Commments
2289
2257
  addIssueComment,
@@ -2376,9 +2344,6 @@ var __publicField = (obj, key, value) => {
2376
2344
  }
2377
2345
  )
2378
2346
  );
2379
- const selectIssueAttachment = (attachmentId) => (root) => {
2380
- return root.issueReducer.attachments[attachmentId];
2381
- };
2382
2347
  const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
2383
2348
  toolkit.createSelector(
2384
2349
  [selectIssueAttachments, (_state, issueId) => issueId],
@@ -2507,15 +2472,15 @@ var __publicField = (obj, key, value) => {
2507
2472
  }
2508
2473
  );
2509
2474
  const issueReducer = issueSlice.reducer;
2510
- const initialState$h = {
2475
+ const initialState$f = {
2511
2476
  s3Urls: {}
2512
2477
  };
2513
2478
  const msPerHour = 1e3 * 60 * 60;
2514
2479
  const msPerWeek = msPerHour * 24 * 7;
2515
2480
  const fileSlice = toolkit.createSlice({
2516
2481
  name: "file",
2517
- initialState: initialState$h,
2518
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2482
+ initialState: initialState$f,
2483
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2519
2484
  reducers: {
2520
2485
  setUploadUrl: (state, action) => {
2521
2486
  const { url, fields, sha1 } = action.payload;
@@ -2542,7 +2507,7 @@ var __publicField = (obj, key, value) => {
2542
2507
  return url;
2543
2508
  };
2544
2509
  const fileReducer = fileSlice.reducer;
2545
- const initialState$g = {
2510
+ const initialState$e = {
2546
2511
  // TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
2547
2512
  mapStyle: MapStyle.SATELLITE,
2548
2513
  showTooltips: false,
@@ -2550,8 +2515,8 @@ var __publicField = (obj, key, value) => {
2550
2515
  };
2551
2516
  const mapSlice = toolkit.createSlice({
2552
2517
  name: "map",
2553
- initialState: initialState$g,
2554
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2518
+ initialState: initialState$e,
2519
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2555
2520
  reducers: {
2556
2521
  setMapStyle: (state, action) => {
2557
2522
  state.mapStyle = action.payload;
@@ -2620,7 +2585,7 @@ var __publicField = (obj, key, value) => {
2620
2585
  LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
2621
2586
  return LicenseStatus2;
2622
2587
  })(LicenseStatus || {});
2623
- const initialState$f = {
2588
+ const initialState$d = {
2624
2589
  users: {},
2625
2590
  currentUser: {
2626
2591
  id: 0,
@@ -2631,8 +2596,8 @@ var __publicField = (obj, key, value) => {
2631
2596
  };
2632
2597
  const userSlice = toolkit.createSlice({
2633
2598
  name: "users",
2634
- initialState: initialState$f,
2635
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2599
+ initialState: initialState$d,
2600
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2636
2601
  reducers: {
2637
2602
  setUsers: (state, action) => {
2638
2603
  const usersMapping = {};
@@ -2694,13 +2659,13 @@ var __publicField = (obj, key, value) => {
2694
2659
  const selectUsersAsMapping = (state) => state.userReducer.users;
2695
2660
  const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
2696
2661
  const userReducer = userSlice.reducer;
2697
- const initialState$e = {
2662
+ const initialState$c = {
2698
2663
  organizationAccesses: {}
2699
2664
  };
2700
2665
  const organizationAccessSlice = toolkit.createSlice({
2701
2666
  name: "organizationAccess",
2702
- initialState: initialState$e,
2703
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2667
+ initialState: initialState$c,
2668
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2704
2669
  reducers: {
2705
2670
  setOrganizationAccesses: (state, action) => {
2706
2671
  if (!Array.isArray(action.payload))
@@ -2763,13 +2728,13 @@ var __publicField = (obj, key, value) => {
2763
2728
  return organizationAccesses;
2764
2729
  };
2765
2730
  const organizationAccessReducer = organizationAccessSlice.reducer;
2766
- const initialState$d = {
2731
+ const initialState$b = {
2767
2732
  licenses: {}
2768
2733
  };
2769
2734
  const licenseSlice = toolkit.createSlice({
2770
2735
  name: "license",
2771
- initialState: initialState$d,
2772
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2736
+ initialState: initialState$b,
2737
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2773
2738
  reducers: {
2774
2739
  setLicenses: (state, action) => {
2775
2740
  if (!Array.isArray(action.payload))
@@ -2814,13 +2779,13 @@ var __publicField = (obj, key, value) => {
2814
2779
  (licenses) => Object.values(licenses).filter((license) => license.project).reduce((accum, license) => ({ ...accum, [license.project]: license }), {})
2815
2780
  );
2816
2781
  const licenseReducer = licenseSlice.reducer;
2817
- const initialState$c = {
2782
+ const initialState$a = {
2818
2783
  projectAccesses: {}
2819
2784
  };
2820
2785
  const projectAccessSlice = toolkit.createSlice({
2821
2786
  name: "projectAccess",
2822
- initialState: initialState$c,
2823
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2787
+ initialState: initialState$a,
2788
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2824
2789
  reducers: {
2825
2790
  setProjectAccesses: (state, action) => {
2826
2791
  if (!Array.isArray(action.payload))
@@ -2888,7 +2853,7 @@ var __publicField = (obj, key, value) => {
2888
2853
  return projectAccesses;
2889
2854
  };
2890
2855
  const projectAccessReducer = projectAccessSlice.reducer;
2891
- const initialState$b = {
2856
+ const initialState$9 = {
2892
2857
  projects: {},
2893
2858
  activeProjectId: null,
2894
2859
  recentProjectIds: [],
@@ -2898,7 +2863,7 @@ var __publicField = (obj, key, value) => {
2898
2863
  };
2899
2864
  const projectSlice = toolkit.createSlice({
2900
2865
  name: "projects",
2901
- initialState: initialState$b,
2866
+ initialState: initialState$9,
2902
2867
  reducers: {
2903
2868
  setProjects: (state, action) => {
2904
2869
  const projectsMap = {};
@@ -3085,14 +3050,14 @@ var __publicField = (obj, key, value) => {
3085
3050
  }
3086
3051
  )
3087
3052
  );
3088
- const initialState$a = {
3053
+ const initialState$8 = {
3089
3054
  organizations: {},
3090
3055
  activeOrganizationId: null
3091
3056
  };
3092
3057
  const organizationSlice = toolkit.createSlice({
3093
3058
  name: "organizations",
3094
- initialState: initialState$a,
3095
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
3059
+ initialState: initialState$8,
3060
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3096
3061
  reducers: {
3097
3062
  setOrganizations: (state, action) => {
3098
3063
  for (const org of action.payload) {
@@ -3211,14 +3176,14 @@ var __publicField = (obj, key, value) => {
3211
3176
  }
3212
3177
  };
3213
3178
  };
3214
- const initialState$9 = {
3179
+ const initialState$7 = {
3215
3180
  deletedRequests: [],
3216
3181
  latestRetryTime: 0
3217
3182
  };
3218
3183
  const outboxSlice = toolkit.createSlice({
3219
3184
  name: "outbox",
3220
- initialState: initialState$9,
3221
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
3185
+ initialState: initialState$7,
3186
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
3222
3187
  reducers: {
3223
3188
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
3224
3189
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -3250,7 +3215,7 @@ var __publicField = (obj, key, value) => {
3250
3215
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
3251
3216
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
3252
3217
  const outboxReducer = outboxSlice.reducer;
3253
- const initialState$8 = {
3218
+ const initialState$6 = {
3254
3219
  projectFiles: {},
3255
3220
  activeProjectFileId: null,
3256
3221
  isImportingProjectFile: false,
@@ -3258,8 +3223,8 @@ var __publicField = (obj, key, value) => {
3258
3223
  };
3259
3224
  const projectFileSlice = toolkit.createSlice({
3260
3225
  name: "projectFiles",
3261
- initialState: initialState$8,
3262
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3226
+ initialState: initialState$6,
3227
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3263
3228
  reducers: {
3264
3229
  addOrReplaceProjectFiles: (state, action) => {
3265
3230
  for (let fileObj of action.payload) {
@@ -3360,12 +3325,12 @@ var __publicField = (obj, key, value) => {
3360
3325
  const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProjectFileId;
3361
3326
  const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
3362
3327
  const projectFileReducer = projectFileSlice.reducer;
3363
- const initialState$7 = {
3328
+ const initialState$5 = {
3364
3329
  isRehydrated: false
3365
3330
  };
3366
3331
  const rehydratedSlice = toolkit.createSlice({
3367
3332
  name: "rehydrated",
3368
- initialState: initialState$7,
3333
+ initialState: initialState$5,
3369
3334
  // The `reducers` field lets us define reducers and generate associated actions
3370
3335
  reducers: {
3371
3336
  setRehydrated: (state, action) => {
@@ -3375,7 +3340,7 @@ var __publicField = (obj, key, value) => {
3375
3340
  });
3376
3341
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
3377
3342
  const rehydratedReducer = rehydratedSlice.reducer;
3378
- const initialState$6 = {
3343
+ const initialState$4 = {
3379
3344
  useIssueTemplate: false,
3380
3345
  placementMode: false,
3381
3346
  enableClustering: false,
@@ -3392,8 +3357,8 @@ var __publicField = (obj, key, value) => {
3392
3357
  };
3393
3358
  const settingSlice = toolkit.createSlice({
3394
3359
  name: "settings",
3395
- initialState: initialState$6,
3396
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3360
+ initialState: initialState$4,
3361
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3397
3362
  reducers: {
3398
3363
  setEnableDuplicateIssues: (state, action) => {
3399
3364
  state.useIssueTemplate = action.payload;
@@ -3439,248 +3404,146 @@ var __publicField = (obj, key, value) => {
3439
3404
  const settingReducer = settingSlice.reducer;
3440
3405
  const selectIsFetchingInitialData = (state) => state.settingReducer.isFetchingInitialData;
3441
3406
  const selectIsLoading = (state) => state.settingReducer.isLoading;
3442
- const LATEST_FORM_REVISION_CACHE = {};
3443
- function considerCachingFormRevision(formRevision, formId2, preferPending = false) {
3407
+ const LATEST_REVISION_CACHE = {};
3408
+ function considerCachingRevision(revision, formId2, preferPending = false) {
3444
3409
  var _a2;
3445
- if (!formRevision) {
3410
+ if (!revision) {
3446
3411
  if (!formId2) {
3447
- throw new Error("If form revision is null, formId is required.");
3412
+ throw new Error("If revision is null, formId is required.");
3448
3413
  }
3449
- const currentLatestFormRevision = getLatestFormRevisionFromCache(formId2);
3450
- if (currentLatestFormRevision)
3414
+ const currentLatestRevision = getLatestRevisionFromCache(formId2);
3415
+ if (currentLatestRevision)
3451
3416
  return;
3452
- LATEST_FORM_REVISION_CACHE[formId2] = null;
3417
+ LATEST_REVISION_CACHE[formId2] = null;
3453
3418
  return;
3454
3419
  }
3455
- if (formRevision.revision === "Pending") {
3420
+ if (revision.revision === "Pending") {
3456
3421
  if (preferPending) {
3457
- LATEST_FORM_REVISION_CACHE[formRevision.form] = formRevision;
3422
+ LATEST_REVISION_CACHE[revision.form] = revision;
3458
3423
  }
3459
3424
  return;
3460
3425
  }
3461
- const cachedFormRevision = (_a2 = LATEST_FORM_REVISION_CACHE[formRevision.form]) == null ? void 0 : _a2.revision;
3462
- if (formRevision.revision > (typeof cachedFormRevision === "number" ? cachedFormRevision : -1)) {
3463
- LATEST_FORM_REVISION_CACHE[formRevision.form] = formRevision;
3426
+ const cachedRevision = (_a2 = LATEST_REVISION_CACHE[revision.form]) == null ? void 0 : _a2.revision;
3427
+ if (revision.revision > (typeof cachedRevision === "number" ? cachedRevision : -1)) {
3428
+ LATEST_REVISION_CACHE[revision.form] = revision;
3464
3429
  }
3465
3430
  }
3466
- function getLatestFormRevisionFromCache(formId2) {
3467
- return LATEST_FORM_REVISION_CACHE[formId2];
3431
+ function getLatestRevisionFromCache(formId2) {
3432
+ return LATEST_REVISION_CACHE[formId2];
3468
3433
  }
3469
- const initialState$5 = {
3470
- formRevisions: {},
3471
- attachments: {}
3472
- };
3473
- const formRevisionsSlice = toolkit.createSlice({
3474
- name: "formRevisions",
3475
- initialState: initialState$5,
3476
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3434
+ const initialState$3 = {
3435
+ userForms: {},
3436
+ revisions: {},
3437
+ submissions: {},
3438
+ submissionAttachments: {},
3439
+ revisionAttachments: {}
3440
+ };
3441
+ const userFormSlice = toolkit.createSlice({
3442
+ name: "userForms",
3443
+ initialState: initialState$3,
3444
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3477
3445
  reducers: {
3478
- // revision related actions
3479
- setFormRevision: (state, action) => {
3480
- state.formRevisions[action.payload.offline_id] = action.payload;
3481
- considerCachingFormRevision(action.payload);
3446
+ setUserForms: (state, action) => {
3447
+ state.userForms = {};
3448
+ action.payload.forEach((userForm) => {
3449
+ state.userForms[userForm.offline_id] = userForm;
3450
+ });
3482
3451
  },
3483
- setFormRevisions: (state, action) => {
3484
- state.formRevisions = {};
3485
- for (const revision of action.payload) {
3486
- state.formRevisions[revision.offline_id] = revision;
3487
- considerCachingFormRevision(revision);
3488
- }
3452
+ addUserForm: (state, action) => {
3453
+ state.userForms[action.payload.offline_id] = action.payload;
3489
3454
  },
3490
- addFormRevision: (state, action) => {
3491
- if (state.formRevisions[action.payload.offline_id] !== void 0) {
3492
- throw new Error(`Revision with offline_id ${action.payload.offline_id} already exists`);
3493
- }
3494
- state.formRevisions[action.payload.offline_id] = action.payload;
3495
- considerCachingFormRevision(action.payload);
3455
+ addUserForms: (state, action) => {
3456
+ action.payload.forEach((userForm) => {
3457
+ state.userForms[userForm.offline_id] = userForm;
3458
+ });
3496
3459
  },
3497
- // TODO: @Audiopolis / Magnus - do we want to standardize using PayloadAction?
3498
- addFormRevisions: (state, action) => {
3499
- for (const userFormRevision of action.payload) {
3500
- if (state.formRevisions[userFormRevision.offline_id] !== void 0) {
3501
- throw new Error(`Revision with offline_id ${userFormRevision.offline_id} already exists`);
3502
- }
3503
- }
3504
- for (const userFormRevision of action.payload) {
3505
- state.formRevisions[userFormRevision.offline_id] = userFormRevision;
3506
- considerCachingFormRevision(userFormRevision);
3507
- }
3460
+ addUserFormRevisions: (state, action) => {
3461
+ action.payload.forEach((userFormRevision) => {
3462
+ state.revisions[userFormRevision.offline_id] = userFormRevision;
3463
+ considerCachingRevision(userFormRevision);
3464
+ });
3508
3465
  },
3509
- // UserFormRevisions do not get updated
3510
- deleteFormRevision: (state, action) => {
3511
- if (state.formRevisions[action.payload] === void 0) {
3512
- throw new Error(`Revision with offline_id ${action.payload} does not exist`);
3513
- }
3514
- delete state.formRevisions[action.payload];
3515
- delete LATEST_FORM_REVISION_CACHE[action.payload];
3466
+ addUserFormRevision: (state, action) => {
3467
+ state.revisions[action.payload.offline_id] = action.payload;
3468
+ considerCachingRevision(action.payload);
3516
3469
  },
3517
- deleteFormRevisions: (state, action) => {
3518
- for (const offlineId of action.payload) {
3519
- if (state.formRevisions[offlineId] === void 0) {
3520
- throw new Error(`Revision with offline_id ${offlineId} does not exist`);
3521
- }
3522
- }
3523
- for (const offlineId of action.payload) {
3524
- delete state.formRevisions[offlineId];
3525
- delete LATEST_FORM_REVISION_CACHE[offlineId];
3470
+ deleteUserFormRevision: (state, action) => {
3471
+ delete state.revisions[action.payload];
3472
+ delete LATEST_REVISION_CACHE[action.payload];
3473
+ },
3474
+ deleteUserFormRevisions: (state, action) => {
3475
+ for (const userFormRevision of action.payload) {
3476
+ delete state.revisions[userFormRevision.offline_id];
3477
+ delete LATEST_REVISION_CACHE[userFormRevision.offline_id];
3526
3478
  }
3527
3479
  },
3528
- // attachment related actions
3529
- setFormRevisionAttachments: (state, action) => {
3530
- state.attachments = {};
3531
- for (const attachment of action.payload) {
3532
- state.attachments[attachment.offline_id] = attachment;
3480
+ updateOrCreateUserFormSubmission: (state, action) => {
3481
+ state.submissions[action.payload.offline_id] = action.payload;
3482
+ },
3483
+ addUserFormSubmissionAttachment: (state, action) => {
3484
+ const submissionId = action.payload.submission;
3485
+ const submissionAttachments = state.submissionAttachments[submissionId];
3486
+ if (submissionAttachments) {
3487
+ submissionAttachments.push(action.payload);
3488
+ } else {
3489
+ state.submissionAttachments[submissionId] = [action.payload];
3533
3490
  }
3534
3491
  },
3535
- addFormRevisionAttachment: (state, action) => {
3536
- if (state.attachments[action.payload.offline_id] !== void 0) {
3537
- throw new Error(`Attachment with offline_id ${action.payload.offline_id} already exists`);
3492
+ addUserFormRevisionAttachment: (state, action) => {
3493
+ const revisionId = action.payload.revision;
3494
+ const revisionAttachments = state.revisionAttachments[revisionId];
3495
+ if (revisionAttachments) {
3496
+ revisionAttachments.push(action.payload);
3497
+ } else {
3498
+ state.revisionAttachments[revisionId] = [action.payload];
3538
3499
  }
3539
- state.attachments[action.payload.offline_id] = action.payload;
3540
3500
  },
3541
- addFormRevisionAttachments: (state, action) => {
3501
+ setUserFormSubmissionAttachments: (state, action) => {
3502
+ state.submissionAttachments = {};
3542
3503
  for (const attachment of action.payload) {
3543
- if (state.attachments[attachment.offline_id] !== void 0) {
3544
- throw new Error(`Attachment with offline_id ${attachment.offline_id} already exists`);
3504
+ const submissionId = attachment.submission;
3505
+ const submissionAttachments = state.submissionAttachments[submissionId];
3506
+ if (submissionAttachments) {
3507
+ submissionAttachments.push(attachment);
3508
+ } else {
3509
+ state.submissionAttachments[submissionId] = [attachment];
3545
3510
  }
3546
3511
  }
3512
+ },
3513
+ setUserFormRevisionAttachments: (state, action) => {
3514
+ state.revisionAttachments = {};
3547
3515
  for (const attachment of action.payload) {
3548
- state.attachments[attachment.offline_id] = attachment;
3516
+ const revisionId = attachment.revision;
3517
+ const revisionAttachments = state.revisionAttachments[revisionId];
3518
+ if (revisionAttachments) {
3519
+ revisionAttachments.push(attachment);
3520
+ } else {
3521
+ state.revisionAttachments[revisionId] = [attachment];
3522
+ }
3549
3523
  }
3550
3524
  },
3551
- deleteFormRevisionAttachment: (state, action) => {
3552
- if (state.attachments[action.payload] === void 0) {
3553
- throw new Error(`Attachment with offline_id ${action.payload} does not exist`);
3554
- }
3555
- delete state.attachments[action.payload];
3525
+ deleteUserFormSubmission: (state, action) => {
3526
+ delete state.submissions[action.payload];
3556
3527
  },
3557
- deleteFormRevisionAttachments: (state, action) => {
3558
- for (const offlineId of action.payload) {
3559
- if (state.attachments[offlineId] === void 0) {
3560
- throw new Error(`Attachment with offline_id ${offlineId} does not exist`);
3561
- }
3562
- }
3563
- for (const offlineId of action.payload) {
3564
- delete state.attachments[offlineId];
3528
+ deleteUserFormSubmissions: (state, action) => {
3529
+ for (const userFormSubmission of action.payload) {
3530
+ delete state.submissions[userFormSubmission.offline_id];
3565
3531
  }
3566
- }
3567
- }
3568
- });
3569
- const {
3570
- setFormRevision,
3571
- setFormRevisions,
3572
- addFormRevision,
3573
- addFormRevisions,
3574
- deleteFormRevision,
3575
- deleteFormRevisions,
3576
- setFormRevisionAttachments,
3577
- addFormRevisionAttachment,
3578
- addFormRevisionAttachments,
3579
- deleteFormRevisionAttachment,
3580
- deleteFormRevisionAttachments
3581
- } = formRevisionsSlice.actions;
3582
- const selectFormRevisionMapping = (state) => state.formRevisionReducer.formRevisions;
3583
- const selectFormRevisions = toolkit.createSelector(
3584
- [selectFormRevisionMapping],
3585
- (formRevisions) => Object.values(formRevisions)
3586
- );
3587
- const selectFormRevision = (formRevisionId) => (state) => {
3588
- return state.formRevisionReducer.formRevisions[formRevisionId];
3589
- };
3590
- const _selectLatestFormRevision = (formRevisions, formId2) => {
3591
- let ret = null;
3592
- for (const candidate of Object.values(formRevisions)) {
3593
- if (candidate.form === formId2 && (!ret || ret.revision < candidate.revision)) {
3594
- ret = candidate;
3595
- }
3596
- }
3597
- if (!ret) {
3598
- throw new Error("No form revision found for form " + formId2);
3599
- }
3600
- return ret;
3601
- };
3602
- const selectLatestFormRevisionOfForm = restructureCreateSelectorWithArgs(
3603
- toolkit.createSelector([selectFormRevisionMapping, (_state, formId2) => formId2], (revisions, formId2) => {
3604
- if (!formId2) {
3605
- throw new Error("formId is required");
3606
- }
3607
- return _selectLatestFormRevision(revisions, formId2);
3608
- })
3609
- );
3610
- const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
3611
- toolkit.createSelector([selectFormRevisions, (_state, formId2) => formId2], (revisions, formId2) => {
3612
- return revisions.filter((revision) => {
3613
- return revision.form === formId2;
3614
- });
3615
- })
3616
- );
3617
- const selectLatestFormRevisionsOfComponentTypes = restructureCreateSelectorWithArgs(
3618
- toolkit.createSelector(
3619
- [
3620
- (state) => state.formReducer.forms,
3621
- selectFormRevisionMapping,
3622
- (_state, componentTypeIds) => componentTypeIds
3623
- ],
3624
- (userForms, revisions, componentTypeIds) => {
3625
- const componentTypeIdsSet = new Set(componentTypeIds);
3626
- const ret = {};
3627
- for (const form of Object.values(userForms)) {
3628
- if (form.component_type && componentTypeIdsSet.has(form.component_type)) {
3629
- ret[form.component_type] = _selectLatestFormRevision(revisions, form.offline_id);
3630
- }
3631
- }
3632
- return ret;
3633
- }
3634
- )
3635
- );
3636
- const selectLatestFormRevisionByForm = toolkit.createSelector([selectFormRevisionMapping], (revisions) => {
3637
- const latestRevisions = {};
3638
- for (const revision of Object.values(revisions)) {
3639
- const formId2 = revision.form;
3640
- const currentLatestRevision = latestRevisions[formId2];
3641
- if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
3642
- latestRevisions[formId2] = revision;
3643
- }
3644
- }
3645
- return latestRevisions;
3646
- });
3647
- const selectUserFormRevisionAttachmentsMapping = (state) => {
3648
- return state.formRevisionReducer.attachments;
3649
- };
3650
- const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
3651
- toolkit.createSelector(
3652
- [selectUserFormRevisionAttachmentsMapping, (_state, revisionId) => revisionId],
3653
- (attachments, revisionId) => {
3654
- return Object.values(attachments).filter((attachment) => attachment.revision === revisionId);
3655
- }
3656
- )
3657
- );
3658
- const formRevisionReducer = formRevisionsSlice.reducer;
3659
- const initialState$4 = {
3660
- forms: {}
3661
- };
3662
- const formSlice = toolkit.createSlice({
3663
- name: "forms",
3664
- initialState: initialState$4,
3665
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3666
- reducers: {
3667
- setForms: (state, action) => {
3668
- state.forms = {};
3669
- action.payload.forEach((userForm) => {
3670
- state.forms[userForm.offline_id] = userForm;
3671
- });
3672
3532
  },
3673
- addForm: (state, action) => {
3674
- state.forms[action.payload.offline_id] = action.payload;
3533
+ addUserFormSubmissions: (state, action) => {
3534
+ for (const submission of action.payload) {
3535
+ state.submissions[submission.offline_id] = submission;
3536
+ }
3675
3537
  },
3676
- addForms: (state, action) => {
3677
- action.payload.forEach((userForm) => {
3678
- state.forms[userForm.offline_id] = userForm;
3538
+ setUserFormSubmissions: (state, action) => {
3539
+ state.submissions = {};
3540
+ action.payload.forEach((submission) => {
3541
+ state.submissions[submission.offline_id] = submission;
3679
3542
  });
3680
3543
  },
3681
3544
  favoriteForm: (state, action) => {
3682
3545
  const { formId: formId2 } = action.payload;
3683
- const form = state.forms[formId2];
3546
+ const form = state.userForms[formId2];
3684
3547
  if (!form) {
3685
3548
  throw new Error("No form exists with the id " + formId2);
3686
3549
  }
@@ -3688,23 +3551,48 @@ var __publicField = (obj, key, value) => {
3688
3551
  },
3689
3552
  unfavoriteForm: (state, action) => {
3690
3553
  const { formId: formId2 } = action.payload;
3691
- const form = state.forms[formId2];
3554
+ const form = state.userForms[formId2];
3692
3555
  if (!form) {
3693
3556
  throw new Error("No form exists with the id " + formId2);
3694
3557
  }
3695
3558
  form.favorite = false;
3696
3559
  },
3697
- deleteForm: (state, action) => {
3698
- delete state.forms[action.payload];
3560
+ deleteUserForm: (state, action) => {
3561
+ delete state.userForms[action.payload];
3699
3562
  }
3700
3563
  }
3701
3564
  });
3702
- const { setForms, addForm, addForms, favoriteForm, unfavoriteForm, deleteForm } = formSlice.actions;
3703
- const selectFilteredForms = restructureCreateSelectorWithArgs(
3565
+ const {
3566
+ addUserForm,
3567
+ addUserForms,
3568
+ addUserFormRevisions,
3569
+ updateOrCreateUserFormSubmission,
3570
+ addUserFormSubmissions,
3571
+ deleteUserFormSubmission,
3572
+ deleteUserFormSubmissions,
3573
+ favoriteForm,
3574
+ unfavoriteForm,
3575
+ deleteUserForm,
3576
+ deleteUserFormRevision,
3577
+ deleteUserFormRevisions,
3578
+ setUserFormSubmissions,
3579
+ addUserFormRevision,
3580
+ addUserFormSubmissionAttachment,
3581
+ addUserFormRevisionAttachment,
3582
+ setUserFormSubmissionAttachments,
3583
+ setUserFormRevisionAttachments
3584
+ } = userFormSlice.actions;
3585
+ const selectSubmissionAttachments = (submissionId) => (state) => {
3586
+ return state.userFormReducer.submissionAttachments[submissionId] || [];
3587
+ };
3588
+ const selectRevisionAttachments = (revisionId) => (state) => {
3589
+ return state.userFormReducer.revisionAttachments[revisionId] || [];
3590
+ };
3591
+ const selectFilteredUserForms = restructureCreateSelectorWithArgs(
3704
3592
  toolkit.createSelector(
3705
3593
  [
3706
- (state) => state.formReducer.forms,
3707
- (state) => state.formRevisionReducer.formRevisions,
3594
+ (state) => state.userFormReducer.userForms,
3595
+ (state) => state.userFormReducer.revisions,
3708
3596
  (_state, search) => search
3709
3597
  ],
3710
3598
  (userForms, revisions, search) => {
@@ -3738,188 +3626,63 @@ var __publicField = (obj, key, value) => {
3738
3626
  { memoizeOptions: { equalityCheck: reactRedux.shallowEqual } }
3739
3627
  )
3740
3628
  );
3741
- const selectForm = (formId2) => (state) => {
3742
- return state.formReducer.forms[formId2];
3629
+ const selectFormRevision = (revisionId) => (state) => {
3630
+ return state.userFormReducer.revisions[revisionId];
3743
3631
  };
3744
- const selectFormMapping = (state) => {
3745
- return state.formReducer.forms;
3632
+ const _selectLatestFormRevision = (revisions, formId2) => {
3633
+ let ret = null;
3634
+ for (const candidate of Object.values(revisions)) {
3635
+ if (candidate.form === formId2 && (!ret || ret.revision < candidate.revision)) {
3636
+ ret = candidate;
3637
+ }
3638
+ }
3639
+ if (!ret) {
3640
+ throw new Error("No revision found for form " + formId2);
3641
+ }
3642
+ return ret;
3746
3643
  };
3747
- const selectFormOfComponentType = restructureCreateSelectorWithArgs(
3644
+ const selectLatestFormRevision = restructureCreateSelectorWithArgs(
3748
3645
  toolkit.createSelector(
3749
- [selectFormMapping, (_state, componentTypeId) => componentTypeId],
3750
- (userForms, componentTypeId) => {
3751
- return Object.values(userForms).find((userForm) => userForm.component_type === componentTypeId);
3646
+ [(state) => state.userFormReducer.revisions, (_state, formId2) => formId2],
3647
+ (revisions, formId2) => {
3648
+ if (!formId2) {
3649
+ throw new Error("formId is required");
3650
+ }
3651
+ return _selectLatestFormRevision(revisions, formId2);
3752
3652
  }
3753
3653
  )
3754
3654
  );
3755
- const selectFormsCount = toolkit.createSelector([selectFormMapping], (userForms) => {
3756
- return Object.keys(userForms).length;
3757
- });
3758
- const selectGeneralFormCount = toolkit.createSelector([selectFormMapping], (userForms) => {
3759
- return Object.values(userForms).filter((form) => !form.component_type).length;
3760
- });
3761
- const formReducer = formSlice.reducer;
3762
- const initialState$3 = {
3763
- formSubmissions: {},
3764
- attachments: {}
3765
- };
3766
- const formSubmissionSlice = toolkit.createSlice({
3767
- name: "formSubmissions",
3768
- initialState: initialState$3,
3769
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3770
- reducers: {
3771
- setFormSubmission: (state, action) => {
3772
- state.formSubmissions[action.payload.offline_id] = action.payload;
3773
- },
3774
- setFormSubmissions: (state, action) => {
3775
- state.formSubmissions = {};
3776
- for (const submission of action.payload) {
3777
- state.formSubmissions[submission.offline_id] = submission;
3778
- }
3779
- },
3780
- addFormSubmission: (state, action) => {
3781
- if (state.formSubmissions[action.payload.offline_id] !== void 0) {
3782
- throw new Error(`Submission with offline_id ${action.payload.offline_id} already exists`);
3783
- }
3784
- state.formSubmissions[action.payload.offline_id] = action.payload;
3785
- },
3786
- addFormSubmissions: (state, action) => {
3787
- for (const submission of action.payload) {
3788
- if (state.formSubmissions[submission.offline_id] !== void 0) {
3789
- throw new Error(`Submission with offline_id ${submission.offline_id} already exists`);
3790
- }
3791
- }
3792
- for (const submission of action.payload) {
3793
- state.formSubmissions[submission.offline_id] = submission;
3794
- }
3795
- },
3796
- updateFormSubmission: (state, action) => {
3797
- if (state.formSubmissions[action.payload.offline_id] === void 0) {
3798
- throw new Error(`Submission with offline_id ${action.payload.offline_id} does not exist`);
3799
- }
3800
- state.formSubmissions[action.payload.offline_id] = action.payload;
3801
- },
3802
- updateFormSubmissions: (state, action) => {
3803
- for (const submission of action.payload) {
3804
- if (state.formSubmissions[submission.offline_id] === void 0) {
3805
- throw new Error(`Submission with offline_id ${submission.offline_id} does not exist`);
3806
- }
3807
- }
3808
- for (const submission of action.payload) {
3809
- state.formSubmissions[submission.offline_id] = submission;
3810
- }
3811
- },
3812
- deleteFormSubmission: (state, action) => {
3813
- if (state.formSubmissions[action.payload] === void 0) {
3814
- throw new Error(`Submission with offline_id ${action.payload} does not exist`);
3815
- }
3816
- delete state.formSubmissions[action.payload];
3817
- },
3818
- deleteFormSubmissions: (state, action) => {
3819
- for (const offlineId of action.payload) {
3820
- if (state.formSubmissions[offlineId] === void 0) {
3821
- throw new Error(`Submission with offline_id ${offlineId} does not exist`);
3822
- }
3823
- delete state.formSubmissions[offlineId];
3824
- }
3825
- for (const offlineId of action.payload) {
3826
- delete state.formSubmissions[offlineId];
3827
- }
3828
- },
3829
- // Attachments
3830
- addFormSubmissionAttachment: (state, action) => {
3831
- if (state.attachments[action.payload.offline_id] !== void 0) {
3832
- throw new Error(`Attachment with offline_id ${action.payload.offline_id} already exists`);
3833
- }
3834
- state.attachments[action.payload.offline_id] = action.payload;
3835
- },
3836
- addFormSubmissionAttachments: (state, action) => {
3837
- for (const attachment of action.payload) {
3838
- if (state.attachments[attachment.offline_id] !== void 0) {
3839
- throw new Error(`Attachment with offline_id ${attachment.offline_id} already exists`);
3840
- }
3841
- }
3842
- for (const attachment of action.payload) {
3843
- state.attachments[attachment.offline_id] = attachment;
3844
- }
3845
- },
3846
- // We only need a multi set for attachments because they are not updated, only added and deleted
3847
- setFormSubmissionAttachments: (state, action) => {
3848
- state.attachments = {};
3849
- for (const attachment of action.payload) {
3850
- state.attachments[attachment.offline_id] = attachment;
3851
- }
3852
- },
3853
- updateFormSubmissionAttachments: (state, action) => {
3854
- for (const attachment of action.payload) {
3855
- if (state.attachments[attachment.offline_id] === void 0) {
3856
- throw new Error(`Attachment with offline_id ${attachment.offline_id} does not exist`);
3857
- }
3858
- }
3859
- for (const attachment of action.payload) {
3860
- state.attachments[attachment.offline_id] = attachment;
3861
- }
3862
- },
3863
- // The delete actions for UserFormSubmissionAttachments are not used in the app, but are included for completeness
3864
- // Could be used if editing a submission is ever supported, will be applicable for supporting tip tap content in submissions
3865
- deleteFormSubmissionAttachment: (state, action) => {
3866
- if (state.attachments[action.payload] === void 0) {
3867
- throw new Error(`Attachment with offline_id ${action.payload} does not exist`);
3868
- }
3869
- delete state.attachments[action.payload];
3870
- },
3871
- deleteFormSubmissionAttachments: (state, action) => {
3872
- for (const offlineId of action.payload) {
3873
- if (state.attachments[offlineId] === void 0) {
3874
- throw new Error(`Attachment with offline_id ${offlineId} does not exist`);
3875
- }
3876
- delete state.attachments[offlineId];
3877
- }
3878
- }
3879
- }
3880
- });
3881
- const {
3882
- setFormSubmission,
3883
- setFormSubmissions,
3884
- addFormSubmission,
3885
- addFormSubmissions,
3886
- updateFormSubmission,
3887
- updateFormSubmissions,
3888
- deleteFormSubmission,
3889
- deleteFormSubmissions,
3890
- addFormSubmissionAttachment,
3891
- addFormSubmissionAttachments,
3892
- setFormSubmissionAttachments,
3893
- updateFormSubmissionAttachments,
3894
- deleteFormSubmissionAttachment,
3895
- deleteFormSubmissionAttachments
3896
- } = formSubmissionSlice.actions;
3897
- const selectFormSubmissionsMapping = (state) => {
3898
- return state.formSubmissionReducer.formSubmissions;
3899
- };
3900
- const selectFormSubmissions = toolkit.createSelector(
3901
- [selectFormSubmissionsMapping],
3902
- (submissions) => {
3903
- return Object.values(submissions);
3904
- }
3655
+ const selectUserForm = (formId2) => (state) => {
3656
+ return state.userFormReducer.userForms[formId2];
3657
+ };
3658
+ const selectSubmissionMapping = (state) => state.userFormReducer.submissions;
3659
+ const selectUserFormSubmission = (submissionId) => (state) => {
3660
+ return state.userFormReducer.submissions[submissionId];
3661
+ };
3662
+ const selectSubmissions = toolkit.createSelector([selectSubmissionMapping], (submissions) => Object.values(submissions));
3663
+ const selectRevisionMapping = (state) => state.userFormReducer.revisions;
3664
+ const selectRevisions = toolkit.createSelector([selectRevisionMapping], (revisions) => Object.values(revisions));
3665
+ const selectRevisionsForForm = restructureCreateSelectorWithArgs(
3666
+ toolkit.createSelector([selectRevisions, (_state, formId2) => formId2], (revisions, formId2) => {
3667
+ return revisions.filter((revision) => {
3668
+ return revision.form === formId2;
3669
+ });
3670
+ })
3905
3671
  );
3906
- const selectFormSubmission = (submissionId) => (state) => {
3907
- return state.formSubmissionReducer.formSubmissions[submissionId];
3908
- };
3909
- const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
3672
+ const selectSubmissionsForForm = restructureCreateSelectorWithArgs(
3910
3673
  toolkit.createSelector(
3911
- [selectFormSubmissions, selectFormRevisionMapping, (_state, formId2) => formId2],
3674
+ [selectSubmissions, selectRevisionMapping, (_state, formId2) => formId2],
3912
3675
  (submissions, revisionMapping, formId2) => {
3913
- return submissions.filter((submission) => {
3676
+ return Object.values(submissions).filter((submission) => {
3914
3677
  const revision = revisionMapping[submission.form_revision];
3915
3678
  return (revision == null ? void 0 : revision.form) === formId2;
3916
3679
  });
3917
3680
  }
3918
3681
  )
3919
3682
  );
3920
- const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
3683
+ const selectSubmissionsForIssue = restructureCreateSelectorWithArgs(
3921
3684
  toolkit.createSelector(
3922
- [selectFormSubmissions, (_state, issueId) => issueId],
3685
+ [(state) => state.userFormReducer.submissions, (_state, issueId) => issueId],
3923
3686
  (submissions, issueId) => {
3924
3687
  return Object.values(submissions).filter((submission) => {
3925
3688
  return submission.issue === issueId;
@@ -3927,9 +3690,9 @@ var __publicField = (obj, key, value) => {
3927
3690
  }
3928
3691
  )
3929
3692
  );
3930
- const selectFormSubmissionsOfComponent = restructureCreateSelectorWithArgs(
3693
+ const selectSubmissionsForComponent = restructureCreateSelectorWithArgs(
3931
3694
  toolkit.createSelector(
3932
- [selectFormSubmissions, (_state, componentId) => componentId],
3695
+ [selectSubmissions, (_state, componentId) => componentId],
3933
3696
  (submissions, componentId) => {
3934
3697
  return submissions.filter((submission) => {
3935
3698
  return submission.component === componentId;
@@ -3937,8 +3700,8 @@ var __publicField = (obj, key, value) => {
3937
3700
  }
3938
3701
  )
3939
3702
  );
3940
- const selectFormSubmissionsByComponents = toolkit.createSelector(
3941
- [selectFormSubmissionsMapping, selectComponentsMapping],
3703
+ const selectComponentSubmissionMapping = toolkit.createSelector(
3704
+ [selectSubmissionMapping, selectComponentsMapping],
3942
3705
  (submissions, components) => {
3943
3706
  var _a2;
3944
3707
  const componentSubmissionMapping = {};
@@ -3954,18 +3717,54 @@ var __publicField = (obj, key, value) => {
3954
3717
  return componentSubmissionMapping;
3955
3718
  }
3956
3719
  );
3957
- const selectFormSubmissionAttachmentsMapping = (state) => {
3958
- return state.formSubmissionReducer.attachments;
3720
+ const selectUserFormMapping = (state) => {
3721
+ return state.userFormReducer.userForms;
3959
3722
  };
3960
- const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
3723
+ const selectComponentTypeForm = restructureCreateSelectorWithArgs(
3961
3724
  toolkit.createSelector(
3962
- [selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
3963
- (attachmentsMapping, submissionId) => {
3964
- return Object.values(attachmentsMapping).filter((attachment) => attachment.submission === submissionId);
3725
+ [selectUserFormMapping, (_state, componentTypeId) => componentTypeId],
3726
+ (userForms, componentTypeId) => {
3727
+ return Object.values(userForms).find((userForm) => userForm.component_type === componentTypeId);
3965
3728
  }
3966
3729
  )
3967
3730
  );
3968
- const formSubmissionReducer = formSubmissionSlice.reducer;
3731
+ const selectLatestRevisionsFromComponentTypeIds = restructureCreateSelectorWithArgs(
3732
+ toolkit.createSelector(
3733
+ [
3734
+ selectUserFormMapping,
3735
+ selectRevisionMapping,
3736
+ (_state, componentTypeIds) => componentTypeIds
3737
+ ],
3738
+ (userForms, revisions, componentTypeIds) => {
3739
+ const componentTypeIdsSet = new Set(componentTypeIds);
3740
+ const ret = {};
3741
+ for (const form of Object.values(userForms)) {
3742
+ if (form.component_type && componentTypeIdsSet.has(form.component_type)) {
3743
+ ret[form.component_type] = _selectLatestFormRevision(revisions, form.offline_id);
3744
+ }
3745
+ }
3746
+ return ret;
3747
+ }
3748
+ )
3749
+ );
3750
+ const selectLatestRevisionByFormId = toolkit.createSelector([selectRevisionMapping], (revisions) => {
3751
+ const latestRevisions = {};
3752
+ for (const revision of Object.values(revisions)) {
3753
+ const formId2 = revision.form;
3754
+ const currentLatestRevision = latestRevisions[formId2];
3755
+ if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
3756
+ latestRevisions[formId2] = revision;
3757
+ }
3758
+ }
3759
+ return latestRevisions;
3760
+ });
3761
+ const selectNumberOfUserForms = toolkit.createSelector([selectUserFormMapping], (userForms) => {
3762
+ return Object.keys(userForms).length;
3763
+ });
3764
+ const selectNumberOfGeneralUserForms = toolkit.createSelector([selectUserFormMapping], (userForms) => {
3765
+ return Object.values(userForms).filter((form) => !form.component_type).length;
3766
+ });
3767
+ const userFormReducer = userFormSlice.reducer;
3969
3768
  const initialState$2 = {
3970
3769
  emailDomains: {}
3971
3770
  };
@@ -4193,9 +3992,6 @@ var __publicField = (obj, key, value) => {
4193
3992
  [selectDocumentAttachmentMapping],
4194
3993
  (mapping) => Object.values(mapping)
4195
3994
  );
4196
- const selectDocumentAttachment = (attachmentId) => (state) => {
4197
- return state.documentsReducer.attachments[attachmentId];
4198
- };
4199
3995
  const selectAttachmentsOfDocument = restructureCreateSelectorWithArgs(
4200
3996
  toolkit.createSelector(
4201
3997
  [selectAllDocumentAttachments, (_state, documentId) => documentId],
@@ -4263,9 +4059,7 @@ var __publicField = (obj, key, value) => {
4263
4059
  projectFileReducer,
4264
4060
  rehydratedReducer,
4265
4061
  settingReducer,
4266
- formReducer,
4267
- formRevisionReducer,
4268
- formSubmissionReducer,
4062
+ userFormReducer,
4269
4063
  userReducer,
4270
4064
  workspaceReducer,
4271
4065
  emailDomainsReducer,
@@ -4318,7 +4112,9 @@ var __publicField = (obj, key, value) => {
4318
4112
  throw new Error(`Failed to update index_workspace of issue ${issue.offline_id} to main workspace`);
4319
4113
  }
4320
4114
  }
4321
- const indexedForms = Object.values(draft.formReducer.forms).filter((form) => form.index_workspace === workspaceId);
4115
+ const indexedForms = Object.values(draft.userFormReducer.userForms).filter(
4116
+ (form) => form.index_workspace === workspaceId
4117
+ );
4322
4118
  for (const form of indexedForms) {
4323
4119
  form.index_workspace = mainWorkspace.offline_id;
4324
4120
  }
@@ -4796,23 +4592,6 @@ var __publicField = (obj, key, value) => {
4796
4592
  }
4797
4593
  }
4798
4594
  class AttachmentService extends BaseApiService {
4799
- processPresignedUrls(presignedUrls) {
4800
- for (const [sha1, presignedUrl] of Object.entries(presignedUrls)) {
4801
- console.debug(sha1, presignedUrl);
4802
- void this.enqueueRequest({
4803
- url: presignedUrl.url,
4804
- description: "Upload file to S3",
4805
- method: HttpMethod.POST,
4806
- isExternalUrl: true,
4807
- isAuthNeeded: false,
4808
- attachmentHash: sha1,
4809
- // TODO: can we use the sha1 as the blocker?
4810
- blockers: [`s3-${presignedUrl.fields.key}`],
4811
- blocks: [sha1],
4812
- s3url: presignedUrl
4813
- });
4814
- }
4815
- }
4816
4595
  fetchAll(projectId) {
4817
4596
  const promise = this.enqueueRequest({
4818
4597
  description: "Fetch attachments",
@@ -4839,7 +4618,6 @@ var __publicField = (obj, key, value) => {
4839
4618
  }
4840
4619
  const offlineAttachment = {
4841
4620
  ...attachmentPayload,
4842
- // TODO: just handle creating the objectURL in here, then the front end doesn't need to worry about it
4843
4621
  file: attachmentPayload.file.objectURL,
4844
4622
  file_name: attachmentPayload.file.name,
4845
4623
  file_type: attachmentPayload.file.type,
@@ -4873,7 +4651,6 @@ var __publicField = (obj, key, value) => {
4873
4651
  }
4874
4652
  const offlineAttachment = {
4875
4653
  ...attachmentPayload,
4876
- // TODO: just handle creating the objectURL in here, then the front end doesn't need to worry about it
4877
4654
  file: attachmentPayload.file.objectURL,
4878
4655
  file_name: attachmentPayload.file.name,
4879
4656
  file_type: attachmentPayload.file.type,
@@ -4907,7 +4684,6 @@ var __publicField = (obj, key, value) => {
4907
4684
  }
4908
4685
  const offlineAttachment = {
4909
4686
  ...attachmentPayload,
4910
- // TODO: just handle creating the objectURL in here, then the front end doesn't need to worry about it
4911
4687
  file: attachmentPayload.file.objectURL,
4912
4688
  file_name: attachmentPayload.file.name,
4913
4689
  file_type: attachmentPayload.file.type,
@@ -4973,54 +4749,26 @@ var __publicField = (obj, key, value) => {
4973
4749
  /** the outer Promise is needed to await the hashing of each file, which is required before offline use. If wanting to
4974
4750
  * attach promise handlers to the request to add the attachment in the backend, apply it on the promise returned from the
4975
4751
  * OptimisticModelResult. */
4976
- // note the method is only marked as async since files needs to be hashed
4977
- async attachFilesToIssue(files, issueId) {
4978
- const { store } = this.client;
4979
- const offlineAttachments = [];
4980
- const attachmentsPayload = [];
4981
- const currentUser = store.getState().userReducer.currentUser;
4982
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
4983
- for (const file of files) {
4984
- const attachment = offline({
4985
- file: URL.createObjectURL(file),
4986
- file_name: file.name,
4987
- file_type: file.type,
4988
- file_sha1: await hashFile(file),
4989
- description: "",
4990
- submitted_at: submittedAt,
4991
- created_by: currentUser.id,
4992
- issue: issueId
4993
- });
4994
- attachmentsPayload.push({
4995
- offline_id: attachment.offline_id,
4996
- name: attachment.file_name,
4997
- sha1: attachment.file_sha1,
4998
- description: attachment.description,
4999
- created_by: attachment.created_by,
5000
- issue_id: attachment.issue
5001
- });
5002
- offlineAttachments.push(attachment);
5003
- }
5004
- store.dispatch(addIssueAttachments(offlineAttachments));
5005
- const promise = this.enqueueRequest({
5006
- description: "Attach files to issue",
5007
- method: HttpMethod.POST,
5008
- url: `/issues/${issueId}/attach/`,
5009
- payload: {
5010
- submitted_at: submittedAt,
5011
- attachments: attachmentsPayload,
5012
- files: await constructUploadedFilePayloads(files)
5013
- },
5014
- blocks: offlineAttachments.map((attachment) => attachment.offline_id),
5015
- blockers: offlineAttachments.map((attachment) => attachment.file_sha1)
5016
- });
5017
- promise.then(({ attachments, presigned_urls }) => {
5018
- store.dispatch(updateIssueAttachments(attachments));
5019
- this.processPresignedUrls(presigned_urls);
5020
- }).catch(() => {
5021
- store.dispatch(removeIssueAttachments(offlineAttachments.map((attachment) => attachment.offline_id)));
4752
+ attachFilesToIssue(filesToSubmit, issueId) {
4753
+ return filesToSubmit.map((file) => {
4754
+ if (!(file instanceof File)) {
4755
+ throw new Error("Expected a File instance.");
4756
+ }
4757
+ const photoAttachmentPromise = async (file2) => {
4758
+ const hash = await hashFile(file2);
4759
+ const attachment = offline({
4760
+ file: file2,
4761
+ file_name: file2.name,
4762
+ file_type: file2.type,
4763
+ issue: issueId,
4764
+ file_sha1: hash,
4765
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
4766
+ created_by: this.client.store.getState().userReducer.currentUser.id
4767
+ });
4768
+ return this.addIssueAttachment(attachment);
4769
+ };
4770
+ return photoAttachmentPromise(file);
5022
4771
  });
5023
- return [offlineAttachments, promise.then(({ attachments }) => attachments)];
5024
4772
  }
5025
4773
  attachFilesToComponent(filesToSubmit, componentId) {
5026
4774
  return filesToSubmit.map((file) => {
@@ -7003,7 +6751,7 @@ var __publicField = (obj, key, value) => {
7003
6751
  ...revisionAttachmentPayload,
7004
6752
  file: URL.createObjectURL(image)
7005
6753
  };
7006
- store.dispatch(addFormRevisionAttachment(offlinePayload));
6754
+ store.dispatch(addUserFormRevisionAttachment(offlinePayload));
7007
6755
  return attach;
7008
6756
  });
7009
6757
  });
@@ -7037,8 +6785,8 @@ var __publicField = (obj, key, value) => {
7037
6785
  revision: 0
7038
6786
  };
7039
6787
  const { store } = this.client;
7040
- store.dispatch(addForm(retForm));
7041
- store.dispatch(addFormRevision(retRevision));
6788
+ store.dispatch(addUserForm(retForm));
6789
+ store.dispatch(addUserFormRevision(retRevision));
7042
6790
  const formPromise = this.enqueueRequest({
7043
6791
  description: "Create form",
7044
6792
  method: HttpMethod.POST,
@@ -7056,8 +6804,8 @@ var __publicField = (obj, key, value) => {
7056
6804
  });
7057
6805
  const attachImagesPromises = this.getAttachImagePromises(images, offlineRevisionPayload.offline_id);
7058
6806
  void formPromise.catch((e) => {
7059
- store.dispatch(deleteForm(retForm.offline_id));
7060
- store.dispatch(deleteFormRevision(retRevision.offline_id));
6807
+ store.dispatch(deleteUserForm(retForm.offline_id));
6808
+ store.dispatch(deleteUserFormRevision(retRevision.offline_id));
7061
6809
  throw e;
7062
6810
  });
7063
6811
  const settledPromise = Promise.all([formPromise, ...attachImagesPromises]).then(() => formPromise);
@@ -7099,7 +6847,7 @@ var __publicField = (obj, key, value) => {
7099
6847
  revision: "Pending",
7100
6848
  form: formId2
7101
6849
  };
7102
- store.dispatch(addFormRevision(fullRevision));
6850
+ store.dispatch(addUserFormRevision(fullRevision));
7103
6851
  const promise = this.enqueueRequest({
7104
6852
  description: "Create form revision",
7105
6853
  method: HttpMethod.PATCH,
@@ -7113,9 +6861,9 @@ var __publicField = (obj, key, value) => {
7113
6861
  });
7114
6862
  const attachImagesPromises = this.getAttachImagePromises(images, offlineRevision.offline_id);
7115
6863
  void promise.then((result) => {
7116
- store.dispatch(setFormRevision(result));
6864
+ store.dispatch(addUserFormRevision(result));
7117
6865
  }).catch(() => {
7118
- store.dispatch(deleteFormRevision(fullRevision.offline_id));
6866
+ store.dispatch(deleteUserFormRevision(fullRevision.offline_id));
7119
6867
  });
7120
6868
  const settledPromise = Promise.all([promise, ...attachImagesPromises]).then(() => promise);
7121
6869
  return [fullRevision, settledPromise];
@@ -7157,19 +6905,19 @@ var __publicField = (obj, key, value) => {
7157
6905
  async delete(formId2) {
7158
6906
  const { store } = this.client;
7159
6907
  const state = store.getState();
7160
- const userForm = selectForm(formId2)(state);
6908
+ const userForm = selectUserForm(formId2)(state);
7161
6909
  if (!userForm) {
7162
6910
  throw new Error("Expected userForm to exist");
7163
6911
  }
7164
- const userFormSubmissions = selectFormSubmissionsOfForm(formId2)(state);
6912
+ const userFormSubmissions = selectSubmissionsForForm(formId2)(state);
7165
6913
  if (userFormSubmissions && userFormSubmissions.length > 0) {
7166
- store.dispatch(deleteFormSubmissions(userFormSubmissions.map(({ offline_id }) => offline_id)));
6914
+ store.dispatch(deleteUserFormSubmissions(userFormSubmissions));
7167
6915
  }
7168
- const userFormRevisions = selectFormRevisionsOfForm(formId2)(state);
6916
+ const userFormRevisions = selectRevisionsForForm(formId2)(state);
7169
6917
  if (userFormRevisions && userFormRevisions.length > 0) {
7170
- store.dispatch(deleteFormRevisions(userFormRevisions.map(({ offline_id }) => offline_id)));
6918
+ store.dispatch(deleteUserFormRevisions(userFormRevisions));
7171
6919
  }
7172
- store.dispatch(deleteForm(formId2));
6920
+ store.dispatch(deleteUserForm(formId2));
7173
6921
  try {
7174
6922
  return await this.enqueueRequest({
7175
6923
  description: "Delete form",
@@ -7179,12 +6927,12 @@ var __publicField = (obj, key, value) => {
7179
6927
  blocks: []
7180
6928
  });
7181
6929
  } catch (e) {
7182
- store.dispatch(addForm(userForm));
6930
+ store.dispatch(addUserForm(userForm));
7183
6931
  if (userFormRevisions && userFormRevisions.length > 0) {
7184
- store.dispatch(addFormRevisions(userFormRevisions));
6932
+ store.dispatch(addUserFormRevisions(userFormRevisions));
7185
6933
  }
7186
6934
  if (userFormSubmissions && userFormSubmissions.length > 0) {
7187
- store.dispatch(addFormSubmissions(userFormSubmissions));
6935
+ store.dispatch(addUserFormSubmissions(userFormSubmissions));
7188
6936
  }
7189
6937
  throw e;
7190
6938
  }
@@ -7198,15 +6946,16 @@ var __publicField = (obj, key, value) => {
7198
6946
  blockers: [],
7199
6947
  blocks: []
7200
6948
  });
7201
- store.dispatch(setForms(Object.values(result.forms)));
7202
- store.dispatch(setFormRevisions(Object.values(result.revisions)));
7203
- store.dispatch(setFormRevisionAttachments(Object.values(result.attachments)));
6949
+ store.dispatch(addUserForms(Object.values(result.forms)));
6950
+ store.dispatch(addUserFormRevisions(Object.values(result.revisions)));
6951
+ store.dispatch(setUserFormRevisionAttachments(Object.values(result.attachments)));
7204
6952
  }
7205
6953
  }
7206
6954
  const isArrayOfFiles = (value) => {
7207
6955
  return Array.isArray(value) && value[0] instanceof File;
7208
6956
  };
7209
- const separateFilesFromValues = (values) => {
6957
+ const separateFilesFromValues = (payload) => {
6958
+ const { values } = payload;
7210
6959
  const files = {};
7211
6960
  const newValues = {};
7212
6961
  for (const key in values) {
@@ -7221,13 +6970,17 @@ var __publicField = (obj, key, value) => {
7221
6970
  newValues[key] = value;
7222
6971
  }
7223
6972
  }
7224
- return { values: newValues, files };
6973
+ const payloadWithoutFiles = {
6974
+ ...payload,
6975
+ values: newValues
6976
+ };
6977
+ return { payloadWithoutFiles, files };
7225
6978
  };
7226
6979
  class UserFormSubmissionService extends BaseApiService {
7227
6980
  constructor() {
7228
6981
  super(...arguments);
7229
6982
  // Attach files to submission, after uploading them to S3
7230
- __publicField(this, "getAttachFilesPromises", (files, submission) => {
6983
+ __publicField(this, "getAttachFilesPromises", (files, payload) => {
7231
6984
  const { store } = this.client;
7232
6985
  return Object.entries(files).map(async ([key, fileArray]) => {
7233
6986
  const attachResults = [];
@@ -7237,27 +6990,24 @@ var __publicField = (obj, key, value) => {
7237
6990
  const [fileProps] = await this.client.files.uploadFileToS3(sha1);
7238
6991
  const submissionAttachmentPayload = offline({
7239
6992
  ...fileProps,
7240
- submission: submission.offline_id,
6993
+ submission: payload.offline_id,
7241
6994
  field_identifier: key
7242
6995
  });
7243
6996
  const attach = await this.enqueueRequest({
7244
6997
  description: "Attach file to form submission",
7245
6998
  method: HttpMethod.POST,
7246
- url: `/forms/submission/${submission.offline_id}/attachments/`,
6999
+ url: `/forms/submission/${payload.offline_id}/attachments/`,
7247
7000
  payload: submissionAttachmentPayload,
7248
- blockers: [
7249
- submission.component,
7250
- submission.component_stage,
7251
- submission.issue,
7252
- submission.form_revision
7253
- ].filter((x) => x !== void 0),
7001
+ blockers: [payload.component, payload.component_stage, payload.issue, payload.form_revision].filter(
7002
+ (x) => x !== void 0
7003
+ ),
7254
7004
  blocks: [submissionAttachmentPayload.offline_id]
7255
7005
  });
7256
7006
  const offlinePayload = {
7257
7007
  ...submissionAttachmentPayload,
7258
7008
  file: URL.createObjectURL(file)
7259
7009
  };
7260
- store.dispatch(addFormSubmissionAttachment(offlinePayload));
7010
+ store.dispatch(addUserFormSubmissionAttachment(offlinePayload));
7261
7011
  attachResults.push(attach);
7262
7012
  }
7263
7013
  return attachResults;
@@ -7271,165 +7021,70 @@ var __publicField = (obj, key, value) => {
7271
7021
  if (!activeProjectId) {
7272
7022
  throw new Error("Expected an active project");
7273
7023
  }
7274
- const { values, files } = separateFilesFromValues(payload.values);
7275
- const offlineSubmission = {
7276
- ...payload,
7277
- values,
7278
- created_by: state.userReducer.currentUser.id,
7279
- submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7280
- };
7024
+ const { payloadWithoutFiles, files } = separateFilesFromValues(payload);
7281
7025
  const promise = this.enqueueRequest({
7282
7026
  description: "Respond to form",
7283
7027
  method: HttpMethod.POST,
7284
7028
  url: `/forms/revisions/${payload.form_revision}/respond/`,
7285
- payload: { ...offlineSubmission, project: activeProjectId },
7029
+ payload: { ...payloadWithoutFiles, project: activeProjectId },
7286
7030
  blockers: [payload.issue, payload.component, payload.component_stage, "add-form-entry"].filter(
7287
7031
  (x) => x !== void 0
7288
7032
  ),
7289
7033
  blocks: [payload.offline_id]
7290
7034
  });
7291
- const attachFilesPromises = this.getAttachFilesPromises(files, offlineSubmission);
7292
- store.dispatch(addFormSubmission(offlineSubmission));
7035
+ const attachFilesPromises = this.getAttachFilesPromises(files, payload);
7036
+ const now = (/* @__PURE__ */ new Date()).toISOString();
7037
+ const fullOfflineResult = {
7038
+ ...payload,
7039
+ created_by: state.userReducer.currentUser.id,
7040
+ created_at: now,
7041
+ updated_at: now
7042
+ };
7043
+ const offlineResultWithoutFiles = {
7044
+ ...fullOfflineResult,
7045
+ ...payloadWithoutFiles
7046
+ };
7047
+ store.dispatch(updateOrCreateUserFormSubmission(offlineResultWithoutFiles));
7293
7048
  void promise.then((result) => {
7294
7049
  store.dispatch(addActiveProjectFormSubmissionsCount(1));
7295
- store.dispatch(setFormSubmission(result));
7050
+ store.dispatch(updateOrCreateUserFormSubmission(result));
7296
7051
  return result;
7297
7052
  }).catch(() => {
7298
- store.dispatch(deleteFormSubmission(payload.offline_id));
7053
+ store.dispatch(deleteUserFormSubmission(payload.offline_id));
7299
7054
  store.dispatch(addActiveProjectFormSubmissionsCount(-1));
7300
7055
  });
7301
7056
  const settledPromise = Promise.all([promise, ...attachFilesPromises]).then(() => promise);
7302
- return [offlineSubmission, settledPromise];
7303
- }
7304
- // Note currently the bulkAdd method is specific to form submissions for components
7305
- // TODO: adapt the support bulk adding to any model type
7306
- async bulkAdd(args) {
7307
- const { form_revision, values: argsValues, componentOfflineIds } = args;
7308
- const { store } = this.client;
7309
- const offlineSubmissions = [];
7310
- const offlineAttachments = [];
7311
- const submissionOfflineIds = [];
7312
- const submissionsPayload = [];
7313
- const attachmentsPayload = [];
7314
- const { values, files } = separateFilesFromValues(argsValues);
7315
- const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7316
- const createdBy = store.getState().userReducer.currentUser.id;
7317
- for (const component_id of componentOfflineIds) {
7318
- const submission = offline({
7319
- form_revision,
7320
- values,
7321
- created_by: createdBy,
7322
- submitted_at: submittedAt,
7323
- component: component_id
7324
- });
7325
- submissionOfflineIds.push(submission.offline_id);
7326
- submissionsPayload.push({ offline_id: submission.offline_id, component_id });
7327
- offlineSubmissions.push(submission);
7328
- for (const [fieldIdentifier, fileArray] of Object.entries(files)) {
7329
- for (const file of fileArray) {
7330
- const sha1 = await hashFile(file);
7331
- await this.client.files.addCache(file, sha1);
7332
- const offlineAttachment = offline({
7333
- file_name: file.name,
7334
- file_sha1: sha1,
7335
- file: URL.createObjectURL(file),
7336
- submission: submission.offline_id,
7337
- field_identifier: fieldIdentifier
7338
- });
7339
- offlineAttachments.push(offlineAttachment);
7340
- attachmentsPayload.push({
7341
- offline_id: offlineAttachment.offline_id,
7342
- submission_id: submission.offline_id,
7343
- sha1,
7344
- name: file.name,
7345
- field_identifier: fieldIdentifier
7346
- });
7347
- }
7348
- }
7349
- }
7350
- const filesRecord = {};
7351
- for (const file of Object.values(files).flat()) {
7352
- const sha1 = await hashFile(file);
7353
- filesRecord[sha1] = {
7354
- sha1,
7355
- extension: file.name.split(".").pop() || "",
7356
- file_type: file.type,
7357
- size: file.size
7358
- };
7359
- }
7360
- store.dispatch(addFormSubmissions(offlineSubmissions));
7361
- store.dispatch(addFormSubmissionAttachments(offlineAttachments));
7362
- const promise = this.enqueueRequest({
7363
- description: "Bulk add form submissions",
7364
- method: HttpMethod.POST,
7365
- url: `/forms/revisions/${form_revision}/bulk-respond/`,
7366
- payload: {
7367
- form_data: values,
7368
- submitted_at: submittedAt,
7369
- submissions: submissionsPayload,
7370
- attachments: attachmentsPayload,
7371
- files: Object.values(filesRecord)
7372
- },
7373
- blockers: componentOfflineIds,
7374
- blocks: submissionOfflineIds
7375
- });
7376
- promise.then(({ submissions, attachments, presigned_urls }) => {
7377
- store.dispatch(updateFormSubmissions(submissions));
7378
- store.dispatch(updateFormSubmissionAttachments(attachments));
7379
- for (const [sha1, presigned_url] of Object.entries(presigned_urls)) {
7380
- const file = filesRecord[sha1];
7381
- if (!file)
7382
- continue;
7383
- void this.enqueueRequest({
7384
- url: presigned_url.url,
7385
- description: "Upload file",
7386
- method: HttpMethod.POST,
7387
- isExternalUrl: true,
7388
- isAuthNeeded: false,
7389
- attachmentHash: sha1,
7390
- blockers: [`s3-${file.sha1}.${file.extension}`],
7391
- blocks: [sha1],
7392
- s3url: presigned_url
7393
- });
7394
- }
7395
- }).catch(() => {
7396
- store.dispatch(deleteFormSubmissions(submissionOfflineIds));
7397
- store.dispatch(deleteFormSubmissionAttachments(offlineAttachments.map((x) => x.offline_id)));
7398
- });
7399
- return [offlineSubmissions, promise.then(({ submissions }) => submissions)];
7057
+ return [fullOfflineResult, settledPromise];
7400
7058
  }
7401
7059
  update(submission) {
7402
7060
  const { store } = this.client;
7403
- const { values, files } = separateFilesFromValues(submission.values);
7061
+ const { payloadWithoutFiles, files } = separateFilesFromValues(submission);
7062
+ if (!("created_by" in payloadWithoutFiles) || !("created_at" in payloadWithoutFiles)) {
7063
+ throw new Error("Expected payloadWithoutFiles to have created_by and created_at fields.");
7064
+ }
7404
7065
  const attachFilesPromises = this.getAttachFilesPromises(files, submission);
7405
- const offlineSubmission = {
7406
- ...submission,
7407
- values
7066
+ const fullResult = {
7067
+ ...payloadWithoutFiles,
7068
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
7408
7069
  };
7409
- const submissionToBeUpdated = store.getState().formSubmissionReducer.formSubmissions[submission.offline_id];
7410
- store.dispatch(updateFormSubmission(offlineSubmission));
7070
+ store.dispatch(updateOrCreateUserFormSubmission(fullResult));
7411
7071
  const promise = this.enqueueRequest({
7412
7072
  description: "Patch form submission",
7413
7073
  method: HttpMethod.PATCH,
7414
7074
  url: `/forms/submissions/${submission.offline_id}/`,
7415
- payload: offlineSubmission,
7416
- blockers: [offlineSubmission.issue, offlineSubmission.component, offlineSubmission.component_stage].filter(
7075
+ payload: fullResult,
7076
+ blockers: [fullResult.issue, fullResult.component, fullResult.component_stage].filter(
7417
7077
  (x) => x !== void 0
7418
7078
  ),
7419
- blocks: [offlineSubmission.offline_id]
7420
- });
7421
- promise.then((createdSubmission) => {
7422
- store.dispatch(setFormSubmission(createdSubmission));
7423
- }).catch(() => {
7424
- store.dispatch(setFormSubmission(submissionToBeUpdated));
7079
+ blocks: [fullResult.offline_id]
7425
7080
  });
7426
- return [offlineSubmission, Promise.all([promise, ...attachFilesPromises]).then(() => promise)];
7081
+ return Promise.all([promise, ...attachFilesPromises]).then(() => promise);
7427
7082
  }
7428
7083
  async delete(submissionId) {
7429
7084
  const { store } = this.client;
7430
7085
  const state = store.getState();
7431
- const submission = state.formSubmissionReducer.formSubmissions[submissionId];
7432
- store.dispatch(deleteFormSubmission(submissionId));
7086
+ const submission = state.userFormReducer.submissions[submissionId];
7087
+ store.dispatch(deleteUserFormSubmission(submissionId));
7433
7088
  store.dispatch(addActiveProjectFormSubmissionsCount(-1));
7434
7089
  try {
7435
7090
  return await this.enqueueRequest({
@@ -7440,8 +7095,10 @@ var __publicField = (obj, key, value) => {
7440
7095
  blocks: []
7441
7096
  });
7442
7097
  } catch (e) {
7443
- store.dispatch(addActiveProjectFormSubmissionsCount(1));
7444
- store.dispatch(addFormSubmission(submission));
7098
+ if (submission) {
7099
+ store.dispatch(addActiveProjectFormSubmissionsCount(1));
7100
+ store.dispatch(updateOrCreateUserFormSubmission(submission));
7101
+ }
7445
7102
  throw e;
7446
7103
  }
7447
7104
  }
@@ -7455,7 +7112,7 @@ var __publicField = (obj, key, value) => {
7455
7112
  blockers: [],
7456
7113
  blocks: []
7457
7114
  });
7458
- store.dispatch(setFormSubmissions(submissions));
7115
+ store.dispatch(setUserFormSubmissions(submissions));
7459
7116
  const attachments = await this.enqueueRequest({
7460
7117
  description: "Fetch form attachments",
7461
7118
  method: HttpMethod.GET,
@@ -7463,7 +7120,7 @@ var __publicField = (obj, key, value) => {
7463
7120
  blockers: [],
7464
7121
  blocks: []
7465
7122
  });
7466
- store.dispatch(setFormSubmissionAttachments(attachments));
7123
+ store.dispatch(setUserFormSubmissionAttachments(attachments));
7467
7124
  }
7468
7125
  }
7469
7126
  class WorkspaceService extends BaseApiService {
@@ -14322,7 +13979,7 @@ var __publicField = (obj, key, value) => {
14322
13979
  };
14323
13980
  const useAttachImagesToFormRevisionFields = (revision) => {
14324
13981
  const { sdk } = useSDK();
14325
- const attachments = useAppSelector(selectAttachmentsOfFormRevision((revision == null ? void 0 : revision.offline_id) ?? ""));
13982
+ const attachments = useAppSelector(selectRevisionAttachments((revision == null ? void 0 : revision.offline_id) ?? ""));
14326
13983
  return React.useMemo(() => {
14327
13984
  if (!revision || !attachments)
14328
13985
  return revision;
@@ -14419,7 +14076,7 @@ var __publicField = (obj, key, value) => {
14419
14076
  return formRevisionToSchema(revisionWithImages, { readonly: true });
14420
14077
  }, [revisionWithImages]);
14421
14078
  const submissionValuesWithAttachments = React.useMemo(() => {
14422
- const attachments = selectAttachmentsOfFormSubmission(submission.offline_id)(sdk.store.getState()) ?? [];
14079
+ const attachments = selectSubmissionAttachments(submission.offline_id)(sdk.store.getState()) ?? [];
14423
14080
  const downloadedAttachments = {};
14424
14081
  for (const attachment of attachments) {
14425
14082
  const promise = sdk.files.fetchFileFromUrl(attachment.file, attachment.file_sha1, attachment.file_name);
@@ -14469,8 +14126,8 @@ var __publicField = (obj, key, value) => {
14469
14126
  }
14470
14127
  return ret;
14471
14128
  }, [filter, maxResults, ownerFilter]);
14472
- const userForms = useAppSelector(selectFilteredForms(ownerFilterOptions)) ?? [];
14473
- const userFormMapping = useAppSelector(selectFormMapping);
14129
+ const userForms = useAppSelector(selectFilteredUserForms(ownerFilterOptions)) ?? [];
14130
+ const userFormMapping = useAppSelector(selectUserFormMapping);
14474
14131
  const attachableUserForms = userForms.filter((form) => !form.component_type);
14475
14132
  const attachableUserFormMapping = Object.values(userFormMapping).filter(
14476
14133
  (form) => !form.component_type
@@ -14503,7 +14160,7 @@ var __publicField = (obj, key, value) => {
14503
14160
  const handleChange = React.useCallback((e) => {
14504
14161
  setFilter(e.currentTarget.value);
14505
14162
  }, []);
14506
- const numberOfForms = useAppSelector(selectGeneralFormCount) || 0;
14163
+ const numberOfForms = useAppSelector(selectNumberOfGeneralUserForms) || 0;
14507
14164
  const numberOfHiddenForms = numberOfForms - attachableUserForms.length;
14508
14165
  const overflowMessage = attachableUserForms.length == maxResults && numberOfHiddenForms > 0 ? `Only the first ${maxResults} results are shown (${numberOfHiddenForms} hidden)` : numberOfHiddenForms > 0 && `${numberOfHiddenForms} hidden forms`;
14509
14166
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { ref, direction: "column", gap: "2", children: [
@@ -14597,13 +14254,16 @@ var __publicField = (obj, key, value) => {
14597
14254
  const { submission, onSubmissionClick, compact, labelType, rowDecorator } = props;
14598
14255
  const currentUser = useAppSelector(selectCurrentUser);
14599
14256
  const createdBy = useAppSelector(selectUser("created_by" in submission ? submission.created_by : currentUser.id));
14600
- const dateToUse = submission.submitted_at;
14601
- const formattedDateTime = getLocalDateString(dateToUse);
14257
+ const dateToUse = getCreatedAtOrSubmittedAtDate(submission);
14258
+ const formattedDateTime = isToday(dateToUse) ? dateToUse.toLocaleTimeString([], {
14259
+ hour: "2-digit",
14260
+ minute: "2-digit"
14261
+ }) : getLocalDateString(dateToUse);
14602
14262
  const revision = useAppSelector(selectFormRevision(submission.form_revision));
14603
14263
  if (!revision) {
14604
14264
  throw new Error(`Could not find revision ${submission.form_revision} for submission ${submission.offline_id}.`);
14605
14265
  }
14606
- const latestRevisionNumber = (_a2 = useAppSelector(selectLatestFormRevisionOfForm(revision.form))) == null ? void 0 : _a2.revision;
14266
+ const latestRevisionNumber = (_a2 = useAppSelector(selectLatestFormRevision(revision.form))) == null ? void 0 : _a2.revision;
14607
14267
  const creatorProfileSrc = useFileSrc({
14608
14268
  file: (createdBy == null ? void 0 : createdBy.profile.file) ?? null,
14609
14269
  fileSha1: (createdBy == null ? void 0 : createdBy.profile.file_sha1) ?? null
@@ -14634,6 +14294,10 @@ var __publicField = (obj, key, value) => {
14634
14294
  return row;
14635
14295
  });
14636
14296
  FormSubmissionBrowserEntry.displayName = "FormSubmissionBrowserEntry";
14297
+ const getCreatedAtOrSubmittedAtDate = (submission) => {
14298
+ const date = "created_at" in submission ? submission.created_at : submission.submitted_at;
14299
+ return new Date(date);
14300
+ };
14637
14301
  const FormSubmissionBrowser = React.memo((props) => {
14638
14302
  const {
14639
14303
  formId: formId2,
@@ -14647,10 +14311,10 @@ var __publicField = (obj, key, value) => {
14647
14311
  if (!!formId2 === !!propSubmissions) {
14648
14312
  throw new Error("Either formId or submissions must be provided, but not both.");
14649
14313
  }
14650
- const submissions = useAppSelector(propSubmissions ? () => propSubmissions : selectFormSubmissionsOfForm(formId2));
14314
+ const submissions = useAppSelector(propSubmissions ? () => propSubmissions : selectSubmissionsForForm(formId2));
14651
14315
  const sortedSubmissions = React.useMemo(
14652
14316
  () => submissions == null ? void 0 : submissions.sort((a, b) => {
14653
- return a.submitted_at.localeCompare(b.submitted_at);
14317
+ return getCreatedAtOrSubmittedAtDate(b).getTime() - getCreatedAtOrSubmittedAtDate(a).getTime();
14654
14318
  }),
14655
14319
  [submissions]
14656
14320
  );
@@ -15967,7 +15631,6 @@ var __publicField = (obj, key, value) => {
15967
15631
  exports2.VerificationCodeType = VerificationCodeType;
15968
15632
  exports2.WorkspaceService = WorkspaceService;
15969
15633
  exports2.YELLOW = YELLOW;
15970
- exports2._selectLatestFormRevision = _selectLatestFormRevision;
15971
15634
  exports2._setLatestRetryTime = _setLatestRetryTime;
15972
15635
  exports2.acceptProjectInvite = acceptProjectInvite;
15973
15636
  exports2.addActiveProjectFormSubmissionsCount = addActiveProjectFormSubmissionsCount;
@@ -15985,16 +15648,6 @@ var __publicField = (obj, key, value) => {
15985
15648
  exports2.addDocuments = addDocuments;
15986
15649
  exports2.addEmailDomain = addEmailDomain;
15987
15650
  exports2.addFavouriteProjectId = addFavouriteProjectId;
15988
- exports2.addForm = addForm;
15989
- exports2.addFormRevision = addFormRevision;
15990
- exports2.addFormRevisionAttachment = addFormRevisionAttachment;
15991
- exports2.addFormRevisionAttachments = addFormRevisionAttachments;
15992
- exports2.addFormRevisions = addFormRevisions;
15993
- exports2.addFormSubmission = addFormSubmission;
15994
- exports2.addFormSubmissionAttachment = addFormSubmissionAttachment;
15995
- exports2.addFormSubmissionAttachments = addFormSubmissionAttachments;
15996
- exports2.addFormSubmissions = addFormSubmissions;
15997
- exports2.addForms = addForms;
15998
15651
  exports2.addIssue = addIssue;
15999
15652
  exports2.addIssueAttachment = addIssueAttachment;
16000
15653
  exports2.addIssueAttachments = addIssueAttachments;
@@ -16015,6 +15668,13 @@ var __publicField = (obj, key, value) => {
16015
15668
  exports2.addStageCompletions = addStageCompletions;
16016
15669
  exports2.addStages = addStages;
16017
15670
  exports2.addToRecentIssues = addToRecentIssues;
15671
+ exports2.addUserForm = addUserForm;
15672
+ exports2.addUserFormRevision = addUserFormRevision;
15673
+ exports2.addUserFormRevisionAttachment = addUserFormRevisionAttachment;
15674
+ exports2.addUserFormRevisions = addUserFormRevisions;
15675
+ exports2.addUserFormSubmissionAttachment = addUserFormSubmissionAttachment;
15676
+ exports2.addUserFormSubmissions = addUserFormSubmissions;
15677
+ exports2.addUserForms = addUserForms;
16018
15678
  exports2.addUsers = addUsers;
16019
15679
  exports2.addWorkspace = addWorkspace;
16020
15680
  exports2.areArraysEqual = areArraysEqual;
@@ -16035,7 +15695,6 @@ var __publicField = (obj, key, value) => {
16035
15695
  exports2.componentStageSlice = componentStageSlice;
16036
15696
  exports2.componentTypeReducer = componentTypeReducer;
16037
15697
  exports2.componentTypeSlice = componentTypeSlice;
16038
- exports2.constructUploadedFilePayloads = constructUploadedFilePayloads;
16039
15698
  exports2.coordinatesAreEqual = coordinatesAreEqual;
16040
15699
  exports2.coordinatesToLiteral = coordinatesToLiteral;
16041
15700
  exports2.coordinatesToPointGeometry = coordinatesToPointGeometry;
@@ -16046,16 +15705,12 @@ var __publicField = (obj, key, value) => {
16046
15705
  exports2.defaultBadgeColor = defaultBadgeColor;
16047
15706
  exports2.defaultStore = defaultStore;
16048
15707
  exports2.deleteComponentType = deleteComponentType;
16049
- exports2.deleteForm = deleteForm;
16050
- exports2.deleteFormRevision = deleteFormRevision;
16051
- exports2.deleteFormRevisionAttachment = deleteFormRevisionAttachment;
16052
- exports2.deleteFormRevisionAttachments = deleteFormRevisionAttachments;
16053
- exports2.deleteFormRevisions = deleteFormRevisions;
16054
- exports2.deleteFormSubmission = deleteFormSubmission;
16055
- exports2.deleteFormSubmissionAttachment = deleteFormSubmissionAttachment;
16056
- exports2.deleteFormSubmissionAttachments = deleteFormSubmissionAttachments;
16057
- exports2.deleteFormSubmissions = deleteFormSubmissions;
16058
15708
  exports2.deleteProject = deleteProject;
15709
+ exports2.deleteUserForm = deleteUserForm;
15710
+ exports2.deleteUserFormRevision = deleteUserFormRevision;
15711
+ exports2.deleteUserFormRevisions = deleteUserFormRevisions;
15712
+ exports2.deleteUserFormSubmission = deleteUserFormSubmission;
15713
+ exports2.deleteUserFormSubmissions = deleteUserFormSubmissions;
16059
15714
  exports2.dequeue = dequeue;
16060
15715
  exports2.deserialize = deserialize;
16061
15716
  exports2.deserializeField = deserializeField;
@@ -16084,13 +15739,7 @@ var __publicField = (obj, key, value) => {
16084
15739
  exports2.fileSlice = fileSlice;
16085
15740
  exports2.fileToBlob = fileToBlob;
16086
15741
  exports2.flipCoordinates = flipCoordinates;
16087
- exports2.formReducer = formReducer;
16088
- exports2.formRevisionReducer = formRevisionReducer;
16089
15742
  exports2.formRevisionToSchema = formRevisionToSchema;
16090
- exports2.formRevisionsSlice = formRevisionsSlice;
16091
- exports2.formSlice = formSlice;
16092
- exports2.formSubmissionReducer = formSubmissionReducer;
16093
- exports2.formSubmissionSlice = formSubmissionSlice;
16094
15743
  exports2.forms = index;
16095
15744
  exports2.fullComponentMarkerSize = fullComponentMarkerSize;
16096
15745
  exports2.generateBadgeColors = generateBadgeColors;
@@ -16166,7 +15815,6 @@ var __publicField = (obj, key, value) => {
16166
15815
  exports2.removeFavouriteProjectId = removeFavouriteProjectId;
16167
15816
  exports2.removeIssue = removeIssue;
16168
15817
  exports2.removeIssueAttachment = removeIssueAttachment;
16169
- exports2.removeIssueAttachments = removeIssueAttachments;
16170
15818
  exports2.removeIssueComment = removeIssueComment;
16171
15819
  exports2.removeIssueComments = removeIssueComments;
16172
15820
  exports2.removeIssueUpdate = removeIssueUpdate;
@@ -16219,8 +15867,6 @@ var __publicField = (obj, key, value) => {
16219
15867
  exports2.selectAttachmentsOfComponentTypeByType = selectAttachmentsOfComponentTypeByType;
16220
15868
  exports2.selectAttachmentsOfDocument = selectAttachmentsOfDocument;
16221
15869
  exports2.selectAttachmentsOfDocumentByType = selectAttachmentsOfDocumentByType;
16222
- exports2.selectAttachmentsOfFormRevision = selectAttachmentsOfFormRevision;
16223
- exports2.selectAttachmentsOfFormSubmission = selectAttachmentsOfFormSubmission;
16224
15870
  exports2.selectAttachmentsOfIssue = selectAttachmentsOfIssue;
16225
15871
  exports2.selectAttachmentsOfIssueByType = selectAttachmentsOfIssueByType;
16226
15872
  exports2.selectAttachmentsOfProject = selectAttachmentsOfProject;
@@ -16236,11 +15882,11 @@ var __publicField = (obj, key, value) => {
16236
15882
  exports2.selectCompletedStageIdsForComponent = selectCompletedStageIdsForComponent;
16237
15883
  exports2.selectCompletedStages = selectCompletedStages;
16238
15884
  exports2.selectComponent = selectComponent;
16239
- exports2.selectComponentAttachment = selectComponentAttachment;
16240
15885
  exports2.selectComponentAttachmentMapping = selectComponentAttachmentMapping;
15886
+ exports2.selectComponentSubmissionMapping = selectComponentSubmissionMapping;
16241
15887
  exports2.selectComponentType = selectComponentType;
16242
- exports2.selectComponentTypeAttachment = selectComponentTypeAttachment;
16243
15888
  exports2.selectComponentTypeAttachmentMapping = selectComponentTypeAttachmentMapping;
15889
+ exports2.selectComponentTypeForm = selectComponentTypeForm;
16244
15890
  exports2.selectComponentTypeFromComponent = selectComponentTypeFromComponent;
16245
15891
  exports2.selectComponentTypeFromComponents = selectComponentTypeFromComponents;
16246
15892
  exports2.selectComponentTypeStagesMapping = selectComponentTypeStagesMapping;
@@ -16256,7 +15902,6 @@ var __publicField = (obj, key, value) => {
16256
15902
  exports2.selectCurrentUser = selectCurrentUser;
16257
15903
  exports2.selectDeletedRequests = selectDeletedRequests;
16258
15904
  exports2.selectDocument = selectDocument;
16259
- exports2.selectDocumentAttachment = selectDocumentAttachment;
16260
15905
  exports2.selectDocumentAttachmentMapping = selectDocumentAttachmentMapping;
16261
15906
  exports2.selectDocuments = selectDocuments;
16262
15907
  exports2.selectDocumentsMapping = selectDocumentsMapping;
@@ -16270,24 +15915,8 @@ var __publicField = (obj, key, value) => {
16270
15915
  exports2.selectExpandedSections = selectExpandedSections;
16271
15916
  exports2.selectFavouriteProjects = selectFavouriteProjects;
16272
15917
  exports2.selectFileAttachmentsOfIssue = selectFileAttachmentsOfIssue;
16273
- exports2.selectFilteredForms = selectFilteredForms;
16274
- exports2.selectForm = selectForm;
16275
- exports2.selectFormMapping = selectFormMapping;
16276
- exports2.selectFormOfComponentType = selectFormOfComponentType;
15918
+ exports2.selectFilteredUserForms = selectFilteredUserForms;
16277
15919
  exports2.selectFormRevision = selectFormRevision;
16278
- exports2.selectFormRevisionMapping = selectFormRevisionMapping;
16279
- exports2.selectFormRevisions = selectFormRevisions;
16280
- exports2.selectFormRevisionsOfForm = selectFormRevisionsOfForm;
16281
- exports2.selectFormSubmission = selectFormSubmission;
16282
- exports2.selectFormSubmissionAttachmentsMapping = selectFormSubmissionAttachmentsMapping;
16283
- exports2.selectFormSubmissions = selectFormSubmissions;
16284
- exports2.selectFormSubmissionsByComponents = selectFormSubmissionsByComponents;
16285
- exports2.selectFormSubmissionsMapping = selectFormSubmissionsMapping;
16286
- exports2.selectFormSubmissionsOfComponent = selectFormSubmissionsOfComponent;
16287
- exports2.selectFormSubmissionsOfForm = selectFormSubmissionsOfForm;
16288
- exports2.selectFormSubmissionsOfIssue = selectFormSubmissionsOfIssue;
16289
- exports2.selectFormsCount = selectFormsCount;
16290
- exports2.selectGeneralFormCount = selectGeneralFormCount;
16291
15920
  exports2.selectHiddenCategoryCount = selectHiddenCategoryCount;
16292
15921
  exports2.selectHiddenComponentTypeIds = selectHiddenComponentTypeIds;
16293
15922
  exports2.selectIsFetchingInitialData = selectIsFetchingInitialData;
@@ -16295,17 +15924,16 @@ var __publicField = (obj, key, value) => {
16295
15924
  exports2.selectIsLoading = selectIsLoading;
16296
15925
  exports2.selectIsLoggedIn = selectIsLoggedIn;
16297
15926
  exports2.selectIssue = selectIssue;
16298
- exports2.selectIssueAttachment = selectIssueAttachment;
16299
15927
  exports2.selectIssueAttachmentMapping = selectIssueAttachmentMapping;
16300
15928
  exports2.selectIssueAttachments = selectIssueAttachments;
16301
15929
  exports2.selectIssueMapping = selectIssueMapping;
16302
15930
  exports2.selectIssueUpdateMapping = selectIssueUpdateMapping;
16303
15931
  exports2.selectIssueUpdatesOfIssue = selectIssueUpdatesOfIssue;
16304
15932
  exports2.selectIssues = selectIssues;
16305
- exports2.selectLatestFormRevisionByForm = selectLatestFormRevisionByForm;
16306
- exports2.selectLatestFormRevisionOfForm = selectLatestFormRevisionOfForm;
16307
- exports2.selectLatestFormRevisionsOfComponentTypes = selectLatestFormRevisionsOfComponentTypes;
15933
+ exports2.selectLatestFormRevision = selectLatestFormRevision;
16308
15934
  exports2.selectLatestRetryTime = selectLatestRetryTime;
15935
+ exports2.selectLatestRevisionByFormId = selectLatestRevisionByFormId;
15936
+ exports2.selectLatestRevisionsFromComponentTypeIds = selectLatestRevisionsFromComponentTypeIds;
16309
15937
  exports2.selectLicense = selectLicense;
16310
15938
  exports2.selectLicenseForProject = selectLicenseForProject;
16311
15939
  exports2.selectLicenses = selectLicenses;
@@ -16314,6 +15942,8 @@ var __publicField = (obj, key, value) => {
16314
15942
  exports2.selectMapStyle = selectMapStyle;
16315
15943
  exports2.selectNumberOfComponentTypesMatchingCaseInsensitiveName = selectNumberOfComponentTypesMatchingCaseInsensitiveName;
16316
15944
  exports2.selectNumberOfComponentsOfComponentType = selectNumberOfComponentsOfComponentType;
15945
+ exports2.selectNumberOfGeneralUserForms = selectNumberOfGeneralUserForms;
15946
+ exports2.selectNumberOfUserForms = selectNumberOfUserForms;
16317
15947
  exports2.selectOrganization = selectOrganization;
16318
15948
  exports2.selectOrganizationAccess = selectOrganizationAccess;
16319
15949
  exports2.selectOrganizationAccessForUser = selectOrganizationAccessForUser;
@@ -16341,6 +15971,8 @@ var __publicField = (obj, key, value) => {
16341
15971
  exports2.selectRecentIssuesAsSearchResults = selectRecentIssuesAsSearchResults;
16342
15972
  exports2.selectRecentProjects = selectRecentProjects;
16343
15973
  exports2.selectRehydrated = selectRehydrated;
15974
+ exports2.selectRevisionAttachments = selectRevisionAttachments;
15975
+ exports2.selectRevisionsForForm = selectRevisionsForForm;
16344
15976
  exports2.selectRootDocuments = selectRootDocuments;
16345
15977
  exports2.selectShowTooltips = selectShowTooltips;
16346
15978
  exports2.selectSortedEmailDomains = selectSortedEmailDomains;
@@ -16355,10 +15987,16 @@ var __publicField = (obj, key, value) => {
16355
15987
  exports2.selectStagesFromComponentType = selectStagesFromComponentType;
16356
15988
  exports2.selectStagesFromComponentTypeIds = selectStagesFromComponentTypeIds;
16357
15989
  exports2.selectStagesFromStageIds = selectStagesFromStageIds;
15990
+ exports2.selectSubmissionAttachments = selectSubmissionAttachments;
15991
+ exports2.selectSubmissionsForComponent = selectSubmissionsForComponent;
15992
+ exports2.selectSubmissionsForForm = selectSubmissionsForForm;
15993
+ exports2.selectSubmissionsForIssue = selectSubmissionsForIssue;
16358
15994
  exports2.selectUploadUrl = selectUploadUrl;
16359
15995
  exports2.selectUsedColors = selectUsedColors;
16360
15996
  exports2.selectUser = selectUser;
16361
- exports2.selectUserFormRevisionAttachmentsMapping = selectUserFormRevisionAttachmentsMapping;
15997
+ exports2.selectUserForm = selectUserForm;
15998
+ exports2.selectUserFormMapping = selectUserFormMapping;
15999
+ exports2.selectUserFormSubmission = selectUserFormSubmission;
16362
16000
  exports2.selectUsersAsMapping = selectUsersAsMapping;
16363
16001
  exports2.selectVisibleStatuses = selectVisibleStatuses;
16364
16002
  exports2.selectVisibleUserIds = selectVisibleUserIds;
@@ -16385,13 +16023,6 @@ var __publicField = (obj, key, value) => {
16385
16023
  exports2.setEnableClustering = setEnableClustering;
16386
16024
  exports2.setEnableDuplicateIssues = setEnableDuplicateIssues;
16387
16025
  exports2.setEnablePlacementMode = setEnablePlacementMode;
16388
- exports2.setFormRevision = setFormRevision;
16389
- exports2.setFormRevisionAttachments = setFormRevisionAttachments;
16390
- exports2.setFormRevisions = setFormRevisions;
16391
- exports2.setFormSubmission = setFormSubmission;
16392
- exports2.setFormSubmissionAttachments = setFormSubmissionAttachments;
16393
- exports2.setFormSubmissions = setFormSubmissions;
16394
- exports2.setForms = setForms;
16395
16026
  exports2.setIsFetchingInitialData = setIsFetchingInitialData;
16396
16027
  exports2.setIsImportingProjectFile = setIsImportingProjectFile;
16397
16028
  exports2.setIsLoading = setIsLoading;
@@ -16416,6 +16047,9 @@ var __publicField = (obj, key, value) => {
16416
16047
  exports2.setTokens = setTokens;
16417
16048
  exports2.setTourStep = setTourStep;
16418
16049
  exports2.setUploadUrl = setUploadUrl;
16050
+ exports2.setUserFormRevisionAttachments = setUserFormRevisionAttachments;
16051
+ exports2.setUserFormSubmissionAttachments = setUserFormSubmissionAttachments;
16052
+ exports2.setUserFormSubmissions = setUserFormSubmissions;
16419
16053
  exports2.setUsers = setUsers;
16420
16054
  exports2.setVisibleStatuses = setVisibleStatuses;
16421
16055
  exports2.setVisibleUserIds = setVisibleUserIds;
@@ -16440,14 +16074,11 @@ var __publicField = (obj, key, value) => {
16440
16074
  exports2.updateComponentTypeAttachment = updateComponentTypeAttachment;
16441
16075
  exports2.updateDocumentAttachment = updateDocumentAttachment;
16442
16076
  exports2.updateDocuments = updateDocuments;
16443
- exports2.updateFormSubmission = updateFormSubmission;
16444
- exports2.updateFormSubmissionAttachments = updateFormSubmissionAttachments;
16445
- exports2.updateFormSubmissions = updateFormSubmissions;
16446
16077
  exports2.updateIssue = updateIssue;
16447
16078
  exports2.updateIssueAttachment = updateIssueAttachment;
16448
- exports2.updateIssueAttachments = updateIssueAttachments;
16449
16079
  exports2.updateLicense = updateLicense;
16450
16080
  exports2.updateOrCreateProject = updateOrCreateProject;
16081
+ exports2.updateOrCreateUserFormSubmission = updateOrCreateUserFormSubmission;
16451
16082
  exports2.updateOrganizationAccess = updateOrganizationAccess;
16452
16083
  exports2.updateProjectAccess = updateProjectAccess;
16453
16084
  exports2.updateProjectAttachment = updateProjectAttachment;
@@ -16461,6 +16092,8 @@ var __publicField = (obj, key, value) => {
16461
16092
  exports2.useFormikInput = useFormikInput;
16462
16093
  exports2.useMemoCompare = useMemoCompare;
16463
16094
  exports2.useSDK = useSDK;
16095
+ exports2.userFormReducer = userFormReducer;
16096
+ exports2.userFormSlice = userFormSlice;
16464
16097
  exports2.userReducer = userReducer;
16465
16098
  exports2.userSlice = userSlice;
16466
16099
  exports2.valueIsFile = valueIsFile;