-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vision): add release layering support
- Loading branch information
Showing
8 changed files
with
204 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,36 @@ | ||
import {type ClientPerspective} from '@sanity/client' | ||
|
||
export type SupportedPerspective = 'raw' | 'previewDrafts' | 'published' | 'drafts' | ||
|
||
export const SUPPORTED_PERSPECTIVES = [ | ||
'pinnedRelease', | ||
'raw', | ||
'previewDrafts', | ||
'published', | ||
'drafts', | ||
] satisfies ClientPerspective[] | ||
export const DEFAULT_PERSPECTIVE = SUPPORTED_PERSPECTIVES[0] | ||
] as const | ||
|
||
export type SupportedPerspective = (typeof SUPPORTED_PERSPECTIVES)[number] | ||
|
||
/** | ||
* Virtual perspectives are recognised by Vision, but do not concretely reflect the names of real | ||
* perspectives. Virtual perspectives are transformed into real perspectives before being used to | ||
* interact with data. | ||
* | ||
* For example, the `pinnedRelease` virtual perspective is transformed to the real perspective | ||
* currently pinned in Studio. | ||
*/ | ||
export const VIRTUAL_PERSPECTIVES = ['pinnedRelease'] as const | ||
|
||
export type VirtualPerspective = (typeof VIRTUAL_PERSPECTIVES)[number] | ||
|
||
export const DEFAULT_PERSPECTIVE: SupportedPerspective = 'raw' | ||
|
||
export function isSupportedPerspective(p: string): p is SupportedPerspective { | ||
return SUPPORTED_PERSPECTIVES.includes(p as SupportedPerspective) | ||
} | ||
|
||
export function isVirtualPerspective( | ||
maybeVirtualPerspective: unknown, | ||
): maybeVirtualPerspective is VirtualPerspective { | ||
return ( | ||
typeof maybeVirtualPerspective === 'string' && | ||
VIRTUAL_PERSPECTIVES.includes(maybeVirtualPerspective as VirtualPerspective) | ||
) | ||
} |
Oops, something went wrong.