UNPKG

@prismicio/types-internal

Version:
31 lines (30 loc) 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EmptyContent = exports.EmptyLegacy = exports.isEmptyContent = exports.EmptyContentType = void 0; const tslib_1 = require("tslib"); const fp_ts_1 = require("fp-ts"); const function_1 = require("fp-ts/lib/function"); const t = (0, tslib_1.__importStar)(require("io-ts")); const utils_1 = require("../utils"); exports.EmptyContentType = "EmptyContent"; const isEmptyContent = (u) => (0, utils_1.hasContentType)(u) && u.__TYPE__ === exports.EmptyContentType; exports.isEmptyContent = isEmptyContent; const legacyReader = t.union([ t.null, t.type({ value: t.null, }), ]); const EmptyLegacy = (type) => new t.Type("EmptyLegacy", exports.isEmptyContent, (content) => { return (0, function_1.pipe)(legacyReader.decode(content), fp_ts_1.either.map(() => { return { type, __TYPE__: exports.EmptyContentType, }; })); }, () => null); exports.EmptyLegacy = EmptyLegacy; exports.EmptyContent = t.strict({ type: t.string, __TYPE__: t.literal(exports.EmptyContentType), });