feat: add fields prop for fetching necessary findings data

This commit is contained in:
Chandrapal Badshah
2025-08-11 19:20:42 +05:30
parent c3e50e3600
commit 5b7bf307d4
2 changed files with 29 additions and 0 deletions
+4
View File
@@ -8,6 +8,7 @@ export const getLighthouseFindings = async ({
query = "",
sort = "",
filters = {},
fields = [],
}) => {
const headers = await getAuthHeaders({ contentType: false });
@@ -21,6 +22,9 @@ export const getLighthouseFindings = async ({
if (query) url.searchParams.append("filter[search]", query);
if (sort) url.searchParams.append("sort", sort);
if (fields.length > 0) {
url.searchParams.append("fields[findings]", fields.join(","));
}
Object.entries(filters).forEach(([key, value]) => {
url.searchParams.append(key, String(value));
+25
View File
@@ -213,6 +213,31 @@ export const getFindingsSchema = z.object({
.describe(
"The filters to apply. Default is {}. Only add necessary filters and ignore others. Generate the filters object **only** with non-empty values included.",
),
fields: z
.array(
z.enum([
"uid",
"delta",
"status",
"status_extended",
"severity",
"check_id",
"check_metadata",
"raw_result",
"inserted_at",
"updated_at",
"first_seen_at",
"muted",
"muted_reason",
"url",
"scan",
"resources",
]),
)
.optional()
.describe(
"List of fields to include in the response. Use only available fields.",
),
});
// Get Metadata Info Schema