@gen3/core 0.11.34 → 0.11.35

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
@@ -2292,18 +2292,18 @@ const explorerTags = guppyApi.enhanceEndpoints({
2292
2292
  */ const explorerApi = explorerTags.injectEndpoints({
2293
2293
  endpoints: (builder)=>({
2294
2294
  getAllFieldsForType: builder.query({
2295
- query: (type)=>({
2296
- query: `{ _mapping ${type} } }`
2295
+ query: ({ type, indexPrefix = '' })=>({
2296
+ query: `{ ${indexPrefix}_mapping ${type} } }`
2297
2297
  }),
2298
2298
  transformResponse: (response, _meta, params)=>{
2299
2299
  return response[params.type];
2300
2300
  }
2301
2301
  }),
2302
2302
  getAccessibleData: builder.query({
2303
- query: ({ type, fields, accessibility })=>{
2303
+ query: ({ type, fields, accessibility, indexPrefix = '' })=>{
2304
2304
  const fieldParts = fields.map((field)=>`${field} { histogram { key count } }`);
2305
2305
  return {
2306
- query: `_aggregation {
2306
+ query: `${indexPrefix}_aggregation {
2307
2307
  ${type} (accessibility: ${accessibility}) {
2308
2308
  ${fieldParts.join(',')}
2309
2309
  }
@@ -2312,7 +2312,7 @@ const explorerTags = guppyApi.enhanceEndpoints({
2312
2312
  }
2313
2313
  }),
2314
2314
  getRawDataAndTotalCounts: builder.query({
2315
- query: ({ type, fields, filters, sort, offset = 0, size = 20, accessibility = Accessibility.ALL, format = undefined })=>{
2315
+ query: ({ type, fields, filters, sort, offset = 0, size = 20, accessibility = Accessibility.ALL, format = undefined, indexPrefix = '' })=>{
2316
2316
  const gqlFilter = convertFilterSetToGqlFilter(filters);
2317
2317
  const params = [
2318
2318
  ...sort ? [
@@ -2337,7 +2337,7 @@ const explorerTags = guppyApi.enhanceEndpoints({
2337
2337
  'filter: $filter'
2338
2338
  ] : []
2339
2339
  ].join(',');
2340
- const dataTypeLine = `${type} (accessibility: ${accessibility}, offset: ${offset}, first: ${size},
2340
+ const dataTypeLine = `${indexPrefix}${type} (accessibility: ${accessibility}, offset: ${offset}, first: ${size},
2341
2341
  ${dataParams}) {`;
2342
2342
  const typeAggsLine = `${type} (${gqlFilter && 'filter: $filter,'} accessibility: ${accessibility}) {`;
2343
2343
  const processedFields = fields.map((field)=>rawDataQueryStrForEachField(field));
@@ -2345,7 +2345,7 @@ const explorerTags = guppyApi.enhanceEndpoints({
2345
2345
  ${dataTypeLine}
2346
2346
  ${processedFields.join(' ')}
2347
2347
  }
2348
- _aggregation {
2348
+ ${indexPrefix}_aggregation {
2349
2349
  ${typeAggsLine}
2350
2350
  _totalCount
2351
2351
  }
@@ -2373,13 +2373,13 @@ const explorerTags = guppyApi.enhanceEndpoints({
2373
2373
  ]
2374
2374
  }),
2375
2375
  getAggs: builder.query({
2376
- query: ({ type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false })=>{
2377
- return buildGetAggregationQuery(type, fields, filters, accessibility, filterSelf);
2376
+ query: ({ type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false, indexPrefix = '' })=>{
2377
+ return buildGetAggregationQuery(type, fields, filters, accessibility, filterSelf, undefined, indexPrefix);
2378
2378
  },
2379
2379
  transformResponse: (response, _meta, args)=>{
2380
- const buckets = processHistogramResponse(response?.data?._aggregation[args.type] ?? {});
2380
+ const buckets = processHistogramResponse(response?.data?.[`${args?.indexPrefix ?? ''}_aggregation`][args.type] ?? {});
2381
2381
  // check for totals
2382
- const count = response?.data?._aggregation[args.type]?._totalCount ?? null;
2382
+ const count = response?.data?.[`${args?.indexPrefix ?? ''}_aggregation`][args.type]?._totalCount ?? null;
2383
2383
  return {
2384
2384
  _totalCount: [
2385
2385
  {
@@ -2395,24 +2395,24 @@ const explorerTags = guppyApi.enhanceEndpoints({
2395
2395
  ]
2396
2396
  }),
2397
2397
  getStatsAggregations: builder.query({
2398
- query: ({ type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false, queryId = undefined })=>{
2399
- return buildGetStatsAggregationQuery(type, fields, filters, accessibility, filterSelf, queryId);
2398
+ query: ({ type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false, queryId = undefined, indexPrefix = '' })=>{
2399
+ return buildGetStatsAggregationQuery(type, fields, filters, accessibility, filterSelf, queryId, indexPrefix);
2400
2400
  },
2401
2401
  transformResponse: (response, _meta, args)=>{
2402
- return processHistogramResponse(response?.data?._aggregation[args.type] ?? {});
2402
+ return processHistogramResponse(response?.data?.[`${args?.indexPrefix ?? ''}_aggregation`][args.type] ?? {});
2403
2403
  },
2404
2404
  providesTags: [
2405
2405
  'STATS'
2406
2406
  ]
2407
2407
  }),
2408
2408
  getSubAggs: builder.query({
2409
- query: ({ type, mainField, termsFields = undefined, missingFields = undefined, numericAggAsText = false, filters = undefined, accessibility = Accessibility.ALL })=>{
2409
+ query: ({ type, mainField, termsFields = undefined, missingFields = undefined, numericAggAsText = false, filters = undefined, accessibility = Accessibility.ALL, indexPrefix = '' })=>{
2410
2410
  const nestedAggFields = {
2411
2411
  termsFields: termsFields,
2412
2412
  missingFields: missingFields
2413
2413
  };
2414
2414
  const query = `query getSubAggs ( ${filters ?? '$filter: JSON,'} $nestedAggFields: JSON) {
2415
- _aggregation {
2415
+ ${indexPrefix}_aggregation {
2416
2416
  ${type} ( ${filters ?? 'filter: $filter, filterSelf: false,'} nestedAggFields: $nestedAggFields, accessibility: ${accessibility}) {
2417
2417
  _totalCounts
2418
2418
  ${nestedHistogramQueryStrForEachField(mainField, numericAggAsText)}
@@ -2428,18 +2428,18 @@ const explorerTags = guppyApi.enhanceEndpoints({
2428
2428
  };
2429
2429
  },
2430
2430
  transformResponse: (response, _meta, args)=>{
2431
- return processHistogramResponse(response?.data?._aggregation[args.type] ?? {});
2431
+ return processHistogramResponse(response?.data?.[`${args?.indexPrefix ?? ''}_aggregation`][args.type] ?? {});
2432
2432
  },
2433
2433
  providesTags: [
2434
2434
  'AGGS'
2435
2435
  ]
2436
2436
  }),
2437
2437
  getCounts: builder.query({
2438
- query: ({ type, filters, accessibility = Accessibility.ALL, queryId = undefined })=>{
2438
+ query: ({ type, filters, accessibility = Accessibility.ALL, queryId = undefined, indexPrefix = '' })=>{
2439
2439
  const gqlFilters = convertFilterSetToGqlFilter(filters);
2440
- const queryLine = `query totalCounts${queryId ? `_${queryId}` : ''} ${gqlFilters ? '($filter: JSON)' : ''}{`;
2440
+ const queryLine = `query totalCounts${queryId ? `${indexPrefix}_${queryId}` : ''} ${gqlFilters ? '($filter: JSON)' : ''}{`;
2441
2441
  const typeAggsLine = `${type} ${gqlFilters ? '(filter: $filter, ' : '('} accessibility: ${accessibility}) {`;
2442
- const query = `${queryLine} _aggregation {
2442
+ const query = `${queryLine} ${indexPrefix}_aggregation {
2443
2443
  ${typeAggsLine}
2444
2444
  _totalCount
2445
2445
  }
@@ -2455,23 +2455,23 @@ const explorerTags = guppyApi.enhanceEndpoints({
2455
2455
  };
2456
2456
  },
2457
2457
  transformResponse: (response, _meta, args)=>{
2458
- if (!response.data || !response.data._aggregation) {
2458
+ if (!response.data || !response.data[`${args?.indexPrefix ?? ''}_aggregation`]) {
2459
2459
  throw new Error('Invalid response: Missing data or _aggregation field');
2460
2460
  }
2461
- if (!(args.type in response.data._aggregation)) {
2461
+ if (!(args.type in response.data[`${args?.indexPrefix ?? ''}_aggregation`])) {
2462
2462
  throw new Error(`Invalid response: Missing expected key '${args.type}' in _aggregation`);
2463
2463
  }
2464
- return response.data._aggregation[args.type]._totalCount ?? 0;
2464
+ return response.data[`${args?.indexPrefix ?? ''}_aggregation`][args.type]._totalCount ?? 0;
2465
2465
  },
2466
2466
  providesTags: [
2467
2467
  'COUNTS'
2468
2468
  ]
2469
2469
  }),
2470
2470
  getFieldCountSummary: builder.query({
2471
- query: ({ type, field, filters, accessibility = Accessibility.ALL })=>{
2471
+ query: ({ type, field, filters, accessibility = Accessibility.ALL, indexPrefix = '' })=>{
2472
2472
  const gqlFilters = convertFilterSetToGqlFilter(filters);
2473
2473
  const query = `query summary ($filter: JSON) {
2474
- _aggregation {
2474
+ ${indexPrefix}_aggregation {
2475
2475
  ${type} (filter: $filter, accessibility: ${accessibility}) {
2476
2476
  ${field} {
2477
2477
  histogram {
@@ -2492,15 +2492,15 @@ const explorerTags = guppyApi.enhanceEndpoints({
2492
2492
  }
2493
2493
  }),
2494
2494
  getFieldsForIndex: builder.query({
2495
- query: (index)=>{
2495
+ query: ({ index, indexPrefix = '' })=>{
2496
2496
  return {
2497
2497
  query: `{
2498
- _mapping { ${index} }
2498
+ ${indexPrefix}_mapping { ${index} }
2499
2499
  }`
2500
2500
  };
2501
2501
  },
2502
- transformResponse: (response)=>{
2503
- return response['_mapping'];
2502
+ transformResponse: (response, _meta, args)=>{
2503
+ return response[`${args.indexPrefix}_mapping`];
2504
2504
  }
2505
2505
  }),
2506
2506
  getSharedFieldsForIndex: builder.query({
@@ -2537,16 +2537,18 @@ const useGetArrayTypes = ()=>{
2537
2537
  return data ? data['indices'] : {};
2538
2538
  }
2539
2539
  };
2540
- const useGetIndexFields = (index)=>{
2541
- const { data } = useGetFieldsForIndexQuery(index);
2540
+ const useGetIndexFields = (index, indexPrefix = '')=>{
2541
+ const { data } = useGetFieldsForIndexQuery({
2542
+ index: index,
2543
+ indexPrefix: indexPrefix
2544
+ });
2542
2545
  return data ?? [];
2543
2546
  };
2544
- const buildGetAggregationQuery = (type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false, queryId = undefined)=>{
2545
- const queryStart = isFilterEmpty(filters) ? `
2546
- query getAggs${queryId ? `_${queryId}` : ''} {
2547
- _aggregation {
2547
+ const buildGetAggregationQuery = (type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false, queryId = undefined, indexPrefix = '')=>{
2548
+ const queryStart = isFilterEmpty(filters) ? `query getAggs${queryId ? `_${queryId}` : ''} {
2549
+ ${indexPrefix}_aggregation {
2548
2550
  ${type} (accessibility: ${accessibility}) {` : `query getAggs ($filter: JSON) {
2549
- _aggregation {
2551
+ ${indexPrefix}_aggregation {
2550
2552
 
2551
2553
  ${type} (filter: $filter, filterSelf: ${filterSelf ? 'true' : 'false'}, accessibility: ${accessibility}) { _totalCount`;
2552
2554
  const query = `${queryStart}
@@ -2562,12 +2564,12 @@ const buildGetAggregationQuery = (type, fields, filters, accessibility = Accessi
2562
2564
  };
2563
2565
  return queryBody;
2564
2566
  };
2565
- const buildGetStatsAggregationQuery = (type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false, queryId = undefined)=>{
2567
+ const buildGetStatsAggregationQuery = (type, fields, filters, accessibility = Accessibility.ALL, filterSelf = false, queryId = undefined, indexPrefix = '')=>{
2566
2568
  const queryStart = isFilterEmpty(filters) ? `
2567
2569
  query getStatsAggs${queryId ? `_${queryId}` : ''} {
2568
- _aggregation {
2570
+ ${indexPrefix}_aggregation {
2569
2571
  ${type} (accessibility: ${accessibility}) {` : `query getStatsAggs${queryId ? `_${queryId}` : ''} ($filter: JSON) {
2570
- _aggregation {
2572
+ ${indexPrefix}_aggregation {
2571
2573
  ${type} (filter: $filter, filterSelf: ${filterSelf ? 'true' : 'false'}, accessibility: ${accessibility}) { _totalCount`;
2572
2574
  const query = `${queryStart}
2573
2575
  ${fields.map((field)=>statsQueryStrForEachField(field))}