"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransientNodeService = void 0;
const tslib_1 = require("tslib");
const core_1 = require("@loopback/core");
const models_1 = require("../../models");
const extension_description_1 = require("./../../integration/extension-description");
const application_service_1 = require("./../application.service");
const content_entity_service_1 = require("./../content-entity/content-entity.service");
const object_type_service_1 = require("./../object-type.service");
const transient_entity_const_1 = require("./transient-entity.const");
const transient_entity_service_1 = require("./transient-entity.service");
let TransientNodeService = class TransientNodeService {
    constructor(objectTypeService, contentEntityService, transientEntityService, applicationService) {
        this.objectTypeService = objectTypeService;
        this.contentEntityService = contentEntityService;
        this.transientEntityService = transientEntityService;
        this.applicationService = applicationService;
        this.providerId = transient_entity_const_1.TRANSIENT_ENTITY_PROVIDER;
        this.serviceId = TransientNodeService.name;
        this.description = this.getPostTreatmentDescription.bind(this);
        this.transientEntityService.registerTransientEntityService(models_1.EntityName.objectNode, this);
    }
    getPostTreatmentDescription() {
        const treatment = new extension_description_1.TreatmentDescription(transient_entity_const_1.TRANSIENT_ENTITY_PROVIDER, TransientNodeService.name, 'objectNode: Add Node Content Data');
        treatment.subTreatments.push(...this.contentEntityService.getPostTreatmentDescription());
        return treatment;
    }
    async completeReturnedEntity(entity, ctx) {
        const objectNode = entity;
        const objectType = await ctx.nodeContext.objectType.getOrSetValue(async () => this.objectTypeService.searchById(objectNode.objectTypeId));
        await this.contentEntityService.addTransientContent(models_1.EntityName.objectNode, objectType.contentType, entity);
    }
};
TransientNodeService = tslib_1.__decorate([
    tslib_1.__param(0, core_1.service(object_type_service_1.ObjectTypeService)),
    tslib_1.__param(1, core_1.service(content_entity_service_1.ContentEntityService)),
    tslib_1.__param(2, core_1.service(transient_entity_service_1.TransientEntityService)),
    tslib_1.__param(3, core_1.service(application_service_1.ApplicationService)),
    tslib_1.__metadata("design:paramtypes", [object_type_service_1.ObjectTypeService,
        content_entity_service_1.ContentEntityService,
        transient_entity_service_1.TransientEntityService,
        application_service_1.ApplicationService])
], TransientNodeService);
exports.TransientNodeService = TransientNodeService;
//# sourceMappingURL=transient-node.service.js.map