UNPKG

@prismicio/client

Version:

The official JavaScript + TypeScript client library for Prismic

54 lines (53 loc) 2.1 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const link = require("../types/value/link.cjs"); const richText = require("../types/value/richText.cjs"); const filledLinkToMedia = (value) => { if (value && typeof value === "object" && !("version" in value)) { if ("link_type" in value && value.link_type === link.LinkType.Media && "id" in value && "name" in value && "kind" in value && "url" in value && "size" in value) { return true; } } return false; }; const imageLike = (value) => { if (value && typeof value === "object" && (!("version" in value) || typeof value.version === "object")) { if ("id" in value && "url" in value && typeof value.url === "string" && "dimensions" in value && "edit" in value && "alt" in value && "copyright" in value) { return true; } } return false; }; const filledImage = (value) => { if (imageLike(value) && (!("type" in value) || value.type !== richText.RichTextNodeType.image)) { return true; } return false; }; const rtImageNode = (value) => { if (imageLike(value) && "type" in value && value.type === richText.RichTextNodeType.image) { return true; } return false; }; const filledContentRelationship = (value) => { if (value && typeof value === "object" && !("version" in value)) { if ("link_type" in value && value.link_type === link.LinkType.Document && "id" in value && "type" in value && "tags" in value && "lang" in value) { return true; } } return false; }; const prismicDocument = (value) => { try { return typeof value === "object" && value !== null && "id" in value && "href" in value && typeof value.href === "string" && new URL(value.href) && "type" in value && "lang" in value && "tags" in value && Array.isArray(value.tags); } catch { return false; } }; exports.filledContentRelationship = filledContentRelationship; exports.filledImage = filledImage; exports.filledLinkToMedia = filledLinkToMedia; exports.prismicDocument = prismicDocument; exports.rtImageNode = rtImageNode; //# sourceMappingURL=isValue.cjs.map