feat: implement permission-aware search baseline

This commit is contained in:
2026-07-29 15:50:11 +02:00
parent 89a4fd0874
commit c60ca2776e
27 changed files with 2282 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
import {
apiFetch,
apiPath,
type ApiSettings
} from "@govoplan/core-webui";
export type SearchExternalReference = {
system: string;
object_type: string;
object_id: string;
maturity: string;
connector_id?: string | null;
canonical_url?: string | null;
};
export type SearchResult = {
provider_id: string;
module_id: string;
resource_type: string;
resource_id: string;
title: string;
summary?: string | null;
url: string;
score: number;
highlights: string[];
breadcrumbs: string[];
external_reference?: SearchExternalReference | null;
metadata: Record<string, unknown>;
};
export type SearchResponse = {
query: string;
results: SearchResult[];
diagnostics: Array<{
provider_id: string;
status: "unavailable";
message: string;
}>;
};
export type SearchRequest = {
query: string;
modules?: string[];
resourceTypes?: string[];
contextKind?: "global" | "module" | "resource";
contextId?: string;
limit?: number;
offset?: number;
};
export function search(
settings: ApiSettings,
request: SearchRequest,
signal?: AbortSignal
): Promise<SearchResponse> {
return apiFetch<SearchResponse>(
settings,
apiPath("/api/v1/search", {
q: request.query,
module: request.modules,
resource_type: request.resourceTypes,
context_kind: request.contextKind,
context_id: request.contextId,
limit: request.limit,
offset: request.offset
}),
{ signal }
);
}