@gen3/core 0.11.43 → 0.11.45
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 +66 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/dts/features/guppy/guppyApi.d.ts.map +1 -1
- package/dist/dts/features/guppy/guppySlice.d.ts +20 -20
- package/dist/dts/features/guppy/guppySlice.d.ts.map +1 -1
- package/dist/esm/index.js +66 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +20 -20
- package/package.json +3 -2
package/dist/cjs/index.js
CHANGED
|
@@ -827,16 +827,26 @@ const cartReducerPath = 'cart';
|
|
|
827
827
|
method: 'POST',
|
|
828
828
|
body: JSON.stringify(query)
|
|
829
829
|
});
|
|
830
|
+
const data = await response.json();
|
|
831
|
+
// Check the response for GraphQL errors
|
|
832
|
+
if (data && 'errors' in data) {
|
|
833
|
+
// Return an object with an 'error' property if GraphQL errors are present
|
|
834
|
+
return {
|
|
835
|
+
error: {
|
|
836
|
+
message: data.errors[0].message,
|
|
837
|
+
locations: data.errors[0].locations
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
}
|
|
830
841
|
return {
|
|
831
|
-
data
|
|
842
|
+
data
|
|
832
843
|
};
|
|
833
844
|
} catch (e) {
|
|
834
845
|
if (e instanceof graphql.GraphQLError) {
|
|
835
846
|
return {
|
|
836
847
|
error: {
|
|
837
848
|
message: e.message,
|
|
838
|
-
locations: e.locations
|
|
839
|
-
path: e.path
|
|
849
|
+
locations: e.locations
|
|
840
850
|
}
|
|
841
851
|
};
|
|
842
852
|
}
|
|
@@ -2411,6 +2421,59 @@ const explorerTags = guppyApi.enhanceEndpoints({
|
|
|
2411
2421
|
variables
|
|
2412
2422
|
};
|
|
2413
2423
|
},
|
|
2424
|
+
// return . seperated fields as proper values
|
|
2425
|
+
transformResponse: (response, _meta, args)=>{
|
|
2426
|
+
const containsDots = args?.fields?.filter((f)=>f.includes('.'));
|
|
2427
|
+
// check if dot seperated in arry and not object
|
|
2428
|
+
if (containsDots && containsDots.length > 0 && response.data) {
|
|
2429
|
+
const containsDotsUniqueBase = containsDots.reduce((acc, field)=>{
|
|
2430
|
+
const partsArr = field.split('.');
|
|
2431
|
+
if (partsArr.length < 2) {
|
|
2432
|
+
throw new Error("Explorer does not support field with more than one '.' separator");
|
|
2433
|
+
}
|
|
2434
|
+
const basePart = partsArr[0];
|
|
2435
|
+
if (!acc.includes(basePart)) {
|
|
2436
|
+
acc.push(basePart);
|
|
2437
|
+
}
|
|
2438
|
+
return acc;
|
|
2439
|
+
}, []);
|
|
2440
|
+
// checks if api is returning an array of objects for the base part
|
|
2441
|
+
// if so, it restructures the object to group the sub parts into arrays
|
|
2442
|
+
// e.g. {a: [{b: 1, c:2}, {b:3, c:4}]} becomes {a: {b: [1,3], c:[2,4]}}
|
|
2443
|
+
// this is to make it easier to work with in the table component
|
|
2444
|
+
// currently only supports one level of nesting
|
|
2445
|
+
// also puts original into subRows for dropdown viewing
|
|
2446
|
+
const tempResponse = response.data[`${args.indexPrefix}${args.type}`].map((item)=>{
|
|
2447
|
+
const tempItem = item;
|
|
2448
|
+
for(let i = 0; i < containsDotsUniqueBase.length; i++){
|
|
2449
|
+
const basePart = containsDotsUniqueBase[i];
|
|
2450
|
+
if (item[basePart] && Array.isArray(item[basePart])) {
|
|
2451
|
+
// move original to subRows
|
|
2452
|
+
tempItem.subRows = tempItem[basePart];
|
|
2453
|
+
tempItem[basePart] = tempItem[basePart].reduce((acc, obj)=>{
|
|
2454
|
+
for(const key in obj){
|
|
2455
|
+
if (Object.hasOwn(obj, key)) {
|
|
2456
|
+
if (!acc[key]) {
|
|
2457
|
+
acc[key] = [];
|
|
2458
|
+
}
|
|
2459
|
+
acc[key].push(obj[key]);
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
return acc;
|
|
2463
|
+
}, {});
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
return tempItem;
|
|
2467
|
+
});
|
|
2468
|
+
return {
|
|
2469
|
+
data: {
|
|
2470
|
+
_aggregation: response.data._aggregation,
|
|
2471
|
+
[`${args.indexPrefix}${args.type}`]: tempResponse
|
|
2472
|
+
}
|
|
2473
|
+
};
|
|
2474
|
+
}
|
|
2475
|
+
return response;
|
|
2476
|
+
},
|
|
2414
2477
|
providesTags: [
|
|
2415
2478
|
'RAW_DATA',
|
|
2416
2479
|
'TABLE_DATA'
|