@overmap-ai/core 1.0.50 → 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))
@@ -1587,14 +1600,14 @@ var __publicField = (obj, key, value) => {
1587
1600
  delete state.attachments[attachmentId];
1588
1601
  }
1589
1602
  }
1590
- const initialState$l = {
1603
+ const initialState$n = {
1591
1604
  components: {},
1592
1605
  attachments: {}
1593
1606
  };
1594
1607
  const componentSlice = toolkit.createSlice({
1595
1608
  name: "components",
1596
- initialState: initialState$l,
1597
- 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)),
1598
1611
  reducers: {
1599
1612
  addComponent: (state, action) => {
1600
1613
  state.components[action.payload.offline_id] = action.payload;
@@ -1750,13 +1763,13 @@ var __publicField = (obj, key, value) => {
1750
1763
  removeAllComponentsOfType
1751
1764
  } = componentSlice.actions;
1752
1765
  const componentReducer = componentSlice.reducer;
1753
- const initialState$k = {
1766
+ const initialState$m = {
1754
1767
  completionsByComponentId: {}
1755
1768
  };
1756
1769
  const componentStageCompletionSlice = toolkit.createSlice({
1757
1770
  name: "componentStageCompletions",
1758
- initialState: initialState$k,
1759
- 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)),
1760
1773
  reducers: {
1761
1774
  addStageCompletion: (state, action) => {
1762
1775
  let stageToCompletionDateMapping = state.completionsByComponentId[action.payload.component];
@@ -1807,13 +1820,13 @@ var __publicField = (obj, key, value) => {
1807
1820
  return Object.keys(state.componentStageCompletionReducer.completionsByComponentId[component.offline_id] ?? {});
1808
1821
  };
1809
1822
  const componentStageCompletionReducer = componentStageCompletionSlice.reducer;
1810
- const initialState$j = {
1823
+ const initialState$l = {
1811
1824
  stages: {}
1812
1825
  };
1813
1826
  const componentStageSlice = toolkit.createSlice({
1814
1827
  name: "componentStages",
1815
- initialState: initialState$j,
1816
- 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)),
1817
1830
  reducers: {
1818
1831
  addStages: (state, action) => {
1819
1832
  Object.assign(state.stages, toOfflineIdRecord(action.payload));
@@ -1923,15 +1936,15 @@ var __publicField = (obj, key, value) => {
1923
1936
  );
1924
1937
  const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = componentStageSlice.actions;
1925
1938
  const componentStageReducer = componentStageSlice.reducer;
1926
- const initialState$i = {
1939
+ const initialState$k = {
1927
1940
  componentTypes: {},
1928
1941
  hiddenComponentTypeIds: {},
1929
1942
  attachments: {}
1930
1943
  };
1931
1944
  const componentTypeSlice = toolkit.createSlice({
1932
1945
  name: "componentTypes",
1933
- initialState: initialState$i,
1934
- 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)),
1935
1948
  reducers: {
1936
1949
  addComponentType: (state, action) => {
1937
1950
  state.componentTypes[action.payload.offline_id] = action.payload;
@@ -2042,13 +2055,13 @@ var __publicField = (obj, key, value) => {
2042
2055
  deleteComponentType
2043
2056
  } = componentTypeSlice.actions;
2044
2057
  const componentTypeReducer = componentTypeSlice.reducer;
2045
- const initialState$h = {
2058
+ const initialState$j = {
2046
2059
  workspaces: {},
2047
2060
  activeWorkspaceId: null
2048
2061
  };
2049
2062
  const workspaceSlice = toolkit.createSlice({
2050
2063
  name: "workspace",
2051
- initialState: initialState$h,
2064
+ initialState: initialState$j,
2052
2065
  // The `reducers` field lets us define reducers and generate associated actions
2053
2066
  reducers: {
2054
2067
  setWorkspaces: (state, action) => {
@@ -2105,7 +2118,7 @@ var __publicField = (obj, key, value) => {
2105
2118
  );
2106
2119
  const workspaceReducer = workspaceSlice.reducer;
2107
2120
  const maxRecentIssues = 10;
2108
- const initialState$g = {
2121
+ const initialState$i = {
2109
2122
  issues: {},
2110
2123
  attachments: {},
2111
2124
  comments: {},
@@ -2117,9 +2130,9 @@ var __publicField = (obj, key, value) => {
2117
2130
  };
2118
2131
  const issueSlice = toolkit.createSlice({
2119
2132
  name: "issues",
2120
- initialState: initialState$g,
2133
+ initialState: initialState$i,
2121
2134
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2122
- Object.assign(state, initialState$g);
2135
+ Object.assign(state, initialState$i);
2123
2136
  }),
2124
2137
  reducers: {
2125
2138
  setIssues: (state, action) => {
@@ -2527,15 +2540,15 @@ var __publicField = (obj, key, value) => {
2527
2540
  }
2528
2541
  );
2529
2542
  const issueReducer = issueSlice.reducer;
2530
- const initialState$f = {
2543
+ const initialState$h = {
2531
2544
  s3Urls: {}
2532
2545
  };
2533
2546
  const msPerHour = 1e3 * 60 * 60;
2534
2547
  const msPerWeek = msPerHour * 24 * 7;
2535
2548
  const fileSlice = toolkit.createSlice({
2536
2549
  name: "file",
2537
- initialState: initialState$f,
2538
- 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)),
2539
2552
  reducers: {
2540
2553
  setUploadUrl: (state, action) => {
2541
2554
  const { url, fields, sha1 } = action.payload;
@@ -2562,7 +2575,7 @@ var __publicField = (obj, key, value) => {
2562
2575
  return url;
2563
2576
  };
2564
2577
  const fileReducer = fileSlice.reducer;
2565
- const initialState$e = {
2578
+ const initialState$g = {
2566
2579
  // TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
2567
2580
  mapStyle: MapStyle.SATELLITE,
2568
2581
  showTooltips: false,
@@ -2570,8 +2583,8 @@ var __publicField = (obj, key, value) => {
2570
2583
  };
2571
2584
  const mapSlice = toolkit.createSlice({
2572
2585
  name: "map",
2573
- initialState: initialState$e,
2574
- 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)),
2575
2588
  reducers: {
2576
2589
  setMapStyle: (state, action) => {
2577
2590
  state.mapStyle = action.payload;
@@ -2640,7 +2653,7 @@ var __publicField = (obj, key, value) => {
2640
2653
  LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
2641
2654
  return LicenseStatus2;
2642
2655
  })(LicenseStatus || {});
2643
- const initialState$d = {
2656
+ const initialState$f = {
2644
2657
  users: {},
2645
2658
  currentUser: {
2646
2659
  id: 0,
@@ -2651,8 +2664,8 @@ var __publicField = (obj, key, value) => {
2651
2664
  };
2652
2665
  const userSlice = toolkit.createSlice({
2653
2666
  name: "users",
2654
- initialState: initialState$d,
2655
- 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)),
2656
2669
  reducers: {
2657
2670
  setUsers: (state, action) => {
2658
2671
  const usersMapping = {};
@@ -2714,13 +2727,13 @@ var __publicField = (obj, key, value) => {
2714
2727
  const selectUsersAsMapping = (state) => state.userReducer.users;
2715
2728
  const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
2716
2729
  const userReducer = userSlice.reducer;
2717
- const initialState$c = {
2730
+ const initialState$e = {
2718
2731
  organizationAccesses: {}
2719
2732
  };
2720
2733
  const organizationAccessSlice = toolkit.createSlice({
2721
2734
  name: "organizationAccess",
2722
- initialState: initialState$c,
2723
- 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)),
2724
2737
  reducers: {
2725
2738
  setOrganizationAccesses: (state, action) => {
2726
2739
  if (!Array.isArray(action.payload))
@@ -2783,13 +2796,13 @@ var __publicField = (obj, key, value) => {
2783
2796
  return organizationAccesses;
2784
2797
  };
2785
2798
  const organizationAccessReducer = organizationAccessSlice.reducer;
2786
- const initialState$b = {
2799
+ const initialState$d = {
2787
2800
  licenses: {}
2788
2801
  };
2789
2802
  const licenseSlice = toolkit.createSlice({
2790
2803
  name: "license",
2791
- initialState: initialState$b,
2792
- 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)),
2793
2806
  reducers: {
2794
2807
  setLicenses: (state, action) => {
2795
2808
  if (!Array.isArray(action.payload))
@@ -2834,13 +2847,13 @@ var __publicField = (obj, key, value) => {
2834
2847
  (licenses) => Object.values(licenses).filter((license) => license.project).reduce((accum, license) => ({ ...accum, [license.project]: license }), {})
2835
2848
  );
2836
2849
  const licenseReducer = licenseSlice.reducer;
2837
- const initialState$a = {
2850
+ const initialState$c = {
2838
2851
  projectAccesses: {}
2839
2852
  };
2840
2853
  const projectAccessSlice = toolkit.createSlice({
2841
2854
  name: "projectAccess",
2842
- initialState: initialState$a,
2843
- 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)),
2844
2857
  reducers: {
2845
2858
  setProjectAccesses: (state, action) => {
2846
2859
  if (!Array.isArray(action.payload))
@@ -2908,7 +2921,7 @@ var __publicField = (obj, key, value) => {
2908
2921
  return projectAccesses;
2909
2922
  };
2910
2923
  const projectAccessReducer = projectAccessSlice.reducer;
2911
- const initialState$9 = {
2924
+ const initialState$b = {
2912
2925
  projects: {},
2913
2926
  activeProjectId: null,
2914
2927
  recentProjectIds: [],
@@ -2918,7 +2931,7 @@ var __publicField = (obj, key, value) => {
2918
2931
  };
2919
2932
  const projectSlice = toolkit.createSlice({
2920
2933
  name: "projects",
2921
- initialState: initialState$9,
2934
+ initialState: initialState$b,
2922
2935
  reducers: {
2923
2936
  setProjects: (state, action) => {
2924
2937
  const projectsMap = {};
@@ -3105,14 +3118,14 @@ var __publicField = (obj, key, value) => {
3105
3118
  }
3106
3119
  )
3107
3120
  );
3108
- const initialState$8 = {
3121
+ const initialState$a = {
3109
3122
  organizations: {},
3110
3123
  activeOrganizationId: null
3111
3124
  };
3112
3125
  const organizationSlice = toolkit.createSlice({
3113
3126
  name: "organizations",
3114
- initialState: initialState$8,
3115
- 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)),
3116
3129
  reducers: {
3117
3130
  setOrganizations: (state, action) => {
3118
3131
  for (const org of action.payload) {
@@ -3231,14 +3244,14 @@ var __publicField = (obj, key, value) => {
3231
3244
  }
3232
3245
  };
3233
3246
  };
3234
- const initialState$7 = {
3247
+ const initialState$9 = {
3235
3248
  deletedRequests: [],
3236
3249
  latestRetryTime: 0
3237
3250
  };
3238
3251
  const outboxSlice = toolkit.createSlice({
3239
3252
  name: "outbox",
3240
- initialState: initialState$7,
3241
- 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)),
3242
3255
  reducers: {
3243
3256
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
3244
3257
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -3270,7 +3283,7 @@ var __publicField = (obj, key, value) => {
3270
3283
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
3271
3284
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
3272
3285
  const outboxReducer = outboxSlice.reducer;
3273
- const initialState$6 = {
3286
+ const initialState$8 = {
3274
3287
  projectFiles: {},
3275
3288
  activeProjectFileId: null,
3276
3289
  isImportingProjectFile: false,
@@ -3278,8 +3291,8 @@ var __publicField = (obj, key, value) => {
3278
3291
  };
3279
3292
  const projectFileSlice = toolkit.createSlice({
3280
3293
  name: "projectFiles",
3281
- initialState: initialState$6,
3282
- 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)),
3283
3296
  reducers: {
3284
3297
  addOrReplaceProjectFiles: (state, action) => {
3285
3298
  for (let fileObj of action.payload) {
@@ -3380,12 +3393,12 @@ var __publicField = (obj, key, value) => {
3380
3393
  const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProjectFileId;
3381
3394
  const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
3382
3395
  const projectFileReducer = projectFileSlice.reducer;
3383
- const initialState$5 = {
3396
+ const initialState$7 = {
3384
3397
  isRehydrated: false
3385
3398
  };
3386
3399
  const rehydratedSlice = toolkit.createSlice({
3387
3400
  name: "rehydrated",
3388
- initialState: initialState$5,
3401
+ initialState: initialState$7,
3389
3402
  // The `reducers` field lets us define reducers and generate associated actions
3390
3403
  reducers: {
3391
3404
  setRehydrated: (state, action) => {
@@ -3395,7 +3408,7 @@ var __publicField = (obj, key, value) => {
3395
3408
  });
3396
3409
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
3397
3410
  const rehydratedReducer = rehydratedSlice.reducer;
3398
- const initialState$4 = {
3411
+ const initialState$6 = {
3399
3412
  useIssueTemplate: false,
3400
3413
  placementMode: false,
3401
3414
  enableClustering: false,
@@ -3412,8 +3425,8 @@ var __publicField = (obj, key, value) => {
3412
3425
  };
3413
3426
  const settingSlice = toolkit.createSlice({
3414
3427
  name: "settings",
3415
- initialState: initialState$4,
3416
- 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)),
3417
3430
  reducers: {
3418
3431
  setEnableDuplicateIssues: (state, action) => {
3419
3432
  state.useIssueTemplate = action.payload;
@@ -3459,146 +3472,248 @@ var __publicField = (obj, key, value) => {
3459
3472
  const settingReducer = settingSlice.reducer;
3460
3473
  const selectIsFetchingInitialData = (state) => state.settingReducer.isFetchingInitialData;
3461
3474
  const selectIsLoading = (state) => state.settingReducer.isLoading;
3462
- const LATEST_REVISION_CACHE = {};
3463
- function considerCachingRevision(revision, formId2, preferPending = false) {
3475
+ const LATEST_FORM_REVISION_CACHE = {};
3476
+ function considerCachingFormRevision(formRevision, formId2, preferPending = false) {
3464
3477
  var _a2;
3465
- if (!revision) {
3478
+ if (!formRevision) {
3466
3479
  if (!formId2) {
3467
- throw new Error("If revision is null, formId is required.");
3480
+ throw new Error("If form revision is null, formId is required.");
3468
3481
  }
3469
- const currentLatestRevision = getLatestRevisionFromCache(formId2);
3470
- if (currentLatestRevision)
3482
+ const currentLatestFormRevision = getLatestFormRevisionFromCache(formId2);
3483
+ if (currentLatestFormRevision)
3471
3484
  return;
3472
- LATEST_REVISION_CACHE[formId2] = null;
3485
+ LATEST_FORM_REVISION_CACHE[formId2] = null;
3473
3486
  return;
3474
3487
  }
3475
- if (revision.revision === "Pending") {
3488
+ if (formRevision.revision === "Pending") {
3476
3489
  if (preferPending) {
3477
- LATEST_REVISION_CACHE[revision.form] = revision;
3490
+ LATEST_FORM_REVISION_CACHE[formRevision.form] = formRevision;
3478
3491
  }
3479
3492
  return;
3480
3493
  }
3481
- const cachedRevision = (_a2 = LATEST_REVISION_CACHE[revision.form]) == null ? void 0 : _a2.revision;
3482
- if (revision.revision > (typeof cachedRevision === "number" ? cachedRevision : -1)) {
3483
- 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;
3484
3497
  }
3485
3498
  }
3486
- function getLatestRevisionFromCache(formId2) {
3487
- return LATEST_REVISION_CACHE[formId2];
3499
+ function getLatestFormRevisionFromCache(formId2) {
3500
+ return LATEST_FORM_REVISION_CACHE[formId2];
3488
3501
  }
3489
- const initialState$3 = {
3490
- userForms: {},
3491
- revisions: {},
3492
- submissions: {},
3493
- submissionAttachments: {},
3494
- revisionAttachments: {}
3495
- };
3496
- const userFormSlice = toolkit.createSlice({
3497
- name: "userForms",
3498
- initialState: initialState$3,
3499
- 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)),
3500
3510
  reducers: {
3501
- setUserForms: (state, action) => {
3502
- state.userForms = {};
3503
- action.payload.forEach((userForm) => {
3504
- state.userForms[userForm.offline_id] = userForm;
3505
- });
3506
- },
3507
- addUserForm: (state, action) => {
3508
- state.userForms[action.payload.offline_id] = action.payload;
3509
- },
3510
- addUserForms: (state, action) => {
3511
- action.payload.forEach((userForm) => {
3512
- state.userForms[userForm.offline_id] = userForm;
3513
- });
3514
- },
3515
- addUserFormRevisions: (state, action) => {
3516
- action.payload.forEach((userFormRevision) => {
3517
- state.revisions[userFormRevision.offline_id] = userFormRevision;
3518
- considerCachingRevision(userFormRevision);
3519
- });
3511
+ // revision related actions
3512
+ setFormRevision: (state, action) => {
3513
+ state.formRevisions[action.payload.offline_id] = action.payload;
3514
+ considerCachingFormRevision(action.payload);
3520
3515
  },
3521
- addUserFormRevision: (state, action) => {
3522
- state.revisions[action.payload.offline_id] = action.payload;
3523
- 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
+ }
3524
3522
  },
3525
- deleteUserFormRevision: (state, action) => {
3526
- delete state.revisions[action.payload];
3527
- 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);
3528
3529
  },
3529
- deleteUserFormRevisions: (state, action) => {
3530
+ // TODO: @Audiopolis / Magnus - do we want to standardize using PayloadAction?
3531
+ addFormRevisions: (state, action) => {
3530
3532
  for (const userFormRevision of action.payload) {
3531
- delete state.revisions[userFormRevision.offline_id];
3532
- 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);
3533
3540
  }
3534
3541
  },
3535
- updateOrCreateUserFormSubmission: (state, action) => {
3536
- state.submissions[action.payload.offline_id] = action.payload;
3537
- },
3538
- addUserFormSubmissionAttachment: (state, action) => {
3539
- const submissionId = action.payload.submission;
3540
- const submissionAttachments = state.submissionAttachments[submissionId];
3541
- if (submissionAttachments) {
3542
- submissionAttachments.push(action.payload);
3543
- } else {
3544
- 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`);
3545
3546
  }
3547
+ delete state.formRevisions[action.payload];
3548
+ delete LATEST_FORM_REVISION_CACHE[action.payload];
3546
3549
  },
3547
- addUserFormRevisionAttachment: (state, action) => {
3548
- const revisionId = action.payload.revision;
3549
- const revisionAttachments = state.revisionAttachments[revisionId];
3550
- if (revisionAttachments) {
3551
- revisionAttachments.push(action.payload);
3552
- } else {
3553
- 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];
3554
3559
  }
3555
3560
  },
3556
- setUserFormSubmissionAttachments: (state, action) => {
3557
- state.submissionAttachments = {};
3561
+ // attachment related actions
3562
+ setFormRevisionAttachments: (state, action) => {
3563
+ state.attachments = {};
3558
3564
  for (const attachment of action.payload) {
3559
- const submissionId = attachment.submission;
3560
- const submissionAttachments = state.submissionAttachments[submissionId];
3561
- if (submissionAttachments) {
3562
- submissionAttachments.push(attachment);
3563
- } else {
3564
- state.submissionAttachments[submissionId] = [attachment];
3565
- }
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`);
3566
3571
  }
3572
+ state.attachments[action.payload.offline_id] = action.payload;
3567
3573
  },
3568
- setUserFormRevisionAttachments: (state, action) => {
3569
- state.revisionAttachments = {};
3574
+ addFormRevisionAttachments: (state, action) => {
3570
3575
  for (const attachment of action.payload) {
3571
- const revisionId = attachment.revision;
3572
- const revisionAttachments = state.revisionAttachments[revisionId];
3573
- if (revisionAttachments) {
3574
- revisionAttachments.push(attachment);
3575
- } else {
3576
- 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`);
3577
3578
  }
3578
3579
  }
3580
+ for (const attachment of action.payload) {
3581
+ state.attachments[attachment.offline_id] = attachment;
3582
+ }
3579
3583
  },
3580
- deleteUserFormSubmission: (state, action) => {
3581
- delete state.submissions[action.payload];
3582
- },
3583
- deleteUserFormSubmissions: (state, action) => {
3584
- for (const userFormSubmission of action.payload) {
3585
- 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`);
3586
3587
  }
3588
+ delete state.attachments[action.payload];
3587
3589
  },
3588
- addUserFormSubmissions: (state, action) => {
3589
- for (const submission of action.payload) {
3590
- 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];
3591
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
+ }
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;
3592
3708
  },
3593
- setUserFormSubmissions: (state, action) => {
3594
- state.submissions = {};
3595
- action.payload.forEach((submission) => {
3596
- state.submissions[submission.offline_id] = submission;
3709
+ addForms: (state, action) => {
3710
+ action.payload.forEach((userForm) => {
3711
+ state.forms[userForm.offline_id] = userForm;
3597
3712
  });
3598
3713
  },
3599
3714
  favoriteForm: (state, action) => {
3600
3715
  const { formId: formId2 } = action.payload;
3601
- const form = state.userForms[formId2];
3716
+ const form = state.forms[formId2];
3602
3717
  if (!form) {
3603
3718
  throw new Error("No form exists with the id " + formId2);
3604
3719
  }
@@ -3606,48 +3721,23 @@ var __publicField = (obj, key, value) => {
3606
3721
  },
3607
3722
  unfavoriteForm: (state, action) => {
3608
3723
  const { formId: formId2 } = action.payload;
3609
- const form = state.userForms[formId2];
3724
+ const form = state.forms[formId2];
3610
3725
  if (!form) {
3611
3726
  throw new Error("No form exists with the id " + formId2);
3612
3727
  }
3613
3728
  form.favorite = false;
3614
3729
  },
3615
- deleteUserForm: (state, action) => {
3616
- delete state.userForms[action.payload];
3730
+ deleteForm: (state, action) => {
3731
+ delete state.forms[action.payload];
3617
3732
  }
3618
3733
  }
3619
3734
  });
3620
- const {
3621
- addUserForm,
3622
- addUserForms,
3623
- addUserFormRevisions,
3624
- updateOrCreateUserFormSubmission,
3625
- addUserFormSubmissions,
3626
- deleteUserFormSubmission,
3627
- deleteUserFormSubmissions,
3628
- favoriteForm,
3629
- unfavoriteForm,
3630
- deleteUserForm,
3631
- deleteUserFormRevision,
3632
- deleteUserFormRevisions,
3633
- setUserFormSubmissions,
3634
- addUserFormRevision,
3635
- addUserFormSubmissionAttachment,
3636
- addUserFormRevisionAttachment,
3637
- setUserFormSubmissionAttachments,
3638
- setUserFormRevisionAttachments
3639
- } = userFormSlice.actions;
3640
- const selectSubmissionAttachments = (submissionId) => (state) => {
3641
- return state.userFormReducer.submissionAttachments[submissionId] || [];
3642
- };
3643
- const selectRevisionAttachments = (revisionId) => (state) => {
3644
- return state.userFormReducer.revisionAttachments[revisionId] || [];
3645
- };
3646
- const selectFilteredUserForms = restructureCreateSelectorWithArgs(
3735
+ const { setForms, addForm, addForms, favoriteForm, unfavoriteForm, deleteForm } = formSlice.actions;
3736
+ const selectFilteredForms = restructureCreateSelectorWithArgs(
3647
3737
  toolkit.createSelector(
3648
3738
  [
3649
- (state) => state.userFormReducer.userForms,
3650
- (state) => state.userFormReducer.revisions,
3739
+ (state) => state.formReducer.forms,
3740
+ (state) => state.formRevisionReducer.formRevisions,
3651
3741
  (_state, search) => search
3652
3742
  ],
3653
3743
  (userForms, revisions, search) => {
@@ -3681,63 +3771,188 @@ var __publicField = (obj, key, value) => {
3681
3771
  { memoizeOptions: { equalityCheck: reactRedux.shallowEqual } }
3682
3772
  )
3683
3773
  );
3684
- const selectFormRevision = (revisionId) => (state) => {
3685
- return state.userFormReducer.revisions[revisionId];
3774
+ const selectForm = (formId2) => (state) => {
3775
+ return state.formReducer.forms[formId2];
3686
3776
  };
3687
- const _selectLatestFormRevision = (revisions, formId2) => {
3688
- let ret = null;
3689
- for (const candidate of Object.values(revisions)) {
3690
- if (candidate.form === formId2 && (!ret || ret.revision < candidate.revision)) {
3691
- ret = candidate;
3692
- }
3693
- }
3694
- if (!ret) {
3695
- throw new Error("No revision found for form " + formId2);
3696
- }
3697
- return ret;
3777
+ const selectFormMapping = (state) => {
3778
+ return state.formReducer.forms;
3698
3779
  };
3699
- const selectLatestFormRevision = restructureCreateSelectorWithArgs(
3780
+ const selectFormOfComponentType = restructureCreateSelectorWithArgs(
3700
3781
  toolkit.createSelector(
3701
- [(state) => state.userFormReducer.revisions, (_state, formId2) => formId2],
3702
- (revisions, formId2) => {
3703
- if (!formId2) {
3704
- throw new Error("formId is required");
3705
- }
3706
- return _selectLatestFormRevision(revisions, formId2);
3782
+ [selectFormMapping, (_state, componentTypeId) => componentTypeId],
3783
+ (userForms, componentTypeId) => {
3784
+ return Object.values(userForms).find((userForm) => userForm.component_type === componentTypeId);
3707
3785
  }
3708
3786
  )
3709
3787
  );
3710
- const selectUserForm = (formId2) => (state) => {
3711
- return state.userFormReducer.userForms[formId2];
3712
- };
3713
- const selectSubmissionMapping = (state) => state.userFormReducer.submissions;
3714
- const selectUserFormSubmission = (submissionId) => (state) => {
3715
- return state.userFormReducer.submissions[submissionId];
3716
- };
3717
- const selectSubmissions = toolkit.createSelector([selectSubmissionMapping], (submissions) => Object.values(submissions));
3718
- const selectRevisionMapping = (state) => state.userFormReducer.revisions;
3719
- const selectRevisions = toolkit.createSelector([selectRevisionMapping], (revisions) => Object.values(revisions));
3720
- const selectRevisionsForForm = restructureCreateSelectorWithArgs(
3721
- toolkit.createSelector([selectRevisions, (_state, formId2) => formId2], (revisions, formId2) => {
3722
- return revisions.filter((revision) => {
3723
- return revision.form === formId2;
3724
- });
3725
- })
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
+ }
3726
3938
  );
3727
- const selectSubmissionsForForm = restructureCreateSelectorWithArgs(
3939
+ const selectFormSubmission = (submissionId) => (state) => {
3940
+ return state.formSubmissionReducer.formSubmissions[submissionId];
3941
+ };
3942
+ const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
3728
3943
  toolkit.createSelector(
3729
- [selectSubmissions, selectRevisionMapping, (_state, formId2) => formId2],
3944
+ [selectFormSubmissions, selectFormRevisionMapping, (_state, formId2) => formId2],
3730
3945
  (submissions, revisionMapping, formId2) => {
3731
- return Object.values(submissions).filter((submission) => {
3946
+ return submissions.filter((submission) => {
3732
3947
  const revision = revisionMapping[submission.form_revision];
3733
3948
  return (revision == null ? void 0 : revision.form) === formId2;
3734
3949
  });
3735
3950
  }
3736
3951
  )
3737
3952
  );
3738
- const selectSubmissionsForIssue = restructureCreateSelectorWithArgs(
3953
+ const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
3739
3954
  toolkit.createSelector(
3740
- [(state) => state.userFormReducer.submissions, (_state, issueId) => issueId],
3955
+ [selectFormSubmissions, (_state, issueId) => issueId],
3741
3956
  (submissions, issueId) => {
3742
3957
  return Object.values(submissions).filter((submission) => {
3743
3958
  return submission.issue === issueId;
@@ -3745,9 +3960,9 @@ var __publicField = (obj, key, value) => {
3745
3960
  }
3746
3961
  )
3747
3962
  );
3748
- const selectSubmissionsForComponent = restructureCreateSelectorWithArgs(
3963
+ const selectFormSubmissionsOfComponent = restructureCreateSelectorWithArgs(
3749
3964
  toolkit.createSelector(
3750
- [selectSubmissions, (_state, componentId) => componentId],
3965
+ [selectFormSubmissions, (_state, componentId) => componentId],
3751
3966
  (submissions, componentId) => {
3752
3967
  return submissions.filter((submission) => {
3753
3968
  return submission.component === componentId;
@@ -3755,8 +3970,8 @@ var __publicField = (obj, key, value) => {
3755
3970
  }
3756
3971
  )
3757
3972
  );
3758
- const selectComponentSubmissionMapping = toolkit.createSelector(
3759
- [selectSubmissionMapping, selectComponentsMapping],
3973
+ const selectFormSubmissionsByComponents = toolkit.createSelector(
3974
+ [selectFormSubmissionsMapping, selectComponentsMapping],
3760
3975
  (submissions, components) => {
3761
3976
  var _a2;
3762
3977
  const componentSubmissionMapping = {};
@@ -3772,54 +3987,18 @@ var __publicField = (obj, key, value) => {
3772
3987
  return componentSubmissionMapping;
3773
3988
  }
3774
3989
  );
3775
- const selectUserFormMapping = (state) => {
3776
- return state.userFormReducer.userForms;
3990
+ const selectFormSubmissionAttachmentsMapping = (state) => {
3991
+ return state.formSubmissionReducer.attachments;
3777
3992
  };
3778
- const selectComponentTypeForm = restructureCreateSelectorWithArgs(
3993
+ const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
3779
3994
  toolkit.createSelector(
3780
- [selectUserFormMapping, (_state, componentTypeId) => componentTypeId],
3781
- (userForms, componentTypeId) => {
3782
- return Object.values(userForms).find((userForm) => userForm.component_type === componentTypeId);
3783
- }
3784
- )
3785
- );
3786
- const selectLatestRevisionsFromComponentTypeIds = restructureCreateSelectorWithArgs(
3787
- toolkit.createSelector(
3788
- [
3789
- selectUserFormMapping,
3790
- selectRevisionMapping,
3791
- (_state, componentTypeIds) => componentTypeIds
3792
- ],
3793
- (userForms, revisions, componentTypeIds) => {
3794
- const componentTypeIdsSet = new Set(componentTypeIds);
3795
- const ret = {};
3796
- for (const form of Object.values(userForms)) {
3797
- if (form.component_type && componentTypeIdsSet.has(form.component_type)) {
3798
- ret[form.component_type] = _selectLatestFormRevision(revisions, form.offline_id);
3799
- }
3800
- }
3801
- return ret;
3995
+ [selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
3996
+ (attachmentsMapping, submissionId) => {
3997
+ return Object.values(attachmentsMapping).filter((attachment) => attachment.submission === submissionId);
3802
3998
  }
3803
3999
  )
3804
4000
  );
3805
- const selectLatestRevisionByFormId = toolkit.createSelector([selectRevisionMapping], (revisions) => {
3806
- const latestRevisions = {};
3807
- for (const revision of Object.values(revisions)) {
3808
- const formId2 = revision.form;
3809
- const currentLatestRevision = latestRevisions[formId2];
3810
- if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
3811
- latestRevisions[formId2] = revision;
3812
- }
3813
- }
3814
- return latestRevisions;
3815
- });
3816
- const selectNumberOfUserForms = toolkit.createSelector([selectUserFormMapping], (userForms) => {
3817
- return Object.keys(userForms).length;
3818
- });
3819
- const selectNumberOfGeneralUserForms = toolkit.createSelector([selectUserFormMapping], (userForms) => {
3820
- return Object.values(userForms).filter((form) => !form.component_type).length;
3821
- });
3822
- const userFormReducer = userFormSlice.reducer;
4001
+ const formSubmissionReducer = formSubmissionSlice.reducer;
3823
4002
  const initialState$2 = {
3824
4003
  emailDomains: {}
3825
4004
  };
@@ -4117,7 +4296,9 @@ var __publicField = (obj, key, value) => {
4117
4296
  projectFileReducer,
4118
4297
  rehydratedReducer,
4119
4298
  settingReducer,
4120
- userFormReducer,
4299
+ formReducer,
4300
+ formRevisionReducer,
4301
+ formSubmissionReducer,
4121
4302
  userReducer,
4122
4303
  workspaceReducer,
4123
4304
  emailDomainsReducer,
@@ -4170,9 +4351,7 @@ var __publicField = (obj, key, value) => {
4170
4351
  throw new Error(`Failed to update index_workspace of issue ${issue.offline_id} to main workspace`);
4171
4352
  }
4172
4353
  }
4173
- const indexedForms = Object.values(draft.userFormReducer.userForms).filter(
4174
- (form) => form.index_workspace === workspaceId
4175
- );
4354
+ const indexedForms = Object.values(draft.formReducer.forms).filter((form) => form.index_workspace === workspaceId);
4176
4355
  for (const form of indexedForms) {
4177
4356
  form.index_workspace = mainWorkspace.offline_id;
4178
4357
  }
@@ -6800,7 +6979,7 @@ var __publicField = (obj, key, value) => {
6800
6979
  ...revisionAttachmentPayload,
6801
6980
  file: URL.createObjectURL(image)
6802
6981
  };
6803
- store.dispatch(addUserFormRevisionAttachment(offlinePayload));
6982
+ store.dispatch(addFormRevisionAttachment(offlinePayload));
6804
6983
  return attach;
6805
6984
  });
6806
6985
  });
@@ -6834,8 +7013,8 @@ var __publicField = (obj, key, value) => {
6834
7013
  revision: 0
6835
7014
  };
6836
7015
  const { store } = this.client;
6837
- store.dispatch(addUserForm(retForm));
6838
- store.dispatch(addUserFormRevision(retRevision));
7016
+ store.dispatch(addForm(retForm));
7017
+ store.dispatch(addFormRevision(retRevision));
6839
7018
  const formPromise = this.enqueueRequest({
6840
7019
  description: "Create form",
6841
7020
  method: HttpMethod.POST,
@@ -6853,8 +7032,8 @@ var __publicField = (obj, key, value) => {
6853
7032
  });
6854
7033
  const attachImagesPromises = this.getAttachImagePromises(images, offlineRevisionPayload.offline_id);
6855
7034
  void formPromise.catch((e) => {
6856
- store.dispatch(deleteUserForm(retForm.offline_id));
6857
- store.dispatch(deleteUserFormRevision(retRevision.offline_id));
7035
+ store.dispatch(deleteForm(retForm.offline_id));
7036
+ store.dispatch(deleteFormRevision(retRevision.offline_id));
6858
7037
  throw e;
6859
7038
  });
6860
7039
  const settledPromise = Promise.all([formPromise, ...attachImagesPromises]).then(() => formPromise);
@@ -6896,7 +7075,7 @@ var __publicField = (obj, key, value) => {
6896
7075
  revision: "Pending",
6897
7076
  form: formId2
6898
7077
  };
6899
- store.dispatch(addUserFormRevision(fullRevision));
7078
+ store.dispatch(addFormRevision(fullRevision));
6900
7079
  const promise = this.enqueueRequest({
6901
7080
  description: "Create form revision",
6902
7081
  method: HttpMethod.PATCH,
@@ -6910,9 +7089,9 @@ var __publicField = (obj, key, value) => {
6910
7089
  });
6911
7090
  const attachImagesPromises = this.getAttachImagePromises(images, offlineRevision.offline_id);
6912
7091
  void promise.then((result) => {
6913
- store.dispatch(addUserFormRevision(result));
7092
+ store.dispatch(setFormRevision(result));
6914
7093
  }).catch(() => {
6915
- store.dispatch(deleteUserFormRevision(fullRevision.offline_id));
7094
+ store.dispatch(deleteFormRevision(fullRevision.offline_id));
6916
7095
  });
6917
7096
  const settledPromise = Promise.all([promise, ...attachImagesPromises]).then(() => promise);
6918
7097
  return [fullRevision, settledPromise];
@@ -6954,19 +7133,19 @@ var __publicField = (obj, key, value) => {
6954
7133
  async delete(formId2) {
6955
7134
  const { store } = this.client;
6956
7135
  const state = store.getState();
6957
- const userForm = selectUserForm(formId2)(state);
7136
+ const userForm = selectForm(formId2)(state);
6958
7137
  if (!userForm) {
6959
7138
  throw new Error("Expected userForm to exist");
6960
7139
  }
6961
- const userFormSubmissions = selectSubmissionsForForm(formId2)(state);
7140
+ const userFormSubmissions = selectFormSubmissionsOfForm(formId2)(state);
6962
7141
  if (userFormSubmissions && userFormSubmissions.length > 0) {
6963
- store.dispatch(deleteUserFormSubmissions(userFormSubmissions));
7142
+ store.dispatch(deleteFormSubmissions(userFormSubmissions.map(({ offline_id }) => offline_id)));
6964
7143
  }
6965
- const userFormRevisions = selectRevisionsForForm(formId2)(state);
7144
+ const userFormRevisions = selectFormRevisionsOfForm(formId2)(state);
6966
7145
  if (userFormRevisions && userFormRevisions.length > 0) {
6967
- store.dispatch(deleteUserFormRevisions(userFormRevisions));
7146
+ store.dispatch(deleteFormRevisions(userFormRevisions.map(({ offline_id }) => offline_id)));
6968
7147
  }
6969
- store.dispatch(deleteUserForm(formId2));
7148
+ store.dispatch(deleteForm(formId2));
6970
7149
  try {
6971
7150
  return await this.enqueueRequest({
6972
7151
  description: "Delete form",
@@ -6976,12 +7155,12 @@ var __publicField = (obj, key, value) => {
6976
7155
  blocks: []
6977
7156
  });
6978
7157
  } catch (e) {
6979
- store.dispatch(addUserForm(userForm));
7158
+ store.dispatch(addForm(userForm));
6980
7159
  if (userFormRevisions && userFormRevisions.length > 0) {
6981
- store.dispatch(addUserFormRevisions(userFormRevisions));
7160
+ store.dispatch(addFormRevisions(userFormRevisions));
6982
7161
  }
6983
7162
  if (userFormSubmissions && userFormSubmissions.length > 0) {
6984
- store.dispatch(addUserFormSubmissions(userFormSubmissions));
7163
+ store.dispatch(addFormSubmissions(userFormSubmissions));
6985
7164
  }
6986
7165
  throw e;
6987
7166
  }
@@ -6995,16 +7174,15 @@ var __publicField = (obj, key, value) => {
6995
7174
  blockers: [],
6996
7175
  blocks: []
6997
7176
  });
6998
- store.dispatch(addUserForms(Object.values(result.forms)));
6999
- store.dispatch(addUserFormRevisions(Object.values(result.revisions)));
7000
- 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)));
7001
7180
  }
7002
7181
  }
7003
7182
  const isArrayOfFiles = (value) => {
7004
7183
  return Array.isArray(value) && value[0] instanceof File;
7005
7184
  };
7006
- const separateFilesFromValues = (payload) => {
7007
- const { values } = payload;
7185
+ const separateFilesFromValues = (values) => {
7008
7186
  const files = {};
7009
7187
  const newValues = {};
7010
7188
  for (const key in values) {
@@ -7019,17 +7197,13 @@ var __publicField = (obj, key, value) => {
7019
7197
  newValues[key] = value;
7020
7198
  }
7021
7199
  }
7022
- const payloadWithoutFiles = {
7023
- ...payload,
7024
- values: newValues
7025
- };
7026
- return { payloadWithoutFiles, files };
7200
+ return { values: newValues, files };
7027
7201
  };
7028
7202
  class UserFormSubmissionService extends BaseApiService {
7029
7203
  constructor() {
7030
7204
  super(...arguments);
7031
7205
  // Attach files to submission, after uploading them to S3
7032
- __publicField(this, "getAttachFilesPromises", (files, payload) => {
7206
+ __publicField(this, "getAttachFilesPromises", (files, submission) => {
7033
7207
  const { store } = this.client;
7034
7208
  return Object.entries(files).map(async ([key, fileArray]) => {
7035
7209
  const attachResults = [];
@@ -7039,24 +7213,27 @@ var __publicField = (obj, key, value) => {
7039
7213
  const [fileProps] = await this.client.files.uploadFileToS3(sha1);
7040
7214
  const submissionAttachmentPayload = offline({
7041
7215
  ...fileProps,
7042
- submission: payload.offline_id,
7216
+ submission: submission.offline_id,
7043
7217
  field_identifier: key
7044
7218
  });
7045
7219
  const attach = await this.enqueueRequest({
7046
7220
  description: "Attach file to form submission",
7047
7221
  method: HttpMethod.POST,
7048
- url: `/forms/submission/${payload.offline_id}/attachments/`,
7222
+ url: `/forms/submission/${submission.offline_id}/attachments/`,
7049
7223
  payload: submissionAttachmentPayload,
7050
- blockers: [payload.component, payload.component_stage, payload.issue, payload.form_revision].filter(
7051
- (x) => x !== void 0
7052
- ),
7224
+ blockers: [
7225
+ submission.component,
7226
+ submission.component_stage,
7227
+ submission.issue,
7228
+ submission.form_revision
7229
+ ].filter((x) => x !== void 0),
7053
7230
  blocks: [submissionAttachmentPayload.offline_id]
7054
7231
  });
7055
7232
  const offlinePayload = {
7056
7233
  ...submissionAttachmentPayload,
7057
7234
  file: URL.createObjectURL(file)
7058
7235
  };
7059
- store.dispatch(addUserFormSubmissionAttachment(offlinePayload));
7236
+ store.dispatch(addFormSubmissionAttachment(offlinePayload));
7060
7237
  attachResults.push(attach);
7061
7238
  }
7062
7239
  return attachResults;
@@ -7070,70 +7247,165 @@ var __publicField = (obj, key, value) => {
7070
7247
  if (!activeProjectId) {
7071
7248
  throw new Error("Expected an active project");
7072
7249
  }
7073
- 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
+ };
7074
7257
  const promise = this.enqueueRequest({
7075
7258
  description: "Respond to form",
7076
7259
  method: HttpMethod.POST,
7077
7260
  url: `/forms/revisions/${payload.form_revision}/respond/`,
7078
- payload: { ...payloadWithoutFiles, project: activeProjectId },
7261
+ payload: { ...offlineSubmission, project: activeProjectId },
7079
7262
  blockers: [payload.issue, payload.component, payload.component_stage, "add-form-entry"].filter(
7080
7263
  (x) => x !== void 0
7081
7264
  ),
7082
7265
  blocks: [payload.offline_id]
7083
7266
  });
7084
- const attachFilesPromises = this.getAttachFilesPromises(files, payload);
7085
- const now = (/* @__PURE__ */ new Date()).toISOString();
7086
- const fullOfflineResult = {
7087
- ...payload,
7088
- created_by: state.userReducer.currentUser.id,
7089
- created_at: now,
7090
- updated_at: now
7091
- };
7092
- const offlineResultWithoutFiles = {
7093
- ...fullOfflineResult,
7094
- ...payloadWithoutFiles
7095
- };
7096
- store.dispatch(updateOrCreateUserFormSubmission(offlineResultWithoutFiles));
7267
+ const attachFilesPromises = this.getAttachFilesPromises(files, offlineSubmission);
7268
+ store.dispatch(addFormSubmission(offlineSubmission));
7097
7269
  void promise.then((result) => {
7098
7270
  store.dispatch(addActiveProjectFormSubmissionsCount(1));
7099
- store.dispatch(updateOrCreateUserFormSubmission(result));
7271
+ store.dispatch(setFormSubmission(result));
7100
7272
  return result;
7101
7273
  }).catch(() => {
7102
- store.dispatch(deleteUserFormSubmission(payload.offline_id));
7274
+ store.dispatch(deleteFormSubmission(payload.offline_id));
7103
7275
  store.dispatch(addActiveProjectFormSubmissionsCount(-1));
7104
7276
  });
7105
7277
  const settledPromise = Promise.all([promise, ...attachFilesPromises]).then(() => promise);
7106
- return [fullOfflineResult, settledPromise];
7278
+ return [offlineSubmission, settledPromise];
7107
7279
  }
7108
- 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;
7109
7284
  const { store } = this.client;
7110
- const { payloadWithoutFiles, files } = separateFilesFromValues(submission);
7111
- if (!("created_by" in payloadWithoutFiles) || !("created_at" in payloadWithoutFiles)) {
7112
- 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
+ }
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
+ };
7113
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);
7114
7380
  const attachFilesPromises = this.getAttachFilesPromises(files, submission);
7115
- const fullResult = {
7116
- ...payloadWithoutFiles,
7117
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
7381
+ const offlineSubmission = {
7382
+ ...submission,
7383
+ values
7118
7384
  };
7119
- store.dispatch(updateOrCreateUserFormSubmission(fullResult));
7385
+ const submissionToBeUpdated = store.getState().formSubmissionReducer.formSubmissions[submission.offline_id];
7386
+ store.dispatch(updateFormSubmission(offlineSubmission));
7120
7387
  const promise = this.enqueueRequest({
7121
7388
  description: "Patch form submission",
7122
7389
  method: HttpMethod.PATCH,
7123
7390
  url: `/forms/submissions/${submission.offline_id}/`,
7124
- payload: fullResult,
7125
- blockers: [fullResult.issue, fullResult.component, fullResult.component_stage].filter(
7391
+ payload: offlineSubmission,
7392
+ blockers: [offlineSubmission.issue, offlineSubmission.component, offlineSubmission.component_stage].filter(
7126
7393
  (x) => x !== void 0
7127
7394
  ),
7128
- blocks: [fullResult.offline_id]
7395
+ blocks: [offlineSubmission.offline_id]
7129
7396
  });
7130
- return Promise.all([promise, ...attachFilesPromises]).then(() => promise);
7397
+ promise.then((createdSubmission) => {
7398
+ store.dispatch(setFormSubmission(createdSubmission));
7399
+ }).catch(() => {
7400
+ store.dispatch(setFormSubmission(submissionToBeUpdated));
7401
+ });
7402
+ return [offlineSubmission, Promise.all([promise, ...attachFilesPromises]).then(() => promise)];
7131
7403
  }
7132
7404
  async delete(submissionId) {
7133
7405
  const { store } = this.client;
7134
7406
  const state = store.getState();
7135
- const submission = state.userFormReducer.submissions[submissionId];
7136
- store.dispatch(deleteUserFormSubmission(submissionId));
7407
+ const submission = state.formSubmissionReducer.formSubmissions[submissionId];
7408
+ store.dispatch(deleteFormSubmission(submissionId));
7137
7409
  store.dispatch(addActiveProjectFormSubmissionsCount(-1));
7138
7410
  try {
7139
7411
  return await this.enqueueRequest({
@@ -7144,10 +7416,8 @@ var __publicField = (obj, key, value) => {
7144
7416
  blocks: []
7145
7417
  });
7146
7418
  } catch (e) {
7147
- if (submission) {
7148
- store.dispatch(addActiveProjectFormSubmissionsCount(1));
7149
- store.dispatch(updateOrCreateUserFormSubmission(submission));
7150
- }
7419
+ store.dispatch(addActiveProjectFormSubmissionsCount(1));
7420
+ store.dispatch(addFormSubmission(submission));
7151
7421
  throw e;
7152
7422
  }
7153
7423
  }
@@ -7161,7 +7431,7 @@ var __publicField = (obj, key, value) => {
7161
7431
  blockers: [],
7162
7432
  blocks: []
7163
7433
  });
7164
- store.dispatch(setUserFormSubmissions(submissions));
7434
+ store.dispatch(setFormSubmissions(submissions));
7165
7435
  const attachments = await this.enqueueRequest({
7166
7436
  description: "Fetch form attachments",
7167
7437
  method: HttpMethod.GET,
@@ -7169,7 +7439,7 @@ var __publicField = (obj, key, value) => {
7169
7439
  blockers: [],
7170
7440
  blocks: []
7171
7441
  });
7172
- store.dispatch(setUserFormSubmissionAttachments(attachments));
7442
+ store.dispatch(setFormSubmissionAttachments(attachments));
7173
7443
  }
7174
7444
  }
7175
7445
  class WorkspaceService extends BaseApiService {
@@ -14027,7 +14297,7 @@ var __publicField = (obj, key, value) => {
14027
14297
  };
14028
14298
  const useAttachImagesToFormRevisionFields = (revision) => {
14029
14299
  const { sdk } = useSDK();
14030
- const attachments = useAppSelector(selectRevisionAttachments((revision == null ? void 0 : revision.offline_id) ?? ""));
14300
+ const attachments = useAppSelector(selectAttachmentsOfFormRevision((revision == null ? void 0 : revision.offline_id) ?? ""));
14031
14301
  return React.useMemo(() => {
14032
14302
  if (!revision || !attachments)
14033
14303
  return revision;
@@ -14124,7 +14394,7 @@ var __publicField = (obj, key, value) => {
14124
14394
  return formRevisionToSchema(revisionWithImages, { readonly: true });
14125
14395
  }, [revisionWithImages]);
14126
14396
  const submissionValuesWithAttachments = React.useMemo(() => {
14127
- const attachments = selectSubmissionAttachments(submission.offline_id)(sdk.store.getState()) ?? [];
14397
+ const attachments = selectAttachmentsOfFormSubmission(submission.offline_id)(sdk.store.getState()) ?? [];
14128
14398
  const downloadedAttachments = {};
14129
14399
  for (const attachment of attachments) {
14130
14400
  const promise = sdk.files.fetchFileFromUrl(attachment.file, attachment.file_sha1, attachment.file_name);
@@ -14174,8 +14444,8 @@ var __publicField = (obj, key, value) => {
14174
14444
  }
14175
14445
  return ret;
14176
14446
  }, [filter, maxResults, ownerFilter]);
14177
- const userForms = useAppSelector(selectFilteredUserForms(ownerFilterOptions)) ?? [];
14178
- const userFormMapping = useAppSelector(selectUserFormMapping);
14447
+ const userForms = useAppSelector(selectFilteredForms(ownerFilterOptions)) ?? [];
14448
+ const userFormMapping = useAppSelector(selectFormMapping);
14179
14449
  const attachableUserForms = userForms.filter((form) => !form.component_type);
14180
14450
  const attachableUserFormMapping = Object.values(userFormMapping).filter(
14181
14451
  (form) => !form.component_type
@@ -14208,7 +14478,7 @@ var __publicField = (obj, key, value) => {
14208
14478
  const handleChange = React.useCallback((e) => {
14209
14479
  setFilter(e.currentTarget.value);
14210
14480
  }, []);
14211
- const numberOfForms = useAppSelector(selectNumberOfGeneralUserForms) || 0;
14481
+ const numberOfForms = useAppSelector(selectGeneralFormCount) || 0;
14212
14482
  const numberOfHiddenForms = numberOfForms - attachableUserForms.length;
14213
14483
  const overflowMessage = attachableUserForms.length == maxResults && numberOfHiddenForms > 0 ? `Only the first ${maxResults} results are shown (${numberOfHiddenForms} hidden)` : numberOfHiddenForms > 0 && `${numberOfHiddenForms} hidden forms`;
14214
14484
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { ref, direction: "column", gap: "2", children: [
@@ -14302,16 +14572,13 @@ var __publicField = (obj, key, value) => {
14302
14572
  const { submission, onSubmissionClick, compact, labelType, rowDecorator } = props;
14303
14573
  const currentUser = useAppSelector(selectCurrentUser);
14304
14574
  const createdBy = useAppSelector(selectUser("created_by" in submission ? submission.created_by : currentUser.id));
14305
- const dateToUse = getCreatedAtOrSubmittedAtDate(submission);
14306
- const formattedDateTime = isToday(dateToUse) ? dateToUse.toLocaleTimeString([], {
14307
- hour: "2-digit",
14308
- minute: "2-digit"
14309
- }) : getLocalDateString(dateToUse);
14575
+ const dateToUse = submission.submitted_at;
14576
+ const formattedDateTime = getLocalDateString(dateToUse);
14310
14577
  const revision = useAppSelector(selectFormRevision(submission.form_revision));
14311
14578
  if (!revision) {
14312
14579
  throw new Error(`Could not find revision ${submission.form_revision} for submission ${submission.offline_id}.`);
14313
14580
  }
14314
- 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;
14315
14582
  const creatorProfileSrc = useFileSrc({
14316
14583
  file: (createdBy == null ? void 0 : createdBy.profile.file) ?? null,
14317
14584
  fileSha1: (createdBy == null ? void 0 : createdBy.profile.file_sha1) ?? null
@@ -14342,10 +14609,6 @@ var __publicField = (obj, key, value) => {
14342
14609
  return row;
14343
14610
  });
14344
14611
  FormSubmissionBrowserEntry.displayName = "FormSubmissionBrowserEntry";
14345
- const getCreatedAtOrSubmittedAtDate = (submission) => {
14346
- const date = "created_at" in submission ? submission.created_at : submission.submitted_at;
14347
- return new Date(date);
14348
- };
14349
14612
  const FormSubmissionBrowser = React.memo((props) => {
14350
14613
  const {
14351
14614
  formId: formId2,
@@ -14359,10 +14622,10 @@ var __publicField = (obj, key, value) => {
14359
14622
  if (!!formId2 === !!propSubmissions) {
14360
14623
  throw new Error("Either formId or submissions must be provided, but not both.");
14361
14624
  }
14362
- const submissions = useAppSelector(propSubmissions ? () => propSubmissions : selectSubmissionsForForm(formId2));
14625
+ const submissions = useAppSelector(propSubmissions ? () => propSubmissions : selectFormSubmissionsOfForm(formId2));
14363
14626
  const sortedSubmissions = React.useMemo(
14364
14627
  () => submissions == null ? void 0 : submissions.sort((a, b) => {
14365
- return getCreatedAtOrSubmittedAtDate(b).getTime() - getCreatedAtOrSubmittedAtDate(a).getTime();
14628
+ return a.submitted_at.localeCompare(b.submitted_at);
14366
14629
  }),
14367
14630
  [submissions]
14368
14631
  );
@@ -15679,6 +15942,7 @@ var __publicField = (obj, key, value) => {
15679
15942
  exports2.VerificationCodeType = VerificationCodeType;
15680
15943
  exports2.WorkspaceService = WorkspaceService;
15681
15944
  exports2.YELLOW = YELLOW;
15945
+ exports2._selectLatestFormRevision = _selectLatestFormRevision;
15682
15946
  exports2._setLatestRetryTime = _setLatestRetryTime;
15683
15947
  exports2.acceptProjectInvite = acceptProjectInvite;
15684
15948
  exports2.addActiveProjectFormSubmissionsCount = addActiveProjectFormSubmissionsCount;
@@ -15696,6 +15960,16 @@ var __publicField = (obj, key, value) => {
15696
15960
  exports2.addDocuments = addDocuments;
15697
15961
  exports2.addEmailDomain = addEmailDomain;
15698
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;
15699
15973
  exports2.addIssue = addIssue;
15700
15974
  exports2.addIssueAttachment = addIssueAttachment;
15701
15975
  exports2.addIssueAttachments = addIssueAttachments;
@@ -15716,13 +15990,6 @@ var __publicField = (obj, key, value) => {
15716
15990
  exports2.addStageCompletions = addStageCompletions;
15717
15991
  exports2.addStages = addStages;
15718
15992
  exports2.addToRecentIssues = addToRecentIssues;
15719
- exports2.addUserForm = addUserForm;
15720
- exports2.addUserFormRevision = addUserFormRevision;
15721
- exports2.addUserFormRevisionAttachment = addUserFormRevisionAttachment;
15722
- exports2.addUserFormRevisions = addUserFormRevisions;
15723
- exports2.addUserFormSubmissionAttachment = addUserFormSubmissionAttachment;
15724
- exports2.addUserFormSubmissions = addUserFormSubmissions;
15725
- exports2.addUserForms = addUserForms;
15726
15993
  exports2.addUsers = addUsers;
15727
15994
  exports2.addWorkspace = addWorkspace;
15728
15995
  exports2.areArraysEqual = areArraysEqual;
@@ -15743,6 +16010,7 @@ var __publicField = (obj, key, value) => {
15743
16010
  exports2.componentStageSlice = componentStageSlice;
15744
16011
  exports2.componentTypeReducer = componentTypeReducer;
15745
16012
  exports2.componentTypeSlice = componentTypeSlice;
16013
+ exports2.constructUploadedFilePayloads = constructUploadedFilePayloads;
15746
16014
  exports2.coordinatesAreEqual = coordinatesAreEqual;
15747
16015
  exports2.coordinatesToLiteral = coordinatesToLiteral;
15748
16016
  exports2.coordinatesToPointGeometry = coordinatesToPointGeometry;
@@ -15753,12 +16021,16 @@ var __publicField = (obj, key, value) => {
15753
16021
  exports2.defaultBadgeColor = defaultBadgeColor;
15754
16022
  exports2.defaultStore = defaultStore;
15755
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;
15756
16033
  exports2.deleteProject = deleteProject;
15757
- exports2.deleteUserForm = deleteUserForm;
15758
- exports2.deleteUserFormRevision = deleteUserFormRevision;
15759
- exports2.deleteUserFormRevisions = deleteUserFormRevisions;
15760
- exports2.deleteUserFormSubmission = deleteUserFormSubmission;
15761
- exports2.deleteUserFormSubmissions = deleteUserFormSubmissions;
15762
16034
  exports2.dequeue = dequeue;
15763
16035
  exports2.deserialize = deserialize;
15764
16036
  exports2.deserializeField = deserializeField;
@@ -15787,7 +16059,13 @@ var __publicField = (obj, key, value) => {
15787
16059
  exports2.fileSlice = fileSlice;
15788
16060
  exports2.fileToBlob = fileToBlob;
15789
16061
  exports2.flipCoordinates = flipCoordinates;
16062
+ exports2.formReducer = formReducer;
16063
+ exports2.formRevisionReducer = formRevisionReducer;
15790
16064
  exports2.formRevisionToSchema = formRevisionToSchema;
16065
+ exports2.formRevisionsSlice = formRevisionsSlice;
16066
+ exports2.formSlice = formSlice;
16067
+ exports2.formSubmissionReducer = formSubmissionReducer;
16068
+ exports2.formSubmissionSlice = formSubmissionSlice;
15791
16069
  exports2.forms = index;
15792
16070
  exports2.fullComponentMarkerSize = fullComponentMarkerSize;
15793
16071
  exports2.generateBadgeColors = generateBadgeColors;
@@ -15915,6 +16193,8 @@ var __publicField = (obj, key, value) => {
15915
16193
  exports2.selectAttachmentsOfComponentTypeByType = selectAttachmentsOfComponentTypeByType;
15916
16194
  exports2.selectAttachmentsOfDocument = selectAttachmentsOfDocument;
15917
16195
  exports2.selectAttachmentsOfDocumentByType = selectAttachmentsOfDocumentByType;
16196
+ exports2.selectAttachmentsOfFormRevision = selectAttachmentsOfFormRevision;
16197
+ exports2.selectAttachmentsOfFormSubmission = selectAttachmentsOfFormSubmission;
15918
16198
  exports2.selectAttachmentsOfIssue = selectAttachmentsOfIssue;
15919
16199
  exports2.selectAttachmentsOfIssueByType = selectAttachmentsOfIssueByType;
15920
16200
  exports2.selectAttachmentsOfProject = selectAttachmentsOfProject;
@@ -15932,11 +16212,9 @@ var __publicField = (obj, key, value) => {
15932
16212
  exports2.selectComponent = selectComponent;
15933
16213
  exports2.selectComponentAttachment = selectComponentAttachment;
15934
16214
  exports2.selectComponentAttachmentMapping = selectComponentAttachmentMapping;
15935
- exports2.selectComponentSubmissionMapping = selectComponentSubmissionMapping;
15936
16215
  exports2.selectComponentType = selectComponentType;
15937
16216
  exports2.selectComponentTypeAttachment = selectComponentTypeAttachment;
15938
16217
  exports2.selectComponentTypeAttachmentMapping = selectComponentTypeAttachmentMapping;
15939
- exports2.selectComponentTypeForm = selectComponentTypeForm;
15940
16218
  exports2.selectComponentTypeFromComponent = selectComponentTypeFromComponent;
15941
16219
  exports2.selectComponentTypeFromComponents = selectComponentTypeFromComponents;
15942
16220
  exports2.selectComponentTypeStagesMapping = selectComponentTypeStagesMapping;
@@ -15966,8 +16244,24 @@ var __publicField = (obj, key, value) => {
15966
16244
  exports2.selectExpandedSections = selectExpandedSections;
15967
16245
  exports2.selectFavouriteProjects = selectFavouriteProjects;
15968
16246
  exports2.selectFileAttachmentsOfIssue = selectFileAttachmentsOfIssue;
15969
- exports2.selectFilteredUserForms = selectFilteredUserForms;
16247
+ exports2.selectFilteredForms = selectFilteredForms;
16248
+ exports2.selectForm = selectForm;
16249
+ exports2.selectFormMapping = selectFormMapping;
16250
+ exports2.selectFormOfComponentType = selectFormOfComponentType;
15970
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;
15971
16265
  exports2.selectHiddenCategoryCount = selectHiddenCategoryCount;
15972
16266
  exports2.selectHiddenComponentTypeIds = selectHiddenComponentTypeIds;
15973
16267
  exports2.selectIsFetchingInitialData = selectIsFetchingInitialData;
@@ -15982,10 +16276,10 @@ var __publicField = (obj, key, value) => {
15982
16276
  exports2.selectIssueUpdateMapping = selectIssueUpdateMapping;
15983
16277
  exports2.selectIssueUpdatesOfIssue = selectIssueUpdatesOfIssue;
15984
16278
  exports2.selectIssues = selectIssues;
15985
- exports2.selectLatestFormRevision = selectLatestFormRevision;
16279
+ exports2.selectLatestFormRevisionByForm = selectLatestFormRevisionByForm;
16280
+ exports2.selectLatestFormRevisionOfForm = selectLatestFormRevisionOfForm;
16281
+ exports2.selectLatestFormRevisionsOfComponentTypes = selectLatestFormRevisionsOfComponentTypes;
15986
16282
  exports2.selectLatestRetryTime = selectLatestRetryTime;
15987
- exports2.selectLatestRevisionByFormId = selectLatestRevisionByFormId;
15988
- exports2.selectLatestRevisionsFromComponentTypeIds = selectLatestRevisionsFromComponentTypeIds;
15989
16283
  exports2.selectLicense = selectLicense;
15990
16284
  exports2.selectLicenseForProject = selectLicenseForProject;
15991
16285
  exports2.selectLicenses = selectLicenses;
@@ -15994,8 +16288,6 @@ var __publicField = (obj, key, value) => {
15994
16288
  exports2.selectMapStyle = selectMapStyle;
15995
16289
  exports2.selectNumberOfComponentTypesMatchingCaseInsensitiveName = selectNumberOfComponentTypesMatchingCaseInsensitiveName;
15996
16290
  exports2.selectNumberOfComponentsOfComponentType = selectNumberOfComponentsOfComponentType;
15997
- exports2.selectNumberOfGeneralUserForms = selectNumberOfGeneralUserForms;
15998
- exports2.selectNumberOfUserForms = selectNumberOfUserForms;
15999
16291
  exports2.selectOrganization = selectOrganization;
16000
16292
  exports2.selectOrganizationAccess = selectOrganizationAccess;
16001
16293
  exports2.selectOrganizationAccessForUser = selectOrganizationAccessForUser;
@@ -16023,8 +16315,6 @@ var __publicField = (obj, key, value) => {
16023
16315
  exports2.selectRecentIssuesAsSearchResults = selectRecentIssuesAsSearchResults;
16024
16316
  exports2.selectRecentProjects = selectRecentProjects;
16025
16317
  exports2.selectRehydrated = selectRehydrated;
16026
- exports2.selectRevisionAttachments = selectRevisionAttachments;
16027
- exports2.selectRevisionsForForm = selectRevisionsForForm;
16028
16318
  exports2.selectRootDocuments = selectRootDocuments;
16029
16319
  exports2.selectShowTooltips = selectShowTooltips;
16030
16320
  exports2.selectSortedEmailDomains = selectSortedEmailDomains;
@@ -16039,16 +16329,10 @@ var __publicField = (obj, key, value) => {
16039
16329
  exports2.selectStagesFromComponentType = selectStagesFromComponentType;
16040
16330
  exports2.selectStagesFromComponentTypeIds = selectStagesFromComponentTypeIds;
16041
16331
  exports2.selectStagesFromStageIds = selectStagesFromStageIds;
16042
- exports2.selectSubmissionAttachments = selectSubmissionAttachments;
16043
- exports2.selectSubmissionsForComponent = selectSubmissionsForComponent;
16044
- exports2.selectSubmissionsForForm = selectSubmissionsForForm;
16045
- exports2.selectSubmissionsForIssue = selectSubmissionsForIssue;
16046
16332
  exports2.selectUploadUrl = selectUploadUrl;
16047
16333
  exports2.selectUsedColors = selectUsedColors;
16048
16334
  exports2.selectUser = selectUser;
16049
- exports2.selectUserForm = selectUserForm;
16050
- exports2.selectUserFormMapping = selectUserFormMapping;
16051
- exports2.selectUserFormSubmission = selectUserFormSubmission;
16335
+ exports2.selectUserFormRevisionAttachmentsMapping = selectUserFormRevisionAttachmentsMapping;
16052
16336
  exports2.selectUsersAsMapping = selectUsersAsMapping;
16053
16337
  exports2.selectVisibleStatuses = selectVisibleStatuses;
16054
16338
  exports2.selectVisibleUserIds = selectVisibleUserIds;
@@ -16075,6 +16359,13 @@ var __publicField = (obj, key, value) => {
16075
16359
  exports2.setEnableClustering = setEnableClustering;
16076
16360
  exports2.setEnableDuplicateIssues = setEnableDuplicateIssues;
16077
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;
16078
16369
  exports2.setIsFetchingInitialData = setIsFetchingInitialData;
16079
16370
  exports2.setIsImportingProjectFile = setIsImportingProjectFile;
16080
16371
  exports2.setIsLoading = setIsLoading;
@@ -16099,9 +16390,6 @@ var __publicField = (obj, key, value) => {
16099
16390
  exports2.setTokens = setTokens;
16100
16391
  exports2.setTourStep = setTourStep;
16101
16392
  exports2.setUploadUrl = setUploadUrl;
16102
- exports2.setUserFormRevisionAttachments = setUserFormRevisionAttachments;
16103
- exports2.setUserFormSubmissionAttachments = setUserFormSubmissionAttachments;
16104
- exports2.setUserFormSubmissions = setUserFormSubmissions;
16105
16393
  exports2.setUsers = setUsers;
16106
16394
  exports2.setVisibleStatuses = setVisibleStatuses;
16107
16395
  exports2.setVisibleUserIds = setVisibleUserIds;
@@ -16126,11 +16414,13 @@ var __publicField = (obj, key, value) => {
16126
16414
  exports2.updateComponentTypeAttachment = updateComponentTypeAttachment;
16127
16415
  exports2.updateDocumentAttachment = updateDocumentAttachment;
16128
16416
  exports2.updateDocuments = updateDocuments;
16417
+ exports2.updateFormSubmission = updateFormSubmission;
16418
+ exports2.updateFormSubmissionAttachments = updateFormSubmissionAttachments;
16419
+ exports2.updateFormSubmissions = updateFormSubmissions;
16129
16420
  exports2.updateIssue = updateIssue;
16130
16421
  exports2.updateIssueAttachment = updateIssueAttachment;
16131
16422
  exports2.updateLicense = updateLicense;
16132
16423
  exports2.updateOrCreateProject = updateOrCreateProject;
16133
- exports2.updateOrCreateUserFormSubmission = updateOrCreateUserFormSubmission;
16134
16424
  exports2.updateOrganizationAccess = updateOrganizationAccess;
16135
16425
  exports2.updateProjectAccess = updateProjectAccess;
16136
16426
  exports2.updateProjectAttachment = updateProjectAttachment;
@@ -16144,8 +16434,6 @@ var __publicField = (obj, key, value) => {
16144
16434
  exports2.useFormikInput = useFormikInput;
16145
16435
  exports2.useMemoCompare = useMemoCompare;
16146
16436
  exports2.useSDK = useSDK;
16147
- exports2.userFormReducer = userFormReducer;
16148
- exports2.userFormSlice = userFormSlice;
16149
16437
  exports2.userReducer = userReducer;
16150
16438
  exports2.userSlice = userSlice;
16151
16439
  exports2.valueIsFile = valueIsFile;