refactor(app): DRY pass — split large files, extract shared utils
S1: delete page.new.js (1724L abandoned) + remove dead getAntigravityProjectId
S2: split large files by natural seams
- usage.js → usage/{github,google,claude,codex,kiro,minimax,misc,shared}.js
- media-providers page → components/{Embedding,Tts,Generic,Stt}ExampleCard.js
- EndpointPageClient → endpointConstants.js + endpointPing.js + components/
- tokenRefresh.js → tokenRefresh/{dedup,providers}.js
- ProviderLimits/index.js: 16 pure fn + 9 constants → utils.js
- oauth/providers.js: 7 pure helpers → providerHelpers.js
S3: shared utils
- getModelKind(m, fallback) → shared/constants/models.js (replaces 20× m.kind||m.type)
- getStatusVariant → shared/utils/connectionStatus.js (dedup ConnectionRow/ConnectionsCard)
- sseChunk → open-sse/utils/sse.js (dedup grok-web/perplexity-web)
- fetchWithTimeout → usage/shared.js (replace 4× AbortController pattern in google.js)
fix: enableObservability2 field name in requestDetailsRepo
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { PROVIDER_MODELS } from "open-sse/config/providerModels.js";
|
||||
import { AI_PROVIDERS, ALIAS_TO_ID } from "@/shared/constants/providers";
|
||||
import { getModelKind } from "@/shared/constants/models";
|
||||
|
||||
const KIND_ENDPOINT = {
|
||||
llm: "/v1/chat/completions",
|
||||
@@ -52,10 +53,10 @@ function lookup(fullId, requestedKind) {
|
||||
// PROVIDER_MODELS lookup (by alias key, fallback to providerId)
|
||||
const list = PROVIDER_MODELS[alias] || PROVIDER_MODELS[providerId] || [];
|
||||
const m = requestedKind
|
||||
? list.find((x) => x.id === modelId && (x.kind || x.type || "llm") === requestedKind)
|
||||
? list.find((x) => x.id === modelId && getModelKind(x, "llm") === requestedKind)
|
||||
: list.find((x) => x.id === modelId);
|
||||
if (m) {
|
||||
const kind = m.kind || m.type || "llm";
|
||||
const kind = getModelKind(m, "llm");
|
||||
return buildInfo({ alias, providerId, model: m, kind, providerInfo });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PROVIDER_MODELS, PROVIDER_ID_TO_ALIAS } from "@/shared/constants/models";
|
||||
import { PROVIDER_MODELS, PROVIDER_ID_TO_ALIAS, getModelKind } from "@/shared/constants/models";
|
||||
import {
|
||||
AI_PROVIDERS,
|
||||
getProviderAlias,
|
||||
@@ -316,7 +316,7 @@ export async function buildModelsList(kindFilter) {
|
||||
|
||||
const customModelIds = customModels
|
||||
.filter((m) => {
|
||||
if (!m?.id || ((m.kind || m.type) && (m.kind || m.type) !== "llm")) return false;
|
||||
if (!m?.id || (getModelKind(m) && getModelKind(m) !== "llm")) return false;
|
||||
const alias = m.providerAlias;
|
||||
return alias === staticAlias || alias === outputAlias || alias === providerId;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user