Skip to content
Source
Sign inSign up
TanStack/schemas
Open History to see the last commit

upstream-model.ts

15 lines466 Bytes

1import type { FactSource, UpstreamModelIdentity } from './types.ts'
2​
3/** Split a provider-published `namespace/model` id at the first slash. */
4export function namespacedUpstreamIdentity(
5 rawId: string,
6 source: FactSource,
7): UpstreamModelIdentity | null {
8 const slash = rawId.indexOf('/')
9 if (slash <= 0 || slash === rawId.length - 1) return null
10 return {
11 providerNamespace: rawId.slice(0, slash),
12 rawId: rawId.slice(slash + 1),
13 source,
14 }