UNPKG

@kontent-ai/management-sdk

Version:
47 lines 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.elementsMapper = exports.ElementsMapper = void 0; const models_1 = require("../models"); const base_mapper_1 = require("./base-mapper"); class ElementsMapper extends base_mapper_1.BaseMapper { mapTypeElements(elementsRaw) { return elementsRaw.map((m) => this.mapTypeElement(m)); } mapTypeElement(rawElement) { return rawElement; } mapElements(elementsRaw) { return elementsRaw.map((m) => { return this.mapElement(m); }); } mapElement(rawElement) { var _a; return new models_1.ElementModels.ContentItemElement({ element: super.mapReference(rawElement.element), value: this.mapElementValue(rawElement.value), components: this.mapElementComponents((_a = rawElement.components) !== null && _a !== void 0 ? _a : []), display_timezone: rawElement.display_timezone, mode: rawElement.mode, searchableValue: rawElement.searchableValue, _raw: rawElement }); } mapElementComponents(components) { return components.map((m) => new models_1.ElementModels.ContentItemElementComponent({ elements: this.mapElements(m.elements), id: m.id, type: m.type, _raw: m })); } mapElementValue(rawValue) { if (Array.isArray(rawValue)) { return rawValue.map((m) => super.mapReference(m)); } return rawValue; } } exports.ElementsMapper = ElementsMapper; exports.elementsMapper = new ElementsMapper(); //# sourceMappingURL=elements-mapper.js.map