@overmap-ai/core 1.0.50-fix-error-messaging.0 → 1.0.51-bulk-form-submission.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.
@@ -668,15 +668,15 @@ var __publicField = (obj, key, value) => {
668
668
  };
669
669
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
670
670
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
671
- const initialState$n = {
671
+ const initialState$p = {
672
672
  accessToken: "",
673
673
  refreshToken: "",
674
674
  isLoggedIn: false
675
675
  };
676
676
  const authSlice = toolkit.createSlice({
677
677
  name: "auth",
678
- initialState: initialState$n,
679
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
678
+ initialState: initialState$p,
679
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
680
680
  reducers: {
681
681
  setTokens: (state, action) => {
682
682
  state.accessToken = action.payload.accessToken;
@@ -841,6 +841,19 @@ var __publicField = (obj, key, value) => {
841
841
  element.click();
842
842
  document.body.removeChild(element);
843
843
  }
844
+ const constructUploadedFilePayloads = async (files) => {
845
+ const filePayloads = {};
846
+ for (const file of files) {
847
+ const sha1 = await hashFile(file);
848
+ filePayloads[sha1] = {
849
+ sha1,
850
+ extension: file.name.split(".").pop() || "",
851
+ file_type: file.type,
852
+ size: file.size
853
+ };
854
+ }
855
+ return Object.values(filePayloads);
856
+ };
844
857
  const fileToBlob = async (dataUrl) => {
845
858
  return (await fetch(dataUrl)).blob();
846
859
  };
@@ -1407,7 +1420,7 @@ var __publicField = (obj, key, value) => {
1407
1420
  return getLocalDateString(date);
1408
1421
  return relative.format(days, "days");
1409
1422
  });
1410
- const initialState$m = {
1423
+ const initialState$o = {
1411
1424
  categories: {},
1412
1425
  usedCategoryColors: [],
1413
1426
  categoryVisibility: {
@@ -1417,8 +1430,8 @@ var __publicField = (obj, key, value) => {
1417
1430
  };
1418
1431
  const categorySlice = toolkit.createSlice({
1419
1432
  name: "categories",
1420
- initialState: initialState$m,
1421
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1433
+ initialState: initialState$o,
1434
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1422
1435
  reducers: {
1423
1436
  setCategories: (state, action) => {
1424
1437
  if (!Array.isArray(action.payload))
@@ -1552,6 +1565,7 @@ var __publicField = (obj, key, value) => {
1552
1565
  };
1553
1566
  const categoryReducer = categorySlice.reducer;
1554
1567
  function setAttachments(state, action) {
1568
+ state.attachments = {};
1555
1569
  for (const attachment of action.payload) {
1556
1570
  state.attachments[attachment.offline_id] = attachment;
1557
1571
  }
@@ -1586,14 +1600,14 @@ var __publicField = (obj, key, value) => {
1586
1600
  delete state.attachments[attachmentId];
1587
1601
  }
1588
1602
  }
1589
- const initialState$l = {
1603
+ const initialState$n = {
1590
1604
  components: {},
1591
1605
  attachments: {}
1592
1606
  };
1593
1607
  const componentSlice = toolkit.createSlice({
1594
1608
  name: "components",
1595
- initialState: initialState$l,
1596
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1609
+ initialState: initialState$n,
1610
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1597
1611
  reducers: {
1598
1612
  addComponent: (state, action) => {
1599
1613
  state.components[action.payload.offline_id] = action.payload;
@@ -1706,6 +1720,9 @@ var __publicField = (obj, key, value) => {
1706
1720
  [selectComponentAttachmentMapping],
1707
1721
  (mapping) => Object.values(mapping)
1708
1722
  );
1723
+ const selectComponentAttachment = (attachmentId) => (state) => {
1724
+ return state.componentReducer.attachments[attachmentId];
1725
+ };
1709
1726
  const selectAttachmentsOfComponent = restructureCreateSelectorWithArgs(
1710
1727
  toolkit.createSelector(
1711
1728
  [selectAllComponentAttachments, (_state, componentId) => componentId],
@@ -1746,13 +1763,13 @@ var __publicField = (obj, key, value) => {
1746
1763
  removeAllComponentsOfType
1747
1764
  } = componentSlice.actions;
1748
1765
  const componentReducer = componentSlice.reducer;
1749
- const initialState$k = {
1766
+ const initialState$m = {
1750
1767
  completionsByComponentId: {}
1751
1768
  };
1752
1769
  const componentStageCompletionSlice = toolkit.createSlice({
1753
1770
  name: "componentStageCompletions",
1754
- initialState: initialState$k,
1755
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1771
+ initialState: initialState$m,
1772
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1756
1773
  reducers: {
1757
1774
  addStageCompletion: (state, action) => {
1758
1775
  let stageToCompletionDateMapping = state.completionsByComponentId[action.payload.component];
@@ -1803,13 +1820,13 @@ var __publicField = (obj, key, value) => {
1803
1820
  return Object.keys(state.componentStageCompletionReducer.completionsByComponentId[component.offline_id] ?? {});
1804
1821
  };
1805
1822
  const componentStageCompletionReducer = componentStageCompletionSlice.reducer;
1806
- const initialState$j = {
1823
+ const initialState$l = {
1807
1824
  stages: {}
1808
1825
  };
1809
1826
  const componentStageSlice = toolkit.createSlice({
1810
1827
  name: "componentStages",
1811
- initialState: initialState$j,
1812
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1828
+ initialState: initialState$l,
1829
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1813
1830
  reducers: {
1814
1831
  addStages: (state, action) => {
1815
1832
  Object.assign(state.stages, toOfflineIdRecord(action.payload));
@@ -1919,15 +1936,15 @@ var __publicField = (obj, key, value) => {
1919
1936
  );
1920
1937
  const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = componentStageSlice.actions;
1921
1938
  const componentStageReducer = componentStageSlice.reducer;
1922
- const initialState$i = {
1939
+ const initialState$k = {
1923
1940
  componentTypes: {},
1924
1941
  hiddenComponentTypeIds: {},
1925
1942
  attachments: {}
1926
1943
  };
1927
1944
  const componentTypeSlice = toolkit.createSlice({
1928
1945
  name: "componentTypes",
1929
- initialState: initialState$i,
1930
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1946
+ initialState: initialState$k,
1947
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1931
1948
  reducers: {
1932
1949
  addComponentType: (state, action) => {
1933
1950
  state.componentTypes[action.payload.offline_id] = action.payload;
@@ -1995,6 +2012,9 @@ var __publicField = (obj, key, value) => {
1995
2012
  [selectComponentTypeAttachmentMapping],
1996
2013
  (mapping) => Object.values(mapping)
1997
2014
  );
2015
+ const selectComponentTypeAttachment = (attachmentId) => (state) => {
2016
+ return state.componentTypeReducer.attachments[attachmentId];
2017
+ };
1998
2018
  const selectAttachmentsOfComponentType = restructureCreateSelectorWithArgs(
1999
2019
  toolkit.createSelector(
2000
2020
  [selectAllComponentTypeAttachments, (_state, componentTypeId) => componentTypeId],
@@ -2035,13 +2055,13 @@ var __publicField = (obj, key, value) => {
2035
2055
  deleteComponentType
2036
2056
  } = componentTypeSlice.actions;
2037
2057
  const componentTypeReducer = componentTypeSlice.reducer;
2038
- const initialState$h = {
2058
+ const initialState$j = {
2039
2059
  workspaces: {},
2040
2060
  activeWorkspaceId: null
2041
2061
  };
2042
2062
  const workspaceSlice = toolkit.createSlice({
2043
2063
  name: "workspace",
2044
- initialState: initialState$h,
2064
+ initialState: initialState$j,
2045
2065
  // The `reducers` field lets us define reducers and generate associated actions
2046
2066
  reducers: {
2047
2067
  setWorkspaces: (state, action) => {
@@ -2098,7 +2118,7 @@ var __publicField = (obj, key, value) => {
2098
2118
  );
2099
2119
  const workspaceReducer = workspaceSlice.reducer;
2100
2120
  const maxRecentIssues = 10;
2101
- const initialState$g = {
2121
+ const initialState$i = {
2102
2122
  issues: {},
2103
2123
  attachments: {},
2104
2124
  comments: {},
@@ -2110,9 +2130,9 @@ var __publicField = (obj, key, value) => {
2110
2130
  };
2111
2131
  const issueSlice = toolkit.createSlice({
2112
2132
  name: "issues",
2113
- initialState: initialState$g,
2133
+ initialState: initialState$i,
2114
2134
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2115
- Object.assign(state, initialState$g);
2135
+ Object.assign(state, initialState$i);
2116
2136
  }),
2117
2137
  reducers: {
2118
2138
  setIssues: (state, action) => {
@@ -2389,6 +2409,9 @@ var __publicField = (obj, key, value) => {
2389
2409
  }
2390
2410
  )
2391
2411
  );
2412
+ const selectIssueAttachment = (attachmentId) => (root) => {
2413
+ return root.issueReducer.attachments[attachmentId];
2414
+ };
2392
2415
  const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
2393
2416
  toolkit.createSelector(
2394
2417
  [selectIssueAttachments, (_state, issueId) => issueId],
@@ -2517,15 +2540,15 @@ var __publicField = (obj, key, value) => {
2517
2540
  }
2518
2541
  );
2519
2542
  const issueReducer = issueSlice.reducer;
2520
- const initialState$f = {
2543
+ const initialState$h = {
2521
2544
  s3Urls: {}
2522
2545
  };
2523
2546
  const msPerHour = 1e3 * 60 * 60;
2524
2547
  const msPerWeek = msPerHour * 24 * 7;
2525
2548
  const fileSlice = toolkit.createSlice({
2526
2549
  name: "file",
2527
- initialState: initialState$f,
2528
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2550
+ initialState: initialState$h,
2551
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2529
2552
  reducers: {
2530
2553
  setUploadUrl: (state, action) => {
2531
2554
  const { url, fields, sha1 } = action.payload;
@@ -2552,7 +2575,7 @@ var __publicField = (obj, key, value) => {
2552
2575
  return url;
2553
2576
  };
2554
2577
  const fileReducer = fileSlice.reducer;
2555
- const initialState$e = {
2578
+ const initialState$g = {
2556
2579
  // TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
2557
2580
  mapStyle: MapStyle.SATELLITE,
2558
2581
  showTooltips: false,
@@ -2560,8 +2583,8 @@ var __publicField = (obj, key, value) => {
2560
2583
  };
2561
2584
  const mapSlice = toolkit.createSlice({
2562
2585
  name: "map",
2563
- initialState: initialState$e,
2564
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2586
+ initialState: initialState$g,
2587
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2565
2588
  reducers: {
2566
2589
  setMapStyle: (state, action) => {
2567
2590
  state.mapStyle = action.payload;
@@ -2630,7 +2653,7 @@ var __publicField = (obj, key, value) => {
2630
2653
  LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
2631
2654
  return LicenseStatus2;
2632
2655
  })(LicenseStatus || {});
2633
- const initialState$d = {
2656
+ const initialState$f = {
2634
2657
  users: {},
2635
2658
  currentUser: {
2636
2659
  id: 0,
@@ -2641,8 +2664,8 @@ var __publicField = (obj, key, value) => {
2641
2664
  };
2642
2665
  const userSlice = toolkit.createSlice({
2643
2666
  name: "users",
2644
- initialState: initialState$d,
2645
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2667
+ initialState: initialState$f,
2668
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2646
2669
  reducers: {
2647
2670
  setUsers: (state, action) => {
2648
2671
  const usersMapping = {};
@@ -2704,13 +2727,13 @@ var __publicField = (obj, key, value) => {
2704
2727
  const selectUsersAsMapping = (state) => state.userReducer.users;
2705
2728
  const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
2706
2729
  const userReducer = userSlice.reducer;
2707
- const initialState$c = {
2730
+ const initialState$e = {
2708
2731
  organizationAccesses: {}
2709
2732
  };
2710
2733
  const organizationAccessSlice = toolkit.createSlice({
2711
2734
  name: "organizationAccess",
2712
- initialState: initialState$c,
2713
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2735
+ initialState: initialState$e,
2736
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2714
2737
  reducers: {
2715
2738
  setOrganizationAccesses: (state, action) => {
2716
2739
  if (!Array.isArray(action.payload))
@@ -2773,13 +2796,13 @@ var __publicField = (obj, key, value) => {
2773
2796
  return organizationAccesses;
2774
2797
  };
2775
2798
  const organizationAccessReducer = organizationAccessSlice.reducer;
2776
- const initialState$b = {
2799
+ const initialState$d = {
2777
2800
  licenses: {}
2778
2801
  };
2779
2802
  const licenseSlice = toolkit.createSlice({
2780
2803
  name: "license",
2781
- initialState: initialState$b,
2782
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2804
+ initialState: initialState$d,
2805
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2783
2806
  reducers: {
2784
2807
  setLicenses: (state, action) => {
2785
2808
  if (!Array.isArray(action.payload))
@@ -2824,13 +2847,13 @@ var __publicField = (obj, key, value) => {
2824
2847
  (licenses) => Object.values(licenses).filter((license) => license.project).reduce((accum, license) => ({ ...accum, [license.project]: license }), {})
2825
2848
  );
2826
2849
  const licenseReducer = licenseSlice.reducer;
2827
- const initialState$a = {
2850
+ const initialState$c = {
2828
2851
  projectAccesses: {}
2829
2852
  };
2830
2853
  const projectAccessSlice = toolkit.createSlice({
2831
2854
  name: "projectAccess",
2832
- initialState: initialState$a,
2833
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2855
+ initialState: initialState$c,
2856
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2834
2857
  reducers: {
2835
2858
  setProjectAccesses: (state, action) => {
2836
2859
  if (!Array.isArray(action.payload))
@@ -2898,7 +2921,7 @@ var __publicField = (obj, key, value) => {
2898
2921
  return projectAccesses;
2899
2922
  };
2900
2923
  const projectAccessReducer = projectAccessSlice.reducer;
2901
- const initialState$9 = {
2924
+ const initialState$b = {
2902
2925
  projects: {},
2903
2926
  activeProjectId: null,
2904
2927
  recentProjectIds: [],
@@ -2908,7 +2931,7 @@ var __publicField = (obj, key, value) => {
2908
2931
  };
2909
2932
  const projectSlice = toolkit.createSlice({
2910
2933
  name: "projects",
2911
- initialState: initialState$9,
2934
+ initialState: initialState$b,
2912
2935
  reducers: {
2913
2936
  setProjects: (state, action) => {
2914
2937
  const projectsMap = {};
@@ -3095,14 +3118,14 @@ var __publicField = (obj, key, value) => {
3095
3118
  }
3096
3119
  )
3097
3120
  );
3098
- const initialState$8 = {
3121
+ const initialState$a = {
3099
3122
  organizations: {},
3100
3123
  activeOrganizationId: null
3101
3124
  };
3102
3125
  const organizationSlice = toolkit.createSlice({
3103
3126
  name: "organizations",
3104
- initialState: initialState$8,
3105
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3127
+ initialState: initialState$a,
3128
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
3106
3129
  reducers: {
3107
3130
  setOrganizations: (state, action) => {
3108
3131
  for (const org of action.payload) {
@@ -3221,14 +3244,14 @@ var __publicField = (obj, key, value) => {
3221
3244
  }
3222
3245
  };
3223
3246
  };
3224
- const initialState$7 = {
3247
+ const initialState$9 = {
3225
3248
  deletedRequests: [],
3226
3249
  latestRetryTime: 0
3227
3250
  };
3228
3251
  const outboxSlice = toolkit.createSlice({
3229
3252
  name: "outbox",
3230
- initialState: initialState$7,
3231
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
3253
+ initialState: initialState$9,
3254
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
3232
3255
  reducers: {
3233
3256
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
3234
3257
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -3260,7 +3283,7 @@ var __publicField = (obj, key, value) => {
3260
3283
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
3261
3284
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
3262
3285
  const outboxReducer = outboxSlice.reducer;
3263
- const initialState$6 = {
3286
+ const initialState$8 = {
3264
3287
  projectFiles: {},
3265
3288
  activeProjectFileId: null,
3266
3289
  isImportingProjectFile: false,
@@ -3268,8 +3291,8 @@ var __publicField = (obj, key, value) => {
3268
3291
  };
3269
3292
  const projectFileSlice = toolkit.createSlice({
3270
3293
  name: "projectFiles",
3271
- initialState: initialState$6,
3272
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3294
+ initialState: initialState$8,
3295
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3273
3296
  reducers: {
3274
3297
  addOrReplaceProjectFiles: (state, action) => {
3275
3298
  for (let fileObj of action.payload) {
@@ -3370,12 +3393,12 @@ var __publicField = (obj, key, value) => {
3370
3393
  const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProjectFileId;
3371
3394
  const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
3372
3395
  const projectFileReducer = projectFileSlice.reducer;
3373
- const initialState$5 = {
3396
+ const initialState$7 = {
3374
3397
  isRehydrated: false
3375
3398
  };
3376
3399
  const rehydratedSlice = toolkit.createSlice({
3377
3400
  name: "rehydrated",
3378
- initialState: initialState$5,
3401
+ initialState: initialState$7,
3379
3402
  // The `reducers` field lets us define reducers and generate associated actions
3380
3403
  reducers: {
3381
3404
  setRehydrated: (state, action) => {
@@ -3385,7 +3408,7 @@ var __publicField = (obj, key, value) => {
3385
3408
  });
3386
3409
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
3387
3410
  const rehydratedReducer = rehydratedSlice.reducer;
3388
- const initialState$4 = {
3411
+ const initialState$6 = {
3389
3412
  useIssueTemplate: false,
3390
3413
  placementMode: false,
3391
3414
  enableClustering: false,
@@ -3402,8 +3425,8 @@ var __publicField = (obj, key, value) => {
3402
3425
  };
3403
3426
  const settingSlice = toolkit.createSlice({
3404
3427
  name: "settings",
3405
- initialState: initialState$4,
3406
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3428
+ initialState: initialState$6,
3429
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3407
3430
  reducers: {
3408
3431
  setEnableDuplicateIssues: (state, action) => {
3409
3432
  state.useIssueTemplate = action.payload;
@@ -3449,146 +3472,248 @@ var __publicField = (obj, key, value) => {
3449
3472
  const settingReducer = settingSlice.reducer;
3450
3473
  const selectIsFetchingInitialData = (state) => state.settingReducer.isFetchingInitialData;
3451
3474
  const selectIsLoading = (state) => state.settingReducer.isLoading;
3452
- const LATEST_REVISION_CACHE = {};
3453
- function considerCachingRevision(revision, formId2, preferPending = false) {
3475
+ const LATEST_FORM_REVISION_CACHE = {};
3476
+ function considerCachingFormRevision(formRevision, formId2, preferPending = false) {
3454
3477
  var _a2;
3455
- if (!revision) {
3478
+ if (!formRevision) {
3456
3479
  if (!formId2) {
3457
- throw new Error("If revision is null, formId is required.");
3480
+ throw new Error("If form revision is null, formId is required.");
3458
3481
  }
3459
- const currentLatestRevision = getLatestRevisionFromCache(formId2);
3460
- if (currentLatestRevision)
3482
+ const currentLatestFormRevision = getLatestFormRevisionFromCache(formId2);
3483
+ if (currentLatestFormRevision)
3461
3484
  return;
3462
- LATEST_REVISION_CACHE[formId2] = null;
3485
+ LATEST_FORM_REVISION_CACHE[formId2] = null;
3463
3486
  return;
3464
3487
  }
3465
- if (revision.revision === "Pending") {
3488
+ if (formRevision.revision === "Pending") {
3466
3489
  if (preferPending) {
3467
- LATEST_REVISION_CACHE[revision.form] = revision;
3490
+ LATEST_FORM_REVISION_CACHE[formRevision.form] = formRevision;
3468
3491
  }
3469
3492
  return;
3470
3493
  }
3471
- const cachedRevision = (_a2 = LATEST_REVISION_CACHE[revision.form]) == null ? void 0 : _a2.revision;
3472
- if (revision.revision > (typeof cachedRevision === "number" ? cachedRevision : -1)) {
3473
- LATEST_REVISION_CACHE[revision.form] = revision;
3494
+ const cachedFormRevision = (_a2 = LATEST_FORM_REVISION_CACHE[formRevision.form]) == null ? void 0 : _a2.revision;
3495
+ if (formRevision.revision > (typeof cachedFormRevision === "number" ? cachedFormRevision : -1)) {
3496
+ LATEST_FORM_REVISION_CACHE[formRevision.form] = formRevision;
3474
3497
  }
3475
3498
  }
3476
- function getLatestRevisionFromCache(formId2) {
3477
- return LATEST_REVISION_CACHE[formId2];
3499
+ function getLatestFormRevisionFromCache(formId2) {
3500
+ return LATEST_FORM_REVISION_CACHE[formId2];
3478
3501
  }
3479
- const initialState$3 = {
3480
- userForms: {},
3481
- revisions: {},
3482
- submissions: {},
3483
- submissionAttachments: {},
3484
- revisionAttachments: {}
3485
- };
3486
- const userFormSlice = toolkit.createSlice({
3487
- name: "userForms",
3488
- initialState: initialState$3,
3489
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3502
+ const initialState$5 = {
3503
+ formRevisions: {},
3504
+ attachments: {}
3505
+ };
3506
+ const formRevisionsSlice = toolkit.createSlice({
3507
+ name: "formRevisions",
3508
+ initialState: initialState$5,
3509
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3490
3510
  reducers: {
3491
- setUserForms: (state, action) => {
3492
- state.userForms = {};
3493
- action.payload.forEach((userForm) => {
3494
- state.userForms[userForm.offline_id] = userForm;
3495
- });
3496
- },
3497
- addUserForm: (state, action) => {
3498
- state.userForms[action.payload.offline_id] = action.payload;
3499
- },
3500
- addUserForms: (state, action) => {
3501
- action.payload.forEach((userForm) => {
3502
- state.userForms[userForm.offline_id] = userForm;
3503
- });
3504
- },
3505
- addUserFormRevisions: (state, action) => {
3506
- action.payload.forEach((userFormRevision) => {
3507
- state.revisions[userFormRevision.offline_id] = userFormRevision;
3508
- considerCachingRevision(userFormRevision);
3509
- });
3511
+ // revision related actions
3512
+ setFormRevision: (state, action) => {
3513
+ state.formRevisions[action.payload.offline_id] = action.payload;
3514
+ considerCachingFormRevision(action.payload);
3510
3515
  },
3511
- addUserFormRevision: (state, action) => {
3512
- state.revisions[action.payload.offline_id] = action.payload;
3513
- considerCachingRevision(action.payload);
3516
+ setFormRevisions: (state, action) => {
3517
+ state.formRevisions = {};
3518
+ for (const revision of action.payload) {
3519
+ state.formRevisions[revision.offline_id] = revision;
3520
+ considerCachingFormRevision(revision);
3521
+ }
3514
3522
  },
3515
- deleteUserFormRevision: (state, action) => {
3516
- delete state.revisions[action.payload];
3517
- delete LATEST_REVISION_CACHE[action.payload];
3523
+ addFormRevision: (state, action) => {
3524
+ if (state.formRevisions[action.payload.offline_id] !== void 0) {
3525
+ throw new Error(`Revision with offline_id ${action.payload.offline_id} already exists`);
3526
+ }
3527
+ state.formRevisions[action.payload.offline_id] = action.payload;
3528
+ considerCachingFormRevision(action.payload);
3518
3529
  },
3519
- deleteUserFormRevisions: (state, action) => {
3530
+ // TODO: @Audiopolis / Magnus - do we want to standardize using PayloadAction?
3531
+ addFormRevisions: (state, action) => {
3520
3532
  for (const userFormRevision of action.payload) {
3521
- delete state.revisions[userFormRevision.offline_id];
3522
- delete LATEST_REVISION_CACHE[userFormRevision.offline_id];
3533
+ if (state.formRevisions[userFormRevision.offline_id] !== void 0) {
3534
+ throw new Error(`Revision with offline_id ${userFormRevision.offline_id} already exists`);
3535
+ }
3536
+ }
3537
+ for (const userFormRevision of action.payload) {
3538
+ state.formRevisions[userFormRevision.offline_id] = userFormRevision;
3539
+ considerCachingFormRevision(userFormRevision);
3523
3540
  }
3524
3541
  },
3525
- updateOrCreateUserFormSubmission: (state, action) => {
3526
- state.submissions[action.payload.offline_id] = action.payload;
3527
- },
3528
- addUserFormSubmissionAttachment: (state, action) => {
3529
- const submissionId = action.payload.submission;
3530
- const submissionAttachments = state.submissionAttachments[submissionId];
3531
- if (submissionAttachments) {
3532
- submissionAttachments.push(action.payload);
3533
- } else {
3534
- state.submissionAttachments[submissionId] = [action.payload];
3542
+ // UserFormRevisions do not get updated
3543
+ deleteFormRevision: (state, action) => {
3544
+ if (state.formRevisions[action.payload] === void 0) {
3545
+ throw new Error(`Revision with offline_id ${action.payload} does not exist`);
3535
3546
  }
3547
+ delete state.formRevisions[action.payload];
3548
+ delete LATEST_FORM_REVISION_CACHE[action.payload];
3536
3549
  },
3537
- addUserFormRevisionAttachment: (state, action) => {
3538
- const revisionId = action.payload.revision;
3539
- const revisionAttachments = state.revisionAttachments[revisionId];
3540
- if (revisionAttachments) {
3541
- revisionAttachments.push(action.payload);
3542
- } else {
3543
- state.revisionAttachments[revisionId] = [action.payload];
3550
+ deleteFormRevisions: (state, action) => {
3551
+ for (const offlineId of action.payload) {
3552
+ if (state.formRevisions[offlineId] === void 0) {
3553
+ throw new Error(`Revision with offline_id ${offlineId} does not exist`);
3554
+ }
3555
+ }
3556
+ for (const offlineId of action.payload) {
3557
+ delete state.formRevisions[offlineId];
3558
+ delete LATEST_FORM_REVISION_CACHE[offlineId];
3544
3559
  }
3545
3560
  },
3546
- setUserFormSubmissionAttachments: (state, action) => {
3547
- state.submissionAttachments = {};
3561
+ // attachment related actions
3562
+ setFormRevisionAttachments: (state, action) => {
3563
+ state.attachments = {};
3548
3564
  for (const attachment of action.payload) {
3549
- const submissionId = attachment.submission;
3550
- const submissionAttachments = state.submissionAttachments[submissionId];
3551
- if (submissionAttachments) {
3552
- submissionAttachments.push(attachment);
3553
- } else {
3554
- state.submissionAttachments[submissionId] = [attachment];
3555
- }
3565
+ state.attachments[attachment.offline_id] = attachment;
3566
+ }
3567
+ },
3568
+ addFormRevisionAttachment: (state, action) => {
3569
+ if (state.attachments[action.payload.offline_id] !== void 0) {
3570
+ throw new Error(`Attachment with offline_id ${action.payload.offline_id} already exists`);
3556
3571
  }
3572
+ state.attachments[action.payload.offline_id] = action.payload;
3557
3573
  },
3558
- setUserFormRevisionAttachments: (state, action) => {
3559
- state.revisionAttachments = {};
3574
+ addFormRevisionAttachments: (state, action) => {
3560
3575
  for (const attachment of action.payload) {
3561
- const revisionId = attachment.revision;
3562
- const revisionAttachments = state.revisionAttachments[revisionId];
3563
- if (revisionAttachments) {
3564
- revisionAttachments.push(attachment);
3565
- } else {
3566
- state.revisionAttachments[revisionId] = [attachment];
3576
+ if (state.attachments[attachment.offline_id] !== void 0) {
3577
+ throw new Error(`Attachment with offline_id ${attachment.offline_id} already exists`);
3567
3578
  }
3568
3579
  }
3580
+ for (const attachment of action.payload) {
3581
+ state.attachments[attachment.offline_id] = attachment;
3582
+ }
3569
3583
  },
3570
- deleteUserFormSubmission: (state, action) => {
3571
- delete state.submissions[action.payload];
3572
- },
3573
- deleteUserFormSubmissions: (state, action) => {
3574
- for (const userFormSubmission of action.payload) {
3575
- delete state.submissions[userFormSubmission.offline_id];
3584
+ deleteFormRevisionAttachment: (state, action) => {
3585
+ if (state.attachments[action.payload] === void 0) {
3586
+ throw new Error(`Attachment with offline_id ${action.payload} does not exist`);
3576
3587
  }
3588
+ delete state.attachments[action.payload];
3577
3589
  },
3578
- addUserFormSubmissions: (state, action) => {
3579
- for (const submission of action.payload) {
3580
- state.submissions[submission.offline_id] = submission;
3590
+ deleteFormRevisionAttachments: (state, action) => {
3591
+ for (const offlineId of action.payload) {
3592
+ if (state.attachments[offlineId] === void 0) {
3593
+ throw new Error(`Attachment with offline_id ${offlineId} does not exist`);
3594
+ }
3595
+ }
3596
+ for (const offlineId of action.payload) {
3597
+ delete state.attachments[offlineId];
3598
+ }
3599
+ }
3600
+ }
3601
+ });
3602
+ const {
3603
+ setFormRevision,
3604
+ setFormRevisions,
3605
+ addFormRevision,
3606
+ addFormRevisions,
3607
+ deleteFormRevision,
3608
+ deleteFormRevisions,
3609
+ setFormRevisionAttachments,
3610
+ addFormRevisionAttachment,
3611
+ addFormRevisionAttachments,
3612
+ deleteFormRevisionAttachment,
3613
+ deleteFormRevisionAttachments
3614
+ } = formRevisionsSlice.actions;
3615
+ const selectFormRevisionMapping = (state) => state.formRevisionReducer.formRevisions;
3616
+ const selectFormRevisions = toolkit.createSelector(
3617
+ [selectFormRevisionMapping],
3618
+ (formRevisions) => Object.values(formRevisions)
3619
+ );
3620
+ const selectFormRevision = (formRevisionId) => (state) => {
3621
+ return state.formRevisionReducer.formRevisions[formRevisionId];
3622
+ };
3623
+ const _selectLatestFormRevision = (formRevisions, formId2) => {
3624
+ let ret = null;
3625
+ for (const candidate of Object.values(formRevisions)) {
3626
+ if (candidate.form === formId2 && (!ret || ret.revision < candidate.revision)) {
3627
+ ret = candidate;
3628
+ }
3629
+ }
3630
+ if (!ret) {
3631
+ throw new Error("No form revision found for form " + formId2);
3632
+ }
3633
+ return ret;
3634
+ };
3635
+ const selectLatestFormRevisionOfForm = restructureCreateSelectorWithArgs(
3636
+ toolkit.createSelector([selectFormRevisionMapping, (_state, formId2) => formId2], (revisions, formId2) => {
3637
+ if (!formId2) {
3638
+ throw new Error("formId is required");
3639
+ }
3640
+ return _selectLatestFormRevision(revisions, formId2);
3641
+ })
3642
+ );
3643
+ const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
3644
+ toolkit.createSelector([selectFormRevisions, (_state, formId2) => formId2], (revisions, formId2) => {
3645
+ return revisions.filter((revision) => {
3646
+ return revision.form === formId2;
3647
+ });
3648
+ })
3649
+ );
3650
+ const selectLatestFormRevisionsOfComponentTypes = restructureCreateSelectorWithArgs(
3651
+ toolkit.createSelector(
3652
+ [
3653
+ (state) => state.formReducer.forms,
3654
+ selectFormRevisionMapping,
3655
+ (_state, componentTypeIds) => componentTypeIds
3656
+ ],
3657
+ (userForms, revisions, componentTypeIds) => {
3658
+ const componentTypeIdsSet = new Set(componentTypeIds);
3659
+ const ret = {};
3660
+ for (const form of Object.values(userForms)) {
3661
+ if (form.component_type && componentTypeIdsSet.has(form.component_type)) {
3662
+ ret[form.component_type] = _selectLatestFormRevision(revisions, form.offline_id);
3663
+ }
3581
3664
  }
3665
+ return ret;
3666
+ }
3667
+ )
3668
+ );
3669
+ const selectLatestFormRevisionByForm = toolkit.createSelector([selectFormRevisionMapping], (revisions) => {
3670
+ const latestRevisions = {};
3671
+ for (const revision of Object.values(revisions)) {
3672
+ const formId2 = revision.form;
3673
+ const currentLatestRevision = latestRevisions[formId2];
3674
+ if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
3675
+ latestRevisions[formId2] = revision;
3676
+ }
3677
+ }
3678
+ return latestRevisions;
3679
+ });
3680
+ const selectUserFormRevisionAttachmentsMapping = (state) => {
3681
+ return state.formRevisionReducer.attachments;
3682
+ };
3683
+ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
3684
+ toolkit.createSelector(
3685
+ [selectUserFormRevisionAttachmentsMapping, (_state, revisionId) => revisionId],
3686
+ (attachments, revisionId) => {
3687
+ return Object.values(attachments).filter((attachment) => attachment.revision === revisionId);
3688
+ }
3689
+ )
3690
+ );
3691
+ const formRevisionReducer = formRevisionsSlice.reducer;
3692
+ const initialState$4 = {
3693
+ forms: {}
3694
+ };
3695
+ const formSlice = toolkit.createSlice({
3696
+ name: "forms",
3697
+ initialState: initialState$4,
3698
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3699
+ reducers: {
3700
+ setForms: (state, action) => {
3701
+ state.forms = {};
3702
+ action.payload.forEach((userForm) => {
3703
+ state.forms[userForm.offline_id] = userForm;
3704
+ });
3705
+ },
3706
+ addForm: (state, action) => {
3707
+ state.forms[action.payload.offline_id] = action.payload;
3582
3708
  },
3583
- setUserFormSubmissions: (state, action) => {
3584
- state.submissions = {};
3585
- action.payload.forEach((submission) => {
3586
- state.submissions[submission.offline_id] = submission;
3709
+ addForms: (state, action) => {
3710
+ action.payload.forEach((userForm) => {
3711
+ state.forms[userForm.offline_id] = userForm;
3587
3712
  });
3588
3713
  },
3589
3714
  favoriteForm: (state, action) => {
3590
3715
  const { formId: formId2 } = action.payload;
3591
- const form = state.userForms[formId2];
3716
+ const form = state.forms[formId2];
3592
3717
  if (!form) {
3593
3718
  throw new Error("No form exists with the id " + formId2);
3594
3719
  }
@@ -3596,48 +3721,23 @@ var __publicField = (obj, key, value) => {
3596
3721
  },
3597
3722
  unfavoriteForm: (state, action) => {
3598
3723
  const { formId: formId2 } = action.payload;
3599
- const form = state.userForms[formId2];
3724
+ const form = state.forms[formId2];
3600
3725
  if (!form) {
3601
3726
  throw new Error("No form exists with the id " + formId2);
3602
3727
  }
3603
3728
  form.favorite = false;
3604
3729
  },
3605
- deleteUserForm: (state, action) => {
3606
- delete state.userForms[action.payload];
3730
+ deleteForm: (state, action) => {
3731
+ delete state.forms[action.payload];
3607
3732
  }
3608
3733
  }
3609
3734
  });
3610
- const {
3611
- addUserForm,
3612
- addUserForms,
3613
- addUserFormRevisions,
3614
- updateOrCreateUserFormSubmission,
3615
- addUserFormSubmissions,
3616
- deleteUserFormSubmission,
3617
- deleteUserFormSubmissions,
3618
- favoriteForm,
3619
- unfavoriteForm,
3620
- deleteUserForm,
3621
- deleteUserFormRevision,
3622
- deleteUserFormRevisions,
3623
- setUserFormSubmissions,
3624
- addUserFormRevision,
3625
- addUserFormSubmissionAttachment,
3626
- addUserFormRevisionAttachment,
3627
- setUserFormSubmissionAttachments,
3628
- setUserFormRevisionAttachments
3629
- } = userFormSlice.actions;
3630
- const selectSubmissionAttachments = (submissionId) => (state) => {
3631
- return state.userFormReducer.submissionAttachments[submissionId] || [];
3632
- };
3633
- const selectRevisionAttachments = (revisionId) => (state) => {
3634
- return state.userFormReducer.revisionAttachments[revisionId] || [];
3635
- };
3636
- const selectFilteredUserForms = restructureCreateSelectorWithArgs(
3735
+ const { setForms, addForm, addForms, favoriteForm, unfavoriteForm, deleteForm } = formSlice.actions;
3736
+ const selectFilteredForms = restructureCreateSelectorWithArgs(
3637
3737
  toolkit.createSelector(
3638
3738
  [
3639
- (state) => state.userFormReducer.userForms,
3640
- (state) => state.userFormReducer.revisions,
3739
+ (state) => state.formReducer.forms,
3740
+ (state) => state.formRevisionReducer.formRevisions,
3641
3741
  (_state, search) => search
3642
3742
  ],
3643
3743
  (userForms, revisions, search) => {
@@ -3671,63 +3771,188 @@ var __publicField = (obj, key, value) => {
3671
3771
  { memoizeOptions: { equalityCheck: reactRedux.shallowEqual } }
3672
3772
  )
3673
3773
  );
3674
- const selectFormRevision = (revisionId) => (state) => {
3675
- return state.userFormReducer.revisions[revisionId];
3774
+ const selectForm = (formId2) => (state) => {
3775
+ return state.formReducer.forms[formId2];
3676
3776
  };
3677
- const _selectLatestFormRevision = (revisions, formId2) => {
3678
- let ret = null;
3679
- for (const candidate of Object.values(revisions)) {
3680
- if (candidate.form === formId2 && (!ret || ret.revision < candidate.revision)) {
3681
- ret = candidate;
3682
- }
3683
- }
3684
- if (!ret) {
3685
- throw new Error("No revision found for form " + formId2);
3686
- }
3687
- return ret;
3777
+ const selectFormMapping = (state) => {
3778
+ return state.formReducer.forms;
3688
3779
  };
3689
- const selectLatestFormRevision = restructureCreateSelectorWithArgs(
3780
+ const selectFormOfComponentType = restructureCreateSelectorWithArgs(
3690
3781
  toolkit.createSelector(
3691
- [(state) => state.userFormReducer.revisions, (_state, formId2) => formId2],
3692
- (revisions, formId2) => {
3693
- if (!formId2) {
3694
- throw new Error("formId is required");
3695
- }
3696
- return _selectLatestFormRevision(revisions, formId2);
3782
+ [selectFormMapping, (_state, componentTypeId) => componentTypeId],
3783
+ (userForms, componentTypeId) => {
3784
+ return Object.values(userForms).find((userForm) => userForm.component_type === componentTypeId);
3697
3785
  }
3698
3786
  )
3699
3787
  );
3700
- const selectUserForm = (formId2) => (state) => {
3701
- return state.userFormReducer.userForms[formId2];
3702
- };
3703
- const selectSubmissionMapping = (state) => state.userFormReducer.submissions;
3704
- const selectUserFormSubmission = (submissionId) => (state) => {
3705
- return state.userFormReducer.submissions[submissionId];
3706
- };
3707
- const selectSubmissions = toolkit.createSelector([selectSubmissionMapping], (submissions) => Object.values(submissions));
3708
- const selectRevisionMapping = (state) => state.userFormReducer.revisions;
3709
- const selectRevisions = toolkit.createSelector([selectRevisionMapping], (revisions) => Object.values(revisions));
3710
- const selectRevisionsForForm = restructureCreateSelectorWithArgs(
3711
- toolkit.createSelector([selectRevisions, (_state, formId2) => formId2], (revisions, formId2) => {
3712
- return revisions.filter((revision) => {
3713
- return revision.form === formId2;
3714
- });
3715
- })
3788
+ const selectFormsCount = toolkit.createSelector([selectFormMapping], (userForms) => {
3789
+ return Object.keys(userForms).length;
3790
+ });
3791
+ const selectGeneralFormCount = toolkit.createSelector([selectFormMapping], (userForms) => {
3792
+ return Object.values(userForms).filter((form) => !form.component_type).length;
3793
+ });
3794
+ const formReducer = formSlice.reducer;
3795
+ const initialState$3 = {
3796
+ formSubmissions: {},
3797
+ attachments: {}
3798
+ };
3799
+ const formSubmissionSlice = toolkit.createSlice({
3800
+ name: "formSubmissions",
3801
+ initialState: initialState$3,
3802
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3803
+ reducers: {
3804
+ setFormSubmission: (state, action) => {
3805
+ state.formSubmissions[action.payload.offline_id] = action.payload;
3806
+ },
3807
+ setFormSubmissions: (state, action) => {
3808
+ state.formSubmissions = {};
3809
+ for (const submission of action.payload) {
3810
+ state.formSubmissions[submission.offline_id] = submission;
3811
+ }
3812
+ },
3813
+ addFormSubmission: (state, action) => {
3814
+ if (state.formSubmissions[action.payload.offline_id] !== void 0) {
3815
+ throw new Error(`Submission with offline_id ${action.payload.offline_id} already exists`);
3816
+ }
3817
+ state.formSubmissions[action.payload.offline_id] = action.payload;
3818
+ },
3819
+ addFormSubmissions: (state, action) => {
3820
+ for (const submission of action.payload) {
3821
+ if (state.formSubmissions[submission.offline_id] !== void 0) {
3822
+ throw new Error(`Submission with offline_id ${submission.offline_id} already exists`);
3823
+ }
3824
+ }
3825
+ for (const submission of action.payload) {
3826
+ state.formSubmissions[submission.offline_id] = submission;
3827
+ }
3828
+ },
3829
+ updateFormSubmission: (state, action) => {
3830
+ if (state.formSubmissions[action.payload.offline_id] === void 0) {
3831
+ throw new Error(`Submission with offline_id ${action.payload.offline_id} does not exist`);
3832
+ }
3833
+ state.formSubmissions[action.payload.offline_id] = action.payload;
3834
+ },
3835
+ updateFormSubmissions: (state, action) => {
3836
+ for (const submission of action.payload) {
3837
+ if (state.formSubmissions[submission.offline_id] === void 0) {
3838
+ throw new Error(`Submission with offline_id ${submission.offline_id} does not exist`);
3839
+ }
3840
+ }
3841
+ for (const submission of action.payload) {
3842
+ state.formSubmissions[submission.offline_id] = submission;
3843
+ }
3844
+ },
3845
+ deleteFormSubmission: (state, action) => {
3846
+ if (state.formSubmissions[action.payload] === void 0) {
3847
+ throw new Error(`Submission with offline_id ${action.payload} does not exist`);
3848
+ }
3849
+ delete state.formSubmissions[action.payload];
3850
+ },
3851
+ deleteFormSubmissions: (state, action) => {
3852
+ for (const offlineId of action.payload) {
3853
+ if (state.formSubmissions[offlineId] === void 0) {
3854
+ throw new Error(`Submission with offline_id ${offlineId} does not exist`);
3855
+ }
3856
+ delete state.formSubmissions[offlineId];
3857
+ }
3858
+ for (const offlineId of action.payload) {
3859
+ delete state.formSubmissions[offlineId];
3860
+ }
3861
+ },
3862
+ // Attachments
3863
+ addFormSubmissionAttachment: (state, action) => {
3864
+ if (state.attachments[action.payload.offline_id] !== void 0) {
3865
+ throw new Error(`Attachment with offline_id ${action.payload.offline_id} already exists`);
3866
+ }
3867
+ state.attachments[action.payload.offline_id] = action.payload;
3868
+ },
3869
+ addFormSubmissionAttachments: (state, action) => {
3870
+ for (const attachment of action.payload) {
3871
+ if (state.attachments[attachment.offline_id] !== void 0) {
3872
+ throw new Error(`Attachment with offline_id ${attachment.offline_id} already exists`);
3873
+ }
3874
+ }
3875
+ for (const attachment of action.payload) {
3876
+ state.attachments[attachment.offline_id] = attachment;
3877
+ }
3878
+ },
3879
+ // We only need a multi set for attachments because they are not updated, only added and deleted
3880
+ setFormSubmissionAttachments: (state, action) => {
3881
+ state.attachments = {};
3882
+ for (const attachment of action.payload) {
3883
+ state.attachments[attachment.offline_id] = attachment;
3884
+ }
3885
+ },
3886
+ updateFormSubmissionAttachments: (state, action) => {
3887
+ for (const attachment of action.payload) {
3888
+ if (state.attachments[attachment.offline_id] === void 0) {
3889
+ throw new Error(`Attachment with offline_id ${attachment.offline_id} does not exist`);
3890
+ }
3891
+ }
3892
+ for (const attachment of action.payload) {
3893
+ state.attachments[attachment.offline_id] = attachment;
3894
+ }
3895
+ },
3896
+ // The delete actions for UserFormSubmissionAttachments are not used in the app, but are included for completeness
3897
+ // Could be used if editing a submission is ever supported, will be applicable for supporting tip tap content in submissions
3898
+ deleteFormSubmissionAttachment: (state, action) => {
3899
+ if (state.attachments[action.payload] === void 0) {
3900
+ throw new Error(`Attachment with offline_id ${action.payload} does not exist`);
3901
+ }
3902
+ delete state.attachments[action.payload];
3903
+ },
3904
+ deleteFormSubmissionAttachments: (state, action) => {
3905
+ for (const offlineId of action.payload) {
3906
+ if (state.attachments[offlineId] === void 0) {
3907
+ throw new Error(`Attachment with offline_id ${offlineId} does not exist`);
3908
+ }
3909
+ delete state.attachments[offlineId];
3910
+ }
3911
+ }
3912
+ }
3913
+ });
3914
+ const {
3915
+ setFormSubmission,
3916
+ setFormSubmissions,
3917
+ addFormSubmission,
3918
+ addFormSubmissions,
3919
+ updateFormSubmission,
3920
+ updateFormSubmissions,
3921
+ deleteFormSubmission,
3922
+ deleteFormSubmissions,
3923
+ addFormSubmissionAttachment,
3924
+ addFormSubmissionAttachments,
3925
+ setFormSubmissionAttachments,
3926
+ updateFormSubmissionAttachments,
3927
+ deleteFormSubmissionAttachment,
3928
+ deleteFormSubmissionAttachments
3929
+ } = formSubmissionSlice.actions;
3930
+ const selectFormSubmissionsMapping = (state) => {
3931
+ return state.formSubmissionReducer.formSubmissions;
3932
+ };
3933
+ const selectFormSubmissions = toolkit.createSelector(
3934
+ [selectFormSubmissionsMapping],
3935
+ (submissions) => {
3936
+ return Object.values(submissions);
3937
+ }
3716
3938
  );
3717
- const selectSubmissionsForForm = restructureCreateSelectorWithArgs(
3939
+ const selectFormSubmission = (submissionId) => (state) => {
3940
+ return state.formSubmissionReducer.formSubmissions[submissionId];
3941
+ };
3942
+ const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
3718
3943
  toolkit.createSelector(
3719
- [selectSubmissions, selectRevisionMapping, (_state, formId2) => formId2],
3944
+ [selectFormSubmissions, selectFormRevisionMapping, (_state, formId2) => formId2],
3720
3945
  (submissions, revisionMapping, formId2) => {
3721
- return Object.values(submissions).filter((submission) => {
3946
+ return submissions.filter((submission) => {
3722
3947
  const revision = revisionMapping[submission.form_revision];
3723
3948
  return (revision == null ? void 0 : revision.form) === formId2;
3724
3949
  });
3725
3950
  }
3726
3951
  )
3727
3952
  );
3728
- const selectSubmissionsForIssue = restructureCreateSelectorWithArgs(
3953
+ const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
3729
3954
  toolkit.createSelector(
3730
- [(state) => state.userFormReducer.submissions, (_state, issueId) => issueId],
3955
+ [selectFormSubmissions, (_state, issueId) => issueId],
3731
3956
  (submissions, issueId) => {
3732
3957
  return Object.values(submissions).filter((submission) => {
3733
3958
  return submission.issue === issueId;
@@ -3735,9 +3960,9 @@ var __publicField = (obj, key, value) => {
3735
3960
  }
3736
3961
  )
3737
3962
  );
3738
- const selectSubmissionsForComponent = restructureCreateSelectorWithArgs(
3963
+ const selectFormSubmissionsOfComponent = restructureCreateSelectorWithArgs(
3739
3964
  toolkit.createSelector(
3740
- [selectSubmissions, (_state, componentId) => componentId],
3965
+ [selectFormSubmissions, (_state, componentId) => componentId],
3741
3966
  (submissions, componentId) => {
3742
3967
  return submissions.filter((submission) => {
3743
3968
  return submission.component === componentId;
@@ -3745,8 +3970,8 @@ var __publicField = (obj, key, value) => {
3745
3970
  }
3746
3971
  )
3747
3972
  );
3748
- const selectComponentSubmissionMapping = toolkit.createSelector(
3749
- [selectSubmissionMapping, selectComponentsMapping],
3973
+ const selectFormSubmissionsByComponents = toolkit.createSelector(
3974
+ [selectFormSubmissionsMapping, selectComponentsMapping],
3750
3975
  (submissions, components) => {
3751
3976
  var _a2;
3752
3977
  const componentSubmissionMapping = {};
@@ -3762,54 +3987,18 @@ var __publicField = (obj, key, value) => {
3762
3987
  return componentSubmissionMapping;
3763
3988
  }
3764
3989
  );
3765
- const selectUserFormMapping = (state) => {
3766
- return state.userFormReducer.userForms;
3990
+ const selectFormSubmissionAttachmentsMapping = (state) => {
3991
+ return state.formSubmissionReducer.attachments;
3767
3992
  };
3768
- const selectComponentTypeForm = restructureCreateSelectorWithArgs(
3769
- toolkit.createSelector(
3770
- [selectUserFormMapping, (_state, componentTypeId) => componentTypeId],
3771
- (userForms, componentTypeId) => {
3772
- return Object.values(userForms).find((userForm) => userForm.component_type === componentTypeId);
3773
- }
3774
- )
3775
- );
3776
- const selectLatestRevisionsFromComponentTypeIds = restructureCreateSelectorWithArgs(
3993
+ const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
3777
3994
  toolkit.createSelector(
3778
- [
3779
- selectUserFormMapping,
3780
- selectRevisionMapping,
3781
- (_state, componentTypeIds) => componentTypeIds
3782
- ],
3783
- (userForms, revisions, componentTypeIds) => {
3784
- const componentTypeIdsSet = new Set(componentTypeIds);
3785
- const ret = {};
3786
- for (const form of Object.values(userForms)) {
3787
- if (form.component_type && componentTypeIdsSet.has(form.component_type)) {
3788
- ret[form.component_type] = _selectLatestFormRevision(revisions, form.offline_id);
3789
- }
3790
- }
3791
- return ret;
3995
+ [selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
3996
+ (attachmentsMapping, submissionId) => {
3997
+ return Object.values(attachmentsMapping).filter((attachment) => attachment.submission === submissionId);
3792
3998
  }
3793
3999
  )
3794
4000
  );
3795
- const selectLatestRevisionByFormId = toolkit.createSelector([selectRevisionMapping], (revisions) => {
3796
- const latestRevisions = {};
3797
- for (const revision of Object.values(revisions)) {
3798
- const formId2 = revision.form;
3799
- const currentLatestRevision = latestRevisions[formId2];
3800
- if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
3801
- latestRevisions[formId2] = revision;
3802
- }
3803
- }
3804
- return latestRevisions;
3805
- });
3806
- const selectNumberOfUserForms = toolkit.createSelector([selectUserFormMapping], (userForms) => {
3807
- return Object.keys(userForms).length;
3808
- });
3809
- const selectNumberOfGeneralUserForms = toolkit.createSelector([selectUserFormMapping], (userForms) => {
3810
- return Object.values(userForms).filter((form) => !form.component_type).length;
3811
- });
3812
- const userFormReducer = userFormSlice.reducer;
4001
+ const formSubmissionReducer = formSubmissionSlice.reducer;
3813
4002
  const initialState$2 = {
3814
4003
  emailDomains: {}
3815
4004
  };
@@ -3843,7 +4032,8 @@ var __publicField = (obj, key, value) => {
3843
4032
  );
3844
4033
  const emailDomainsReducer = emailDomainsSlice.reducer;
3845
4034
  const initialState$1 = {
3846
- documents: {}
4035
+ documents: {},
4036
+ attachments: {}
3847
4037
  };
3848
4038
  const documentSlice = toolkit.createSlice({
3849
4039
  name: "documents",
@@ -3980,10 +4170,28 @@ var __publicField = (obj, key, value) => {
3980
4170
  }
3981
4171
  delete state.documents[documentId];
3982
4172
  }
3983
- }
4173
+ },
4174
+ setDocumentAttachments: setAttachments,
4175
+ addDocumentAttachment: addAttachment,
4176
+ addDocumentAttachments: addAttachments,
4177
+ updateDocumentAttachment: updateAttachment,
4178
+ removeDocumentAttachment: removeAttachment,
4179
+ removeDocumentAttachments: removeAttachments
3984
4180
  }
3985
4181
  });
3986
- const { setDocuments, addDocuments, updateDocuments, moveDocument, removeDocuments } = documentSlice.actions;
4182
+ const {
4183
+ setDocuments,
4184
+ addDocuments,
4185
+ updateDocuments,
4186
+ moveDocument,
4187
+ removeDocuments,
4188
+ setDocumentAttachments,
4189
+ addDocumentAttachment,
4190
+ addDocumentAttachments,
4191
+ updateDocumentAttachment,
4192
+ removeDocumentAttachment,
4193
+ removeDocumentAttachments
4194
+ } = documentSlice.actions;
3987
4195
  const selectDocumentsMapping = (state) => state.documentsReducer.documents;
3988
4196
  const selectDocuments = toolkit.createSelector(
3989
4197
  [selectDocumentsMapping],
@@ -4013,6 +4221,39 @@ var __publicField = (obj, key, value) => {
4013
4221
  [selectDocuments],
4014
4222
  (documents) => documents.filter((document2) => !document2.parent_document)
4015
4223
  );
4224
+ const selectDocumentAttachmentMapping = (state) => state.documentsReducer.attachments;
4225
+ const selectAllDocumentAttachments = toolkit.createSelector(
4226
+ [selectDocumentAttachmentMapping],
4227
+ (mapping) => Object.values(mapping)
4228
+ );
4229
+ const selectDocumentAttachment = (attachmentId) => (state) => {
4230
+ return state.documentsReducer.attachments[attachmentId];
4231
+ };
4232
+ const selectAttachmentsOfDocument = restructureCreateSelectorWithArgs(
4233
+ toolkit.createSelector(
4234
+ [selectAllDocumentAttachments, (_state, documentId) => documentId],
4235
+ (attachments, documentId) => {
4236
+ return attachments.filter(({ document: document2 }) => documentId === document2);
4237
+ }
4238
+ )
4239
+ );
4240
+ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
4241
+ toolkit.createSelector(
4242
+ [selectAllDocumentAttachments, (_state, documentId) => documentId],
4243
+ (attachments, documentId) => {
4244
+ const attachmentsOfProject = attachments.filter(({ document: document2 }) => documentId === document2);
4245
+ const fileAttachments = attachmentsOfProject.filter(
4246
+ // this null check here is necessary, there are cases where file_type is null or undefined
4247
+ ({ file_type }) => !file_type || !file_type.startsWith("image/")
4248
+ );
4249
+ const imageAttachments = attachmentsOfProject.filter(
4250
+ // this null check here is necessary, there are cases where file_type is null or undefined
4251
+ ({ file_type }) => file_type && file_type.startsWith("image/")
4252
+ );
4253
+ return { fileAttachments, imageAttachments };
4254
+ }
4255
+ )
4256
+ );
4016
4257
  const documentsReducer = documentSlice.reducer;
4017
4258
  const initialState = {
4018
4259
  version: 0
@@ -4055,7 +4296,9 @@ var __publicField = (obj, key, value) => {
4055
4296
  projectFileReducer,
4056
4297
  rehydratedReducer,
4057
4298
  settingReducer,
4058
- userFormReducer,
4299
+ formReducer,
4300
+ formRevisionReducer,
4301
+ formSubmissionReducer,
4059
4302
  userReducer,
4060
4303
  workspaceReducer,
4061
4304
  emailDomainsReducer,
@@ -4108,9 +4351,7 @@ var __publicField = (obj, key, value) => {
4108
4351
  throw new Error(`Failed to update index_workspace of issue ${issue.offline_id} to main workspace`);
4109
4352
  }
4110
4353
  }
4111
- const indexedForms = Object.values(draft.userFormReducer.userForms).filter(
4112
- (form) => form.index_workspace === workspaceId
4113
- );
4354
+ const indexedForms = Object.values(draft.formReducer.forms).filter((form) => form.index_workspace === workspaceId);
4114
4355
  for (const form of indexedForms) {
4115
4356
  form.index_workspace = mainWorkspace.offline_id;
4116
4357
  }
@@ -4593,7 +4834,8 @@ var __publicField = (obj, key, value) => {
4593
4834
  issue_attachments: Object.values(state.issueReducer.attachments),
4594
4835
  component_attachments: Object.values(state.componentReducer.attachments),
4595
4836
  component_type_attachments: Object.values(state.componentTypeReducer.attachments),
4596
- project_attachments: Object.values(state.projectReducer.attachments)
4837
+ project_attachments: Object.values(state.projectReducer.attachments),
4838
+ document_attachments: Object.values(state.documentsReducer.attachments)
4597
4839
  };
4598
4840
  return [allAttachments, promise];
4599
4841
  }
@@ -4697,8 +4939,8 @@ var __publicField = (obj, key, value) => {
4697
4939
  });
4698
4940
  return [offlineAttachment, promise];
4699
4941
  }
4700
- async addProjectAttachment(attachmentPayload) {
4701
- const { description: description2, project, file_sha1, offline_id } = attachmentPayload;
4942
+ async addDocumentAttachment(attachmentPayload) {
4943
+ const { description: description2, document: document2, file_sha1, offline_id } = attachmentPayload;
4702
4944
  if (!attachmentPayload.file.objectURL) {
4703
4945
  throw new Error("Expected attachmentPayload.file.objectURL to be defined.");
4704
4946
  }
@@ -4711,24 +4953,24 @@ var __publicField = (obj, key, value) => {
4711
4953
  created_by: this.client.store.getState().userReducer.currentUser.id
4712
4954
  };
4713
4955
  await this.client.files.addCache(attachmentPayload.file, file_sha1);
4714
- this.client.store.dispatch(addProjectAttachment(offlineAttachment));
4956
+ this.client.store.dispatch(addDocumentAttachment(offlineAttachment));
4715
4957
  const [fileProps] = await this.client.files.uploadFileToS3(file_sha1);
4716
4958
  const promise = this.enqueueRequest({
4717
4959
  description: "Create attachment",
4718
4960
  method: HttpMethod.POST,
4719
- url: `/projects/${project}/attach/`,
4720
- blocks: [offline_id, project.toString()],
4961
+ url: `/documents/${document2}/attach/`,
4962
+ blocks: [offline_id, document2],
4721
4963
  blockers: [file_sha1],
4722
4964
  payload: {
4723
4965
  offline_id,
4724
- project,
4966
+ document: document2,
4725
4967
  description: description2 ?? "",
4726
4968
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
4727
4969
  ...fileProps
4728
4970
  }
4729
4971
  });
4730
4972
  promise.catch((error2) => {
4731
- this.client.store.dispatch(removeProjectAttachment(offlineAttachment.offline_id));
4973
+ this.client.store.dispatch(removeDocumentAttachment(offlineAttachment.offline_id));
4732
4974
  throw error2;
4733
4975
  });
4734
4976
  return [offlineAttachment, promise];
@@ -4799,7 +5041,7 @@ var __publicField = (obj, key, value) => {
4799
5041
  return photoAttachmentPromise(file);
4800
5042
  });
4801
5043
  }
4802
- attachFilesToProject(filesToSubmit, projectId) {
5044
+ attachFilesToDocument(filesToSubmit, documentId) {
4803
5045
  return filesToSubmit.map((file) => {
4804
5046
  if (!(file instanceof File)) {
4805
5047
  throw new Error("Expected a File instance.");
@@ -4810,12 +5052,12 @@ var __publicField = (obj, key, value) => {
4810
5052
  file: file2,
4811
5053
  file_name: file2.name,
4812
5054
  file_type: file2.type,
4813
- project: projectId,
5055
+ document: documentId,
4814
5056
  file_sha1: hash,
4815
5057
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
4816
5058
  created_by: this.client.store.getState().userReducer.currentUser.id
4817
5059
  });
4818
- return this.addProjectAttachment(attachment);
5060
+ return this.addDocumentAttachment(attachment);
4819
5061
  };
4820
5062
  return photoAttachmentPromise(file);
4821
5063
  });
@@ -4995,9 +5237,9 @@ var __publicField = (obj, key, value) => {
4995
5237
  const promise = performRequest2();
4996
5238
  return [offlineAttachment, promise];
4997
5239
  }
4998
- async replaceProjectAttachmentFile(attachmentId, newFile) {
5240
+ async replaceDocumentAttachmentFile(attachmentId, newFile) {
4999
5241
  const { store } = this.client;
5000
- const attachment = store.getState().projectReducer.attachments[attachmentId];
5242
+ const attachment = store.getState().documentsReducer.attachments[attachmentId];
5001
5243
  if (!attachment)
5002
5244
  throw new Error(`Attachment ${attachmentId} not found`);
5003
5245
  let oldFile = void 0;
@@ -5011,7 +5253,7 @@ var __publicField = (obj, key, value) => {
5011
5253
  throw new Error(`newFile["objectURL"] is unexpectedly ${newFile.objectURL}`);
5012
5254
  }
5013
5255
  store.dispatch(
5014
- updateProjectAttachment({
5256
+ updateDocumentAttachment({
5015
5257
  ...attachment,
5016
5258
  file_sha1: newSha1,
5017
5259
  file: URL.createObjectURL(newFile)
@@ -5019,13 +5261,13 @@ var __publicField = (obj, key, value) => {
5019
5261
  );
5020
5262
  await this.client.files.addCache(newFile, newSha1);
5021
5263
  const [fileProps] = await this.client.files.uploadFileToS3(newSha1).catch((e) => {
5022
- store.dispatch(updateProjectAttachment(attachment));
5264
+ store.dispatch(updateDocumentAttachment(attachment));
5023
5265
  throw e;
5024
5266
  });
5025
5267
  const promise2 = this.enqueueRequest({
5026
5268
  description: "Edit attachment",
5027
5269
  method: HttpMethod.PATCH,
5028
- url: `/attachments/projects/${attachment.offline_id}/`,
5270
+ url: `/attachments/documents/${attachment.offline_id}/`,
5029
5271
  isResponseBlob: false,
5030
5272
  payload: fileProps,
5031
5273
  blockers: [attachmentId, newSha1],
@@ -5038,7 +5280,7 @@ var __publicField = (obj, key, value) => {
5038
5280
  } catch (e) {
5039
5281
  if (oldFile) {
5040
5282
  store.dispatch(
5041
- updateProjectAttachment({
5283
+ updateDocumentAttachment({
5042
5284
  ...attachment,
5043
5285
  file_sha1: attachment.file_sha1,
5044
5286
  file: URL.createObjectURL(oldFile)
@@ -5108,20 +5350,20 @@ var __publicField = (obj, key, value) => {
5108
5350
  blocks: [componentTypeAttachmentId]
5109
5351
  });
5110
5352
  }
5111
- deleteProjectAttachment(projectAttachmentId) {
5353
+ deleteDocumentAttachment(documentAttachmentId) {
5112
5354
  const { store } = this.client;
5113
- const attachment = selectProjectAttachmentMapping(store.getState())[projectAttachmentId];
5355
+ const attachment = store.getState().documentsReducer.attachments[documentAttachmentId];
5114
5356
  if (!attachment) {
5115
- throw new Error(`Attachment ${projectAttachmentId} not found`);
5357
+ throw new Error(`Attachment ${documentAttachmentId} not found`);
5116
5358
  }
5117
- store.dispatch(removeProjectAttachment(projectAttachmentId));
5359
+ store.dispatch(removeDocumentAttachment(documentAttachmentId));
5118
5360
  void this.client.files.removeCache(attachment.file_sha1);
5119
5361
  return this.enqueueRequest({
5120
- description: "Delete attachment",
5362
+ description: "Delete document attachment",
5121
5363
  method: HttpMethod.DELETE,
5122
- url: `/attachments/projects/${projectAttachmentId}/`,
5123
- blockers: [projectAttachmentId],
5124
- blocks: [projectAttachmentId]
5364
+ url: `/attachments/documents/${documentAttachmentId}/`,
5365
+ blockers: [documentAttachmentId],
5366
+ blocks: [documentAttachmentId]
5125
5367
  });
5126
5368
  }
5127
5369
  }
@@ -6358,11 +6600,18 @@ var __publicField = (obj, key, value) => {
6358
6600
  if (currentProjectId) {
6359
6601
  const [_offlineAttachments, promise] = this.client.attachments.fetchAll(currentProjectId);
6360
6602
  void promise.then((result) => {
6361
- const { issue_attachments, component_type_attachments, component_attachments, project_attachments } = result;
6603
+ const {
6604
+ issue_attachments,
6605
+ component_type_attachments,
6606
+ component_attachments,
6607
+ project_attachments,
6608
+ document_attachments
6609
+ } = result;
6362
6610
  store.dispatch(setIssueAttachments(issue_attachments));
6363
6611
  store.dispatch(setComponentAttachments(component_attachments));
6364
6612
  store.dispatch(setComponentTypeAttachments(component_type_attachments));
6365
6613
  store.dispatch(setProjectAttachments(project_attachments));
6614
+ store.dispatch(setDocumentAttachments(document_attachments));
6366
6615
  });
6367
6616
  void this.client.documents.refreshStore();
6368
6617
  void this.client.issueUpdates.refreshStore();
@@ -6730,7 +6979,7 @@ var __publicField = (obj, key, value) => {
6730
6979
  ...revisionAttachmentPayload,
6731
6980
  file: URL.createObjectURL(image)
6732
6981
  };
6733
- store.dispatch(addUserFormRevisionAttachment(offlinePayload));
6982
+ store.dispatch(addFormRevisionAttachment(offlinePayload));
6734
6983
  return attach;
6735
6984
  });
6736
6985
  });
@@ -6764,8 +7013,8 @@ var __publicField = (obj, key, value) => {
6764
7013
  revision: 0
6765
7014
  };
6766
7015
  const { store } = this.client;
6767
- store.dispatch(addUserForm(retForm));
6768
- store.dispatch(addUserFormRevision(retRevision));
7016
+ store.dispatch(addForm(retForm));
7017
+ store.dispatch(addFormRevision(retRevision));
6769
7018
  const formPromise = this.enqueueRequest({
6770
7019
  description: "Create form",
6771
7020
  method: HttpMethod.POST,
@@ -6783,8 +7032,8 @@ var __publicField = (obj, key, value) => {
6783
7032
  });
6784
7033
  const attachImagesPromises = this.getAttachImagePromises(images, offlineRevisionPayload.offline_id);
6785
7034
  void formPromise.catch((e) => {
6786
- store.dispatch(deleteUserForm(retForm.offline_id));
6787
- store.dispatch(deleteUserFormRevision(retRevision.offline_id));
7035
+ store.dispatch(deleteForm(retForm.offline_id));
7036
+ store.dispatch(deleteFormRevision(retRevision.offline_id));
6788
7037
  throw e;
6789
7038
  });
6790
7039
  const settledPromise = Promise.all([formPromise, ...attachImagesPromises]).then(() => formPromise);
@@ -6826,7 +7075,7 @@ var __publicField = (obj, key, value) => {
6826
7075
  revision: "Pending",
6827
7076
  form: formId2
6828
7077
  };
6829
- store.dispatch(addUserFormRevision(fullRevision));
7078
+ store.dispatch(addFormRevision(fullRevision));
6830
7079
  const promise = this.enqueueRequest({
6831
7080
  description: "Create form revision",
6832
7081
  method: HttpMethod.PATCH,
@@ -6840,9 +7089,9 @@ var __publicField = (obj, key, value) => {
6840
7089
  });
6841
7090
  const attachImagesPromises = this.getAttachImagePromises(images, offlineRevision.offline_id);
6842
7091
  void promise.then((result) => {
6843
- store.dispatch(addUserFormRevision(result));
7092
+ store.dispatch(setFormRevision(result));
6844
7093
  }).catch(() => {
6845
- store.dispatch(deleteUserFormRevision(fullRevision.offline_id));
7094
+ store.dispatch(deleteFormRevision(fullRevision.offline_id));
6846
7095
  });
6847
7096
  const settledPromise = Promise.all([promise, ...attachImagesPromises]).then(() => promise);
6848
7097
  return [fullRevision, settledPromise];
@@ -6884,19 +7133,19 @@ var __publicField = (obj, key, value) => {
6884
7133
  async delete(formId2) {
6885
7134
  const { store } = this.client;
6886
7135
  const state = store.getState();
6887
- const userForm = selectUserForm(formId2)(state);
7136
+ const userForm = selectForm(formId2)(state);
6888
7137
  if (!userForm) {
6889
7138
  throw new Error("Expected userForm to exist");
6890
7139
  }
6891
- const userFormSubmissions = selectSubmissionsForForm(formId2)(state);
7140
+ const userFormSubmissions = selectFormSubmissionsOfForm(formId2)(state);
6892
7141
  if (userFormSubmissions && userFormSubmissions.length > 0) {
6893
- store.dispatch(deleteUserFormSubmissions(userFormSubmissions));
7142
+ store.dispatch(deleteFormSubmissions(userFormSubmissions.map(({ offline_id }) => offline_id)));
6894
7143
  }
6895
- const userFormRevisions = selectRevisionsForForm(formId2)(state);
7144
+ const userFormRevisions = selectFormRevisionsOfForm(formId2)(state);
6896
7145
  if (userFormRevisions && userFormRevisions.length > 0) {
6897
- store.dispatch(deleteUserFormRevisions(userFormRevisions));
7146
+ store.dispatch(deleteFormRevisions(userFormRevisions.map(({ offline_id }) => offline_id)));
6898
7147
  }
6899
- store.dispatch(deleteUserForm(formId2));
7148
+ store.dispatch(deleteForm(formId2));
6900
7149
  try {
6901
7150
  return await this.enqueueRequest({
6902
7151
  description: "Delete form",
@@ -6906,12 +7155,12 @@ var __publicField = (obj, key, value) => {
6906
7155
  blocks: []
6907
7156
  });
6908
7157
  } catch (e) {
6909
- store.dispatch(addUserForm(userForm));
7158
+ store.dispatch(addForm(userForm));
6910
7159
  if (userFormRevisions && userFormRevisions.length > 0) {
6911
- store.dispatch(addUserFormRevisions(userFormRevisions));
7160
+ store.dispatch(addFormRevisions(userFormRevisions));
6912
7161
  }
6913
7162
  if (userFormSubmissions && userFormSubmissions.length > 0) {
6914
- store.dispatch(addUserFormSubmissions(userFormSubmissions));
7163
+ store.dispatch(addFormSubmissions(userFormSubmissions));
6915
7164
  }
6916
7165
  throw e;
6917
7166
  }
@@ -6925,16 +7174,15 @@ var __publicField = (obj, key, value) => {
6925
7174
  blockers: [],
6926
7175
  blocks: []
6927
7176
  });
6928
- store.dispatch(addUserForms(Object.values(result.forms)));
6929
- store.dispatch(addUserFormRevisions(Object.values(result.revisions)));
6930
- store.dispatch(setUserFormRevisionAttachments(Object.values(result.attachments)));
7177
+ store.dispatch(setForms(Object.values(result.forms)));
7178
+ store.dispatch(setFormRevisions(Object.values(result.revisions)));
7179
+ store.dispatch(setFormRevisionAttachments(Object.values(result.attachments)));
6931
7180
  }
6932
7181
  }
6933
7182
  const isArrayOfFiles = (value) => {
6934
7183
  return Array.isArray(value) && value[0] instanceof File;
6935
7184
  };
6936
- const separateFilesFromValues = (payload) => {
6937
- const { values } = payload;
7185
+ const separateFilesFromValues = (values) => {
6938
7186
  const files = {};
6939
7187
  const newValues = {};
6940
7188
  for (const key in values) {
@@ -6949,17 +7197,13 @@ var __publicField = (obj, key, value) => {
6949
7197
  newValues[key] = value;
6950
7198
  }
6951
7199
  }
6952
- const payloadWithoutFiles = {
6953
- ...payload,
6954
- values: newValues
6955
- };
6956
- return { payloadWithoutFiles, files };
7200
+ return { values: newValues, files };
6957
7201
  };
6958
7202
  class UserFormSubmissionService extends BaseApiService {
6959
7203
  constructor() {
6960
7204
  super(...arguments);
6961
7205
  // Attach files to submission, after uploading them to S3
6962
- __publicField(this, "getAttachFilesPromises", (files, payload) => {
7206
+ __publicField(this, "getAttachFilesPromises", (files, submission) => {
6963
7207
  const { store } = this.client;
6964
7208
  return Object.entries(files).map(async ([key, fileArray]) => {
6965
7209
  const attachResults = [];
@@ -6969,24 +7213,27 @@ var __publicField = (obj, key, value) => {
6969
7213
  const [fileProps] = await this.client.files.uploadFileToS3(sha1);
6970
7214
  const submissionAttachmentPayload = offline({
6971
7215
  ...fileProps,
6972
- submission: payload.offline_id,
7216
+ submission: submission.offline_id,
6973
7217
  field_identifier: key
6974
7218
  });
6975
7219
  const attach = await this.enqueueRequest({
6976
7220
  description: "Attach file to form submission",
6977
7221
  method: HttpMethod.POST,
6978
- url: `/forms/submission/${payload.offline_id}/attachments/`,
7222
+ url: `/forms/submission/${submission.offline_id}/attachments/`,
6979
7223
  payload: submissionAttachmentPayload,
6980
- blockers: [payload.component, payload.component_stage, payload.issue, payload.form_revision].filter(
6981
- (x) => x !== void 0
6982
- ),
7224
+ blockers: [
7225
+ submission.component,
7226
+ submission.component_stage,
7227
+ submission.issue,
7228
+ submission.form_revision
7229
+ ].filter((x) => x !== void 0),
6983
7230
  blocks: [submissionAttachmentPayload.offline_id]
6984
7231
  });
6985
7232
  const offlinePayload = {
6986
7233
  ...submissionAttachmentPayload,
6987
7234
  file: URL.createObjectURL(file)
6988
7235
  };
6989
- store.dispatch(addUserFormSubmissionAttachment(offlinePayload));
7236
+ store.dispatch(addFormSubmissionAttachment(offlinePayload));
6990
7237
  attachResults.push(attach);
6991
7238
  }
6992
7239
  return attachResults;
@@ -7000,70 +7247,165 @@ var __publicField = (obj, key, value) => {
7000
7247
  if (!activeProjectId) {
7001
7248
  throw new Error("Expected an active project");
7002
7249
  }
7003
- const { payloadWithoutFiles, files } = separateFilesFromValues(payload);
7250
+ const { values, files } = separateFilesFromValues(payload.values);
7251
+ const offlineSubmission = {
7252
+ ...payload,
7253
+ values,
7254
+ created_by: state.userReducer.currentUser.id,
7255
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7256
+ };
7004
7257
  const promise = this.enqueueRequest({
7005
7258
  description: "Respond to form",
7006
7259
  method: HttpMethod.POST,
7007
7260
  url: `/forms/revisions/${payload.form_revision}/respond/`,
7008
- payload: { ...payloadWithoutFiles, project: activeProjectId },
7261
+ payload: { ...offlineSubmission, project: activeProjectId },
7009
7262
  blockers: [payload.issue, payload.component, payload.component_stage, "add-form-entry"].filter(
7010
7263
  (x) => x !== void 0
7011
7264
  ),
7012
7265
  blocks: [payload.offline_id]
7013
7266
  });
7014
- const attachFilesPromises = this.getAttachFilesPromises(files, payload);
7015
- const now = (/* @__PURE__ */ new Date()).toISOString();
7016
- const fullOfflineResult = {
7017
- ...payload,
7018
- created_by: state.userReducer.currentUser.id,
7019
- created_at: now,
7020
- updated_at: now
7021
- };
7022
- const offlineResultWithoutFiles = {
7023
- ...fullOfflineResult,
7024
- ...payloadWithoutFiles
7025
- };
7026
- store.dispatch(updateOrCreateUserFormSubmission(offlineResultWithoutFiles));
7267
+ const attachFilesPromises = this.getAttachFilesPromises(files, offlineSubmission);
7268
+ store.dispatch(addFormSubmission(offlineSubmission));
7027
7269
  void promise.then((result) => {
7028
7270
  store.dispatch(addActiveProjectFormSubmissionsCount(1));
7029
- store.dispatch(updateOrCreateUserFormSubmission(result));
7271
+ store.dispatch(setFormSubmission(result));
7030
7272
  return result;
7031
7273
  }).catch(() => {
7032
- store.dispatch(deleteUserFormSubmission(payload.offline_id));
7274
+ store.dispatch(deleteFormSubmission(payload.offline_id));
7033
7275
  store.dispatch(addActiveProjectFormSubmissionsCount(-1));
7034
7276
  });
7035
7277
  const settledPromise = Promise.all([promise, ...attachFilesPromises]).then(() => promise);
7036
- return [fullOfflineResult, settledPromise];
7278
+ return [offlineSubmission, settledPromise];
7037
7279
  }
7038
- update(submission) {
7280
+ // Note currently the bulkAdd method is specific to form submissions for components
7281
+ // TODO: adapt the support bulk adding to any model type
7282
+ async bulkAdd(args) {
7283
+ const { form_revision, values: argsValues, componentOfflineIds } = args;
7039
7284
  const { store } = this.client;
7040
- const { payloadWithoutFiles, files } = separateFilesFromValues(submission);
7041
- if (!("created_by" in payloadWithoutFiles) || !("created_at" in payloadWithoutFiles)) {
7042
- throw new Error("Expected payloadWithoutFiles to have created_by and created_at fields.");
7285
+ const offlineSubmissions = [];
7286
+ const offlineAttachments = [];
7287
+ const submissionOfflineIds = [];
7288
+ const submissionsPayload = [];
7289
+ const attachmentsPayload = [];
7290
+ const { values, files } = separateFilesFromValues(argsValues);
7291
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7292
+ const createdBy = store.getState().userReducer.currentUser.id;
7293
+ for (const component_id of componentOfflineIds) {
7294
+ const submission = offline({
7295
+ form_revision,
7296
+ values,
7297
+ created_by: createdBy,
7298
+ submitted_at: submittedAt,
7299
+ component: component_id
7300
+ });
7301
+ submissionOfflineIds.push(submission.offline_id);
7302
+ submissionsPayload.push({ offline_id: submission.offline_id, component_id });
7303
+ offlineSubmissions.push(submission);
7304
+ for (const [fieldIdentifier, fileArray] of Object.entries(files)) {
7305
+ for (const file of fileArray) {
7306
+ const sha1 = await hashFile(file);
7307
+ await this.client.files.addCache(file, sha1);
7308
+ const offlineAttachment = offline({
7309
+ file_name: file.name,
7310
+ file_sha1: sha1,
7311
+ file: URL.createObjectURL(file),
7312
+ submission: submission.offline_id,
7313
+ field_identifier: fieldIdentifier
7314
+ });
7315
+ offlineAttachments.push(offlineAttachment);
7316
+ attachmentsPayload.push({
7317
+ offline_id: offlineAttachment.offline_id,
7318
+ submission_id: submission.offline_id,
7319
+ sha1,
7320
+ name: file.name,
7321
+ field_identifier: fieldIdentifier
7322
+ });
7323
+ }
7324
+ }
7043
7325
  }
7326
+ const filesRecord = {};
7327
+ for (const file of Object.values(files).flat()) {
7328
+ const sha1 = await hashFile(file);
7329
+ filesRecord[sha1] = {
7330
+ sha1,
7331
+ extension: file.name.split(".").pop() || "",
7332
+ file_type: file.type,
7333
+ size: file.size
7334
+ };
7335
+ }
7336
+ store.dispatch(addFormSubmissions(offlineSubmissions));
7337
+ store.dispatch(addFormSubmissionAttachments(offlineAttachments));
7338
+ const promise = this.enqueueRequest({
7339
+ description: "Bulk add form submissions",
7340
+ method: HttpMethod.POST,
7341
+ url: `/forms/revisions/${form_revision}/bulk-respond/`,
7342
+ payload: {
7343
+ form_data: values,
7344
+ submitted_at: submittedAt,
7345
+ submissions: submissionsPayload,
7346
+ attachments: attachmentsPayload,
7347
+ files: Object.values(filesRecord)
7348
+ },
7349
+ blockers: componentOfflineIds,
7350
+ blocks: submissionOfflineIds
7351
+ });
7352
+ promise.then(({ submissions, attachments, presigned_urls }) => {
7353
+ store.dispatch(updateFormSubmissions(submissions));
7354
+ store.dispatch(updateFormSubmissionAttachments(attachments));
7355
+ for (const [sha1, presigned_url] of Object.entries(presigned_urls)) {
7356
+ const file = filesRecord[sha1];
7357
+ if (!file)
7358
+ continue;
7359
+ void this.enqueueRequest({
7360
+ url: presigned_url.url,
7361
+ description: "Upload file",
7362
+ method: HttpMethod.POST,
7363
+ isExternalUrl: true,
7364
+ isAuthNeeded: false,
7365
+ attachmentHash: sha1,
7366
+ blockers: [`s3-${file.sha1}.${file.extension}`],
7367
+ blocks: [sha1],
7368
+ s3url: presigned_url
7369
+ });
7370
+ }
7371
+ }).catch(() => {
7372
+ store.dispatch(deleteFormSubmissions(submissionOfflineIds));
7373
+ store.dispatch(deleteFormSubmissionAttachments(offlineAttachments.map((x) => x.offline_id)));
7374
+ });
7375
+ return [offlineSubmissions, promise.then(({ submissions }) => submissions)];
7376
+ }
7377
+ update(submission) {
7378
+ const { store } = this.client;
7379
+ const { values, files } = separateFilesFromValues(submission.values);
7044
7380
  const attachFilesPromises = this.getAttachFilesPromises(files, submission);
7045
- const fullResult = {
7046
- ...payloadWithoutFiles,
7047
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
7381
+ const offlineSubmission = {
7382
+ ...submission,
7383
+ values
7048
7384
  };
7049
- store.dispatch(updateOrCreateUserFormSubmission(fullResult));
7385
+ const submissionToBeUpdated = store.getState().formSubmissionReducer.formSubmissions[submission.offline_id];
7386
+ store.dispatch(updateFormSubmission(offlineSubmission));
7050
7387
  const promise = this.enqueueRequest({
7051
7388
  description: "Patch form submission",
7052
7389
  method: HttpMethod.PATCH,
7053
7390
  url: `/forms/submissions/${submission.offline_id}/`,
7054
- payload: fullResult,
7055
- blockers: [fullResult.issue, fullResult.component, fullResult.component_stage].filter(
7391
+ payload: offlineSubmission,
7392
+ blockers: [offlineSubmission.issue, offlineSubmission.component, offlineSubmission.component_stage].filter(
7056
7393
  (x) => x !== void 0
7057
7394
  ),
7058
- blocks: [fullResult.offline_id]
7395
+ blocks: [offlineSubmission.offline_id]
7396
+ });
7397
+ promise.then((createdSubmission) => {
7398
+ store.dispatch(setFormSubmission(createdSubmission));
7399
+ }).catch(() => {
7400
+ store.dispatch(setFormSubmission(submissionToBeUpdated));
7059
7401
  });
7060
- return Promise.all([promise, ...attachFilesPromises]).then(() => promise);
7402
+ return [offlineSubmission, Promise.all([promise, ...attachFilesPromises]).then(() => promise)];
7061
7403
  }
7062
7404
  async delete(submissionId) {
7063
7405
  const { store } = this.client;
7064
7406
  const state = store.getState();
7065
- const submission = state.userFormReducer.submissions[submissionId];
7066
- store.dispatch(deleteUserFormSubmission(submissionId));
7407
+ const submission = state.formSubmissionReducer.formSubmissions[submissionId];
7408
+ store.dispatch(deleteFormSubmission(submissionId));
7067
7409
  store.dispatch(addActiveProjectFormSubmissionsCount(-1));
7068
7410
  try {
7069
7411
  return await this.enqueueRequest({
@@ -7074,10 +7416,8 @@ var __publicField = (obj, key, value) => {
7074
7416
  blocks: []
7075
7417
  });
7076
7418
  } catch (e) {
7077
- if (submission) {
7078
- store.dispatch(addActiveProjectFormSubmissionsCount(1));
7079
- store.dispatch(updateOrCreateUserFormSubmission(submission));
7080
- }
7419
+ store.dispatch(addActiveProjectFormSubmissionsCount(1));
7420
+ store.dispatch(addFormSubmission(submission));
7081
7421
  throw e;
7082
7422
  }
7083
7423
  }
@@ -7091,7 +7431,7 @@ var __publicField = (obj, key, value) => {
7091
7431
  blockers: [],
7092
7432
  blocks: []
7093
7433
  });
7094
- store.dispatch(setUserFormSubmissions(submissions));
7434
+ store.dispatch(setFormSubmissions(submissions));
7095
7435
  const attachments = await this.enqueueRequest({
7096
7436
  description: "Fetch form attachments",
7097
7437
  method: HttpMethod.GET,
@@ -7099,7 +7439,7 @@ var __publicField = (obj, key, value) => {
7099
7439
  blockers: [],
7100
7440
  blocks: []
7101
7441
  });
7102
- store.dispatch(setUserFormSubmissionAttachments(attachments));
7442
+ store.dispatch(setFormSubmissionAttachments(attachments));
7103
7443
  }
7104
7444
  }
7105
7445
  class WorkspaceService extends BaseApiService {
@@ -13957,7 +14297,7 @@ var __publicField = (obj, key, value) => {
13957
14297
  };
13958
14298
  const useAttachImagesToFormRevisionFields = (revision) => {
13959
14299
  const { sdk } = useSDK();
13960
- const attachments = useAppSelector(selectRevisionAttachments((revision == null ? void 0 : revision.offline_id) ?? ""));
14300
+ const attachments = useAppSelector(selectAttachmentsOfFormRevision((revision == null ? void 0 : revision.offline_id) ?? ""));
13961
14301
  return React.useMemo(() => {
13962
14302
  if (!revision || !attachments)
13963
14303
  return revision;
@@ -14054,7 +14394,7 @@ var __publicField = (obj, key, value) => {
14054
14394
  return formRevisionToSchema(revisionWithImages, { readonly: true });
14055
14395
  }, [revisionWithImages]);
14056
14396
  const submissionValuesWithAttachments = React.useMemo(() => {
14057
- const attachments = selectSubmissionAttachments(submission.offline_id)(sdk.store.getState()) ?? [];
14397
+ const attachments = selectAttachmentsOfFormSubmission(submission.offline_id)(sdk.store.getState()) ?? [];
14058
14398
  const downloadedAttachments = {};
14059
14399
  for (const attachment of attachments) {
14060
14400
  const promise = sdk.files.fetchFileFromUrl(attachment.file, attachment.file_sha1, attachment.file_name);
@@ -14104,8 +14444,8 @@ var __publicField = (obj, key, value) => {
14104
14444
  }
14105
14445
  return ret;
14106
14446
  }, [filter, maxResults, ownerFilter]);
14107
- const userForms = useAppSelector(selectFilteredUserForms(ownerFilterOptions)) ?? [];
14108
- const userFormMapping = useAppSelector(selectUserFormMapping);
14447
+ const userForms = useAppSelector(selectFilteredForms(ownerFilterOptions)) ?? [];
14448
+ const userFormMapping = useAppSelector(selectFormMapping);
14109
14449
  const attachableUserForms = userForms.filter((form) => !form.component_type);
14110
14450
  const attachableUserFormMapping = Object.values(userFormMapping).filter(
14111
14451
  (form) => !form.component_type
@@ -14138,7 +14478,7 @@ var __publicField = (obj, key, value) => {
14138
14478
  const handleChange = React.useCallback((e) => {
14139
14479
  setFilter(e.currentTarget.value);
14140
14480
  }, []);
14141
- const numberOfForms = useAppSelector(selectNumberOfGeneralUserForms) || 0;
14481
+ const numberOfForms = useAppSelector(selectGeneralFormCount) || 0;
14142
14482
  const numberOfHiddenForms = numberOfForms - attachableUserForms.length;
14143
14483
  const overflowMessage = attachableUserForms.length == maxResults && numberOfHiddenForms > 0 ? `Only the first ${maxResults} results are shown (${numberOfHiddenForms} hidden)` : numberOfHiddenForms > 0 && `${numberOfHiddenForms} hidden forms`;
14144
14484
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { ref, direction: "column", gap: "2", children: [
@@ -14232,16 +14572,13 @@ var __publicField = (obj, key, value) => {
14232
14572
  const { submission, onSubmissionClick, compact, labelType, rowDecorator } = props;
14233
14573
  const currentUser = useAppSelector(selectCurrentUser);
14234
14574
  const createdBy = useAppSelector(selectUser("created_by" in submission ? submission.created_by : currentUser.id));
14235
- const dateToUse = getCreatedAtOrSubmittedAtDate(submission);
14236
- const formattedDateTime = isToday(dateToUse) ? dateToUse.toLocaleTimeString([], {
14237
- hour: "2-digit",
14238
- minute: "2-digit"
14239
- }) : getLocalDateString(dateToUse);
14575
+ const dateToUse = submission.submitted_at;
14576
+ const formattedDateTime = getLocalDateString(dateToUse);
14240
14577
  const revision = useAppSelector(selectFormRevision(submission.form_revision));
14241
14578
  if (!revision) {
14242
14579
  throw new Error(`Could not find revision ${submission.form_revision} for submission ${submission.offline_id}.`);
14243
14580
  }
14244
- const latestRevisionNumber = (_a2 = useAppSelector(selectLatestFormRevision(revision.form))) == null ? void 0 : _a2.revision;
14581
+ const latestRevisionNumber = (_a2 = useAppSelector(selectLatestFormRevisionOfForm(revision.form))) == null ? void 0 : _a2.revision;
14245
14582
  const creatorProfileSrc = useFileSrc({
14246
14583
  file: (createdBy == null ? void 0 : createdBy.profile.file) ?? null,
14247
14584
  fileSha1: (createdBy == null ? void 0 : createdBy.profile.file_sha1) ?? null
@@ -14272,10 +14609,6 @@ var __publicField = (obj, key, value) => {
14272
14609
  return row;
14273
14610
  });
14274
14611
  FormSubmissionBrowserEntry.displayName = "FormSubmissionBrowserEntry";
14275
- const getCreatedAtOrSubmittedAtDate = (submission) => {
14276
- const date = "created_at" in submission ? submission.created_at : submission.submitted_at;
14277
- return new Date(date);
14278
- };
14279
14612
  const FormSubmissionBrowser = React.memo((props) => {
14280
14613
  const {
14281
14614
  formId: formId2,
@@ -14289,10 +14622,10 @@ var __publicField = (obj, key, value) => {
14289
14622
  if (!!formId2 === !!propSubmissions) {
14290
14623
  throw new Error("Either formId or submissions must be provided, but not both.");
14291
14624
  }
14292
- const submissions = useAppSelector(propSubmissions ? () => propSubmissions : selectSubmissionsForForm(formId2));
14625
+ const submissions = useAppSelector(propSubmissions ? () => propSubmissions : selectFormSubmissionsOfForm(formId2));
14293
14626
  const sortedSubmissions = React.useMemo(
14294
14627
  () => submissions == null ? void 0 : submissions.sort((a, b) => {
14295
- return getCreatedAtOrSubmittedAtDate(b).getTime() - getCreatedAtOrSubmittedAtDate(a).getTime();
14628
+ return a.submitted_at.localeCompare(b.submitted_at);
14296
14629
  }),
14297
14630
  [submissions]
14298
14631
  );
@@ -15609,6 +15942,7 @@ var __publicField = (obj, key, value) => {
15609
15942
  exports2.VerificationCodeType = VerificationCodeType;
15610
15943
  exports2.WorkspaceService = WorkspaceService;
15611
15944
  exports2.YELLOW = YELLOW;
15945
+ exports2._selectLatestFormRevision = _selectLatestFormRevision;
15612
15946
  exports2._setLatestRetryTime = _setLatestRetryTime;
15613
15947
  exports2.acceptProjectInvite = acceptProjectInvite;
15614
15948
  exports2.addActiveProjectFormSubmissionsCount = addActiveProjectFormSubmissionsCount;
@@ -15621,9 +15955,21 @@ var __publicField = (obj, key, value) => {
15621
15955
  exports2.addComponentTypeAttachment = addComponentTypeAttachment;
15622
15956
  exports2.addComponentTypeAttachments = addComponentTypeAttachments;
15623
15957
  exports2.addComponentsInBatches = addComponentsInBatches;
15958
+ exports2.addDocumentAttachment = addDocumentAttachment;
15959
+ exports2.addDocumentAttachments = addDocumentAttachments;
15624
15960
  exports2.addDocuments = addDocuments;
15625
15961
  exports2.addEmailDomain = addEmailDomain;
15626
15962
  exports2.addFavouriteProjectId = addFavouriteProjectId;
15963
+ exports2.addForm = addForm;
15964
+ exports2.addFormRevision = addFormRevision;
15965
+ exports2.addFormRevisionAttachment = addFormRevisionAttachment;
15966
+ exports2.addFormRevisionAttachments = addFormRevisionAttachments;
15967
+ exports2.addFormRevisions = addFormRevisions;
15968
+ exports2.addFormSubmission = addFormSubmission;
15969
+ exports2.addFormSubmissionAttachment = addFormSubmissionAttachment;
15970
+ exports2.addFormSubmissionAttachments = addFormSubmissionAttachments;
15971
+ exports2.addFormSubmissions = addFormSubmissions;
15972
+ exports2.addForms = addForms;
15627
15973
  exports2.addIssue = addIssue;
15628
15974
  exports2.addIssueAttachment = addIssueAttachment;
15629
15975
  exports2.addIssueAttachments = addIssueAttachments;
@@ -15644,13 +15990,6 @@ var __publicField = (obj, key, value) => {
15644
15990
  exports2.addStageCompletions = addStageCompletions;
15645
15991
  exports2.addStages = addStages;
15646
15992
  exports2.addToRecentIssues = addToRecentIssues;
15647
- exports2.addUserForm = addUserForm;
15648
- exports2.addUserFormRevision = addUserFormRevision;
15649
- exports2.addUserFormRevisionAttachment = addUserFormRevisionAttachment;
15650
- exports2.addUserFormRevisions = addUserFormRevisions;
15651
- exports2.addUserFormSubmissionAttachment = addUserFormSubmissionAttachment;
15652
- exports2.addUserFormSubmissions = addUserFormSubmissions;
15653
- exports2.addUserForms = addUserForms;
15654
15993
  exports2.addUsers = addUsers;
15655
15994
  exports2.addWorkspace = addWorkspace;
15656
15995
  exports2.areArraysEqual = areArraysEqual;
@@ -15671,6 +16010,7 @@ var __publicField = (obj, key, value) => {
15671
16010
  exports2.componentStageSlice = componentStageSlice;
15672
16011
  exports2.componentTypeReducer = componentTypeReducer;
15673
16012
  exports2.componentTypeSlice = componentTypeSlice;
16013
+ exports2.constructUploadedFilePayloads = constructUploadedFilePayloads;
15674
16014
  exports2.coordinatesAreEqual = coordinatesAreEqual;
15675
16015
  exports2.coordinatesToLiteral = coordinatesToLiteral;
15676
16016
  exports2.coordinatesToPointGeometry = coordinatesToPointGeometry;
@@ -15681,12 +16021,16 @@ var __publicField = (obj, key, value) => {
15681
16021
  exports2.defaultBadgeColor = defaultBadgeColor;
15682
16022
  exports2.defaultStore = defaultStore;
15683
16023
  exports2.deleteComponentType = deleteComponentType;
16024
+ exports2.deleteForm = deleteForm;
16025
+ exports2.deleteFormRevision = deleteFormRevision;
16026
+ exports2.deleteFormRevisionAttachment = deleteFormRevisionAttachment;
16027
+ exports2.deleteFormRevisionAttachments = deleteFormRevisionAttachments;
16028
+ exports2.deleteFormRevisions = deleteFormRevisions;
16029
+ exports2.deleteFormSubmission = deleteFormSubmission;
16030
+ exports2.deleteFormSubmissionAttachment = deleteFormSubmissionAttachment;
16031
+ exports2.deleteFormSubmissionAttachments = deleteFormSubmissionAttachments;
16032
+ exports2.deleteFormSubmissions = deleteFormSubmissions;
15684
16033
  exports2.deleteProject = deleteProject;
15685
- exports2.deleteUserForm = deleteUserForm;
15686
- exports2.deleteUserFormRevision = deleteUserFormRevision;
15687
- exports2.deleteUserFormRevisions = deleteUserFormRevisions;
15688
- exports2.deleteUserFormSubmission = deleteUserFormSubmission;
15689
- exports2.deleteUserFormSubmissions = deleteUserFormSubmissions;
15690
16034
  exports2.dequeue = dequeue;
15691
16035
  exports2.deserialize = deserialize;
15692
16036
  exports2.deserializeField = deserializeField;
@@ -15715,7 +16059,13 @@ var __publicField = (obj, key, value) => {
15715
16059
  exports2.fileSlice = fileSlice;
15716
16060
  exports2.fileToBlob = fileToBlob;
15717
16061
  exports2.flipCoordinates = flipCoordinates;
16062
+ exports2.formReducer = formReducer;
16063
+ exports2.formRevisionReducer = formRevisionReducer;
15718
16064
  exports2.formRevisionToSchema = formRevisionToSchema;
16065
+ exports2.formRevisionsSlice = formRevisionsSlice;
16066
+ exports2.formSlice = formSlice;
16067
+ exports2.formSubmissionReducer = formSubmissionReducer;
16068
+ exports2.formSubmissionSlice = formSubmissionSlice;
15719
16069
  exports2.forms = index;
15720
16070
  exports2.fullComponentMarkerSize = fullComponentMarkerSize;
15721
16071
  exports2.generateBadgeColors = generateBadgeColors;
@@ -15784,6 +16134,8 @@ var __publicField = (obj, key, value) => {
15784
16134
  exports2.removeComponentAttachments = removeComponentAttachments;
15785
16135
  exports2.removeComponentTypeAttachment = removeComponentTypeAttachment;
15786
16136
  exports2.removeComponentTypeAttachments = removeComponentTypeAttachments;
16137
+ exports2.removeDocumentAttachment = removeDocumentAttachment;
16138
+ exports2.removeDocumentAttachments = removeDocumentAttachments;
15787
16139
  exports2.removeDocuments = removeDocuments;
15788
16140
  exports2.removeEmailDomain = removeEmailDomain;
15789
16141
  exports2.removeFavouriteProjectId = removeFavouriteProjectId;
@@ -15831,6 +16183,7 @@ var __publicField = (obj, key, value) => {
15831
16183
  exports2.selectAllAttachments = selectAllAttachments;
15832
16184
  exports2.selectAllComponentAttachments = selectAllComponentAttachments;
15833
16185
  exports2.selectAllComponentTypeAttachments = selectAllComponentTypeAttachments;
16186
+ exports2.selectAllDocumentAttachments = selectAllDocumentAttachments;
15834
16187
  exports2.selectAllProjectAttachments = selectAllProjectAttachments;
15835
16188
  exports2.selectAncestorIdsOfDocument = selectAncestorIdsOfDocument;
15836
16189
  exports2.selectAppearance = selectAppearance;
@@ -15838,6 +16191,10 @@ var __publicField = (obj, key, value) => {
15838
16191
  exports2.selectAttachmentsOfComponentByType = selectAttachmentsOfComponentByType;
15839
16192
  exports2.selectAttachmentsOfComponentType = selectAttachmentsOfComponentType;
15840
16193
  exports2.selectAttachmentsOfComponentTypeByType = selectAttachmentsOfComponentTypeByType;
16194
+ exports2.selectAttachmentsOfDocument = selectAttachmentsOfDocument;
16195
+ exports2.selectAttachmentsOfDocumentByType = selectAttachmentsOfDocumentByType;
16196
+ exports2.selectAttachmentsOfFormRevision = selectAttachmentsOfFormRevision;
16197
+ exports2.selectAttachmentsOfFormSubmission = selectAttachmentsOfFormSubmission;
15841
16198
  exports2.selectAttachmentsOfIssue = selectAttachmentsOfIssue;
15842
16199
  exports2.selectAttachmentsOfIssueByType = selectAttachmentsOfIssueByType;
15843
16200
  exports2.selectAttachmentsOfProject = selectAttachmentsOfProject;
@@ -15853,11 +16210,11 @@ var __publicField = (obj, key, value) => {
15853
16210
  exports2.selectCompletedStageIdsForComponent = selectCompletedStageIdsForComponent;
15854
16211
  exports2.selectCompletedStages = selectCompletedStages;
15855
16212
  exports2.selectComponent = selectComponent;
16213
+ exports2.selectComponentAttachment = selectComponentAttachment;
15856
16214
  exports2.selectComponentAttachmentMapping = selectComponentAttachmentMapping;
15857
- exports2.selectComponentSubmissionMapping = selectComponentSubmissionMapping;
15858
16215
  exports2.selectComponentType = selectComponentType;
16216
+ exports2.selectComponentTypeAttachment = selectComponentTypeAttachment;
15859
16217
  exports2.selectComponentTypeAttachmentMapping = selectComponentTypeAttachmentMapping;
15860
- exports2.selectComponentTypeForm = selectComponentTypeForm;
15861
16218
  exports2.selectComponentTypeFromComponent = selectComponentTypeFromComponent;
15862
16219
  exports2.selectComponentTypeFromComponents = selectComponentTypeFromComponents;
15863
16220
  exports2.selectComponentTypeStagesMapping = selectComponentTypeStagesMapping;
@@ -15873,6 +16230,8 @@ var __publicField = (obj, key, value) => {
15873
16230
  exports2.selectCurrentUser = selectCurrentUser;
15874
16231
  exports2.selectDeletedRequests = selectDeletedRequests;
15875
16232
  exports2.selectDocument = selectDocument;
16233
+ exports2.selectDocumentAttachment = selectDocumentAttachment;
16234
+ exports2.selectDocumentAttachmentMapping = selectDocumentAttachmentMapping;
15876
16235
  exports2.selectDocuments = selectDocuments;
15877
16236
  exports2.selectDocumentsMapping = selectDocumentsMapping;
15878
16237
  exports2.selectEmailDomainsAsMapping = selectEmailDomainsAsMapping;
@@ -15885,8 +16244,24 @@ var __publicField = (obj, key, value) => {
15885
16244
  exports2.selectExpandedSections = selectExpandedSections;
15886
16245
  exports2.selectFavouriteProjects = selectFavouriteProjects;
15887
16246
  exports2.selectFileAttachmentsOfIssue = selectFileAttachmentsOfIssue;
15888
- exports2.selectFilteredUserForms = selectFilteredUserForms;
16247
+ exports2.selectFilteredForms = selectFilteredForms;
16248
+ exports2.selectForm = selectForm;
16249
+ exports2.selectFormMapping = selectFormMapping;
16250
+ exports2.selectFormOfComponentType = selectFormOfComponentType;
15889
16251
  exports2.selectFormRevision = selectFormRevision;
16252
+ exports2.selectFormRevisionMapping = selectFormRevisionMapping;
16253
+ exports2.selectFormRevisions = selectFormRevisions;
16254
+ exports2.selectFormRevisionsOfForm = selectFormRevisionsOfForm;
16255
+ exports2.selectFormSubmission = selectFormSubmission;
16256
+ exports2.selectFormSubmissionAttachmentsMapping = selectFormSubmissionAttachmentsMapping;
16257
+ exports2.selectFormSubmissions = selectFormSubmissions;
16258
+ exports2.selectFormSubmissionsByComponents = selectFormSubmissionsByComponents;
16259
+ exports2.selectFormSubmissionsMapping = selectFormSubmissionsMapping;
16260
+ exports2.selectFormSubmissionsOfComponent = selectFormSubmissionsOfComponent;
16261
+ exports2.selectFormSubmissionsOfForm = selectFormSubmissionsOfForm;
16262
+ exports2.selectFormSubmissionsOfIssue = selectFormSubmissionsOfIssue;
16263
+ exports2.selectFormsCount = selectFormsCount;
16264
+ exports2.selectGeneralFormCount = selectGeneralFormCount;
15890
16265
  exports2.selectHiddenCategoryCount = selectHiddenCategoryCount;
15891
16266
  exports2.selectHiddenComponentTypeIds = selectHiddenComponentTypeIds;
15892
16267
  exports2.selectIsFetchingInitialData = selectIsFetchingInitialData;
@@ -15894,16 +16269,17 @@ var __publicField = (obj, key, value) => {
15894
16269
  exports2.selectIsLoading = selectIsLoading;
15895
16270
  exports2.selectIsLoggedIn = selectIsLoggedIn;
15896
16271
  exports2.selectIssue = selectIssue;
16272
+ exports2.selectIssueAttachment = selectIssueAttachment;
15897
16273
  exports2.selectIssueAttachmentMapping = selectIssueAttachmentMapping;
15898
16274
  exports2.selectIssueAttachments = selectIssueAttachments;
15899
16275
  exports2.selectIssueMapping = selectIssueMapping;
15900
16276
  exports2.selectIssueUpdateMapping = selectIssueUpdateMapping;
15901
16277
  exports2.selectIssueUpdatesOfIssue = selectIssueUpdatesOfIssue;
15902
16278
  exports2.selectIssues = selectIssues;
15903
- exports2.selectLatestFormRevision = selectLatestFormRevision;
16279
+ exports2.selectLatestFormRevisionByForm = selectLatestFormRevisionByForm;
16280
+ exports2.selectLatestFormRevisionOfForm = selectLatestFormRevisionOfForm;
16281
+ exports2.selectLatestFormRevisionsOfComponentTypes = selectLatestFormRevisionsOfComponentTypes;
15904
16282
  exports2.selectLatestRetryTime = selectLatestRetryTime;
15905
- exports2.selectLatestRevisionByFormId = selectLatestRevisionByFormId;
15906
- exports2.selectLatestRevisionsFromComponentTypeIds = selectLatestRevisionsFromComponentTypeIds;
15907
16283
  exports2.selectLicense = selectLicense;
15908
16284
  exports2.selectLicenseForProject = selectLicenseForProject;
15909
16285
  exports2.selectLicenses = selectLicenses;
@@ -15912,8 +16288,6 @@ var __publicField = (obj, key, value) => {
15912
16288
  exports2.selectMapStyle = selectMapStyle;
15913
16289
  exports2.selectNumberOfComponentTypesMatchingCaseInsensitiveName = selectNumberOfComponentTypesMatchingCaseInsensitiveName;
15914
16290
  exports2.selectNumberOfComponentsOfComponentType = selectNumberOfComponentsOfComponentType;
15915
- exports2.selectNumberOfGeneralUserForms = selectNumberOfGeneralUserForms;
15916
- exports2.selectNumberOfUserForms = selectNumberOfUserForms;
15917
16291
  exports2.selectOrganization = selectOrganization;
15918
16292
  exports2.selectOrganizationAccess = selectOrganizationAccess;
15919
16293
  exports2.selectOrganizationAccessForUser = selectOrganizationAccessForUser;
@@ -15941,8 +16315,6 @@ var __publicField = (obj, key, value) => {
15941
16315
  exports2.selectRecentIssuesAsSearchResults = selectRecentIssuesAsSearchResults;
15942
16316
  exports2.selectRecentProjects = selectRecentProjects;
15943
16317
  exports2.selectRehydrated = selectRehydrated;
15944
- exports2.selectRevisionAttachments = selectRevisionAttachments;
15945
- exports2.selectRevisionsForForm = selectRevisionsForForm;
15946
16318
  exports2.selectRootDocuments = selectRootDocuments;
15947
16319
  exports2.selectShowTooltips = selectShowTooltips;
15948
16320
  exports2.selectSortedEmailDomains = selectSortedEmailDomains;
@@ -15957,16 +16329,10 @@ var __publicField = (obj, key, value) => {
15957
16329
  exports2.selectStagesFromComponentType = selectStagesFromComponentType;
15958
16330
  exports2.selectStagesFromComponentTypeIds = selectStagesFromComponentTypeIds;
15959
16331
  exports2.selectStagesFromStageIds = selectStagesFromStageIds;
15960
- exports2.selectSubmissionAttachments = selectSubmissionAttachments;
15961
- exports2.selectSubmissionsForComponent = selectSubmissionsForComponent;
15962
- exports2.selectSubmissionsForForm = selectSubmissionsForForm;
15963
- exports2.selectSubmissionsForIssue = selectSubmissionsForIssue;
15964
16332
  exports2.selectUploadUrl = selectUploadUrl;
15965
16333
  exports2.selectUsedColors = selectUsedColors;
15966
16334
  exports2.selectUser = selectUser;
15967
- exports2.selectUserForm = selectUserForm;
15968
- exports2.selectUserFormMapping = selectUserFormMapping;
15969
- exports2.selectUserFormSubmission = selectUserFormSubmission;
16335
+ exports2.selectUserFormRevisionAttachmentsMapping = selectUserFormRevisionAttachmentsMapping;
15970
16336
  exports2.selectUsersAsMapping = selectUsersAsMapping;
15971
16337
  exports2.selectVisibleStatuses = selectVisibleStatuses;
15972
16338
  exports2.selectVisibleUserIds = selectVisibleUserIds;
@@ -15987,11 +16353,19 @@ var __publicField = (obj, key, value) => {
15987
16353
  exports2.setComponents = setComponents;
15988
16354
  exports2.setCreateProjectType = setCreateProjectType;
15989
16355
  exports2.setCurrentUser = setCurrentUser;
16356
+ exports2.setDocumentAttachments = setDocumentAttachments;
15990
16357
  exports2.setDocuments = setDocuments;
15991
16358
  exports2.setEmailDomains = setEmailDomains;
15992
16359
  exports2.setEnableClustering = setEnableClustering;
15993
16360
  exports2.setEnableDuplicateIssues = setEnableDuplicateIssues;
15994
16361
  exports2.setEnablePlacementMode = setEnablePlacementMode;
16362
+ exports2.setFormRevision = setFormRevision;
16363
+ exports2.setFormRevisionAttachments = setFormRevisionAttachments;
16364
+ exports2.setFormRevisions = setFormRevisions;
16365
+ exports2.setFormSubmission = setFormSubmission;
16366
+ exports2.setFormSubmissionAttachments = setFormSubmissionAttachments;
16367
+ exports2.setFormSubmissions = setFormSubmissions;
16368
+ exports2.setForms = setForms;
15995
16369
  exports2.setIsFetchingInitialData = setIsFetchingInitialData;
15996
16370
  exports2.setIsImportingProjectFile = setIsImportingProjectFile;
15997
16371
  exports2.setIsLoading = setIsLoading;
@@ -16016,9 +16390,6 @@ var __publicField = (obj, key, value) => {
16016
16390
  exports2.setTokens = setTokens;
16017
16391
  exports2.setTourStep = setTourStep;
16018
16392
  exports2.setUploadUrl = setUploadUrl;
16019
- exports2.setUserFormRevisionAttachments = setUserFormRevisionAttachments;
16020
- exports2.setUserFormSubmissionAttachments = setUserFormSubmissionAttachments;
16021
- exports2.setUserFormSubmissions = setUserFormSubmissions;
16022
16393
  exports2.setUsers = setUsers;
16023
16394
  exports2.setVisibleStatuses = setVisibleStatuses;
16024
16395
  exports2.setVisibleUserIds = setVisibleUserIds;
@@ -16041,12 +16412,15 @@ var __publicField = (obj, key, value) => {
16041
16412
  exports2.updateComponent = updateComponent;
16042
16413
  exports2.updateComponentAttachment = updateComponentAttachment;
16043
16414
  exports2.updateComponentTypeAttachment = updateComponentTypeAttachment;
16415
+ exports2.updateDocumentAttachment = updateDocumentAttachment;
16044
16416
  exports2.updateDocuments = updateDocuments;
16417
+ exports2.updateFormSubmission = updateFormSubmission;
16418
+ exports2.updateFormSubmissionAttachments = updateFormSubmissionAttachments;
16419
+ exports2.updateFormSubmissions = updateFormSubmissions;
16045
16420
  exports2.updateIssue = updateIssue;
16046
16421
  exports2.updateIssueAttachment = updateIssueAttachment;
16047
16422
  exports2.updateLicense = updateLicense;
16048
16423
  exports2.updateOrCreateProject = updateOrCreateProject;
16049
- exports2.updateOrCreateUserFormSubmission = updateOrCreateUserFormSubmission;
16050
16424
  exports2.updateOrganizationAccess = updateOrganizationAccess;
16051
16425
  exports2.updateProjectAccess = updateProjectAccess;
16052
16426
  exports2.updateProjectAttachment = updateProjectAttachment;
@@ -16060,8 +16434,6 @@ var __publicField = (obj, key, value) => {
16060
16434
  exports2.useFormikInput = useFormikInput;
16061
16435
  exports2.useMemoCompare = useMemoCompare;
16062
16436
  exports2.useSDK = useSDK;
16063
- exports2.userFormReducer = userFormReducer;
16064
- exports2.userFormSlice = userFormSlice;
16065
16437
  exports2.userReducer = userReducer;
16066
16438
  exports2.userSlice = userSlice;
16067
16439
  exports2.valueIsFile = valueIsFile;