@overmap-ai/core 1.0.51-qr-field.0 → 1.0.52

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$p = {
671
+ const initialState$q = {
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$p,
679
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
678
+ initialState: initialState$q,
679
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
680
680
  reducers: {
681
681
  setTokens: (state, action) => {
682
682
  state.accessToken = action.payload.accessToken;
@@ -1420,7 +1420,7 @@ var __publicField = (obj, key, value) => {
1420
1420
  return getLocalDateString(date);
1421
1421
  return relative.format(days, "days");
1422
1422
  });
1423
- const initialState$o = {
1423
+ const initialState$p = {
1424
1424
  categories: {},
1425
1425
  usedCategoryColors: [],
1426
1426
  categoryVisibility: {
@@ -1430,8 +1430,8 @@ var __publicField = (obj, key, value) => {
1430
1430
  };
1431
1431
  const categorySlice = toolkit.createSlice({
1432
1432
  name: "categories",
1433
- initialState: initialState$o,
1434
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1433
+ initialState: initialState$p,
1434
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1435
1435
  reducers: {
1436
1436
  setCategories: (state, action) => {
1437
1437
  if (!Array.isArray(action.payload))
@@ -1563,6 +1563,9 @@ var __publicField = (obj, key, value) => {
1563
1563
  hiddenCategoryCount++;
1564
1564
  return hiddenCategoryCount;
1565
1565
  };
1566
+ const selectIssueCountOfCategory = (categoryId) => (state) => {
1567
+ return Object.values(state.issueReducer.issues).filter((issue) => issue.category === categoryId).length;
1568
+ };
1566
1569
  const categoryReducer = categorySlice.reducer;
1567
1570
  function setAttachments(state, action) {
1568
1571
  state.attachments = {};
@@ -1600,14 +1603,14 @@ var __publicField = (obj, key, value) => {
1600
1603
  delete state.attachments[attachmentId];
1601
1604
  }
1602
1605
  }
1603
- const initialState$n = {
1606
+ const initialState$o = {
1604
1607
  components: {},
1605
1608
  attachments: {}
1606
1609
  };
1607
1610
  const componentSlice = toolkit.createSlice({
1608
1611
  name: "components",
1609
- initialState: initialState$n,
1610
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1612
+ initialState: initialState$o,
1613
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1611
1614
  reducers: {
1612
1615
  addComponent: (state, action) => {
1613
1616
  state.components[action.payload.offline_id] = action.payload;
@@ -1763,13 +1766,13 @@ var __publicField = (obj, key, value) => {
1763
1766
  removeAllComponentsOfType
1764
1767
  } = componentSlice.actions;
1765
1768
  const componentReducer = componentSlice.reducer;
1766
- const initialState$m = {
1769
+ const initialState$n = {
1767
1770
  completionsByComponentId: {}
1768
1771
  };
1769
1772
  const componentStageCompletionSlice = toolkit.createSlice({
1770
1773
  name: "componentStageCompletions",
1771
- initialState: initialState$m,
1772
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1774
+ initialState: initialState$n,
1775
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1773
1776
  reducers: {
1774
1777
  addStageCompletion: (state, action) => {
1775
1778
  let stageToCompletionDateMapping = state.completionsByComponentId[action.payload.component];
@@ -1820,13 +1823,13 @@ var __publicField = (obj, key, value) => {
1820
1823
  return Object.keys(state.componentStageCompletionReducer.completionsByComponentId[component.offline_id] ?? {});
1821
1824
  };
1822
1825
  const componentStageCompletionReducer = componentStageCompletionSlice.reducer;
1823
- const initialState$l = {
1826
+ const initialState$m = {
1824
1827
  stages: {}
1825
1828
  };
1826
1829
  const componentStageSlice = toolkit.createSlice({
1827
1830
  name: "componentStages",
1828
- initialState: initialState$l,
1829
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1831
+ initialState: initialState$m,
1832
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1830
1833
  reducers: {
1831
1834
  addStages: (state, action) => {
1832
1835
  Object.assign(state.stages, toOfflineIdRecord(action.payload));
@@ -1936,15 +1939,15 @@ var __publicField = (obj, key, value) => {
1936
1939
  );
1937
1940
  const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = componentStageSlice.actions;
1938
1941
  const componentStageReducer = componentStageSlice.reducer;
1939
- const initialState$k = {
1942
+ const initialState$l = {
1940
1943
  componentTypes: {},
1941
1944
  hiddenComponentTypeIds: {},
1942
1945
  attachments: {}
1943
1946
  };
1944
1947
  const componentTypeSlice = toolkit.createSlice({
1945
1948
  name: "componentTypes",
1946
- initialState: initialState$k,
1947
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1949
+ initialState: initialState$l,
1950
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1948
1951
  reducers: {
1949
1952
  addComponentType: (state, action) => {
1950
1953
  state.componentTypes[action.payload.offline_id] = action.payload;
@@ -2055,13 +2058,13 @@ var __publicField = (obj, key, value) => {
2055
2058
  deleteComponentType
2056
2059
  } = componentTypeSlice.actions;
2057
2060
  const componentTypeReducer = componentTypeSlice.reducer;
2058
- const initialState$j = {
2061
+ const initialState$k = {
2059
2062
  workspaces: {},
2060
2063
  activeWorkspaceId: null
2061
2064
  };
2062
2065
  const workspaceSlice = toolkit.createSlice({
2063
2066
  name: "workspace",
2064
- initialState: initialState$j,
2067
+ initialState: initialState$k,
2065
2068
  // The `reducers` field lets us define reducers and generate associated actions
2066
2069
  reducers: {
2067
2070
  setWorkspaces: (state, action) => {
@@ -2118,7 +2121,7 @@ var __publicField = (obj, key, value) => {
2118
2121
  );
2119
2122
  const workspaceReducer = workspaceSlice.reducer;
2120
2123
  const maxRecentIssues = 10;
2121
- const initialState$i = {
2124
+ const initialState$j = {
2122
2125
  issues: {},
2123
2126
  attachments: {},
2124
2127
  comments: {},
@@ -2130,9 +2133,9 @@ var __publicField = (obj, key, value) => {
2130
2133
  };
2131
2134
  const issueSlice = toolkit.createSlice({
2132
2135
  name: "issues",
2133
- initialState: initialState$i,
2136
+ initialState: initialState$j,
2134
2137
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2135
- Object.assign(state, initialState$i);
2138
+ Object.assign(state, initialState$j);
2136
2139
  }),
2137
2140
  reducers: {
2138
2141
  setIssues: (state, action) => {
@@ -2540,15 +2543,15 @@ var __publicField = (obj, key, value) => {
2540
2543
  }
2541
2544
  );
2542
2545
  const issueReducer = issueSlice.reducer;
2543
- const initialState$h = {
2546
+ const initialState$i = {
2544
2547
  s3Urls: {}
2545
2548
  };
2546
2549
  const msPerHour = 1e3 * 60 * 60;
2547
2550
  const msPerWeek = msPerHour * 24 * 7;
2548
2551
  const fileSlice = toolkit.createSlice({
2549
2552
  name: "file",
2550
- initialState: initialState$h,
2551
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2553
+ initialState: initialState$i,
2554
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2552
2555
  reducers: {
2553
2556
  setUploadUrl: (state, action) => {
2554
2557
  const { url, fields, sha1 } = action.payload;
@@ -2575,7 +2578,7 @@ var __publicField = (obj, key, value) => {
2575
2578
  return url;
2576
2579
  };
2577
2580
  const fileReducer = fileSlice.reducer;
2578
- const initialState$g = {
2581
+ const initialState$h = {
2579
2582
  // TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
2580
2583
  mapStyle: MapStyle.SATELLITE,
2581
2584
  showTooltips: false,
@@ -2583,8 +2586,8 @@ var __publicField = (obj, key, value) => {
2583
2586
  };
2584
2587
  const mapSlice = toolkit.createSlice({
2585
2588
  name: "map",
2586
- initialState: initialState$g,
2587
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2589
+ initialState: initialState$h,
2590
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2588
2591
  reducers: {
2589
2592
  setMapStyle: (state, action) => {
2590
2593
  state.mapStyle = action.payload;
@@ -2653,7 +2656,7 @@ var __publicField = (obj, key, value) => {
2653
2656
  LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
2654
2657
  return LicenseStatus2;
2655
2658
  })(LicenseStatus || {});
2656
- const initialState$f = {
2659
+ const initialState$g = {
2657
2660
  users: {},
2658
2661
  currentUser: {
2659
2662
  id: 0,
@@ -2664,8 +2667,8 @@ var __publicField = (obj, key, value) => {
2664
2667
  };
2665
2668
  const userSlice = toolkit.createSlice({
2666
2669
  name: "users",
2667
- initialState: initialState$f,
2668
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2670
+ initialState: initialState$g,
2671
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2669
2672
  reducers: {
2670
2673
  setUsers: (state, action) => {
2671
2674
  const usersMapping = {};
@@ -2727,13 +2730,13 @@ var __publicField = (obj, key, value) => {
2727
2730
  const selectUsersAsMapping = (state) => state.userReducer.users;
2728
2731
  const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
2729
2732
  const userReducer = userSlice.reducer;
2730
- const initialState$e = {
2733
+ const initialState$f = {
2731
2734
  organizationAccesses: {}
2732
2735
  };
2733
2736
  const organizationAccessSlice = toolkit.createSlice({
2734
2737
  name: "organizationAccess",
2735
- initialState: initialState$e,
2736
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2738
+ initialState: initialState$f,
2739
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2737
2740
  reducers: {
2738
2741
  setOrganizationAccesses: (state, action) => {
2739
2742
  if (!Array.isArray(action.payload))
@@ -2796,13 +2799,13 @@ var __publicField = (obj, key, value) => {
2796
2799
  return organizationAccesses;
2797
2800
  };
2798
2801
  const organizationAccessReducer = organizationAccessSlice.reducer;
2799
- const initialState$d = {
2802
+ const initialState$e = {
2800
2803
  licenses: {}
2801
2804
  };
2802
2805
  const licenseSlice = toolkit.createSlice({
2803
2806
  name: "license",
2804
- initialState: initialState$d,
2805
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2807
+ initialState: initialState$e,
2808
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2806
2809
  reducers: {
2807
2810
  setLicenses: (state, action) => {
2808
2811
  if (!Array.isArray(action.payload))
@@ -2847,13 +2850,13 @@ var __publicField = (obj, key, value) => {
2847
2850
  (licenses) => Object.values(licenses).filter((license) => license.project).reduce((accum, license) => ({ ...accum, [license.project]: license }), {})
2848
2851
  );
2849
2852
  const licenseReducer = licenseSlice.reducer;
2850
- const initialState$c = {
2853
+ const initialState$d = {
2851
2854
  projectAccesses: {}
2852
2855
  };
2853
2856
  const projectAccessSlice = toolkit.createSlice({
2854
2857
  name: "projectAccess",
2855
- initialState: initialState$c,
2856
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2858
+ initialState: initialState$d,
2859
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2857
2860
  reducers: {
2858
2861
  setProjectAccesses: (state, action) => {
2859
2862
  if (!Array.isArray(action.payload))
@@ -2921,7 +2924,7 @@ var __publicField = (obj, key, value) => {
2921
2924
  return projectAccesses;
2922
2925
  };
2923
2926
  const projectAccessReducer = projectAccessSlice.reducer;
2924
- const initialState$b = {
2927
+ const initialState$c = {
2925
2928
  projects: {},
2926
2929
  activeProjectId: null,
2927
2930
  recentProjectIds: [],
@@ -2931,7 +2934,7 @@ var __publicField = (obj, key, value) => {
2931
2934
  };
2932
2935
  const projectSlice = toolkit.createSlice({
2933
2936
  name: "projects",
2934
- initialState: initialState$b,
2937
+ initialState: initialState$c,
2935
2938
  reducers: {
2936
2939
  setProjects: (state, action) => {
2937
2940
  const projectsMap = {};
@@ -3118,14 +3121,14 @@ var __publicField = (obj, key, value) => {
3118
3121
  }
3119
3122
  )
3120
3123
  );
3121
- const initialState$a = {
3124
+ const initialState$b = {
3122
3125
  organizations: {},
3123
3126
  activeOrganizationId: null
3124
3127
  };
3125
3128
  const organizationSlice = toolkit.createSlice({
3126
3129
  name: "organizations",
3127
- initialState: initialState$a,
3128
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
3130
+ initialState: initialState$b,
3131
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
3129
3132
  reducers: {
3130
3133
  setOrganizations: (state, action) => {
3131
3134
  for (const org of action.payload) {
@@ -3244,14 +3247,14 @@ var __publicField = (obj, key, value) => {
3244
3247
  }
3245
3248
  };
3246
3249
  };
3247
- const initialState$9 = {
3250
+ const initialState$a = {
3248
3251
  deletedRequests: [],
3249
3252
  latestRetryTime: 0
3250
3253
  };
3251
3254
  const outboxSlice = toolkit.createSlice({
3252
3255
  name: "outbox",
3253
- initialState: initialState$9,
3254
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
3256
+ initialState: initialState$a,
3257
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
3255
3258
  reducers: {
3256
3259
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
3257
3260
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -3283,7 +3286,7 @@ var __publicField = (obj, key, value) => {
3283
3286
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
3284
3287
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
3285
3288
  const outboxReducer = outboxSlice.reducer;
3286
- const initialState$8 = {
3289
+ const initialState$9 = {
3287
3290
  projectFiles: {},
3288
3291
  activeProjectFileId: null,
3289
3292
  isImportingProjectFile: false,
@@ -3291,8 +3294,8 @@ var __publicField = (obj, key, value) => {
3291
3294
  };
3292
3295
  const projectFileSlice = toolkit.createSlice({
3293
3296
  name: "projectFiles",
3294
- initialState: initialState$8,
3295
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3297
+ initialState: initialState$9,
3298
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
3296
3299
  reducers: {
3297
3300
  addOrReplaceProjectFiles: (state, action) => {
3298
3301
  for (let fileObj of action.payload) {
@@ -3393,12 +3396,12 @@ var __publicField = (obj, key, value) => {
3393
3396
  const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProjectFileId;
3394
3397
  const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
3395
3398
  const projectFileReducer = projectFileSlice.reducer;
3396
- const initialState$7 = {
3399
+ const initialState$8 = {
3397
3400
  isRehydrated: false
3398
3401
  };
3399
3402
  const rehydratedSlice = toolkit.createSlice({
3400
3403
  name: "rehydrated",
3401
- initialState: initialState$7,
3404
+ initialState: initialState$8,
3402
3405
  // The `reducers` field lets us define reducers and generate associated actions
3403
3406
  reducers: {
3404
3407
  setRehydrated: (state, action) => {
@@ -3408,7 +3411,7 @@ var __publicField = (obj, key, value) => {
3408
3411
  });
3409
3412
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
3410
3413
  const rehydratedReducer = rehydratedSlice.reducer;
3411
- const initialState$6 = {
3414
+ const initialState$7 = {
3412
3415
  useIssueTemplate: false,
3413
3416
  placementMode: false,
3414
3417
  enableClustering: false,
@@ -3425,8 +3428,8 @@ var __publicField = (obj, key, value) => {
3425
3428
  };
3426
3429
  const settingSlice = toolkit.createSlice({
3427
3430
  name: "settings",
3428
- initialState: initialState$6,
3429
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3431
+ initialState: initialState$7,
3432
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
3430
3433
  reducers: {
3431
3434
  setEnableDuplicateIssues: (state, action) => {
3432
3435
  state.useIssueTemplate = action.payload;
@@ -3485,14 +3488,14 @@ var __publicField = (obj, key, value) => {
3485
3488
  return revisionA < revisionB ? -1 : 1;
3486
3489
  }
3487
3490
  };
3488
- const initialState$5 = {
3491
+ const initialState$6 = {
3489
3492
  formRevisions: {},
3490
3493
  attachments: {}
3491
3494
  };
3492
3495
  const formRevisionsSlice = toolkit.createSlice({
3493
3496
  name: "formRevisions",
3494
- initialState: initialState$5,
3495
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3497
+ initialState: initialState$6,
3498
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3496
3499
  reducers: {
3497
3500
  // revision related actions
3498
3501
  setFormRevision: (state, action) => {
@@ -3672,13 +3675,13 @@ var __publicField = (obj, key, value) => {
3672
3675
  )
3673
3676
  );
3674
3677
  const formRevisionReducer = formRevisionsSlice.reducer;
3675
- const initialState$4 = {
3678
+ const initialState$5 = {
3676
3679
  forms: {}
3677
3680
  };
3678
3681
  const formSlice = toolkit.createSlice({
3679
3682
  name: "forms",
3680
- initialState: initialState$4,
3681
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3683
+ initialState: initialState$5,
3684
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3682
3685
  reducers: {
3683
3686
  setForms: (state, action) => {
3684
3687
  state.forms = {};
@@ -3775,14 +3778,14 @@ var __publicField = (obj, key, value) => {
3775
3778
  return Object.values(userForms).filter((form) => !form.component_type).length;
3776
3779
  });
3777
3780
  const formReducer = formSlice.reducer;
3778
- const initialState$3 = {
3781
+ const initialState$4 = {
3779
3782
  formSubmissions: {},
3780
3783
  attachments: {}
3781
3784
  };
3782
3785
  const formSubmissionSlice = toolkit.createSlice({
3783
3786
  name: "formSubmissions",
3784
- initialState: initialState$3,
3785
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3787
+ initialState: initialState$4,
3788
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3786
3789
  reducers: {
3787
3790
  setFormSubmission: (state, action) => {
3788
3791
  state.formSubmissions[action.payload.offline_id] = action.payload;
@@ -3982,12 +3985,12 @@ var __publicField = (obj, key, value) => {
3982
3985
  )
3983
3986
  );
3984
3987
  const formSubmissionReducer = formSubmissionSlice.reducer;
3985
- const initialState$2 = {
3988
+ const initialState$3 = {
3986
3989
  emailDomains: {}
3987
3990
  };
3988
3991
  const emailDomainsSlice = toolkit.createSlice({
3989
3992
  name: "emailDomains",
3990
- initialState: initialState$2,
3993
+ initialState: initialState$3,
3991
3994
  reducers: {
3992
3995
  setEmailDomains: (state, action) => {
3993
3996
  const emailDomains = {};
@@ -4014,15 +4017,15 @@ var __publicField = (obj, key, value) => {
4014
4017
  (ed1, ed2) => ed1.domain.localeCompare(ed2.domain)
4015
4018
  );
4016
4019
  const emailDomainsReducer = emailDomainsSlice.reducer;
4017
- const initialState$1 = {
4020
+ const initialState$2 = {
4018
4021
  documents: {},
4019
4022
  attachments: {}
4020
4023
  };
4021
4024
  const documentSlice = toolkit.createSlice({
4022
4025
  name: "documents",
4023
- initialState: initialState$1,
4026
+ initialState: initialState$2,
4024
4027
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
4025
- Object.assign(state, initialState$1);
4028
+ Object.assign(state, initialState$2);
4026
4029
  }),
4027
4030
  reducers: {
4028
4031
  setDocuments: (state, action) => {
@@ -4059,9 +4062,18 @@ var __publicField = (obj, key, value) => {
4059
4062
  }
4060
4063
  }
4061
4064
  for (const document2 of action.payload) {
4065
+ const existingDocument = state.documents[document2.offline_id];
4066
+ if (document2.organization !== void 0 && document2.organization !== existingDocument.organization) {
4067
+ throw new Error("organization cannot be updated");
4068
+ }
4069
+ if (document2.project !== void 0 && document2.project !== existingDocument.project) {
4070
+ throw new Error("project cannot be updated");
4071
+ }
4062
4072
  state.documents[document2.offline_id] = {
4063
- ...state.documents[document2.offline_id],
4073
+ ...existingDocument,
4064
4074
  ...document2
4075
+ // Without the cast, TypeScript doesn't realize that we have guaranteed that the document doesn't
4076
+ // have both a project and an organization.
4065
4077
  };
4066
4078
  }
4067
4079
  },
@@ -4238,6 +4250,62 @@ var __publicField = (obj, key, value) => {
4238
4250
  )
4239
4251
  );
4240
4252
  const documentsReducer = documentSlice.reducer;
4253
+ const initialState$1 = {
4254
+ teams: {}
4255
+ };
4256
+ const teamSlice = toolkit.createSlice({
4257
+ name: "teams",
4258
+ initialState: initialState$1,
4259
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$1)),
4260
+ reducers: {
4261
+ setTeam: (state, action) => {
4262
+ state.teams[action.payload.offline_id] = action.payload;
4263
+ },
4264
+ setTeams: (state, action) => {
4265
+ state.teams = {};
4266
+ for (const team of action.payload) {
4267
+ state.teams[team.offline_id] = team;
4268
+ }
4269
+ },
4270
+ addTeam: (state, action) => {
4271
+ if (state.teams[action.payload.offline_id]) {
4272
+ throw new Error(`Team with offline_id ${action.payload.offline_id} already exists`);
4273
+ }
4274
+ state.teams[action.payload.offline_id] = action.payload;
4275
+ },
4276
+ updateTeam: (state, action) => {
4277
+ if (!state.teams[action.payload.offline_id]) {
4278
+ throw new Error(`Team with offline_id ${action.payload.offline_id} does not exist`);
4279
+ }
4280
+ state.teams[action.payload.offline_id] = action.payload;
4281
+ },
4282
+ deleteTeam: (state, action) => {
4283
+ delete state.teams[action.payload];
4284
+ }
4285
+ }
4286
+ });
4287
+ const { setTeam, setTeams, addTeam, updateTeam, deleteTeam } = teamSlice.actions;
4288
+ const selectTeamsMapping = (state) => state.teamReducer.teams;
4289
+ const selectTeams = toolkit.createSelector([selectTeamsMapping], (teams) => {
4290
+ return Object.values(teams);
4291
+ });
4292
+ const selectTeam = (teamId) => (state) => {
4293
+ return state.teamReducer.teams[teamId];
4294
+ };
4295
+ const selectTeamsOfOrganization = restructureCreateSelectorWithArgs(
4296
+ toolkit.createSelector(
4297
+ [selectTeams, (_state, organizationId) => organizationId],
4298
+ (teams, organizationId) => {
4299
+ return teams.filter((team) => team.organization === organizationId);
4300
+ }
4301
+ )
4302
+ );
4303
+ const selectTeamsOfUser = restructureCreateSelectorWithArgs(
4304
+ toolkit.createSelector([selectTeams, (_state, userId) => userId], (teams, userId) => {
4305
+ return teams.filter((team) => team.members.includes(userId));
4306
+ })
4307
+ );
4308
+ const teamReducer = teamSlice.reducer;
4241
4309
  const initialState = {
4242
4310
  version: 0
4243
4311
  };
@@ -4286,7 +4354,8 @@ var __publicField = (obj, key, value) => {
4286
4354
  workspaceReducer,
4287
4355
  emailDomainsReducer,
4288
4356
  licenseReducer,
4289
- documentsReducer
4357
+ documentsReducer,
4358
+ teamReducer
4290
4359
  };
4291
4360
  const overmapReducer = toolkit.combineReducers(overmapReducers);
4292
4361
  const resetStore = "RESET";
@@ -6525,6 +6594,7 @@ var __publicField = (obj, key, value) => {
6525
6594
  }
6526
6595
  if (currentOrgId) {
6527
6596
  await this.client.organizations.fetchInitialOrganizationData(currentOrgId, false);
6597
+ void this.client.teams.refreshStore();
6528
6598
  }
6529
6599
  if (!isProjectIdValid) {
6530
6600
  if (validProjects.length !== 0) {
@@ -7988,17 +8058,28 @@ var __publicField = (obj, key, value) => {
7988
8058
  }
7989
8059
  }
7990
8060
  class DocumentService extends BaseApiService {
8061
+ // TODO: Support adding for project or organization
7991
8062
  add(document2) {
7992
8063
  const { store } = this.client;
7993
8064
  const currentUserId = store.getState().userReducer.currentUser.id;
7994
8065
  const activeProjectId = store.getState().projectReducer.activeProjectId;
7995
- const offlineDocument = offline({ ...document2, created_by: currentUserId });
7996
- store.dispatch(addDocuments([offlineDocument]));
8066
+ if (!activeProjectId) {
8067
+ throw new Error("No active project ID while creating document.");
8068
+ }
8069
+ const offlineDocument = offline(document2);
8070
+ const submittedDocument = {
8071
+ ...offlineDocument,
8072
+ created_by: currentUserId,
8073
+ project: activeProjectId,
8074
+ organization: null,
8075
+ children_documents: []
8076
+ };
8077
+ store.dispatch(addDocuments([submittedDocument]));
7997
8078
  const promise = this.enqueueRequest({
7998
8079
  description: "Create Document",
7999
8080
  method: HttpMethod.POST,
8000
- url: `/projects/${activeProjectId}/create-document/`,
8001
- payload: { ...offlineDocument },
8081
+ url: `/projects/${activeProjectId}/documents/`,
8082
+ payload: offlineDocument,
8002
8083
  queryParams: {
8003
8084
  parent_document: offlineDocument.parent_document ?? void 0
8004
8085
  },
@@ -8009,7 +8090,7 @@ var __publicField = (obj, key, value) => {
8009
8090
  promise.catch(() => {
8010
8091
  store.dispatch(removeDocuments([offlineDocument.offline_id]));
8011
8092
  });
8012
- return [offlineDocument, promise];
8093
+ return [submittedDocument, promise];
8013
8094
  }
8014
8095
  update(document2) {
8015
8096
  const { store } = this.client;
@@ -8109,15 +8190,25 @@ var __publicField = (obj, key, value) => {
8109
8190
  }
8110
8191
  async refreshStore() {
8111
8192
  const { store } = this.client;
8112
- const activeProjectId = store.getState().projectReducer.activeProjectId;
8113
- const result = await this.enqueueRequest({
8193
+ const state = store.getState();
8194
+ const activeProjectId = state.projectReducer.activeProjectId;
8195
+ const projectDocumentsPromise = this.enqueueRequest({
8114
8196
  description: "Get project documents",
8115
8197
  method: HttpMethod.GET,
8116
- url: `/documents/projects/${activeProjectId}/`,
8198
+ url: `/projects/${activeProjectId}/documents/`,
8199
+ blockers: [],
8200
+ blocks: []
8201
+ });
8202
+ const activeOrganizationId = state.organizationReducer.activeOrganizationId;
8203
+ const organizationDocumentsPromise = this.enqueueRequest({
8204
+ description: "Get organization documents",
8205
+ method: HttpMethod.GET,
8206
+ url: `/organizations/${activeOrganizationId}/documents/`,
8117
8207
  blockers: [],
8118
8208
  blocks: []
8119
8209
  });
8120
- store.dispatch(setDocuments(result));
8210
+ store.dispatch(setDocuments(await projectDocumentsPromise));
8211
+ store.dispatch(addDocuments(await organizationDocumentsPromise));
8121
8212
  }
8122
8213
  }
8123
8214
  class AgentService extends BaseApiService {
@@ -8152,6 +8243,142 @@ var __publicField = (obj, key, value) => {
8152
8243
  });
8153
8244
  }
8154
8245
  }
8246
+ class TeamService extends BaseApiService {
8247
+ add(teamPayload) {
8248
+ const { store } = this.client;
8249
+ const state = store.getState();
8250
+ const activeOrganizationId = state.organizationReducer.activeOrganizationId;
8251
+ if (!activeOrganizationId) {
8252
+ throw new Error(`Expected active organization to be set, got ${activeOrganizationId}`);
8253
+ }
8254
+ const offlineTeam = offline({
8255
+ ...teamPayload,
8256
+ organization: activeOrganizationId,
8257
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
8258
+ // TODO: uncomment once supported
8259
+ // created_by: state.userReducer.currentUser.id,
8260
+ });
8261
+ store.dispatch(addTeam(offlineTeam));
8262
+ const promise = this.enqueueRequest({
8263
+ description: "Create team",
8264
+ method: HttpMethod.POST,
8265
+ url: `/organizations/${activeOrganizationId}/teams/`,
8266
+ payload: offlineTeam,
8267
+ // No blocks since users and organizations are not offline
8268
+ blockers: [],
8269
+ blocks: [offlineTeam.offline_id]
8270
+ });
8271
+ promise.then((createdTeam) => {
8272
+ store.dispatch(setTeam(createdTeam));
8273
+ }).catch(() => {
8274
+ store.dispatch(deleteTeam(offlineTeam.offline_id));
8275
+ });
8276
+ return [offlineTeam, promise];
8277
+ }
8278
+ // TODO: @Audiopolis / Magnus - should we pass a offline_id as one arg and a UpdatedTeamProps as a second arg instead of this set up?
8279
+ update(team) {
8280
+ const { store } = this.client;
8281
+ const teamToBeUpdated = store.getState().teamReducer.teams[team.offline_id];
8282
+ const offlineUpdatedTeam = {
8283
+ ...teamToBeUpdated,
8284
+ ...team
8285
+ };
8286
+ store.dispatch(updateTeam(offlineUpdatedTeam));
8287
+ const promise = this.enqueueRequest({
8288
+ description: "Update team",
8289
+ method: HttpMethod.PATCH,
8290
+ url: `/organizations/teams/${team.offline_id}/`,
8291
+ payload: offlineUpdatedTeam,
8292
+ blockers: [team.offline_id],
8293
+ blocks: [team.offline_id]
8294
+ });
8295
+ promise.then((updatedTeam) => {
8296
+ store.dispatch(setTeam(updatedTeam));
8297
+ }).catch(() => {
8298
+ store.dispatch(setTeam(teamToBeUpdated));
8299
+ });
8300
+ return [offlineUpdatedTeam, promise];
8301
+ }
8302
+ async delete(teamId) {
8303
+ const { store } = this.client;
8304
+ const state = store.getState();
8305
+ const team = state.teamReducer.teams[teamId];
8306
+ if (!team) {
8307
+ throw new Error(`Expected team with id ${teamId} to exist`);
8308
+ }
8309
+ store.dispatch(deleteTeam(teamId));
8310
+ try {
8311
+ return await this.enqueueRequest({
8312
+ description: "Delete team",
8313
+ method: HttpMethod.DELETE,
8314
+ url: `/organizations/teams/${teamId}/`,
8315
+ blockers: [teamId],
8316
+ blocks: [teamId]
8317
+ });
8318
+ } catch (e) {
8319
+ store.dispatch(setTeam(team));
8320
+ throw e;
8321
+ }
8322
+ }
8323
+ async setMembers(teamId, members) {
8324
+ const { store } = this.client;
8325
+ const team = store.getState().teamReducer.teams[teamId];
8326
+ if (!team) {
8327
+ throw new Error(`Expected team with id ${teamId} to exist`);
8328
+ }
8329
+ if (members.length !== new Set(members).size) {
8330
+ throw new Error("Duplicate members found in the list");
8331
+ }
8332
+ store.dispatch(updateTeam({ ...team, members }));
8333
+ const promise = this.enqueueRequest({
8334
+ description: "Set team members",
8335
+ method: HttpMethod.PUT,
8336
+ url: `/organizations/teams/${teamId}/set-members/`,
8337
+ payload: {
8338
+ users: members
8339
+ },
8340
+ blockers: [teamId],
8341
+ blocks: [teamId]
8342
+ });
8343
+ promise.catch(() => {
8344
+ store.dispatch(setTeam(team));
8345
+ });
8346
+ return promise;
8347
+ }
8348
+ async addMembers(teamId, members) {
8349
+ const { store } = this.client;
8350
+ const team = store.getState().teamReducer.teams[teamId];
8351
+ if (!team) {
8352
+ throw new Error(`Expected team with id ${teamId} to exist`);
8353
+ }
8354
+ const newMembers = [...team.members, ...members];
8355
+ return this.setMembers(teamId, newMembers);
8356
+ }
8357
+ async removeMembers(teamId, members) {
8358
+ const { store } = this.client;
8359
+ const team = store.getState().teamReducer.teams[teamId];
8360
+ if (!team) {
8361
+ throw new Error(`Expected team with id ${teamId} to exist`);
8362
+ }
8363
+ const newMembers = team.members.filter((member) => !members.includes(member));
8364
+ return this.setMembers(teamId, newMembers);
8365
+ }
8366
+ async refreshStore() {
8367
+ const { store } = this.client;
8368
+ const activeOrganizationId = store.getState().organizationReducer.activeOrganizationId;
8369
+ if (!activeOrganizationId) {
8370
+ throw new Error(`Expected active organization to be set, got ${activeOrganizationId}`);
8371
+ }
8372
+ const result = await this.enqueueRequest({
8373
+ description: "Fetch teams",
8374
+ method: HttpMethod.GET,
8375
+ url: `/organizations/${activeOrganizationId}/teams/`,
8376
+ blockers: [],
8377
+ blocks: []
8378
+ });
8379
+ store.dispatch(setTeams(result));
8380
+ }
8381
+ }
8155
8382
  class OvermapSDK {
8156
8383
  constructor(apiUrl, store) {
8157
8384
  __publicField(this, "API_URL");
@@ -8181,6 +8408,7 @@ var __publicField = (obj, key, value) => {
8181
8408
  __publicField(this, "emailDomains", new EmailDomainsService(this));
8182
8409
  __publicField(this, "licenses", new LicenseService(this));
8183
8410
  __publicField(this, "documents", new DocumentService(this));
8411
+ __publicField(this, "teams", new TeamService(this));
8184
8412
  this.API_URL = apiUrl;
8185
8413
  this.store = store;
8186
8414
  }
@@ -12640,8 +12868,7 @@ var __publicField = (obj, key, value) => {
12640
12868
  description: "List possible options for the user to select from.",
12641
12869
  required: true,
12642
12870
  identifier: `${path}options`,
12643
- minimum_length: 2,
12644
- maximum_length: 20
12871
+ minimum_length: 2
12645
12872
  }),
12646
12873
  showDirectly: true
12647
12874
  }
@@ -16103,6 +16330,7 @@ var __publicField = (obj, key, value) => {
16103
16330
  exports2.SpreadsheetViewer = SpreadsheetViewer;
16104
16331
  exports2.StringField = StringField;
16105
16332
  exports2.StringInput = StringInput;
16333
+ exports2.TeamService = TeamService;
16106
16334
  exports2.TextField = TextField;
16107
16335
  exports2.TextInput = TextInput;
16108
16336
  exports2.UserFormService = UserFormService;
@@ -16157,6 +16385,7 @@ var __publicField = (obj, key, value) => {
16157
16385
  exports2.addStageCompletion = addStageCompletion;
16158
16386
  exports2.addStageCompletions = addStageCompletions;
16159
16387
  exports2.addStages = addStages;
16388
+ exports2.addTeam = addTeam;
16160
16389
  exports2.addToRecentIssues = addToRecentIssues;
16161
16390
  exports2.addUsers = addUsers;
16162
16391
  exports2.addWorkspace = addWorkspace;
@@ -16199,6 +16428,7 @@ var __publicField = (obj, key, value) => {
16199
16428
  exports2.deleteFormSubmissionAttachments = deleteFormSubmissionAttachments;
16200
16429
  exports2.deleteFormSubmissions = deleteFormSubmissions;
16201
16430
  exports2.deleteProject = deleteProject;
16431
+ exports2.deleteTeam = deleteTeam;
16202
16432
  exports2.dequeue = dequeue;
16203
16433
  exports2.deserialize = deserialize;
16204
16434
  exports2.deserializeField = deserializeField;
@@ -16441,6 +16671,7 @@ var __publicField = (obj, key, value) => {
16441
16671
  exports2.selectIssueAttachment = selectIssueAttachment;
16442
16672
  exports2.selectIssueAttachmentMapping = selectIssueAttachmentMapping;
16443
16673
  exports2.selectIssueAttachments = selectIssueAttachments;
16674
+ exports2.selectIssueCountOfCategory = selectIssueCountOfCategory;
16444
16675
  exports2.selectIssueMapping = selectIssueMapping;
16445
16676
  exports2.selectIssueUpdateMapping = selectIssueUpdateMapping;
16446
16677
  exports2.selectIssueUpdatesOfIssue = selectIssueUpdatesOfIssue;
@@ -16498,6 +16729,11 @@ var __publicField = (obj, key, value) => {
16498
16729
  exports2.selectStagesFromComponentType = selectStagesFromComponentType;
16499
16730
  exports2.selectStagesFromComponentTypeIds = selectStagesFromComponentTypeIds;
16500
16731
  exports2.selectStagesFromStageIds = selectStagesFromStageIds;
16732
+ exports2.selectTeam = selectTeam;
16733
+ exports2.selectTeams = selectTeams;
16734
+ exports2.selectTeamsMapping = selectTeamsMapping;
16735
+ exports2.selectTeamsOfOrganization = selectTeamsOfOrganization;
16736
+ exports2.selectTeamsOfUser = selectTeamsOfUser;
16501
16737
  exports2.selectUploadUrl = selectUploadUrl;
16502
16738
  exports2.selectUsedColors = selectUsedColors;
16503
16739
  exports2.selectUser = selectUser;
@@ -16556,6 +16792,8 @@ var __publicField = (obj, key, value) => {
16556
16792
  exports2.setSectionExpanded = setSectionExpanded;
16557
16793
  exports2.setShowTooltips = setShowTooltips;
16558
16794
  exports2.setStageCompletions = setStageCompletions;
16795
+ exports2.setTeam = setTeam;
16796
+ exports2.setTeams = setTeams;
16559
16797
  exports2.setTokens = setTokens;
16560
16798
  exports2.setTourStep = setTourStep;
16561
16799
  exports2.setUploadUrl = setUploadUrl;
@@ -16569,6 +16807,8 @@ var __publicField = (obj, key, value) => {
16569
16807
  exports2.slugify = slugify;
16570
16808
  exports2.spacesToDashesLower = spacesToDashesLower;
16571
16809
  exports2.successColor = successColor;
16810
+ exports2.teamReducer = teamReducer;
16811
+ exports2.teamSlice = teamSlice;
16572
16812
  exports2.toFileNameSafeString = toFileNameSafeString;
16573
16813
  exports2.toOfflineIdRecord = toOfflineIdRecord;
16574
16814
  exports2.toggleComponentTypeVisibility = toggleComponentTypeVisibility;
@@ -16594,6 +16834,7 @@ var __publicField = (obj, key, value) => {
16594
16834
  exports2.updateProjectAccess = updateProjectAccess;
16595
16835
  exports2.updateProjectAttachment = updateProjectAttachment;
16596
16836
  exports2.updateStages = updateStages;
16837
+ exports2.updateTeam = updateTeam;
16597
16838
  exports2.useAppDispatch = useAppDispatch;
16598
16839
  exports2.useAppSelector = useAppSelector;
16599
16840
  exports2.useFieldInput = useFieldInput;