sanity
Version:
Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches
20 lines (19 loc) • 413 B
text/typescript
export function resolveProjectDataset(
resourceType: string,
resourceId: string,
): {
projectId: string
dataset: string
} | null {
if (resourceType !== 'dataset') {
return null
}
const [projectId, dataset] = resourceId.split('.', 2)
if (!projectId || !dataset) {
throw new Error(`Invalid resource ID for resource "dataset": ${resourceId}`)
}
return {
projectId,
dataset,
}
}