Files
OmniRoute/src/lib/providers/serviceKindIndex.ts
Diego Rodrigues de Sa e Souza db362b0126 Release v3.8.30 (#4267)
Release v3.8.30 — see CHANGELOG.md [3.8.30] for the full release notes.
2026-06-20 07:09:43 -03:00

35 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { resolveProviderServiceKinds } from "@omniroute/open-sse/config/mediaServiceKinds.ts";
/**
* Full serviceKinds for a provider — the declared ones (llm, web*, imageToText)
* unioned with the registry-derived media kinds (image / video / music / tts /
* stt / embedding). This is the single client-side source of truth for the
* `/dashboard/providers` category (serviceKind) filter (#4240).
*
* Client-safe: `mediaServiceKinds` only pulls in the pure-data media registries
* (no server-only deps). Results are memoised per providerId+declared signature
* because the filter calls this once per provider on every keystroke/render.
*/
const _cache = new Map<string, readonly string[]>();
export function getProviderServiceKinds(
providerId: string,
declared?: readonly string[] | null
): readonly string[] {
const key = `${providerId}${(declared ?? []).join(",")}`;
const cached = _cache.get(key);
if (cached) return cached;
const kinds = resolveProviderServiceKinds(providerId, declared ?? undefined);
_cache.set(key, kinds);
return kinds;
}
/** True when the provider supports `kind` (declared or registry-derived). */
export function providerHasServiceKind(
providerId: string,
declared: readonly string[] | null | undefined,
kind: string
): boolean {
return getProviderServiceKinds(providerId, declared).includes(kind);
}