@gen3/core 0.10.93 → 0.10.95

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.
Files changed (50) hide show
  1. package/dist/cjs/index.js +386 -122
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/dts/constants.d.ts +1 -0
  4. package/dist/dts/constants.d.ts.map +1 -1
  5. package/dist/dts/features/cohort/cohortSlice.d.ts +152 -77
  6. package/dist/dts/features/cohort/cohortSlice.d.ts.map +1 -1
  7. package/dist/dts/features/cohort/index.d.ts +2 -2
  8. package/dist/dts/features/cohort/index.d.ts.map +1 -1
  9. package/dist/dts/features/cohort/reducers.d.ts +2 -2
  10. package/dist/dts/features/cohort/utils.d.ts +2 -0
  11. package/dist/dts/features/cohort/utils.d.ts.map +1 -0
  12. package/dist/dts/features/filters/filters.d.ts +17 -0
  13. package/dist/dts/features/filters/filters.d.ts.map +1 -1
  14. package/dist/dts/features/filters/index.d.ts +2 -2
  15. package/dist/dts/features/filters/index.d.ts.map +1 -1
  16. package/dist/dts/features/filters/tests/filters.unit.test.d.ts +2 -0
  17. package/dist/dts/features/filters/tests/filters.unit.test.d.ts.map +1 -0
  18. package/dist/dts/features/gen3Apps/Gen3AppRTKQ.d.ts +4 -8
  19. package/dist/dts/features/gen3Apps/Gen3AppRTKQ.d.ts.map +1 -1
  20. package/dist/dts/features/guppy/guppySlice.d.ts +3 -1
  21. package/dist/dts/features/guppy/guppySlice.d.ts.map +1 -1
  22. package/dist/dts/features/guppy/index.d.ts +2 -0
  23. package/dist/dts/features/guppy/index.d.ts.map +1 -1
  24. package/dist/dts/features/guppy/processing.d.ts +20 -0
  25. package/dist/dts/features/guppy/processing.d.ts.map +1 -0
  26. package/dist/dts/features/guppy/tests/processing.unit.test.d.ts +2 -0
  27. package/dist/dts/features/guppy/tests/processing.unit.test.d.ts.map +1 -0
  28. package/dist/dts/features/requestor/index.d.ts +2 -0
  29. package/dist/dts/features/requestor/index.d.ts.map +1 -0
  30. package/dist/dts/features/requestor/requestorSlice.d.ts +298 -0
  31. package/dist/dts/features/requestor/requestorSlice.d.ts.map +1 -0
  32. package/dist/dts/features/user/index.d.ts +2 -2
  33. package/dist/dts/features/user/index.d.ts.map +1 -1
  34. package/dist/dts/features/user/userSliceRTK.d.ts +171 -4
  35. package/dist/dts/features/user/userSliceRTK.d.ts.map +1 -1
  36. package/dist/dts/hooks.d.ts +2 -2
  37. package/dist/dts/index.d.ts +1 -0
  38. package/dist/dts/index.d.ts.map +1 -1
  39. package/dist/dts/reducers.d.ts +3 -3
  40. package/dist/dts/store.d.ts +4 -4
  41. package/dist/dts/types/index.d.ts +12 -6
  42. package/dist/dts/types/index.d.ts.map +1 -1
  43. package/dist/dts/utils/extractvalues.d.ts +1 -4
  44. package/dist/dts/utils/extractvalues.d.ts.map +1 -1
  45. package/dist/dts/utils/fetch.d.ts +1 -1
  46. package/dist/dts/utils/fetch.d.ts.map +1 -1
  47. package/dist/esm/index.js +371 -124
  48. package/dist/esm/index.js.map +1 -1
  49. package/dist/index.d.ts +5459 -4916
  50. package/package.json +3 -3
package/dist/cjs/index.js CHANGED
@@ -16,9 +16,9 @@ var idb = require('idb');
16
16
  var uuid = require('uuid');
17
17
  var reactCookie = require('react-cookie');
18
18
  var useSWR = require('swr');
19
- var jsonpathPlus = require('jsonpath-plus');
20
19
  var flat = require('flat');
21
20
  var Papa = require('papaparse');
21
+ var jsonpathPlus = require('jsonpath-plus');
22
22
  var Queue = require('queue');
23
23
 
