@kontent-ai/management-sdk
Version:
Official Kontent.ai management SDK
46 lines • 2.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.contentItemsMapper = exports.ContentItemsMapper = void 0;
const models_1 = require("../models");
const responses_1 = require("../responses");
const base_mapper_1 = require("./base-mapper");
class ContentItemsMapper extends base_mapper_1.BaseMapper {
mapListingItemsResponse(response) {
const pagination = super.mapPagination(response.data.pagination);
const items = response.data.items.map((m) => this.mapContentItem(m));
return new responses_1.ContentItemResponses.ContentItemsResponse(super.mapResponseDebug(response), response.data, {
pagination: pagination,
items: items
});
}
mapViewContentItemResponse(response) {
return new responses_1.ContentItemResponses.ViewContentItemResponse(super.mapResponseDebug(response), response.data, this.mapContentItem(response.data));
}
mapAddContentItemResponse(response) {
return new responses_1.ContentItemResponses.AddContentItemResponse(super.mapResponseDebug(response), response.data, this.mapContentItem(response.data));
}
mapUpdateContentItemResponse(response) {
return new responses_1.ContentItemResponses.UpdateContentItemResponse(super.mapResponseDebug(response), response.data, this.mapContentItem(response.data));
}
mapUpsertContentItemResponse(response) {
return new responses_1.ContentItemResponses.UpsertContentItemResponse(super.mapResponseDebug(response), response.data, this.mapContentItem(response.data));
}
mapContentItem(rawItem) {
var _a, _b;
return new models_1.ContentItemModels.ContentItem({
codename: rawItem.codename,
externalId: rawItem.external_id,
id: rawItem.id,
lastModified: new Date(rawItem.last_modified),
name: rawItem.name,
type: rawItem.type,
collection: super.mapIdReference(rawItem.collection),
spaces: rawItem.spaces.map((m) => super.mapIdReference(m)),
sitemapLocations: (_b = (_a = rawItem.sitemap_locations) === null || _a === void 0 ? void 0 : _a.map((m) => super.mapIdReference(m))) !== null && _b !== void 0 ? _b : [],
_raw: rawItem
});
}
}
exports.ContentItemsMapper = ContentItemsMapper;
exports.contentItemsMapper = new ContentItemsMapper();
//# sourceMappingURL=content-items-mapper.js.map