UNPKG

@prismicio/types-internal

Version:
32 lines (31 loc) 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GeoPointContent = exports.GeoPointLegacy = exports.isGeoPointContent = exports.GeoPointContentType = void 0; const tslib_1 = require("tslib"); const fp_ts_1 = require("fp-ts"); const function_1 = require("fp-ts/function"); const t = (0, tslib_1.__importStar)(require("io-ts")); const utils_1 = require("../../utils"); exports.GeoPointContentType = "GeoPointContent"; const isGeoPointContent = (u) => (0, utils_1.hasContentType)(u) && u.__TYPE__ === exports.GeoPointContentType; exports.isGeoPointContent = isGeoPointContent; const legacyReader = t.strict({ position: t.strict({ lat: t.number, lng: t.number, }), }); const GeoPointLegacy = (ctx) => new t.Type("GeoPointLegacy", exports.isGeoPointContent, (u) => { return (0, function_1.pipe)(legacyReader.decode(u), fp_ts_1.either.map((geo) => exports.GeoPointContent.encode({ ...geo, __TYPE__: exports.GeoPointContentType }))); }, (geo) => ({ content: { position: geo.position }, types: { [ctx.keyOfType]: "GeoPoint" }, keys: {}, })); exports.GeoPointLegacy = GeoPointLegacy; exports.GeoPointContent = t.intersection([ legacyReader, t.strict({ __TYPE__: t.literal(exports.GeoPointContentType), }), ]);