24
24
  function _interopNamespaceDefault(e) {
@@ -60,6 +60,7 @@ const GEN3_DATA_LIBRARY_API = process.env.NEXT_PUBLIC_GEN3_DATA_LIBRARY_API || `
60
60
  const GEN3_CROSSWALK_API = process.env.NEXT_PUBLIC_GEN3_CROSSWALK_API || `${GEN3_API}/mds`;
61
61
  const GEN3_SOWER_API = process.env.NEXT_PUBLIC_GEN3_SOWER_API || `${GEN3_API}/jobs`;
62
62
  const GEN3_MANIFEST_API = process.env.NEXT_PUBLIC_GEN3_MANIFEST_API || `${GEN3_API}/manifests`;
63
+ const GEN3_REQUESTOR_API = process.env.NEXT_PUBLIC_GEN3_REQUESTOR_API || `${GEN3_API}/requestor`;
63
64
  var Accessibility = /*#__PURE__*/ function(Accessibility) {
64
65
  Accessibility["ACCESSIBLE"] = "accessible";
65
66
  Accessibility["UNACCESSIBLE"] = "unaccessible";
@@ -200,7 +201,7 @@ const userAuthApi = react.createApi({
200
201
  const EMPTY_USER = {
201
202
  username: undefined
202
203
  };
203
- const { useFetchUserDetailsQuery, useLazyFetchUserDetailsQuery, useGetCSRFQuery } = userAuthApi;
204
+ const { useFetchUserDetailsQuery, useLazyFetchUserDetailsQuery, useGetCSRFQuery, useLazyGetCSRFQuery } = userAuthApi;
204
205
  const userAuthApiMiddleware = userAuthApi.middleware;
205
206
  const userAuthApiReducerPath = userAuthApi.reducerPath;
206
207
  const userAuthApiReducer = userAuthApi.reducer;
@@ -416,7 +417,7 @@ const useCoreDispatch = reactRedux.useDispatch.withTypes();
416
417
  });
417
418
  const isAuthenticated = (loginStatus)=>loginStatus === 'authenticated';
418
419
  const isPending = (loginStatus)=>loginStatus === 'pending';
419
- const initialState$7 = {
420
+ const initialState$8 = {
420
421
  status: 'uninitialized',
421
422
  loginStatus: 'unauthenticated',
422
423
  error: undefined
@@ -427,9 +428,9 @@ const initialState$7 = {
427
428
  * @returns: status messages wrapped around fetchUserState response dict
428
429
  */ const slice$4 = toolkit.createSlice({
429
430
  name: 'fence/user',
430
- initialState: initialState$7,
431
+ initialState: initialState$8,
431
432
  reducers: {
432
- resetUserState: ()=>initialState$7
433
+ resetUserState: ()=>initialState$8
433
434
  },
434
435
  extraReducers: (builder)=>{
435
436
  builder.addCase(fetchUserState.fulfilled, (_, action)=>{
@@ -571,11 +572,11 @@ const { useGetExternalLoginsQuery, useLazyGetExternalLoginsQuery, useLazyIsExter
571
572
  }
572
573
  };
573
574
 
574
- const initialState$6 = {};
575
+ const initialState$7 = {};
575
576
  // TODO: document what this does
576
577
  const slice$3 = toolkit.createSlice({
577
578
  name: 'drsResolver',
578
- initialState: initialState$6,
579
+ initialState: initialState$7,
579
580
  reducers: {
580
581
  setDRSHostnames: (_state, action)=>{
581
582
  return action.payload;
@@ -596,12 +597,12 @@ const lookupGen3App = (id)=>{
596
597
  return REGISTRY[id];
597
598
  };
598
599
 
599
- const initialState$5 = {
600
+ const initialState$6 = {
600
601
  gen3Apps: {}
601
602
  };
602
603
  const slice$2 = toolkit.createSlice({
603
604
  name: 'gen3Apps',
604
- initialState: initialState$5,
605
+ initialState: initialState$6,
605
606
  reducers: {
606
607
  addGen3AppMetadata: (state, action)=>{
607
608
  const { name, requiredEntityTypes } = action.payload;
@@ -632,13 +633,13 @@ const selectGen3AppByName = (appName)=>lookupGen3App(appName); // TODO: memoize
632
633
  Modals["GeneralErrorModal"] = "GeneralErrorModal";
633
634
  return Modals;
634
635
  }({});
635
- const initialState$4 = {
636
+ const initialState$5 = {
636
637
  currentModal: null
637
638
  };
638
639
  //Creates a modal slice for tracking showModal and hideModal state.
639
640
  const slice$1 = toolkit.createSlice({
640
641
  name: 'modals',
641
- initialState: initialState$4,
642
+ initialState: initialState$5,
642
643
  reducers: {
643
644
  showModal: (state, action)=>{
644
645
  state.currentModal = action.payload.modal;
@@ -708,7 +709,7 @@ const isTimeGreaterThan = (startTime, minutes)=>{
708
709
  };
709
710
 
710
711
  const NO_WORKSPACE_ID = 'none';
711
- const initialState$3 = {
712
+ const initialState$4 = {
712
713
  id: NO_WORKSPACE_ID,
713
714
  status: WorkspaceStatus.NotFound,
714
715
  requestedStatus: RequestedWorkspaceStatus.Unset,
@@ -716,7 +717,7 @@ const initialState$3 = {
716
717
  };
717
718
  const slice = toolkit.createSlice({
718
719
  name: 'ActiveWorkspace',
719
- initialState: initialState$3,
720
+ initialState: initialState$4,
720
721
  reducers: {
721
722
  setActiveWorkspaceId: (state, action)=>{
722
723
  state = {
@@ -806,119 +807,260 @@ const guppyAPISliceMiddleware = guppyApi.middleware;
806
807
  const guppyApiSliceReducerPath = guppyApi.reducerPath;
807
808
  const guppyApiReducer = guppyApi.reducer;
808
809
 
809
- const EmptyCohort = {
810
- id: 'default',
811
- name: 'Filters',
812
- filters: {},
813
- modified_datetime: new Date().toISOString()
810
+ /**
811
+ * Cohorts in Gen3 are defined as a set of filters for each index in the data.
812
+ * This means one cohort id defined for all "tabs" in CohortBuilder (explorer)
813
+ * Switching a cohort is means that all the cohorts for the index changes.
814
+ */ const UNSAVED_COHORT_NAME = 'Unsaved_Cohort';
815
+ const NULL_COHORT_ID = 'null_cohort_id';
816
+ const newCohort = ({ filters = {}, customName })=>{
817
+ const ts = new Date();
818
+ const newName = customName;
819
+ const newId = createCohortId();
820
+ return {
821
+ name: newName,
822
+ id: newId,
823
+ filters: filters ?? {},
824
+ modified: false,
825
+ saved: false,
826
+ modified_datetime: ts.toISOString()
827
+ };
814
828
  };
815
- const initialCohortState = {
816
- cohort: {
817
- ...EmptyCohort
829
+ const createCohortId = ()=>toolkit.nanoid();
830
+ const cohortsAdapter = toolkit.createEntityAdapter({
831
+ sortComparer: (a, b)=>{
832
+ if (a.modified_datetime <= b.modified_datetime) return 1;
833
+ else return -1;
834
+ },
835
+ selectId: (cohort)=>cohort.id
836
+ });
837
+ // Create an initial unsaved cohort
838
+ const initialCohort = newCohort({
839
+ customName: UNSAVED_COHORT_NAME
840
+ });
841
+ const emptyInitialState = cohortsAdapter.getInitialState({
842
+ currentCohort: initialCohort.id,
843
+ message: undefined
844
+ });
845
+ // Set the initial cohort in the adapter state
846
+ const initialState$3 = cohortsAdapter.setOne(emptyInitialState, initialCohort);
847
+ const getCurrentCohort = (state)=>{
848
+ if (state.currentCohort) {
849
+ return state.currentCohort;
818
850
  }
851
+ return NULL_COHORT_ID;
819
852
  };
820
- // TODO: start using this adapter
821
- /*
822
- const cohortsAdapter = createEntityAdapter<Cohort>({
823
- sortComparer: (a, b) => {
824
- if (a.modified_datetime <= b.modified_datetime) return 1;
825
- else return -1;
826
- },
827
- });
828
- */ /**
853
+ /**
829
854
  * Redux slice for cohort filters
830
855
  */ const cohortSlice = toolkit.createSlice({
831
856
  name: 'cohort',
832
- initialState: initialCohortState,
857
+ initialState: initialState$3,
833
858
  reducers: {
859
+ addNewDefaultUnsavedCohort: (state)=>{
860
+ const cohort = newCohort({
861
+ customName: UNSAVED_COHORT_NAME
862
+ });
863
+ cohortsAdapter.addOne(state, cohort);
864
+ state.currentCohort = cohort.id;
865
+ state.message = [
866
+ `newCohort|${cohort.name}|${cohort.id}`
867
+ ];
868
+ },
869
+ updateCohortName: (state, action)=>{
870
+ cohortsAdapter.updateOne(state, {
871
+ id: getCurrentCohort(state),
872
+ changes: {
873
+ name: action.payload,
874
+ modified: true,
875
+ modified_datetime: new Date().toISOString()
876
+ }
877
+ });
878
+ },
879
+ removeCohort: (state, action)=>{
880
+ const removedCohort = state.entities[action?.payload?.id || getCurrentCohort(state)];
881
+ cohortsAdapter.removeOne(state, action?.payload?.id || getCurrentCohort(state));
882
+ if (action?.payload.shouldShowMessage) {
883
+ state.message = [
884
+ `deleteCohort|${removedCohort?.name}|${state.currentCohort}`
885
+ ];
886
+ }
887
+ },
834
888
  // adds a filter to the cohort filter set at the given index
835
889
  updateCohortFilter: (state, action)=>{
836
890
  const { index, field, filter } = action.payload;
837
- return {
838
- cohort: {
839
- ...state.cohort,
891
+ const currentCohortId = getCurrentCohort(state);
892
+ if (!state.entities[currentCohortId]) {
893
+ return;
894
+ }
895
+ cohortsAdapter.updateOne(state, {
896
+ id: currentCohortId,
897
+ changes: {
840
898
  filters: {
841
- ...state.cohort.filters,
899
+ ...state.entities[currentCohortId].filters,
842
900
  [index]: {
843
- mode: state.cohort.filters?.[index]?.mode ?? 'and',
901
+ mode: state.entities[currentCohortId]?.filters[index]?.mode ?? 'and',
844
902
  root: {
845
- ...state.cohort.filters?.[index]?.root ?? {},
903
+ ...state.entities[currentCohortId]?.filters[index]?.root ?? {},
846
904
  [field]: filter
847
905
  }
848
906
  }
849
- }
907
+ },
908
+ modified: true,
909
+ modified_datetime: new Date().toISOString()
850
910
  }
851
- };
911
+ });
852
912
  },
853
913
  setCohortFilter: (state, action)=>{
854
914
  const { index, filters } = action.payload;
855
- return {
856
- cohort: {
857
- ...state.cohort,
915
+ const currentCohortId = getCurrentCohort(state);
916
+ if (!state.entities[currentCohortId]) {
917
+ console.error(`no cohort with id=${currentCohortId} defined`);
918
+ return;
919
+ }
920
+ cohortsAdapter.updateOne(state, {
921
+ id: currentCohortId,
922
+ changes: {
858
923
  filters: {
859
- ...state.cohort.filters,
924
+ ...state.entities[currentCohortId].filters,
860
925
  [index]: filters
861
- }
926
+ },
927
+ modified: true,
928
+ modified_datetime: new Date().toISOString()
862
929
  }
863
- };
930
+ });
864
931
  },
865
932
  setCohortIndexFilters: (state, action)=>{
866
- return {
867
- cohort: {
868
- ...state.cohort,
869
- filters: {
870
- ...action.payload.filters
871
- }
933
+ const currentCohortId = getCurrentCohort(state);
934
+ if (!state.entities[currentCohortId]) {
935
+ console.error(`no cohort with id=${currentCohortId} defined`);
936
+ return;
937
+ }
938
+ cohortsAdapter.updateOne(state, {
939
+ id: currentCohortId,
940
+ changes: {
941
+ filters: action.payload.filters,
942
+ modified: true,
943
+ modified_datetime: new Date().toISOString()
872
944
  }
873
- };
945
+ });
874
946
  },
875
947
  // removes a filter to the cohort filter set at the given index
876
948
  removeCohortFilter: (state, action)=>{
877
949
  const { index, field } = action.payload;
878
- const filters = state.cohort?.filters?.[index]?.root;
950
+ const currentCohortId = getCurrentCohort(state);
951
+ if (!state.entities[currentCohortId]) {
952
+ console.error(`no cohort with id=${currentCohortId} defined`);
953
+ return;
954
+ }
955
+ const filters = state.entities[currentCohortId]?.filters[index]?.root;
879
956
  if (!filters) {
880
957
  return;
881
958
  }
882
959
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
883
960
  const { [field]: _a, ...updated } = filters;
884
- return {
885
- cohort: {
886
- ...state.cohort,
961
+ cohortsAdapter.updateOne(state, {
962
+ id: currentCohortId,
963
+ changes: {
887
964
  filters: {
888
- ...state.cohort.filters,
965
+ ...state.entities[currentCohortId]?.filters,
889
966
  [index]: {
890
- mode: state.cohort.filters[index].mode,
967
+ mode: state.entities[currentCohortId].filters[index].mode,
891
968
  root: updated
892
969
  }
893
- }
970
+ },
971
+ modified: true,
972
+ modified_datetime: new Date().toISOString()
894
973
  }
895
- };
974
+ });
896
975
  },
897
976
  // removes all filters from the cohort filter set at the given index
898
977
  clearCohortFilters: (state, action)=>{
899
978
  const { index } = action.payload;
900
- return {
901
- cohort: {
902
- ...state.cohort,
979
+ const currentCohortId = getCurrentCohort(state);
980
+ if (!state.entities[currentCohortId]) {
981
+ console.error(`no cohort with id=${currentCohortId} defined`);
982
+ return;
983
+ }
984
+ const filters = state.entities[currentCohortId]?.filters[index]?.root;
985
+ if (!filters) {
986
+ return;
987
+ }
988
+ cohortsAdapter.updateOne(state, {
989
+ id: currentCohortId,
990
+ changes: {
903
991
  filters: {
904
- ...state.cohort.filters,
992
+ ...state.entities[currentCohortId]?.filters,
905
993
  [index]: {
906
- // empty filter set
907
994
  mode: 'and',
908
995
  root: {}
909
996
  }
910
- }
997
+ },
998
+ modified: true,
999
+ modified_datetime: new Date().toISOString()
911
1000
  }
912
- };
1001
+ });
1002
+ },
1003
+ discardCohortChanges: (state, action)=>{
1004
+ const { index, id, filters } = action.payload;
1005
+ const cohortId = id ?? getCurrentCohort(state);
1006
+ cohortsAdapter.updateOne(state, {
1007
+ id: cohortId,
1008
+ changes: {
1009
+ filters: {
1010
+ ...state.entities[cohortId].filters,
1011
+ [index]: filters || {
1012
+ mode: 'and',
1013
+ root: {}
1014
+ }
1015
+ },
1016
+ modified: false,
1017
+ modified_datetime: new Date().toISOString()
1018
+ }
1019
+ });
1020
+ },
1021
+ setCurrentCohortId: (state, action)=>{
1022
+ state.currentCohort = action.payload;
1023
+ },
1024
+ /** @hidden */ setCohortList: (state, action)=>{
1025
+ if (!action.payload) {
1026
+ cohortsAdapter.removeMany(state, state.ids);
1027
+ } else {
1028
+ cohortsAdapter.upsertMany(state, [
1029
+ ...action.payload
1030
+ ]);
1031
+ }
913
1032
  }
914
1033
  }
915
1034
  });
1035
+ /**
1036
+ * Returns the selectors for the cohorts EntityAdapter
1037
+ * @param state - the CoreState
1038
+ *
1039
+ * @hidden
1040
+ */ const cohortSelectors = cohortsAdapter.getSelectors((state)=>state.cohorts.cohort);
1041
+ /**
1042
+ * Returns an array of all the cohorts
1043
+ * @param state - the CoreState
1044
+ * @category Cohort
1045
+ * @category Selectors
1046
+ */ const selectAllCohorts = (state)=>cohortSelectors.selectEntities(state);
1047
+ const getCurrentCohortFromCoreState = (state)=>{
1048
+ if (state.cohorts.cohort.currentCohort) {
1049
+ return state.cohorts.cohort.currentCohort;
1050
+ }
1051
+ return NULL_COHORT_ID;
1052
+ };
916
1053
  // Filter actions: addFilter, removeFilter, updateFilter
917
- const { updateCohortFilter, setCohortFilter, setCohortIndexFilters, removeCohortFilter, clearCohortFilters } = cohortSlice.actions;
918
- const selectCohortFilters = (state)=>state.cohorts.cohort.cohort.filters;
919
- const selectCurrentCohortId = (state)=>state.cohorts.cohort.cohort.id;
920
- const selectCurrentCohort = (state)=>state.cohorts.cohort.cohort;
921
- const selectCurrentCohortName = (state)=>state.cohorts.cohort.cohort.name;
1054
+ const { updateCohortFilter, setCohortFilter, setCohortIndexFilters, removeCohortFilter, clearCohortFilters, removeCohort, discardCohortChanges, addNewDefaultUnsavedCohort, setCurrentCohortId, setCohortList } = cohortSlice.actions;
1055
+ const selectCohortFilters = (state)=>{
1056
+ const currentCohortId = getCurrentCohortFromCoreState(state);
1057
+ return state.cohorts.cohort.entities[currentCohortId]?.filters;
1058
+ };
1059
+ const selectCurrentCohortId = (state)=>{
1060
+ return getCurrentCohort(state.cohorts.cohort);
1061
+ };
1062
+ const selectCurrentCohort = (state)=>cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state));
1063
+ const selectCurrentCohortName = (state)=>cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state)).name;
922
1064
  /**
923
1065
  * Select a filter by its name from the current cohort. If the filter is not found
924
1066
  * returns undefined.
@@ -926,7 +1068,40 @@ const selectCurrentCohortName = (state)=>state.cohorts.cohort.cohort.name;
926
1068
  * @param index which cohort index to select from
927
1069
  * @param name name of the filter to select
928
1070
  */ const selectIndexedFilterByName = (state, index, name)=>{
929
- return state.cohorts.cohort.cohort.filters[index]?.root[name];
1071
+ return cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state)).filters[index]?.root[name];
1072
+ };
1073
+ /**
1074
+ * a thunk to optionally create a caseSet when switching cohorts.
1075
+ * Note the assumption if the caseset member has ids then the caseset has previously been created.
1076
+ */ const setActiveCohort = (cohortId)=>async (dispatch /* getState */ )=>{
1077
+ dispatch(setCurrentCohortId(cohortId));
1078
+ };
1079
+ /**
1080
+ * Returns all the cohorts in the state
1081
+ * @param state - the CoreState
1082
+ *
1083
+ * @category Cohort
1084
+ * @category Selectors
1085
+ */ const selectAvailableCohorts = (state)=>cohortSelectors.selectAll(state);
1086
+ /**
1087
+ * Returns if the current cohort is modified
1088
+ * @param state - the CoreState
1089
+ * @category Cohort
1090
+ * @category Selectors
1091
+ * @hidden
1092
+ */ const selectCurrentCohortModified = (state)=>{
1093
+ const cohort = cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state));
1094
+ return cohort?.modified;
1095
+ };
1096
+ /**
1097
+ * Returns if the current cohort has been saved
1098
+ * @param state - the CoreState
1099
+ * @category Cohort
1100
+ * @category Selectors
1101
+ * @hidden
1102
+ */ const selectCurrentCohortSaved = (state)=>{
1103
+ const cohort = cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state));
1104
+ return cohort?.saved;
930
1105
  };
931
1106
  const EmptyFilterSet = {
932
1107
  mode: 'and',
@@ -938,8 +1113,23 @@ const EmptyFilterSet = {
938
1113
  * @param state - Core
939
1114
  * @param index which cohort index to select from
940
1115
  */ const selectIndexFilters = (state, index)=>{
941
- return state.cohorts.cohort.cohort.filters?.[index] ?? EmptyFilterSet; // TODO: check if this is undefined
1116
+ const cohort = cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state));
1117
+ if (!cohort) {
1118
+ console.error('No Cohort Defined');
1119
+ }
1120
+ return cohort?.filters?.[index] ?? EmptyFilterSet;
942
1121
  };
1122
+ const setActiveCohortList = (cohorts)=>async (dispatch, getState)=>{
1123
+ // set the list of all cohorts
1124
+ if (cohorts) {
1125
+ dispatch(setCohortList(cohorts));
1126
+ return;
1127
+ }
1128
+ const availableCohorts = selectAllCohorts(getState());
1129
+ if (Object.keys(availableCohorts).length === 0) {
1130
+ dispatch(addNewDefaultUnsavedCohort());
1131
+ }
1132
+ };
943
1133
  const cohortReducer = cohortSlice.reducer;
944
1134
 
945
1135
  const initialState$2 = {};
@@ -1058,7 +1248,7 @@ const persistConfig = {
1058
1248
  version: 1,
1059
1249
  storage,
1060
1250
  whitelist: [
1061
- 'cohort',
1251
+ 'cohorts',
1062
1252
  'activeWorkspace'
1063
1253
  ]
1064
1254
  };
@@ -1298,13 +1488,13 @@ const fetchFencePresignedURL = async ({ guid, method = 'GET', onAbort = ()=>null
1298
1488
  } : {}
1299
1489
  });
1300
1490
  if (!response.ok) {
1301
- throw new HTTPError(response.status, response.statusText);
1491
+ throw new HTTPError(response.status, response.statusText, response.text());
1302
1492
  }
1303
1493
  if (response.status === 204) {
1304
1494
  // no content so return null
1305
1495
  return null;
1306
1496
  }
1307
- return response.json();
1497
+ return await response.json();
1308
1498
  };
1309
1499
 
1310
1500
  const queryWTSFederatedLoginStatus = async (signal)=>{
@@ -3086,9 +3276,11 @@ const createGen3AppWithOwnStore = (options)=>{
3086
3276
  return Gen3AppWrapper;
3087
3277
  };
3088
3278
 
3089
- const createAppApiForRTKQ = (reducerPath, baseQuery)=>{
3279
+ const createAppApiForRTKQ = (reducerPath, name, version, additionalReducers, baseQuery)=>{
3280
+ const nameVersion = `${name}::${version}`;
3281
+ const id = uuid.v5(nameVersion, GEN3_APP_NAMESPACE);
3090
3282
  const appContext = React__namespace.createContext(null);
3091
- const useAppSelector = reactRedux.useSelector.withTypes();
3283
+ const useAppSelector = reactRedux.createSelectorHook(appContext);
3092
3284
  const useAppDispatch = reactRedux.createDispatchHook(appContext);
3093
3285
  const useAppStore = reactRedux.createStoreHook(appContext);
3094
3286
  const appCreateApi = react.buildCreateApi(react.coreModule(), react.reactHooksModule({
@@ -3104,13 +3296,12 @@ const createAppApiForRTKQ = (reducerPath, baseQuery)=>{
3104
3296
  baseUrl: `${GEN3_API}`,
3105
3297
  prepareHeaders: (headers)=>{
3106
3298
  headers.set('Content-Type', 'application/json');
3107
- let accessToken = undefined;
3108
3299
  if (process.env.NODE_ENV === 'development') {
3109
3300
  // NOTE: This cookie can only be accessed from the client side
3110
3301
  // in development mode. Otherwise, the cookie is set as httpOnly
3111
- accessToken = cookiesNext.getCookie('credentials_token');
3302
+ const accessToken = cookiesNext.getCookie('credentials_token');
3303
+ if (accessToken) headers.set('Authorization', `Bearer ${accessToken}`);
3112
3304
  }
3113
- if (accessToken) headers.set('Authorization', `Bearer ${accessToken}`);
3114
3305
  return headers;
3115
3306
  }
3116
3307
  }),
@@ -3118,8 +3309,12 @@ const createAppApiForRTKQ = (reducerPath, baseQuery)=>{
3118
3309
  });
3119
3310
  const appMiddleware = appRTKQApi.middleware;
3120
3311
  const appStore = toolkit.configureStore({
3312
+ devTools: {
3313
+ name: `${nameVersion}::${id}`
3314
+ },
3121
3315
  reducer: {
3122
- [appRTKQApi.reducerPath]: appRTKQApi.reducer
3316
+ [appRTKQApi.reducerPath]: appRTKQApi.reducer,
3317
+ ...additionalReducers
3123
3318
  },
3124
3319
  middleware: (getDefaultMiddleware)=>getDefaultMiddleware({
3125
3320
  serializableCheck: {
@@ -3348,8 +3543,12 @@ const groupSharedFields = (data)=>{
3348
3543
  }, {});
3349
3544
  };
3350
3545
 
3351
- const statusEndpoint = '/_status';
3352
- const processHistogramResponse = (data)=>{
3546
+ /**
3547
+ * Processes the histogram data from the given input object and returns an aggregated data object.
3548
+ *
3549
+ * @param {Record<string, unknown>} data - The input data object containing histogram information.
3550
+ * @returns {AggregationsData} An object containing the processed histogram data, structured as key-value pairs.
3551
+ */ const processHistogramResponse = (data)=>{
3353
3552
  const valueData = jsonpathPlus.JSONPath({
3354
3553
  json: data,
3355
3554
  path: '$..histogram',
@@ -3369,6 +3568,42 @@ const processHistogramResponse = (data)=>{
3369
3568
  }, {});
3370
3569
  return results;
3371
3570
  };
3571
+ /**
3572
+ * Adjusts histogram data in the provided object by rounding counts below a specified minimum value.
3573
+ *
3574
+ * This function traverses the input object for histogram data and updates it such that all count values
3575
+ * falling below the defined `minValue` are set to `-1`. By default, the `minValue` is set to `100`.
3576
+ *
3577
+ * @param {Record<string, unknown>} origData - The original input data containing histogram structures to modify.
3578
+ * @param {number} [minValue=100] - The minimum value of histogram counts. Counts below this value are replaced with `-1`.
3579
+ * @returns {Record<string, unknown>} - A new object containing the modified histogram data while preserving other properties.
3580
+ */ const roundHistogramResponse = (origData, minValue = 100)=>{
3581
+ const data = {
3582
+ ...origData
3583
+ };
3584
+ const pointerData = jsonpathPlus.JSONPath({
3585
+ json: data,
3586
+ path: '$..histogram',
3587
+ resultType: 'pointer'
3588
+ });
3589
+ if (pointerData.length === 0) {
3590
+ return {};
3591
+ }
3592
+ pointerData.forEach((element)=>{
3593
+ const key = element.slice(1).replace(/\//g, '.');
3594
+ const histogramData = jsonpathPlus.JSONPath({
3595
+ json: data,
3596
+ path: key,
3597
+ resultType: 'value'
3598
+ });
3599
+ histogramData[0].forEach((x)=>{
3600
+ x.count = x.count < minValue ? -1 : x.count;
3601
+ });
3602
+ });
3603
+ return data;
3604
+ };
3605
+
3606
+ const statusEndpoint = '/_status';
3372
3607
  const fetchJson = async (url)=>{
3373
3608
  const res = await fetch(url, {
3374
3609
  method: 'GET',
@@ -3481,24 +3716,7 @@ const useGetStatus = ()=>{
3481
3716
  }),
3482
3717
  getAggs: builder.query({
3483
3718
  query: ({ type, fields, filters, accessibility = Accessibility.ALL })=>{
3484
- const queryStart = isFilterEmpty(filters) ? `
3485
- query getAggs {
3486
- _aggregation {
3487
- ${type} (accessibility: ${accessibility}) {` : `query getAggs ($filter: JSON) {
3488
- _aggregation {
3489
- ${type} (filter: $filter, filterSelf: false, accessibility: ${accessibility}) {`;
3490
- const query = `${queryStart}
3491
- ${fields.map((field)=>histogramQueryStrForEachField(field))}
3492
- }
3493
- }
3494
- }`;
3495
- const queryBody = {
3496
- query: query,
3497
- variables: {
3498
- filter: convertFilterSetToGqlFilter(filters)
3499
- }
3500
- };
3501
- return queryBody;
3719
+ return buildGetAggregationQuery(type, fields, filters, accessibility, false);
3502
3720
  },
3503
3721
  transformResponse: (response, _meta, args)=>{
3504
3722
  return processHistogramResponse(response?.data?._aggregation[args.type] ?? {});
@@ -3506,24 +3724,7 @@ const useGetStatus = ()=>{
3506
3724
  }),
3507
3725
  getAggsNoFilterSelf: builder.query({
3508
3726
  query: ({ type, fields, filters, accessibility = Accessibility.ALL })=>{
3509
- const queryStart = isFilterEmpty(filters) ? `
3510
- query getAggs {
3511
- _aggregation {
3512
- ${type} (accessibility: ${accessibility}) {` : `query getAggs ($filter: JSON) {
3513
- _aggregation {
3514
- ${type} (filter: $filter, filterSelf: true, accessibility: ${accessibility}) {`;
3515
- const query = `${queryStart}
3516
- ${fields.map((field)=>histogramQueryStrForEachField(field))}
3517
- }
3518
- }
3519
- }`;
3520
- const queryBody = {
3521
- query: query,
3522
- variables: {
3523
- filter: convertFilterSetToGqlFilter(filters)
3524
- }
3525
- };
3526
- return queryBody;
3727
+ return buildGetAggregationQuery(type, fields, filters, accessibility, true);
3527
3728
  },
3528
3729
  transformResponse: (response, _meta, args)=>{
3529
3730
  return processHistogramResponse(response?.data?._aggregation[args.type] ?? {});
@@ -3709,6 +3910,26 @@ const useGetIndexFields = (index)=>{
3709
3910
  const { data } = useGetFieldsForIndexQuery(index);
3710
3911
  return data ?? [];
3711
3912
  };
3913
+ const buildGetAggregationQuery = (type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false)=>{
3914
+ const queryStart = isFilterEmpty(filters) ? `
3915
+ query getAggs {
3916
+ _aggregation {
3917
+ ${type} (accessibility: ${accessibility}) {` : `query getAggs ($filter: JSON) {
3918
+ _aggregation {
3919
+ ${type} (filter: $filter, filterSelf: ${filterSelf ? 'true' : 'false'}, accessibility: ${accessibility}) {`;
3920
+ const query = `${queryStart}
3921
+ ${fields.map((field)=>histogramQueryStrForEachField(field))}
3922
+ }
3923
+ }
3924
+ }`;
3925
+ const queryBody = {
3926
+ query: query,
3927
+ variables: {
3928
+ filter: convertFilterSetToGqlFilter(filters)
3929
+ }
3930
+ };
3931
+ return queryBody;
3932
+ };
3712
3933
  const { useGetRawDataAndTotalCountsQuery, useGetAccessibleDataQuery, useGetAllFieldsForTypeQuery, useGetAggsQuery, useGetAggsNoFilterSelfQuery, useLazyGetAggsQuery, useGetSubAggsQuery, useGetCountsQuery, useGetFieldCountSummaryQuery, useGetFieldsForIndexQuery, useGetSharedFieldsForIndexQuery, useGeneralGQLQuery, useLazyGeneralGQLQuery } = explorerApi;
3713
3934
 
3714
3935
  /**
@@ -3989,6 +4210,32 @@ const queryMultipleMDSRecords = async (guids, useAggMDS = false, signal)=>{
3989
4210
  });
3990
4211
  };
3991
4212
 
4213
+ /**
4214
+ * Defines requester service using a base URL and expected endpoints. Derived from gen3Api core API.
4215
+ *
4216
+ * @param endpoints - Defines endpoints used in discovery page
4217
+ * @param request - Queries Requestor service
4218
+ * @see https://github.com/uc-cdis/requestor?tab=readme-ov-file#requestor
4219
+ * @see https://petstore.swagger.io/?url=https://raw.githubusercontent.com/uc-cdis/requestor/master/docs/openapi.yaml#/Query/list_requests_request_get
4220
+ * @returns: Object of request made
4221
+ */ const requestorApi = gen3Api.injectEndpoints({
4222
+ endpoints: (builder)=>({
4223
+ request: builder.query({
4224
+ query: (queryBody)=>({
4225
+ url: `${GEN3_REQUESTOR_API}/request`,
4226
+ method: 'POST',
4227
+ credentials: 'include',
4228
+ headers: {
4229
+ Accept: 'application/json',
4230
+ 'Content-Type': 'application/json'
4231
+ },
4232
+ body: JSON.stringify(queryBody)
4233
+ })
4234
+ })
4235
+ })
4236
+ });
4237
+ const { useRequestQuery, useLazyRequestQuery } = requestorApi;
4238
+
3992
4239
  /**
3993
4240
  * Creates a loadingStatusApi for checking the status of a sower data download job
3994
4241
  * @param getJobList Shows the list of jobs currently running
@@ -4078,7 +4325,7 @@ const extractValuesFromObject = (jsonPathMappings, obj)=>{
4078
4325
  };
4079
4326
  for(const key in jsonPathMappings){
4080
4327
  if (key in Object.keys(jsonPathMappings)) {
4081
- // Extract value from object and store it in the result.
4328
+ // Extract value from an object and store it in the result.
4082
4329
  result[key] = extractObjectValue(jsonPathMappings[key], obj);
4083
4330
  }
4084
4331
  }
@@ -4393,10 +4640,14 @@ exports.PodConditionType = PodConditionType;
4393
4640
  exports.PodStatus = PodStatus;
4394
4641
  exports.RequestedWorkspaceStatus = RequestedWorkspaceStatus;
4395
4642
  exports.WorkspaceStatus = WorkspaceStatus;
4643
+ exports.addNewDefaultUnsavedCohort = addNewDefaultUnsavedCohort;
4644
+ exports.buildGetAggregationQuery = buildGetAggregationQuery;
4396
4645
  exports.buildListItemsGroupedByDataset = buildListItemsGroupedByDataset;
4397
4646
  exports.clearActiveWorkspaceId = clearActiveWorkspaceId;
4398
4647
  exports.clearCohortFilters = clearCohortFilters;
4648
+ exports.cohortReducer = cohortReducer;
4399
4649
  exports.convertFilterSetToGqlFilter = convertFilterSetToGqlFilter;
4650
+ exports.convertFilterToGqlFilter = convertFilterToGqlFilter;
4400
4651
  exports.coreStore = coreStore;
4401
4652
  exports.createAppApiForRTKQ = createAppApiForRTKQ;
4402
4653
  exports.createAppStore = createAppStore;
@@ -4434,6 +4685,7 @@ exports.guppyApiReducer = guppyApiReducer;
4434
4685
  exports.guppyApiSliceReducerPath = guppyApiSliceReducerPath;
4435
4686
  exports.handleOperation = handleOperation;
4436
4687
  exports.hideModal = hideModal;
4688
+ exports.histogramQueryStrForEachField = histogramQueryStrForEachField;
4437
4689
  exports.isAdditionalDataItem = isAdditionalDataItem;
4438
4690
  exports.isArray = isArray;
4439
4691
  exports.isAuthenticated = isAuthenticated;
@@ -4477,19 +4729,24 @@ exports.listifyMethodsFromMapping = listifyMethodsFromMapping;
4477
4729
  exports.logoutFence = logoutFence;
4478
4730
  exports.manifestApi = manifestApi;
4479
4731
  exports.manifestTags = manifestTags;
4732
+ exports.nestedHistogramQueryStrForEachField = nestedHistogramQueryStrForEachField;
4480
4733
  exports.prepareUrl = prepareUrl$1;
4481
4734
  exports.prependIndexToFieldName = prependIndexToFieldName;
4482
4735
  exports.processHistogramResponse = processHistogramResponse;
4483
4736
  exports.projectCodeFromResourcePath = projectCodeFromResourcePath;
4484
4737
  exports.queryMultipleMDSRecords = queryMultipleMDSRecords;
4485
4738
  exports.rawDataQueryStrForEachField = rawDataQueryStrForEachField;
4739
+ exports.removeCohort = removeCohort;
4486
4740
  exports.removeCohortFilter = removeCohortFilter;
4741
+ exports.requestorApi = requestorApi;
4487
4742
  exports.resetUserState = resetUserState;
4488
4743
  exports.resourcePathFromProjectID = resourcePathFromProjectID;
4744
+ exports.roundHistogramResponse = roundHistogramResponse;
4489
4745
  exports.selectActiveWorkspaceId = selectActiveWorkspaceId;
4490
4746
  exports.selectActiveWorkspaceStatus = selectActiveWorkspaceStatus;
4491
4747
  exports.selectAllCohortFiltersCollapsed = selectAllCohortFiltersCollapsed;
4492
4748
  exports.selectAuthzMappingData = selectAuthzMappingData;
4749
+ exports.selectAvailableCohorts = selectAvailableCohorts;
4493
4750
  exports.selectCSRFToken = selectCSRFToken;
4494
4751
  exports.selectCSRFTokenData = selectCSRFTokenData;
4495
4752
  exports.selectCohortFilterCombineMode = selectCohortFilterCombineMode;
@@ -4497,7 +4754,9 @@ exports.selectCohortFilterExpanded = selectCohortFilterExpanded;
4497
4754
  exports.selectCohortFilters = selectCohortFilters;
4498
4755
  exports.selectCurrentCohort = selectCurrentCohort;
4499
4756
  exports.selectCurrentCohortId = selectCurrentCohortId;
4757
+ exports.selectCurrentCohortModified = selectCurrentCohortModified;
4500
4758
  exports.selectCurrentCohortName = selectCurrentCohortName;
4759
+ exports.selectCurrentCohortSaved = selectCurrentCohortSaved;
4501
4760
  exports.selectCurrentMessage = selectCurrentMessage;
4502
4761
  exports.selectCurrentModal = selectCurrentModal;
4503
4762
  exports.selectGen3AppByName = selectGen3AppByName;
@@ -4518,6 +4777,8 @@ exports.selectUserDetails = selectUserDetails;
4518
4777
  exports.selectUserLoginStatus = selectUserLoginStatus;
4519
4778
  exports.selectWorkspaceStatus = selectWorkspaceStatus;
4520
4779
  exports.selectWorkspaceStatusFromService = selectWorkspaceStatusFromService;
4780
+ exports.setActiveCohort = setActiveCohort;
4781
+ exports.setActiveCohortList = setActiveCohortList;
4521
4782
  exports.setActiveWorkspace = setActiveWorkspace;
4522
4783
  exports.setActiveWorkspaceId = setActiveWorkspaceId;
4523
4784
  exports.setActiveWorkspaceStatus = setActiveWorkspaceStatus;
@@ -4604,6 +4865,7 @@ exports.useLazyFetchUserDetailsQuery = useLazyFetchUserDetailsQuery;
4604
4865
  exports.useLazyGeneralGQLQuery = useLazyGeneralGQLQuery;
4605
4866
  exports.useLazyGetAggsQuery = useLazyGetAggsQuery;
4606
4867
  exports.useLazyGetAuthzMappingsQuery = useLazyGetAuthzMappingsQuery;
4868
+ exports.useLazyGetCSRFQuery = useLazyGetCSRFQuery;
4607
4869
  exports.useLazyGetCrosswalkDataQuery = useLazyGetCrosswalkDataQuery;
4608
4870
  exports.useLazyGetDownloadQuery = useLazyGetDownloadQuery;
4609
4871
  exports.useLazyGetExternalLoginsQuery = useLazyGetExternalLoginsQuery;
@@ -4612,8 +4874,10 @@ exports.useLazyGetProjectsQuery = useLazyGetProjectsQuery;
4612
4874
  exports.useLazyGetSowerJobListQuery = useLazyGetSowerJobListQuery;
4613
4875
  exports.useLazyGetSubmissionGraphQLQuery = useLazyGetSubmissionGraphQLQuery;
4614
4876
  exports.useLazyIsExternalConnectedQuery = useLazyIsExternalConnectedQuery;
4877
+ exports.useLazyRequestQuery = useLazyRequestQuery;
4615
4878
  exports.usePrevious = usePrevious;
4616
4879
  exports.useRemoveCredentialMutation = useRemoveCredentialMutation;
4880
+ exports.useRequestQuery = useRequestQuery;
4617
4881
  exports.useSetCurrentPayModelMutation = useSetCurrentPayModelMutation;
4618
4882
  exports.useSubmitSowerJobMutation = useSubmitSowerJobMutation;
4619
4883
  exports.useTerminateWorkspaceMutation = useTerminateWorkspaceMutation;