@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.
@@ -678,15 +678,15 @@ const wrapMigration = (migrator) => (state) => {
678
678
  };
679
679
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
680
680
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
681
- const initialState$p = {
681
+ const initialState$q = {
682
682
  accessToken: "",
683
683
  refreshToken: "",
684
684
  isLoggedIn: false
685
685
  };
686
686
  const authSlice = createSlice({
687
687
  name: "auth",
688
- initialState: initialState$p,
689
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
688
+ initialState: initialState$q,
689
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
690
690
  reducers: {
691
691
  setTokens: (state, action) => {
692
692
  state.accessToken = action.payload.accessToken;
@@ -1430,7 +1430,7 @@ const getLocalRelativeDateString = memoize((date, min, max) => {
1430
1430
  return getLocalDateString(date);
1431
1431
  return relative.format(days, "days");
1432
1432
  });
1433
- const initialState$o = {
1433
+ const initialState$p = {
1434
1434
  categories: {},
1435
1435
  usedCategoryColors: [],
1436
1436
  categoryVisibility: {
@@ -1440,8 +1440,8 @@ const initialState$o = {
1440
1440
  };
1441
1441
  const categorySlice = createSlice({
1442
1442
  name: "categories",
1443
- initialState: initialState$o,
1444
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1443
+ initialState: initialState$p,
1444
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1445
1445
  reducers: {
1446
1446
  setCategories: (state, action) => {
1447
1447
  if (!Array.isArray(action.payload))
@@ -1573,6 +1573,9 @@ const selectHiddenCategoryCount = (state) => {
1573
1573
  hiddenCategoryCount++;
1574
1574
  return hiddenCategoryCount;
1575
1575
  };
1576
+ const selectIssueCountOfCategory = (categoryId) => (state) => {
1577
+ return Object.values(state.issueReducer.issues).filter((issue) => issue.category === categoryId).length;
1578
+ };
1576
1579
  const categoryReducer = categorySlice.reducer;
1577
1580
  function setAttachments(state, action) {
1578
1581
  state.attachments = {};
@@ -1610,14 +1613,14 @@ function removeAttachments(state, action) {
1610
1613
  delete state.attachments[attachmentId];
1611
1614
  }
1612
1615
  }
1613
- const initialState$n = {
1616
+ const initialState$o = {
1614
1617
  components: {},
1615
1618
  attachments: {}
1616
1619
  };
1617
1620
  const componentSlice = createSlice({
1618
1621
  name: "components",
1619
- initialState: initialState$n,
1620
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1622
+ initialState: initialState$o,
1623
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1621
1624
  reducers: {
1622
1625
  addComponent: (state, action) => {
1623
1626
  state.components[action.payload.offline_id] = action.payload;
@@ -1773,13 +1776,13 @@ const {
1773
1776
  removeAllComponentsOfType
1774
1777
  } = componentSlice.actions;
1775
1778
  const componentReducer = componentSlice.reducer;
1776
- const initialState$m = {
1779
+ const initialState$n = {
1777
1780
  completionsByComponentId: {}
1778
1781
  };
1779
1782
  const componentStageCompletionSlice = createSlice({
1780
1783
  name: "componentStageCompletions",
1781
- initialState: initialState$m,
1782
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1784
+ initialState: initialState$n,
1785
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1783
1786
  reducers: {
1784
1787
  addStageCompletion: (state, action) => {
1785
1788
  let stageToCompletionDateMapping = state.completionsByComponentId[action.payload.component];
@@ -1830,13 +1833,13 @@ const selectCompletedStageIdsForComponent = (component) => (state) => {
1830
1833
  return Object.keys(state.componentStageCompletionReducer.completionsByComponentId[component.offline_id] ?? {});
1831
1834
  };
1832
1835
  const componentStageCompletionReducer = componentStageCompletionSlice.reducer;
1833
- const initialState$l = {
1836
+ const initialState$m = {
1834
1837
  stages: {}
1835
1838
  };
1836
1839
  const componentStageSlice = createSlice({
1837
1840
  name: "componentStages",
1838
- initialState: initialState$l,
1839
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1841
+ initialState: initialState$m,
1842
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1840
1843
  reducers: {
1841
1844
  addStages: (state, action) => {
1842
1845
  Object.assign(state.stages, toOfflineIdRecord(action.payload));
@@ -1946,15 +1949,15 @@ const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
1946
1949
  );
1947
1950
  const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = componentStageSlice.actions;
1948
1951
  const componentStageReducer = componentStageSlice.reducer;
1949
- const initialState$k = {
1952
+ const initialState$l = {
1950
1953
  componentTypes: {},
1951
1954
  hiddenComponentTypeIds: {},
1952
1955
  attachments: {}
1953
1956
  };
1954
1957
  const componentTypeSlice = createSlice({
1955
1958
  name: "componentTypes",
1956
- initialState: initialState$k,
1957
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1959
+ initialState: initialState$l,
1960
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1958
1961
  reducers: {
1959
1962
  addComponentType: (state, action) => {
1960
1963
  state.componentTypes[action.payload.offline_id] = action.payload;
@@ -2065,13 +2068,13 @@ const {
2065
2068
  deleteComponentType
2066
2069
  } = componentTypeSlice.actions;
2067
2070
  const componentTypeReducer = componentTypeSlice.reducer;
2068
- const initialState$j = {
2071
+ const initialState$k = {
2069
2072
  workspaces: {},
2070
2073
  activeWorkspaceId: null
2071
2074
  };
2072
2075
  const workspaceSlice = createSlice({
2073
2076
  name: "workspace",
2074
- initialState: initialState$j,
2077
+ initialState: initialState$k,
2075
2078
  // The `reducers` field lets us define reducers and generate associated actions
2076
2079
  reducers: {
2077
2080
  setWorkspaces: (state, action) => {
@@ -2128,7 +2131,7 @@ const selectPermittedWorkspaceIds = createSelector(
2128
2131
  );
2129
2132
  const workspaceReducer = workspaceSlice.reducer;
2130
2133
  const maxRecentIssues = 10;
2131
- const initialState$i = {
2134
+ const initialState$j = {
2132
2135
  issues: {},
2133
2136
  attachments: {},
2134
2137
  comments: {},
@@ -2140,9 +2143,9 @@ const initialState$i = {
2140
2143
  };
2141
2144
  const issueSlice = createSlice({
2142
2145
  name: "issues",
2143
- initialState: initialState$i,
2146
+ initialState: initialState$j,
2144
2147
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2145
- Object.assign(state, initialState$i);
2148
+ Object.assign(state, initialState$j);
2146
2149
  }),
2147
2150
  reducers: {
2148
2151
  setIssues: (state, action) => {
@@ -2550,15 +2553,15 @@ const selectRecentIssuesAsSearchResults = createSelector(
2550
2553
  }
2551
2554
  );
2552
2555
  const issueReducer = issueSlice.reducer;
2553
- const initialState$h = {
2556
+ const initialState$i = {
2554
2557
  s3Urls: {}
2555
2558
  };
2556
2559
  const msPerHour = 1e3 * 60 * 60;
2557
2560
  const msPerWeek = msPerHour * 24 * 7;
2558
2561
  const fileSlice = createSlice({
2559
2562
  name: "file",
2560
- initialState: initialState$h,
2561
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2563
+ initialState: initialState$i,
2564
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2562
2565
  reducers: {
2563
2566
  setUploadUrl: (state, action) => {
2564
2567
  const { url, fields, sha1 } = action.payload;
@@ -2585,7 +2588,7 @@ const selectUploadUrl = (sha1) => (state) => {
2585
2588
  return url;
2586
2589
  };
2587
2590
  const fileReducer = fileSlice.reducer;
2588
- const initialState$g = {
2591
+ const initialState$h = {
2589
2592
  // TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
2590
2593
  mapStyle: MapStyle.SATELLITE,
2591
2594
  showTooltips: false,
@@ -2593,8 +2596,8 @@ const initialState$g = {
2593
2596
  };
2594
2597
  const mapSlice = createSlice({
2595
2598
  name: "map",
2596
- initialState: initialState$g,
2597
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2599
+ initialState: initialState$h,
2600
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2598
2601
  reducers: {
2599
2602
  setMapStyle: (state, action) => {
2600
2603
  state.mapStyle = action.payload;
@@ -2663,7 +2666,7 @@ var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
2663
2666
  LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
2664
2667
  return LicenseStatus2;
2665
2668
  })(LicenseStatus || {});
2666
- const initialState$f = {
2669
+ const initialState$g = {
2667
2670
  users: {},
2668
2671
  currentUser: {
2669
2672
  id: 0,
@@ -2674,8 +2677,8 @@ const initialState$f = {
2674
2677
  };
2675
2678
  const userSlice = createSlice({
2676
2679
  name: "users",
2677
- initialState: initialState$f,
2678
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2680
+ initialState: initialState$g,
2681
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2679
2682
  reducers: {
2680
2683
  setUsers: (state, action) => {
2681
2684
  const usersMapping = {};
@@ -2737,13 +2740,13 @@ const selectUser = (userId) => (state) => {
2737
2740
  const selectUsersAsMapping = (state) => state.userReducer.users;
2738
2741
  const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
2739
2742
  const userReducer = userSlice.reducer;
2740
- const initialState$e = {
2743
+ const initialState$f = {
2741
2744
  organizationAccesses: {}
2742
2745
  };
2743
2746
  const organizationAccessSlice = createSlice({
2744
2747
  name: "organizationAccess",
2745
- initialState: initialState$e,
2746
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2748
+ initialState: initialState$f,
2749
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2747
2750
  reducers: {
2748
2751
  setOrganizationAccesses: (state, action) => {
2749
2752
  if (!Array.isArray(action.payload))
@@ -2806,13 +2809,13 @@ const selectOrganizationAccessUserMapping = (state) => {
2806
2809
  return organizationAccesses;
2807
2810
  };
2808
2811
  const organizationAccessReducer = organizationAccessSlice.reducer;
2809
- const initialState$d = {
2812
+ const initialState$e = {
2810
2813
  licenses: {}
2811
2814
  };
2812
2815
  const licenseSlice = createSlice({
2813
2816
  name: "license",
2814
- initialState: initialState$d,
2815
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2817
+ initialState: initialState$e,
2818
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2816
2819
  reducers: {
2817
2820
  setLicenses: (state, action) => {
2818
2821
  if (!Array.isArray(action.payload))
@@ -2857,13 +2860,13 @@ const selectLicensesForProjectsMapping = createSelector(
2857
2860
  (licenses) => Object.values(licenses).filter((license) => license.project).reduce((accum, license) => ({ ...accum, [license.project]: license }), {})
2858
2861
  );
2859
2862
  const licenseReducer = licenseSlice.reducer;
2860
- const initialState$c = {
2863
+ const initialState$d = {
2861
2864
  projectAccesses: {}
2862
2865
  };
2863
2866
  const projectAccessSlice = createSlice({
2864
2867
  name: "projectAccess",
2865
- initialState: initialState$c,
2866
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2868
+ initialState: initialState$d,
2869
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2867
2870
  reducers: {
2868
2871
  setProjectAccesses: (state, action) => {
2869
2872
  if (!Array.isArray(action.payload))
@@ -2931,7 +2934,7 @@ const selectProjectAccessUserMapping = (state) => {
2931
2934
  return projectAccesses;
2932
2935
  };
2933
2936
  const projectAccessReducer = projectAccessSlice.reducer;
2934
- const initialState$b = {
2937
+ const initialState$c = {
2935
2938
  projects: {},
2936
2939
  activeProjectId: null,
2937
2940
  recentProjectIds: [],
@@ -2941,7 +2944,7 @@ const initialState$b = {
2941
2944
  };
2942
2945
  const projectSlice = createSlice({
2943
2946
  name: "projects",
2944
- initialState: initialState$b,
2947
+ initialState: initialState$c,
2945
2948
  reducers: {
2946
2949
  setProjects: (state, action) => {
2947
2950
  const projectsMap = {};
@@ -3128,14 +3131,14 @@ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
3128
3131
  }
3129
3132
  )
3130
3133
  );
3131
- const initialState$a = {
3134
+ const initialState$b = {
3132
3135
  organizations: {},
3133
3136
  activeOrganizationId: null
3134
3137
  };
3135
3138
  const organizationSlice = createSlice({
3136
3139
  name: "organizations",
3137
- initialState: initialState$a,
3138
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
3140
+ initialState: initialState$b,
3141
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
3139
3142
  reducers: {
3140
3143
  setOrganizations: (state, action) => {
3141
3144
  for (const org of action.payload) {
@@ -3254,14 +3257,14 @@ const createOfflineAction = (request2, baseUrl) => {
3254
3257
  }
3255
3258
  };
3256
3259
  };
3257
- const initialState$9 = {
3260
+ const initialState$a = {
3258
3261
  deletedRequests: [],
3259
3262
  latestRetryTime: 0
3260
3263
  };
3261
3264
  const outboxSlice = createSlice({
3262
3265
  name: "outbox",
3263
- initialState: initialState$9,
3264
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
3266
+ initialState: initialState$a,
3267
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
3265
3268
  reducers: {
3266
3269
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
3267
3270
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -3293,7 +3296,7 @@ const selectDeletedRequests = (state) => state.outboxReducer.deletedRequests;
3293
3296
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
3294
3297
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
3295
3298
  const outboxReducer = outboxSlice.reducer;
3296
- const initialState$8 = {
3299
+ const initialState$9 = {
3297
3300
  projectFiles: {},
3298
3301
  activeProjectFileId: null,
3299
3302
  isImportingProjectFile: false,
@@ -3301,8 +3304,8 @@ const initialState$8 = {
3301
3304
  };
3302
3305
  const projectFileSlice = createSlice({
3303
3306
  name: "projectFiles",
3304
- initialState: initialState$8,
3305
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3307
+ initialState: initialState$9,
3308
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$9)),
3306
3309
  reducers: {
3307
3310
  addOrReplaceProjectFiles: (state, action) => {
3308
3311
  for (let fileObj of action.payload) {
@@ -3403,12 +3406,12 @@ const selectProjectFiles = createSelector(
3403
3406
  const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProjectFileId;
3404
3407
  const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
3405
3408
  const projectFileReducer = projectFileSlice.reducer;
3406
- const initialState$7 = {
3409
+ const initialState$8 = {
3407
3410
  isRehydrated: false
3408
3411
  };
3409
3412
  const rehydratedSlice = createSlice({
3410
3413
  name: "rehydrated",
3411
- initialState: initialState$7,
3414
+ initialState: initialState$8,
3412
3415
  // The `reducers` field lets us define reducers and generate associated actions
3413
3416
  reducers: {
3414
3417
  setRehydrated: (state, action) => {
@@ -3418,7 +3421,7 @@ const rehydratedSlice = createSlice({
3418
3421
  });
3419
3422
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
3420
3423
  const rehydratedReducer = rehydratedSlice.reducer;
3421
- const initialState$6 = {
3424
+ const initialState$7 = {
3422
3425
  useIssueTemplate: false,
3423
3426
  placementMode: false,
3424
3427
  enableClustering: false,
@@ -3435,8 +3438,8 @@ const initialState$6 = {
3435
3438
  };
3436
3439
  const settingSlice = createSlice({
3437
3440
  name: "settings",
3438
- initialState: initialState$6,
3439
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3441
+ initialState: initialState$7,
3442
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
3440
3443
  reducers: {
3441
3444
  setEnableDuplicateIssues: (state, action) => {
3442
3445
  state.useIssueTemplate = action.payload;
@@ -3495,14 +3498,14 @@ const formRevisionSortFn = (formRevisionA, formRevisionB) => {
3495
3498
  return revisionA < revisionB ? -1 : 1;
3496
3499
  }
3497
3500
  };
3498
- const initialState$5 = {
3501
+ const initialState$6 = {
3499
3502
  formRevisions: {},
3500
3503
  attachments: {}
3501
3504
  };
3502
3505
  const formRevisionsSlice = createSlice({
3503
3506
  name: "formRevisions",
3504
- initialState: initialState$5,
3505
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3507
+ initialState: initialState$6,
3508
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3506
3509
  reducers: {
3507
3510
  // revision related actions
3508
3511
  setFormRevision: (state, action) => {
@@ -3682,13 +3685,13 @@ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
3682
3685
  )
3683
3686
  );
3684
3687
  const formRevisionReducer = formRevisionsSlice.reducer;
3685
- const initialState$4 = {
3688
+ const initialState$5 = {
3686
3689
  forms: {}
3687
3690
  };
3688
3691
  const formSlice = createSlice({
3689
3692
  name: "forms",
3690
- initialState: initialState$4,
3691
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3693
+ initialState: initialState$5,
3694
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3692
3695
  reducers: {
3693
3696
  setForms: (state, action) => {
3694
3697
  state.forms = {};
@@ -3785,14 +3788,14 @@ const selectGeneralFormCount = createSelector([selectFormMapping], (userForms) =
3785
3788
  return Object.values(userForms).filter((form) => !form.component_type).length;
3786
3789
  });
3787
3790
  const formReducer = formSlice.reducer;
3788
- const initialState$3 = {
3791
+ const initialState$4 = {
3789
3792
  formSubmissions: {},
3790
3793
  attachments: {}
3791
3794
  };
3792
3795
  const formSubmissionSlice = createSlice({
3793
3796
  name: "formSubmissions",
3794
- initialState: initialState$3,
3795
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3797
+ initialState: initialState$4,
3798
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3796
3799
  reducers: {
3797
3800
  setFormSubmission: (state, action) => {
3798
3801
  state.formSubmissions[action.payload.offline_id] = action.payload;
@@ -3992,12 +3995,12 @@ const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
3992
3995
  )
3993
3996
  );
3994
3997
  const formSubmissionReducer = formSubmissionSlice.reducer;
3995
- const initialState$2 = {
3998
+ const initialState$3 = {
3996
3999
  emailDomains: {}
3997
4000
  };
3998
4001
  const emailDomainsSlice = createSlice({
3999
4002
  name: "emailDomains",
4000
- initialState: initialState$2,
4003
+ initialState: initialState$3,
4001
4004
  reducers: {
4002
4005
  setEmailDomains: (state, action) => {
4003
4006
  const emailDomains = {};
@@ -4024,15 +4027,15 @@ const selectSortedEmailDomains = (state) => Object.values(state.emailDomainsRedu
4024
4027
  (ed1, ed2) => ed1.domain.localeCompare(ed2.domain)
4025
4028
  );
4026
4029
  const emailDomainsReducer = emailDomainsSlice.reducer;
4027
- const initialState$1 = {
4030
+ const initialState$2 = {
4028
4031
  documents: {},
4029
4032
  attachments: {}
4030
4033
  };
4031
4034
  const documentSlice = createSlice({
4032
4035
  name: "documents",
4033
- initialState: initialState$1,
4036
+ initialState: initialState$2,
4034
4037
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
4035
- Object.assign(state, initialState$1);
4038
+ Object.assign(state, initialState$2);
4036
4039
  }),
4037
4040
  reducers: {
4038
4041
  setDocuments: (state, action) => {
@@ -4069,9 +4072,18 @@ const documentSlice = createSlice({
4069
4072
  }
4070
4073
  }
4071
4074
  for (const document2 of action.payload) {
4075
+ const existingDocument = state.documents[document2.offline_id];
4076
+ if (document2.organization !== void 0 && document2.organization !== existingDocument.organization) {
4077
+ throw new Error("organization cannot be updated");
4078
+ }
4079
+ if (document2.project !== void 0 && document2.project !== existingDocument.project) {
4080
+ throw new Error("project cannot be updated");
4081
+ }
4072
4082
  state.documents[document2.offline_id] = {
4073
- ...state.documents[document2.offline_id],
4083
+ ...existingDocument,
4074
4084
  ...document2
4085
+ // Without the cast, TypeScript doesn't realize that we have guaranteed that the document doesn't
4086
+ // have both a project and an organization.
4075
4087
  };
4076
4088
  }
4077
4089
  },
@@ -4248,6 +4260,62 @@ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
4248
4260
  )
4249
4261
  );
4250
4262
  const documentsReducer = documentSlice.reducer;
4263
+ const initialState$1 = {
4264
+ teams: {}
4265
+ };
4266
+ const teamSlice = createSlice({
4267
+ name: "teams",
4268
+ initialState: initialState$1,
4269
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$1)),
4270
+ reducers: {
4271
+ setTeam: (state, action) => {
4272
+ state.teams[action.payload.offline_id] = action.payload;
4273
+ },
4274
+ setTeams: (state, action) => {
4275
+ state.teams = {};
4276
+ for (const team of action.payload) {
4277
+ state.teams[team.offline_id] = team;
4278
+ }
4279
+ },
4280
+ addTeam: (state, action) => {
4281
+ if (state.teams[action.payload.offline_id]) {
4282
+ throw new Error(`Team with offline_id ${action.payload.offline_id} already exists`);
4283
+ }
4284
+ state.teams[action.payload.offline_id] = action.payload;
4285
+ },
4286
+ updateTeam: (state, action) => {
4287
+ if (!state.teams[action.payload.offline_id]) {
4288
+ throw new Error(`Team with offline_id ${action.payload.offline_id} does not exist`);
4289
+ }
4290
+ state.teams[action.payload.offline_id] = action.payload;
4291
+ },
4292
+ deleteTeam: (state, action) => {
4293
+ delete state.teams[action.payload];
4294
+ }
4295
+ }
4296
+ });
4297
+ const { setTeam, setTeams, addTeam, updateTeam, deleteTeam } = teamSlice.actions;
4298
+ const selectTeamsMapping = (state) => state.teamReducer.teams;
4299
+ const selectTeams = createSelector([selectTeamsMapping], (teams) => {
4300
+ return Object.values(teams);
4301
+ });
4302
+ const selectTeam = (teamId) => (state) => {
4303
+ return state.teamReducer.teams[teamId];
4304
+ };
4305
+ const selectTeamsOfOrganization = restructureCreateSelectorWithArgs(
4306
+ createSelector(
4307
+ [selectTeams, (_state, organizationId) => organizationId],
4308
+ (teams, organizationId) => {
4309
+ return teams.filter((team) => team.organization === organizationId);
4310
+ }
4311
+ )
4312
+ );
4313
+ const selectTeamsOfUser = restructureCreateSelectorWithArgs(
4314
+ createSelector([selectTeams, (_state, userId) => userId], (teams, userId) => {
4315
+ return teams.filter((team) => team.members.includes(userId));
4316
+ })
4317
+ );
4318
+ const teamReducer = teamSlice.reducer;
4251
4319
  const initialState = {
4252
4320
  version: 0
4253
4321
  };
@@ -4296,7 +4364,8 @@ const overmapReducers = {
4296
4364
  workspaceReducer,
4297
4365
  emailDomainsReducer,
4298
4366
  licenseReducer,
4299
- documentsReducer
4367
+ documentsReducer,
4368
+ teamReducer
4300
4369
  };
4301
4370
  const overmapReducer = combineReducers(overmapReducers);
4302
4371
  const resetStore = "RESET";
@@ -6535,6 +6604,7 @@ class MainService extends BaseApiService {
6535
6604
  }
6536
6605
  if (currentOrgId) {
6537
6606
  await this.client.organizations.fetchInitialOrganizationData(currentOrgId, false);
6607
+ void this.client.teams.refreshStore();
6538
6608
  }
6539
6609
  if (!isProjectIdValid) {
6540
6610
  if (validProjects.length !== 0) {
@@ -7998,17 +8068,28 @@ class LicenseService extends BaseApiService {
7998
8068
  }
7999
8069
  }
8000
8070
  class DocumentService extends BaseApiService {
8071
+ // TODO: Support adding for project or organization
8001
8072
  add(document2) {
8002
8073
  const { store } = this.client;
8003
8074
  const currentUserId = store.getState().userReducer.currentUser.id;
8004
8075
  const activeProjectId = store.getState().projectReducer.activeProjectId;
8005
- const offlineDocument = offline({ ...document2, created_by: currentUserId });
8006
- store.dispatch(addDocuments([offlineDocument]));
8076
+ if (!activeProjectId) {
8077
+ throw new Error("No active project ID while creating document.");
8078
+ }
8079
+ const offlineDocument = offline(document2);
8080
+ const submittedDocument = {
8081
+ ...offlineDocument,
8082
+ created_by: currentUserId,
8083
+ project: activeProjectId,
8084
+ organization: null,
8085
+ children_documents: []
8086
+ };
8087
+ store.dispatch(addDocuments([submittedDocument]));
8007
8088
  const promise = this.enqueueRequest({
8008
8089
  description: "Create Document",
8009
8090
  method: HttpMethod.POST,
8010
- url: `/projects/${activeProjectId}/create-document/`,
8011
- payload: { ...offlineDocument },
8091
+ url: `/projects/${activeProjectId}/documents/`,
8092
+ payload: offlineDocument,
8012
8093
  queryParams: {
8013
8094
  parent_document: offlineDocument.parent_document ?? void 0
8014
8095
  },
@@ -8019,7 +8100,7 @@ class DocumentService extends BaseApiService {
8019
8100
  promise.catch(() => {
8020
8101
  store.dispatch(removeDocuments([offlineDocument.offline_id]));
8021
8102
  });
8022
- return [offlineDocument, promise];
8103
+ return [submittedDocument, promise];
8023
8104
  }
8024
8105
  update(document2) {
8025
8106
  const { store } = this.client;
@@ -8119,15 +8200,25 @@ class DocumentService extends BaseApiService {
8119
8200
  }
8120
8201
  async refreshStore() {
8121
8202
  const { store } = this.client;
8122
- const activeProjectId = store.getState().projectReducer.activeProjectId;
8123
- const result = await this.enqueueRequest({
8203
+ const state = store.getState();
8204
+ const activeProjectId = state.projectReducer.activeProjectId;
8205
+ const projectDocumentsPromise = this.enqueueRequest({
8124
8206
  description: "Get project documents",
8125
8207
  method: HttpMethod.GET,
8126
- url: `/documents/projects/${activeProjectId}/`,
8208
+ url: `/projects/${activeProjectId}/documents/`,
8209
+ blockers: [],
8210
+ blocks: []
8211
+ });
8212
+ const activeOrganizationId = state.organizationReducer.activeOrganizationId;
8213
+ const organizationDocumentsPromise = this.enqueueRequest({
8214
+ description: "Get organization documents",
8215
+ method: HttpMethod.GET,
8216
+ url: `/organizations/${activeOrganizationId}/documents/`,
8127
8217
  blockers: [],
8128
8218
  blocks: []
8129
8219
  });
8130
- store.dispatch(setDocuments(result));
8220
+ store.dispatch(setDocuments(await projectDocumentsPromise));
8221
+ store.dispatch(addDocuments(await organizationDocumentsPromise));
8131
8222
  }
8132
8223
  }
8133
8224
  class AgentService extends BaseApiService {
@@ -8162,6 +8253,142 @@ class AgentService extends BaseApiService {
8162
8253
  });
8163
8254
  }
8164
8255
  }
8256
+ class TeamService extends BaseApiService {
8257
+ add(teamPayload) {
8258
+ const { store } = this.client;
8259
+ const state = store.getState();
8260
+ const activeOrganizationId = state.organizationReducer.activeOrganizationId;
8261
+ if (!activeOrganizationId) {
8262
+ throw new Error(`Expected active organization to be set, got ${activeOrganizationId}`);
8263
+ }
8264
+ const offlineTeam = offline({
8265
+ ...teamPayload,
8266
+ organization: activeOrganizationId,
8267
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
8268
+ // TODO: uncomment once supported
8269
+ // created_by: state.userReducer.currentUser.id,
8270
+ });
8271
+ store.dispatch(addTeam(offlineTeam));
8272
+ const promise = this.enqueueRequest({
8273
+ description: "Create team",
8274
+ method: HttpMethod.POST,
8275
+ url: `/organizations/${activeOrganizationId}/teams/`,
8276
+ payload: offlineTeam,
8277
+ // No blocks since users and organizations are not offline
8278
+ blockers: [],
8279
+ blocks: [offlineTeam.offline_id]
8280
+ });
8281
+ promise.then((createdTeam) => {
8282
+ store.dispatch(setTeam(createdTeam));
8283
+ }).catch(() => {
8284
+ store.dispatch(deleteTeam(offlineTeam.offline_id));
8285
+ });
8286
+ return [offlineTeam, promise];
8287
+ }
8288
+ // TODO: @Audiopolis / Magnus - should we pass a offline_id as one arg and a UpdatedTeamProps as a second arg instead of this set up?
8289
+ update(team) {
8290
+ const { store } = this.client;
8291
+ const teamToBeUpdated = store.getState().teamReducer.teams[team.offline_id];
8292
+ const offlineUpdatedTeam = {
8293
+ ...teamToBeUpdated,
8294
+ ...team
8295
+ };
8296
+ store.dispatch(updateTeam(offlineUpdatedTeam));
8297
+ const promise = this.enqueueRequest({
8298
+ description: "Update team",
8299
+ method: HttpMethod.PATCH,
8300
+ url: `/organizations/teams/${team.offline_id}/`,
8301
+ payload: offlineUpdatedTeam,
8302
+ blockers: [team.offline_id],
8303
+ blocks: [team.offline_id]
8304
+ });
8305
+ promise.then((updatedTeam) => {
8306
+ store.dispatch(setTeam(updatedTeam));
8307
+ }).catch(() => {
8308
+ store.dispatch(setTeam(teamToBeUpdated));
8309
+ });
8310
+ return [offlineUpdatedTeam, promise];
8311
+ }
8312
+ async delete(teamId) {
8313
+ const { store } = this.client;
8314
+ const state = store.getState();
8315
+ const team = state.teamReducer.teams[teamId];
8316
+ if (!team) {
8317
+ throw new Error(`Expected team with id ${teamId} to exist`);
8318
+ }
8319
+ store.dispatch(deleteTeam(teamId));
8320
+ try {
8321
+ return await this.enqueueRequest({
8322
+ description: "Delete team",
8323
+ method: HttpMethod.DELETE,
8324
+ url: `/organizations/teams/${teamId}/`,
8325
+ blockers: [teamId],
8326
+ blocks: [teamId]
8327
+ });
8328
+ } catch (e) {
8329
+ store.dispatch(setTeam(team));
8330
+ throw e;
8331
+ }
8332
+ }
8333
+ async setMembers(teamId, members) {
8334
+ const { store } = this.client;
8335
+ const team = store.getState().teamReducer.teams[teamId];
8336
+ if (!team) {
8337
+ throw new Error(`Expected team with id ${teamId} to exist`);
8338
+ }
8339
+ if (members.length !== new Set(members).size) {
8340
+ throw new Error("Duplicate members found in the list");
8341
+ }
8342
+ store.dispatch(updateTeam({ ...team, members }));
8343
+ const promise = this.enqueueRequest({
8344
+ description: "Set team members",
8345
+ method: HttpMethod.PUT,
8346
+ url: `/organizations/teams/${teamId}/set-members/`,
8347
+ payload: {
8348
+ users: members
8349
+ },
8350
+ blockers: [teamId],
8351
+ blocks: [teamId]
8352
+ });
8353
+ promise.catch(() => {
8354
+ store.dispatch(setTeam(team));
8355
+ });
8356
+ return promise;
8357
+ }
8358
+ async addMembers(teamId, members) {
8359
+ const { store } = this.client;
8360
+ const team = store.getState().teamReducer.teams[teamId];
8361
+ if (!team) {
8362
+ throw new Error(`Expected team with id ${teamId} to exist`);
8363
+ }
8364
+ const newMembers = [...team.members, ...members];
8365
+ return this.setMembers(teamId, newMembers);
8366
+ }
8367
+ async removeMembers(teamId, members) {
8368
+ const { store } = this.client;
8369
+ const team = store.getState().teamReducer.teams[teamId];
8370
+ if (!team) {
8371
+ throw new Error(`Expected team with id ${teamId} to exist`);
8372
+ }
8373
+ const newMembers = team.members.filter((member) => !members.includes(member));
8374
+ return this.setMembers(teamId, newMembers);
8375
+ }
8376
+ async refreshStore() {
8377
+ const { store } = this.client;
8378
+ const activeOrganizationId = store.getState().organizationReducer.activeOrganizationId;
8379
+ if (!activeOrganizationId) {
8380
+ throw new Error(`Expected active organization to be set, got ${activeOrganizationId}`);
8381
+ }
8382
+ const result = await this.enqueueRequest({
8383
+ description: "Fetch teams",
8384
+ method: HttpMethod.GET,
8385
+ url: `/organizations/${activeOrganizationId}/teams/`,
8386
+ blockers: [],
8387
+ blocks: []
8388
+ });
8389
+ store.dispatch(setTeams(result));
8390
+ }
8391
+ }
8165
8392
  class OvermapSDK {
8166
8393
  constructor(apiUrl, store) {
8167
8394
  __publicField(this, "API_URL");
@@ -8191,6 +8418,7 @@ class OvermapSDK {
8191
8418
  __publicField(this, "emailDomains", new EmailDomainsService(this));
8192
8419
  __publicField(this, "licenses", new LicenseService(this));
8193
8420
  __publicField(this, "documents", new DocumentService(this));
8421
+ __publicField(this, "teams", new TeamService(this));
8194
8422
  this.API_URL = apiUrl;
8195
8423
  this.store = store;
8196
8424
  }
@@ -12650,8 +12878,7 @@ class BaseSelectField extends BaseField {
12650
12878
  description: "List possible options for the user to select from.",
12651
12879
  required: true,
12652
12880
  identifier: `${path}options`,
12653
- minimum_length: 2,
12654
- maximum_length: 20
12881
+ minimum_length: 2
12655
12882
  }),
12656
12883
  showDirectly: true
12657
12884
  }
@@ -16114,6 +16341,7 @@ export {
16114
16341
  SpreadsheetViewer,
16115
16342
  StringField,
16116
16343
  StringInput,
16344
+ TeamService,
16117
16345
  TextField,
16118
16346
  TextInput,
16119
16347
  UserFormService,
@@ -16168,6 +16396,7 @@ export {
16168
16396
  addStageCompletion,
16169
16397
  addStageCompletions,
16170
16398
  addStages,
16399
+ addTeam,
16171
16400
  addToRecentIssues,
16172
16401
  addUsers,
16173
16402
  addWorkspace,
@@ -16210,6 +16439,7 @@ export {
16210
16439
  deleteFormSubmissionAttachments,
16211
16440
  deleteFormSubmissions,
16212
16441
  deleteProject,
16442
+ deleteTeam,
16213
16443
  dequeue,
16214
16444
  deserialize,
16215
16445
  deserializeField,
@@ -16452,6 +16682,7 @@ export {
16452
16682
  selectIssueAttachment,
16453
16683
  selectIssueAttachmentMapping,
16454
16684
  selectIssueAttachments,
16685
+ selectIssueCountOfCategory,
16455
16686
  selectIssueMapping,
16456
16687
  selectIssueUpdateMapping,
16457
16688
  selectIssueUpdatesOfIssue,
@@ -16509,6 +16740,11 @@ export {
16509
16740
  selectStagesFromComponentType,
16510
16741
  selectStagesFromComponentTypeIds,
16511
16742
  selectStagesFromStageIds,
16743
+ selectTeam,
16744
+ selectTeams,
16745
+ selectTeamsMapping,
16746
+ selectTeamsOfOrganization,
16747
+ selectTeamsOfUser,
16512
16748
  selectUploadUrl,
16513
16749
  selectUsedColors,
16514
16750
  selectUser,
@@ -16567,6 +16803,8 @@ export {
16567
16803
  setSectionExpanded,
16568
16804
  setShowTooltips,
16569
16805
  setStageCompletions,
16806
+ setTeam,
16807
+ setTeams,
16570
16808
  setTokens,
16571
16809
  setTourStep,
16572
16810
  setUploadUrl,
@@ -16580,6 +16818,8 @@ export {
16580
16818
  slugify,
16581
16819
  spacesToDashesLower,
16582
16820
  successColor,
16821
+ teamReducer,
16822
+ teamSlice,
16583
16823
  toFileNameSafeString,
16584
16824
  toOfflineIdRecord,
16585
16825
  toggleComponentTypeVisibility,
@@ -16605,6 +16845,7 @@ export {
16605
16845
  updateProjectAccess,
16606
16846
  updateProjectAttachment,
16607
16847
  updateStages,
16848
+ updateTeam,
16608
16849
  useAppDispatch,
16609
16850
  useAppSelector,
16610
16851
  useFieldInput,