Complete permission-aware native search indexing
This commit is contained in:
@@ -63,6 +63,43 @@ export type SearchProviderListResponse = {
|
||||
resources: SearchResourceType[];
|
||||
};
|
||||
|
||||
export type SearchIndexState = {
|
||||
provider_id: string;
|
||||
module_id: string;
|
||||
resource_type: string;
|
||||
index_version: number;
|
||||
status: string;
|
||||
checkpoint_cursor?: string | null;
|
||||
high_watermark?: string | null;
|
||||
last_change_cursor?: string | null;
|
||||
indexed_documents: number;
|
||||
rejected_documents: number;
|
||||
rebuild_started_at?: string | null;
|
||||
rebuild_completed_at?: string | null;
|
||||
last_success_at?: string | null;
|
||||
last_error?: string | null;
|
||||
};
|
||||
|
||||
export type SearchDiagnostics = {
|
||||
backend: string;
|
||||
trigram_available: boolean;
|
||||
queue: Record<string, number>;
|
||||
queue_oldest_age_seconds?: number | null;
|
||||
states: SearchIndexState[];
|
||||
};
|
||||
|
||||
export type SearchChangeDispatch = {
|
||||
selected: number;
|
||||
applied: number;
|
||||
retrying: number;
|
||||
quarantined: number;
|
||||
};
|
||||
|
||||
export type SearchModuleReconcile = {
|
||||
disabled_documents: number;
|
||||
enabled_documents: number;
|
||||
};
|
||||
|
||||
export type SearchRequest = {
|
||||
query: string;
|
||||
modules?: string[];
|
||||
@@ -107,3 +144,63 @@ export function listSearchProviders(
|
||||
{ signal }
|
||||
);
|
||||
}
|
||||
|
||||
export function getSearchDiagnostics(
|
||||
settings: ApiSettings,
|
||||
signal?: AbortSignal
|
||||
): Promise<SearchDiagnostics> {
|
||||
return apiFetch<SearchDiagnostics>(
|
||||
settings,
|
||||
"/api/v1/search/admin/diagnostics",
|
||||
{ signal }
|
||||
);
|
||||
}
|
||||
|
||||
export function reconcileSearchModules(
|
||||
settings: ApiSettings
|
||||
): Promise<SearchModuleReconcile> {
|
||||
return apiFetch<SearchModuleReconcile>(
|
||||
settings,
|
||||
"/api/v1/search/admin/reconcile-modules",
|
||||
{ method: "POST" }
|
||||
);
|
||||
}
|
||||
|
||||
export function processSearchChanges(
|
||||
settings: ApiSettings,
|
||||
limit = 100
|
||||
): Promise<SearchChangeDispatch> {
|
||||
return apiFetch<SearchChangeDispatch>(
|
||||
settings,
|
||||
apiPath("/api/v1/search/admin/changes/process", { limit }),
|
||||
{ method: "POST" }
|
||||
);
|
||||
}
|
||||
|
||||
export function startSearchRebuild(
|
||||
settings: ApiSettings,
|
||||
providerId: string,
|
||||
resourceType: string
|
||||
): Promise<{ state: SearchIndexState }> {
|
||||
return apiFetch<{ state: SearchIndexState }>(
|
||||
settings,
|
||||
`/api/v1/search/admin/rebuilds/${encodeURIComponent(providerId)}/${encodeURIComponent(resourceType)}/start`,
|
||||
{ method: "POST" }
|
||||
);
|
||||
}
|
||||
|
||||
export function continueSearchRebuild(
|
||||
settings: ApiSettings,
|
||||
providerId: string,
|
||||
resourceType: string,
|
||||
limit = 100
|
||||
): Promise<{ state: SearchIndexState }> {
|
||||
return apiFetch<{ state: SearchIndexState }>(
|
||||
settings,
|
||||
apiPath(
|
||||
`/api/v1/search/admin/rebuilds/${encodeURIComponent(providerId)}/${encodeURIComponent(resourceType)}/continue`,
|
||||
{ limit }
|
||||
),
|
||||
{ method: "POST" }
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user