@gen3/core 0.10.97 → 0.10.99

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.
package/dist/cjs/index.js CHANGED
@@ -602,7 +602,8 @@ const registerGen3App = (id, gen3App)=>{
602
602
  REGISTRY[id] = gen3App;
603
603
  };
604
604
  const lookupGen3App = (id)=>{
605
- return REGISTRY[id];
605
+ if (id in REGISTRY) return REGISTRY[id];
606
+ else return null;
606
607
  };
607
608
 
608
609
  const initialState$6 = {
@@ -831,7 +832,8 @@ const newCohort = ({ filters = {}, customName })=>{
831
832
  filters: filters ?? {},
832
833
  modified: false,
833
834
  saved: false,
834
- modified_datetime: ts.toISOString()
835
+ modified_datetime: ts.toISOString(),
836
+ counts: {}
835
837
  };
836
838
  };
837
839
  const createCohortId = ()=>toolkit.nanoid();
@@ -1505,6 +1507,22 @@ const fetchFencePresignedURL = async ({ guid, method = 'GET', onAbort = ()=>null
1505
1507
  return await response.json();
1506
1508
  };
1507
1509
 
1510
+ /**
1511
+ * Converts HistogramData to HistogramDataAsStringKey by ensuring the key is a string.
1512
+ * If the key is already a string, it's used as is.
1513
+ * If the key is a number tuple [min, max], it's converted to a string in the format "min-max".
1514
+ *
1515
+ * @param data The HistogramData object to convert
1516
+ * @returns HistogramDataAsStringKey with the converted key
1517
+ */ const convertToHistogramDataAsStringKey = (data)=>{
1518
+ return {
1519
+ key: typeof data.key === 'string' ? data.key : `${data.key[0]}-${data.key[1]}`,
1520
+ count: data.count
1521
+ };
1522
+ };
1523
+ const calculatePercentageAsNumber = (count, total)=>count ? count / total * 100 : 0;
1524
+ const calculatePercentageAsString = (count, total)=>`${(count / total * 100).toFixed(2)}%`;
1525
+
1508
1526
  const queryWTSFederatedLoginStatus = async (signal)=>{
1509
1527
  try {
1510
1528
  const results = await fetchJSONDataFromURL(`${GEN3_WTS_API}/external_oidc/`, false, HttpMethod.GET, undefined, signal);
@@ -3621,6 +3639,9 @@ const groupSharedFields = (data)=>{
3621
3639
  path: '$..histogram',
3622
3640
  resultType: 'pointer'
3623
3641
  });
3642
+ if (!pointerData) {
3643
+ return {};
3644
+ }
3624
3645
  if (pointerData.length === 0) {
3625
3646
  return {};
3626
3647
  }
@@ -3631,7 +3652,7 @@ const groupSharedFields = (data)=>{
3631
3652
  path: key,
3632
3653
  resultType: 'value'
3633
3654
  });
3634
- histogramData[0].forEach((x)=>{
3655
+ histogramData?.[0]?.forEach((x)=>{
3635
3656
  x.count = x.count < minValue ? -1 : x.count;
3636
3657
  });
3637
3658
  });
@@ -4872,11 +4893,14 @@ exports.WorkspaceStatus = WorkspaceStatus;
4872
4893
  exports.addNewDefaultUnsavedCohort = addNewDefaultUnsavedCohort;
4873
4894
  exports.buildGetAggregationQuery = buildGetAggregationQuery;
4874
4895
  exports.buildListItemsGroupedByDataset = buildListItemsGroupedByDataset;
4896
+ exports.calculatePercentageAsNumber = calculatePercentageAsNumber;
4897
+ exports.calculatePercentageAsString = calculatePercentageAsString;
4875
4898
  exports.clearActiveWorkspaceId = clearActiveWorkspaceId;
4876
4899
  exports.clearCohortFilters = clearCohortFilters;
4877
4900
  exports.cohortReducer = cohortReducer;
4878
4901
  exports.convertFilterSetToGqlFilter = convertFilterSetToGqlFilter;
4879
4902
  exports.convertFilterToGqlFilter = convertFilterToGqlFilter;
4903
+ exports.convertToHistogramDataAsStringKey = convertToHistogramDataAsStringKey;
4880
4904
  exports.convertToQueryString = convertToQueryString;
4881
4905
  exports.coreStore = coreStore;
4882
4906
  exports.createAppApiForRTKQ = createAppApiForRTKQ;