@prismicio/types-internal
Version:
Prismic types for Custom Types and Prismic Data
26 lines (24 loc) • 492 B
text/typescript
export type Asset = {
id: string
last_modified: string
kind: "image" | "all"
filename?: string
extension?: string
size?: number
origin_url: string
url: string
width?: number
height?: number
notes?: string
credits?: string
alt?: string
}
export const getAssetOrThrow =
(assets: Record<Asset["id"], Asset | undefined>) =>
(assetId: Asset["id"]) => {
const asset = assets[assetId]
if (!asset) {
throw new Error(`Missing asset with id '${assetId}'!`)
}
return asset
}