@gen3/core 0.11.28 → 0.11.30
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 +163 -141
- package/dist/cjs/index.js.map +1 -1
- package/dist/dts/features/cohort/cohortManagerSlice.d.ts +10 -1
- package/dist/dts/features/cohort/cohortManagerSlice.d.ts.map +1 -1
- package/dist/dts/features/cohort/index.d.ts +2 -2
- package/dist/dts/features/cohort/index.d.ts.map +1 -1
- package/dist/dts/features/guppy/guppySlice.d.ts +266 -456
- package/dist/dts/features/guppy/guppySlice.d.ts.map +1 -1
- package/dist/dts/listeners.d.ts.map +1 -1
- package/dist/esm/index.js +160 -142
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +379 -461
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -6,8 +6,9 @@ var cookiesNext = require('cookies-next');
|
|
|
6
6
|
var query = require('@reduxjs/toolkit/query');
|
|
7
7
|
var reactRedux = require('react-redux');
|
|
8
8
|
var React = require('react');
|
|
9
|
-
var
|
|
9
|
+
var nanoid$1 = require('nanoid');
|
|
10
10
|
var useSWR = require('swr');
|
|
11
|
+
var lodash = require('lodash');
|
|
11
12
|
var flat = require('flat');
|
|
12
13
|
var Papa = require('papaparse');
|
|
13
14
|
var jsonpathPlus = require('jsonpath-plus');
|
|
@@ -864,7 +865,8 @@ const newCohort = ({ filters = {}, customName })=>{
|
|
|
864
865
|
counts: {}
|
|
865
866
|
};
|
|
866
867
|
};
|
|
867
|
-
const
|
|
868
|
+
const nanoid = nanoid$1.customAlphabet('1234567890abcdef', 16);
|
|
869
|
+
const createCohortId = ()=>nanoid();
|
|
868
870
|
const cohortsAdapter = toolkit.createEntityAdapter({
|
|
869
871
|
sortComparer: (a, b)=>{
|
|
870
872
|
if (a.modifiedDatetime <= b.modifiedDatetime) return 1;
|
|
@@ -1087,6 +1089,21 @@ const getCurrentCohortId = (state)=>state.currentCohortId;
|
|
|
1087
1089
|
}
|
|
1088
1090
|
});
|
|
1089
1091
|
},
|
|
1092
|
+
updateCohortIndexCountById: (state, action)=>{
|
|
1093
|
+
const { index, cohortId, counts } = action.payload;
|
|
1094
|
+
const cohort = state.entities[cohortId];
|
|
1095
|
+
cohortsAdapter.updateOne(state, {
|
|
1096
|
+
id: cohortId,
|
|
1097
|
+
changes: {
|
|
1098
|
+
counts: {
|
|
1099
|
+
...cohort.counts,
|
|
1100
|
+
...{
|
|
1101
|
+
[index]: counts
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
});
|
|
1106
|
+
},
|
|
1090
1107
|
setCurrentCohortId: (state, action)=>{
|
|
1091
1108
|
state.currentCohortId = action.payload;
|
|
1092
1109
|
},
|
|
@@ -1108,7 +1125,7 @@ const getCurrentCohortId = (state)=>state.currentCohortId;
|
|
|
1108
1125
|
* @hidden
|
|
1109
1126
|
*/ const cohortSelectors = cohortsAdapter.getSelectors((state)=>state.cohorts.cohortManager);
|
|
1110
1127
|
// Filter actions: addFilter, removeFilter, updateFilter
|
|
1111
|
-
const { createNewCohort, updateCohortFilter, setCohortFilter, setCohortIndexFilters, duplicateCohort, removeCohortFilter, clearCohortFilters, removeCohort, setCurrentCohortId, updateCohortName, updateCohortCounts, setCohortList } = cohortManagerSlice.actions;
|
|
1128
|
+
const { createNewCohort, updateCohortFilter, setCohortFilter, setCohortIndexFilters, duplicateCohort, removeCohortFilter, clearCohortFilters, removeCohort, setCurrentCohortId, updateCohortName, updateCohortCounts, updateCohortIndexCountById, setCohortList } = cohortManagerSlice.actions;
|
|
1112
1129
|
const cohortReducer = cohortManagerSlice.reducer;
|
|
1113
1130
|
|
|
1114
1131
|
const initialState$2 = {};
|
|
@@ -1693,75 +1710,6 @@ const trimFirstFieldNameToTitle = (fieldName, trim = false)=>{
|
|
|
1693
1710
|
];
|
|
1694
1711
|
};
|
|
1695
1712
|
|
|
1696
|
-
const { selectAll: selectAllCohorts, selectTotal: selectTotalCohorts, selectById: selectCohortById, selectIds: selectCohortIds } = cohortsAdapter.getSelectors((state)=>state.cohorts.cohortManager);
|
|
1697
|
-
/**
|
|
1698
|
-
* Internally used selector for the exported selectora
|
|
1699
|
-
* @param state
|
|
1700
|
-
*/ const getCurrentCohortFromCoreState = (state)=>{
|
|
1701
|
-
return state.cohorts.cohortManager.currentCohortId;
|
|
1702
|
-
};
|
|
1703
|
-
const selectCohortFilters = (state)=>{
|
|
1704
|
-
const currentCohortId = getCurrentCohortFromCoreState(state);
|
|
1705
|
-
return state.cohorts.cohortManager.entities[currentCohortId]?.filters;
|
|
1706
|
-
};
|
|
1707
|
-
const selectCurrentCohortFilters = (state)=>{
|
|
1708
|
-
const currentCohortId = getCurrentCohortFromCoreState(state);
|
|
1709
|
-
return state.cohorts.cohortManager.entities[currentCohortId]?.filters;
|
|
1710
|
-
};
|
|
1711
|
-
const selectCurrentCohortId = (state)=>{
|
|
1712
|
-
return state.cohorts.cohortManager.currentCohortId;
|
|
1713
|
-
};
|
|
1714
|
-
const selectCurrentCohort = (state)=>cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state));
|
|
1715
|
-
const selectCurrentCohortName = (state)=>cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state)).name;
|
|
1716
|
-
/**
|
|
1717
|
-
* Select a filter by its name from the current cohort. If the filter is not found
|
|
1718
|
-
* returns undefined.
|
|
1719
|
-
* @param state - Core
|
|
1720
|
-
* @param index which cohort index to select from
|
|
1721
|
-
* @param name name of the filter to select
|
|
1722
|
-
*/ const selectIndexedFilterByName = (state, index, name)=>{
|
|
1723
|
-
return cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state)).filters[index]?.root[name];
|
|
1724
|
-
};
|
|
1725
|
-
/**
|
|
1726
|
-
* Returns all the cohorts in the state
|
|
1727
|
-
* @param state - the CoreState
|
|
1728
|
-
*
|
|
1729
|
-
* @category Cohort
|
|
1730
|
-
* @category Selectors
|
|
1731
|
-
*/ const selectAvailableCohorts = (state)=>cohortSelectors.selectAll(state);
|
|
1732
|
-
/**
|
|
1733
|
-
* Returns if the current cohort is modified
|
|
1734
|
-
* @param state - the CoreState
|
|
1735
|
-
* @category Cohort
|
|
1736
|
-
* @category Selectors
|
|
1737
|
-
* @hidden
|
|
1738
|
-
*/ const selectCurrentCohortModified = (state)=>{
|
|
1739
|
-
const cohort = cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state));
|
|
1740
|
-
return cohort?.modified;
|
|
1741
|
-
};
|
|
1742
|
-
/**
|
|
1743
|
-
* Returns if the current cohort has been saved
|
|
1744
|
-
* @param state - the CoreState
|
|
1745
|
-
* @category Cohort
|
|
1746
|
-
* @category Selectors
|
|
1747
|
-
* @hidden
|
|
1748
|
-
*/ const selectCurrentCohortSaved = (state)=>{
|
|
1749
|
-
const cohort = cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state));
|
|
1750
|
-
return cohort?.saved;
|
|
1751
|
-
};
|
|
1752
|
-
/**
|
|
1753
|
-
* Select a filter from the index.
|
|
1754
|
-
* returns undefined.
|
|
1755
|
-
* @param state - Core
|
|
1756
|
-
* @param index which cohort index to select from
|
|
1757
|
-
*/ const selectIndexFilters = (state, index)=>{
|
|
1758
|
-
const cohort = cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state));
|
|
1759
|
-
if (!cohort) {
|
|
1760
|
-
console.error('No Cohort Defined');
|
|
1761
|
-
}
|
|
1762
|
-
return cohort?.filters?.[index] ?? EmptyFilterSet;
|
|
1763
|
-
};
|
|
1764
|
-
|
|
1765
1713
|
/**
|
|
1766
1714
|
* Flattens a deep nested JSON object skipping
|
|
1767
1715
|
* the first level to avoid potentially flattening
|
|
@@ -2129,6 +2077,15 @@ const useGetStatus = ()=>{
|
|
|
2129
2077
|
const fetcher = ()=>fetchJson(`${GEN3_GUPPY_API}${statusEndpoint}`);
|
|
2130
2078
|
return useSWR('explorerStatus', fetcher);
|
|
2131
2079
|
};
|
|
2080
|
+
const explorerTags = guppyApi.enhanceEndpoints({
|
|
2081
|
+
addTagTypes: [
|
|
2082
|
+
'AGGS',
|
|
2083
|
+
'COUNTS',
|
|
2084
|
+
'STATS',
|
|
2085
|
+
'TABLE_DATA',
|
|
2086
|
+
'RAW_DATA'
|
|
2087
|
+
]
|
|
2088
|
+
});
|
|
2132
2089
|
/**
|
|
2133
2090
|
* The main endpoint used in templating Exploration page queries.
|
|
2134
2091
|
* Includes table, filter and aggregation query types and leverages guppyApi defined in ./gupplApi.ts
|
|
@@ -2146,7 +2103,7 @@ const useGetStatus = ()=>{
|
|
|
2146
2103
|
* @param getSubAggs - TODO: not sure what this one does. Looks like nested aggregation
|
|
2147
2104
|
* @param getCounts - Returns total counts of a vertex type
|
|
2148
2105
|
* @returns: A guppy API endpoint for templating queryable data displayed on the exploration page
|
|
2149
|
-
*/ const explorerApi =
|
|
2106
|
+
*/ const explorerApi = explorerTags.injectEndpoints({
|
|
2150
2107
|
endpoints: (builder)=>({
|
|
2151
2108
|
getAllFieldsForType: builder.query({
|
|
2152
2109
|
query: (type)=>({
|
|
@@ -2157,11 +2114,11 @@ const useGetStatus = ()=>{
|
|
|
2157
2114
|
}
|
|
2158
2115
|
}),
|
|
2159
2116
|
getAccessibleData: builder.query({
|
|
2160
|
-
query: ({ type, fields,
|
|
2117
|
+
query: ({ type, fields, accessibility })=>{
|
|
2161
2118
|
const fieldParts = fields.map((field)=>`${field} { histogram { key count } }`);
|
|
2162
2119
|
return {
|
|
2163
2120
|
query: `_aggregation {
|
|
2164
|
-
${type} (accessibility: ${
|
|
2121
|
+
${type} (accessibility: ${accessibility}) {
|
|
2165
2122
|
${fieldParts.join(',')}
|
|
2166
2123
|
}
|
|
2167
2124
|
}`
|
|
@@ -2223,11 +2180,15 @@ const useGetStatus = ()=>{
|
|
|
2223
2180
|
query,
|
|
2224
2181
|
variables
|
|
2225
2182
|
};
|
|
2226
|
-
}
|
|
2183
|
+
},
|
|
2184
|
+
providesTags: [
|
|
2185
|
+
'RAW_DATA',
|
|
2186
|
+
'TABLE_DATA'
|
|
2187
|
+
]
|
|
2227
2188
|
}),
|
|
2228
2189
|
getAggs: builder.query({
|
|
2229
|
-
query: ({ type, fields, filters, accessibility = Accessibility.ALL })=>{
|
|
2230
|
-
return buildGetAggregationQuery(type, fields, filters, accessibility,
|
|
2190
|
+
query: ({ type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false })=>{
|
|
2191
|
+
return buildGetAggregationQuery(type, fields, filters, accessibility, filterSelf);
|
|
2231
2192
|
},
|
|
2232
2193
|
transformResponse: (response, _meta, args)=>{
|
|
2233
2194
|
const buckets = processHistogramResponse(response?.data?._aggregation[args.type] ?? {});
|
|
@@ -2242,41 +2203,39 @@ const useGetStatus = ()=>{
|
|
|
2242
2203
|
],
|
|
2243
2204
|
...buckets
|
|
2244
2205
|
};
|
|
2245
|
-
}
|
|
2246
|
-
}),
|
|
2247
|
-
getAggsNoFilterSelf: builder.query({
|
|
2248
|
-
query: ({ type, fields, filters, accessibility = Accessibility.ALL })=>{
|
|
2249
|
-
return buildGetAggregationQuery(type, fields, filters, accessibility, true);
|
|
2250
2206
|
},
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2207
|
+
providesTags: [
|
|
2208
|
+
'AGGS'
|
|
2209
|
+
]
|
|
2254
2210
|
}),
|
|
2255
2211
|
getStatsAggregations: builder.query({
|
|
2256
|
-
query: ({ type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false })=>{
|
|
2257
|
-
return buildGetStatsAggregationQuery(type, fields, filters, accessibility, filterSelf);
|
|
2212
|
+
query: ({ type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false, queryId = undefined })=>{
|
|
2213
|
+
return buildGetStatsAggregationQuery(type, fields, filters, accessibility, filterSelf, queryId);
|
|
2258
2214
|
},
|
|
2259
2215
|
transformResponse: (response, _meta, args)=>{
|
|
2260
2216
|
return processHistogramResponse(response?.data?._aggregation[args.type] ?? {});
|
|
2261
|
-
}
|
|
2217
|
+
},
|
|
2218
|
+
providesTags: [
|
|
2219
|
+
'STATS'
|
|
2220
|
+
]
|
|
2262
2221
|
}),
|
|
2263
2222
|
getSubAggs: builder.query({
|
|
2264
|
-
query: ({ type, mainField, termsFields = undefined, missingFields = undefined, numericAggAsText = false,
|
|
2223
|
+
query: ({ type, mainField, termsFields = undefined, missingFields = undefined, numericAggAsText = false, filters = undefined, accessibility = Accessibility.ALL })=>{
|
|
2265
2224
|
const nestedAggFields = {
|
|
2266
2225
|
termsFields: termsFields,
|
|
2267
2226
|
missingFields: missingFields
|
|
2268
2227
|
};
|
|
2269
|
-
const query = `query getSubAggs ( ${
|
|
2228
|
+
const query = `query getSubAggs ( ${filters ?? '$filter: JSON,'} $nestedAggFields: JSON) {
|
|
2270
2229
|
_aggregation {
|
|
2271
|
-
${type} ( ${
|
|
2230
|
+
${type} ( ${filters ?? 'filter: $filter, filterSelf: false,'} nestedAggFields: $nestedAggFields, accessibility: ${accessibility}) {
|
|
2272
2231
|
_totalCounts
|
|
2273
2232
|
${nestedHistogramQueryStrForEachField(mainField, numericAggAsText)}
|
|
2274
2233
|
}`;
|
|
2275
2234
|
return {
|
|
2276
2235
|
query: query,
|
|
2277
2236
|
variables: {
|
|
2278
|
-
...
|
|
2279
|
-
filter: convertFilterSetToGqlFilter(
|
|
2237
|
+
...filters && {
|
|
2238
|
+
filter: convertFilterSetToGqlFilter(filters)
|
|
2280
2239
|
},
|
|
2281
2240
|
nestedAggFields: nestedAggFields
|
|
2282
2241
|
}
|
|
@@ -2284,12 +2243,15 @@ const useGetStatus = ()=>{
|
|
|
2284
2243
|
},
|
|
2285
2244
|
transformResponse: (response, _meta, args)=>{
|
|
2286
2245
|
return processHistogramResponse(response?.data?._aggregation[args.type] ?? {});
|
|
2287
|
-
}
|
|
2246
|
+
},
|
|
2247
|
+
providesTags: [
|
|
2248
|
+
'AGGS'
|
|
2249
|
+
]
|
|
2288
2250
|
}),
|
|
2289
2251
|
getCounts: builder.query({
|
|
2290
|
-
query: ({ type, filters, accessibility = Accessibility.ALL })=>{
|
|
2252
|
+
query: ({ type, filters, accessibility = Accessibility.ALL, queryId = undefined })=>{
|
|
2291
2253
|
const gqlFilters = convertFilterSetToGqlFilter(filters);
|
|
2292
|
-
const queryLine = `query totalCounts ${gqlFilters ? '($filter: JSON)' : ''}{`;
|
|
2254
|
+
const queryLine = `query totalCounts${queryId ? `_${queryId}` : ''} ${gqlFilters ? '($filter: JSON)' : ''}{`;
|
|
2293
2255
|
const typeAggsLine = `${type} ${gqlFilters ? '(filter: $filter, ' : '('} accessibility: ${accessibility}) {`;
|
|
2294
2256
|
const query = `${queryLine} _aggregation {
|
|
2295
2257
|
${typeAggsLine}
|
|
@@ -2314,7 +2276,10 @@ const useGetStatus = ()=>{
|
|
|
2314
2276
|
throw new Error(`Invalid response: Missing expected key '${args.type}' in _aggregation`);
|
|
2315
2277
|
}
|
|
2316
2278
|
return response.data._aggregation[args.type]._totalCount ?? 0;
|
|
2317
|
-
}
|
|
2279
|
+
},
|
|
2280
|
+
providesTags: [
|
|
2281
|
+
'COUNTS'
|
|
2282
|
+
]
|
|
2318
2283
|
}),
|
|
2319
2284
|
getFieldCountSummary: builder.query({
|
|
2320
2285
|
query: ({ type, field, filters, accessibility = Accessibility.ALL })=>{
|
|
@@ -2377,8 +2342,6 @@ const useGetStatus = ()=>{
|
|
|
2377
2342
|
})
|
|
2378
2343
|
})
|
|
2379
2344
|
});
|
|
2380
|
-
// query for aggregate data
|
|
2381
|
-
// convert the function below to typescript
|
|
2382
2345
|
const histogramQueryStrForEachField = (field)=>{
|
|
2383
2346
|
const splittedFieldArray = field.split('.');
|
|
2384
2347
|
const splittedField = splittedFieldArray.shift();
|
|
@@ -2461,9 +2424,9 @@ const useGetIndexFields = (index)=>{
|
|
|
2461
2424
|
const { data } = useGetFieldsForIndexQuery(index);
|
|
2462
2425
|
return data ?? [];
|
|
2463
2426
|
};
|
|
2464
|
-
const buildGetAggregationQuery = (type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false)=>{
|
|
2427
|
+
const buildGetAggregationQuery = (type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false, queryId = undefined)=>{
|
|
2465
2428
|
const queryStart = isFilterEmpty(filters) ? `
|
|
2466
|
-
query getAggs {
|
|
2429
|
+
query getAggs${queryId ? `_${queryId}` : ''} {
|
|
2467
2430
|
_aggregation {
|
|
2468
2431
|
${type} (accessibility: ${accessibility}) {` : `query getAggs ($filter: JSON) {
|
|
2469
2432
|
_aggregation {
|
|
@@ -2482,11 +2445,11 @@ const buildGetAggregationQuery = (type, fields, filters, accessibility = Accessi
|
|
|
2482
2445
|
};
|
|
2483
2446
|
return queryBody;
|
|
2484
2447
|
};
|
|
2485
|
-
const buildGetStatsAggregationQuery = (type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false)=>{
|
|
2448
|
+
const buildGetStatsAggregationQuery = (type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false, queryId = undefined)=>{
|
|
2486
2449
|
const queryStart = isFilterEmpty(filters) ? `
|
|
2487
|
-
query
|
|
2450
|
+
query getStatsAggs${queryId ? `_${queryId}` : ''} {
|
|
2488
2451
|
_aggregation {
|
|
2489
|
-
${type} (accessibility: ${accessibility}) {` : `query
|
|
2452
|
+
${type} (accessibility: ${accessibility}) {` : `query getStatsAggs${queryId ? `_${queryId}` : ''} ($filter: JSON) {
|
|
2490
2453
|
_aggregation {
|
|
2491
2454
|
${type} (filter: $filter, filterSelf: ${filterSelf ? 'true' : 'false'}, accessibility: ${accessibility}) { _totalCount`;
|
|
2492
2455
|
const query = `${queryStart}
|
|
@@ -2502,49 +2465,29 @@ const buildGetStatsAggregationQuery = (type, fields, filters, accessibility = Ac
|
|
|
2502
2465
|
};
|
|
2503
2466
|
return queryBody;
|
|
2504
2467
|
};
|
|
2505
|
-
const { useGetRawDataAndTotalCountsQuery, useGetAccessibleDataQuery, useGetAllFieldsForTypeQuery, useGetAggsQuery,
|
|
2468
|
+
const { useGetRawDataAndTotalCountsQuery, useGetAccessibleDataQuery, useGetAllFieldsForTypeQuery, useGetAggsQuery, useLazyGetAggsQuery, useGetStatsAggregationsQuery, useLazyGetStatsAggregationsQuery, useGetSubAggsQuery, useGetCountsQuery, useLazyGetCountsQuery, useGetFieldCountSummaryQuery, useGetFieldsForIndexQuery, useGetSharedFieldsForIndexQuery, useGeneralGQLQuery, useLazyGeneralGQLQuery } = explorerApi;
|
|
2506
2469
|
|
|
2507
|
-
const isPayloadActionWithObject = (action)=>{
|
|
2508
|
-
return typeof action === 'object' && action !== null && 'type' in action && 'payload' in action && typeof action.payload === 'object';
|
|
2509
|
-
};
|
|
2510
2470
|
/**
|
|
2511
2471
|
* Defines coreListeners for adding middleware.
|
|
2512
2472
|
* used to update the current Cohort Case count
|
|
2513
2473
|
*/ const coreStoreListenerMiddleware = toolkit.createListenerMiddleware();
|
|
2514
2474
|
const startCoreListening = coreStoreListenerMiddleware.startListening;
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
// need to pass the current cohort id to the case count fetcher because it is possible that
|
|
2520
|
-
// the current cohort will be different when the fetch is fulfilled
|
|
2521
|
-
if (currentCohortId) console.log('currentCohortId', currentCohortId);
|
|
2522
|
-
}
|
|
2523
|
-
});
|
|
2524
|
-
startCoreListening({
|
|
2525
|
-
matcher: toolkit.isAnyOf(explorerApi.endpoints.getAggs.matchFulfilled),
|
|
2526
|
-
effect: async (action, listenerApi)=>{
|
|
2527
|
-
if (isPayloadActionWithObject(action)) {
|
|
2528
|
-
const root = action.payload;
|
|
2529
|
-
const counts = root?._totalCount.reduce((acc, curr)=>{
|
|
2530
|
-
const { key, count } = curr;
|
|
2531
|
-
acc[key] = count;
|
|
2532
|
-
return acc;
|
|
2533
|
-
}, {});
|
|
2534
|
-
if (counts) {
|
|
2535
|
-
listenerApi.dispatch(updateCohortCounts(counts ?? {}));
|
|
2536
|
-
}
|
|
2537
|
-
}
|
|
2538
|
-
}
|
|
2539
|
-
});
|
|
2540
|
-
startCoreListening({
|
|
2475
|
+
/**
|
|
2476
|
+
* When a getCounts is requested, it might be for a cohort.
|
|
2477
|
+
* If so, then update the cohort's counts for that index
|
|
2478
|
+
*/ startCoreListening({
|
|
2541
2479
|
matcher: toolkit.isAnyOf(explorerApi.endpoints.getCounts.matchFulfilled),
|
|
2542
2480
|
effect: async (action, listenerApi)=>{
|
|
2543
2481
|
const counts = action.payload;
|
|
2544
|
-
const index = action?.meta?.arg?.originalArgs?.index
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2482
|
+
const index = action?.meta?.arg?.originalArgs?.type; // note this is the guppy index name
|
|
2483
|
+
const cohortId = action?.meta?.arg?.originalArgs?.queryId;
|
|
2484
|
+
if (cohortId && index) {
|
|
2485
|
+
listenerApi.dispatch(updateCohortIndexCountById({
|
|
2486
|
+
index,
|
|
2487
|
+
cohortId,
|
|
2488
|
+
counts
|
|
2489
|
+
}));
|
|
2490
|
+
}
|
|
2548
2491
|
}
|
|
2549
2492
|
});
|
|
2550
2493
|
|
|
@@ -3453,6 +3396,81 @@ class CohortStorage {
|
|
|
3453
3396
|
}
|
|
3454
3397
|
}
|
|
3455
3398
|
|
|
3399
|
+
const { selectAll: selectAllCohorts, selectTotal: selectTotalCohorts, selectById: selectCohortById, selectIds: selectCohortIds } = cohortsAdapter.getSelectors((state)=>state.cohorts.cohortManager);
|
|
3400
|
+
/**
|
|
3401
|
+
* Internally used selector for the exported selectora
|
|
3402
|
+
* @param state
|
|
3403
|
+
*/ const getCurrentCohortFromCoreState = (state)=>{
|
|
3404
|
+
return state.cohorts.cohortManager.currentCohortId;
|
|
3405
|
+
};
|
|
3406
|
+
const selectCohortFilters = (state)=>{
|
|
3407
|
+
const currentCohortId = getCurrentCohortFromCoreState(state);
|
|
3408
|
+
return state.cohorts.cohortManager.entities[currentCohortId]?.filters;
|
|
3409
|
+
};
|
|
3410
|
+
const selectCurrentCohortFilters = (state)=>{
|
|
3411
|
+
const currentCohortId = getCurrentCohortFromCoreState(state);
|
|
3412
|
+
return state.cohorts.cohortManager.entities[currentCohortId]?.filters;
|
|
3413
|
+
};
|
|
3414
|
+
const selectCurrentCohortId = (state)=>{
|
|
3415
|
+
return state.cohorts.cohortManager.currentCohortId;
|
|
3416
|
+
};
|
|
3417
|
+
const selectCurrentCohort = (state)=>cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state));
|
|
3418
|
+
const selectCurrentCohortName = (state)=>cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state)).name;
|
|
3419
|
+
/**
|
|
3420
|
+
* Select a filter by its name from the current cohort. If the filter is not found
|
|
3421
|
+
* returns undefined.
|
|
3422
|
+
* @param state - Core
|
|
3423
|
+
* @param index which cohort index to select from
|
|
3424
|
+
* @param name name of the filter to select
|
|
3425
|
+
*/ const selectIndexedFilterByName = (state, index, name)=>{
|
|
3426
|
+
return cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state)).filters[index]?.root[name];
|
|
3427
|
+
};
|
|
3428
|
+
/**
|
|
3429
|
+
* Returns all the cohorts in the state
|
|
3430
|
+
* @param state - the CoreState
|
|
3431
|
+
*
|
|
3432
|
+
* @category Cohort
|
|
3433
|
+
* @category Selectors
|
|
3434
|
+
*/ const selectAvailableCohorts = (state)=>cohortSelectors.selectAll(state);
|
|
3435
|
+
/**
|
|
3436
|
+
* Returns if the current cohort is modified
|
|
3437
|
+
* @param state - the CoreState
|
|
3438
|
+
* @category Cohort
|
|
3439
|
+
* @category Selectors
|
|
3440
|
+
* @hidden
|
|
3441
|
+
*/ const selectCurrentCohortModified = (state)=>{
|
|
3442
|
+
const cohort = cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state));
|
|
3443
|
+
return cohort?.modified;
|
|
3444
|
+
};
|
|
3445
|
+
/**
|
|
3446
|
+
* Returns if the current cohort has been saved
|
|
3447
|
+
* @param state - the CoreState
|
|
3448
|
+
* @category Cohort
|
|
3449
|
+
* @category Selectors
|
|
3450
|
+
* @hidden
|
|
3451
|
+
*/ const selectCurrentCohortSaved = (state)=>{
|
|
3452
|
+
const cohort = cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state));
|
|
3453
|
+
return cohort?.saved;
|
|
3454
|
+
};
|
|
3455
|
+
/**
|
|
3456
|
+
* Select a filter by its name from the current cohort. If the filter is not found
|
|
3457
|
+
* returns undefined.
|
|
3458
|
+
* @param state - Core
|
|
3459
|
+
* @param name name of the filter to select
|
|
3460
|
+
*/ const selectAvailableCohortByName = (state, name)=>cohortSelectors.selectAll(state).find((cohort)=>cohort.name === name);
|
|
3461
|
+
/**
|
|
3462
|
+
* Select a filter from the index.
|
|
3463
|
+
* returns undefined.
|
|
3464
|
+
* @param state - Core
|
|
3465
|
+
* @param index which cohort index to select from
|
|
3466
|
+
*/ const selectIndexFilters = (state, index)=>{
|
|
3467
|
+
const cohort = cohortSelectors.selectById(state, getCurrentCohortFromCoreState(state));
|
|
3468
|
+
if (!cohort) {
|
|
3469
|
+
console.error('No Cohort Defined');
|
|
3470
|
+
}
|
|
3471
|
+
return cohort?.filters?.[index] ?? EmptyFilterSet;
|
|
3472
|
+
};
|
|
3473
|
+
|
|
3456
3474
|
const isFileItem = (item)=>{
|
|
3457
3475
|
return item && 'guid' in item;
|
|
3458
3476
|
};
|
|
@@ -5662,6 +5680,7 @@ exports.downloadJSONDataFromGuppy = downloadJSONDataFromGuppy;
|
|
|
5662
5680
|
exports.drsHostnamesReducer = drsHostnamesReducer;
|
|
5663
5681
|
exports.duplicateCohort = duplicateCohort;
|
|
5664
5682
|
exports.explorerApi = explorerApi;
|
|
5683
|
+
exports.explorerTags = explorerTags;
|
|
5665
5684
|
exports.extractEnumFilterValue = extractEnumFilterValue;
|
|
5666
5685
|
exports.extractFieldNameFromFullFieldName = extractFieldNameFromFullFieldName;
|
|
5667
5686
|
exports.extractFileDatasetsInRecords = extractFileDatasetsInRecords;
|
|
@@ -5764,12 +5783,15 @@ exports.selectActiveWorkspaceStatus = selectActiveWorkspaceStatus;
|
|
|
5764
5783
|
exports.selectAllCohortFiltersCollapsed = selectAllCohortFiltersCollapsed;
|
|
5765
5784
|
exports.selectAllCohorts = selectAllCohorts;
|
|
5766
5785
|
exports.selectAuthzMappingData = selectAuthzMappingData;
|
|
5786
|
+
exports.selectAvailableCohortByName = selectAvailableCohortByName;
|
|
5767
5787
|
exports.selectAvailableCohorts = selectAvailableCohorts;
|
|
5768
5788
|
exports.selectCSRFToken = selectCSRFToken;
|
|
5769
5789
|
exports.selectCSRFTokenData = selectCSRFTokenData;
|
|
5790
|
+
exports.selectCohortById = selectCohortById;
|
|
5770
5791
|
exports.selectCohortFilterCombineMode = selectCohortFilterCombineMode;
|
|
5771
5792
|
exports.selectCohortFilterExpanded = selectCohortFilterExpanded;
|
|
5772
5793
|
exports.selectCohortFilters = selectCohortFilters;
|
|
5794
|
+
exports.selectCohortIds = selectCohortIds;
|
|
5773
5795
|
exports.selectCurrentCohort = selectCurrentCohort;
|
|
5774
5796
|
exports.selectCurrentCohortFilters = selectCurrentCohortFilters;
|
|
5775
5797
|
exports.selectCurrentCohortId = selectCurrentCohortId;
|
|
@@ -5789,6 +5811,7 @@ exports.selectRequestedWorkspaceStatusTimestamp = selectRequestedWorkspaceStatus
|
|
|
5789
5811
|
exports.selectSharedFilters = selectSharedFilters;
|
|
5790
5812
|
exports.selectSharedFiltersForFields = selectSharedFiltersForFields;
|
|
5791
5813
|
exports.selectShouldShareFilters = selectShouldShareFilters;
|
|
5814
|
+
exports.selectTotalCohorts = selectTotalCohorts;
|
|
5792
5815
|
exports.selectUser = selectUser;
|
|
5793
5816
|
exports.selectUserAuthStatus = selectUserAuthStatus;
|
|
5794
5817
|
exports.selectUserData = selectUserData;
|
|
@@ -5836,7 +5859,6 @@ exports.useGetAISearchVersionQuery = useGetAISearchVersionQuery;
|
|
|
5836
5859
|
exports.useGetAccessibleDataQuery = useGetAccessibleDataQuery;
|
|
5837
5860
|
exports.useGetActivePayModelQuery = useGetActivePayModelQuery;
|
|
5838
5861
|
exports.useGetAggMDSQuery = useGetAggMDSQuery;
|
|
5839
|
-
exports.useGetAggsNoFilterSelfQuery = useGetAggsNoFilterSelfQuery;
|
|
5840
5862
|
exports.useGetAggsQuery = useGetAggsQuery;
|
|
5841
5863
|
exports.useGetAllFieldsForTypeQuery = useGetAllFieldsForTypeQuery;
|
|
5842
5864
|
exports.useGetArrayTypes = useGetArrayTypes;
|
|
@@ -5888,11 +5910,11 @@ exports.useIsUserLoggedIn = useIsUserLoggedIn;
|
|
|
5888
5910
|
exports.useLaunchWorkspaceMutation = useLaunchWorkspaceMutation;
|
|
5889
5911
|
exports.useLazyFetchUserDetailsQuery = useLazyFetchUserDetailsQuery;
|
|
5890
5912
|
exports.useLazyGeneralGQLQuery = useLazyGeneralGQLQuery;
|
|
5891
|
-
exports.useLazyGetAggsNoFilterSelfQuery = useLazyGetAggsNoFilterSelfQuery;
|
|
5892
5913
|
exports.useLazyGetAggsQuery = useLazyGetAggsQuery;
|
|
5893
5914
|
exports.useLazyGetAuthzMappingsQuery = useLazyGetAuthzMappingsQuery;
|
|
5894
5915
|
exports.useLazyGetAuthzResourcesQuery = useLazyGetAuthzResourcesQuery;
|
|
5895
5916
|
exports.useLazyGetCSRFQuery = useLazyGetCSRFQuery;
|
|
5917
|
+
exports.useLazyGetCountsQuery = useLazyGetCountsQuery;
|
|
5896
5918
|
exports.useLazyGetCrosswalkDataQuery = useLazyGetCrosswalkDataQuery;
|
|
5897
5919
|
exports.useLazyGetDownloadQuery = useLazyGetDownloadQuery;
|
|
5898
5920
|
exports.useLazyGetExternalLoginsQuery = useLazyGetExternalLoginsQuery;
|