"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActionEntityController = void 0;
const tslib_1 = require("tslib");
const authorization_1 = require("@loopback/authorization");
const core_1 = require("@loopback/core");
const rest_1 = require("@loopback/rest");
const entity_name_1 = require("../../models/entity-name");
const access_rights_const_1 = require("../access-rights/access-rights.const");
const application_service_1 = require("../application.service");
const action_entity_service_1 = require("./action-entity.service");
let ActionEntityController = class ActionEntityController {
    constructor(actionEntityService) {
        this.actionEntityService = actionEntityService;
    }
    async generateNodeView(id, viewId, response, ctx) {
        const generatedView = await this.actionEntityService.generateView(entity_name_1.EntityName.objectNode, id, viewId, {}, ctx);
        return generatedView.getResponse(response);
    }
    async generateNodeViewWith1Arg(id, viewId, response, ctx, arg1) {
        const generatedView = await this.actionEntityService.generateView(entity_name_1.EntityName.objectNode, id, viewId, [arg1], ctx);
        return generatedView.getResponse(response);
    }
    async generateNodeViewWith2Args(id, viewId, response, ctx, arg1, arg2) {
        const generatedView = await this.actionEntityService.generateView(entity_name_1.EntityName.objectNode, id, viewId, [arg1, arg2], ctx);
        return generatedView.getResponse(response);
    }
    async generateNodeViewWith3Args(id, viewId, response, ctx, arg1, arg2, arg3) {
        const generatedView = await this.actionEntityService.generateView(entity_name_1.EntityName.objectNode, id, viewId, [arg1, arg2, arg3], ctx);
        return generatedView.getResponse(response);
    }
    async generateTreeView(id, viewId, response, ctx) {
        const generatedView = await this.actionEntityService.generateView(entity_name_1.EntityName.objectTree, id, viewId, {}, ctx);
        return generatedView.getResponse(response);
    }
    async generateTreeViewWith1Arg(id, viewId, response, ctx, arg1) {
        const generatedView = await this.actionEntityService.generateView(entity_name_1.EntityName.objectTree, id, viewId, [arg1], ctx);
        return generatedView.getResponse(response);
    }
    async generateTreeViewWith2Args(id, viewId, response, ctx, arg1, arg2) {
        const generatedView = await this.actionEntityService.generateView(entity_name_1.EntityName.objectTree, id, viewId, [arg1, arg2], ctx);
        return generatedView.getResponse(response);
    }
    async generateTreeViewWith3Args(id, viewId, response, ctx, arg1, arg2, arg3) {
        const generatedView = await this.actionEntityService.generateView(entity_name_1.EntityName.objectTree, id, viewId, [arg1, arg2, arg3], ctx);
        return generatedView.getResponse(response);
    }
    async runNodeAction(id, methodId, args, ctx) {
        return this.actionEntityService.runMethod(entity_name_1.EntityName.objectNode, id, methodId, args, ctx);
    }
    async runTreeAction(id, methodId, args, ctx) {
        return this.actionEntityService.runMethod(entity_name_1.EntityName.objectTree, id, methodId, args, ctx);
    }
};
tslib_1.__decorate([
    authorization_1.authorize({
        resource: access_rights_const_1.AccessRightsEntity.objectNodeContent,
        scopes: [access_rights_const_1.AccessRightsScope.view],
    }),
    rest_1.get('/object-nodes/{id}/view/{viewId}'),
    tslib_1.__param(0, rest_1.param.path.string('id')),
    tslib_1.__param(1, rest_1.param.path.string('viewId')),
    tslib_1.__param(2, core_1.inject(rest_1.RestBindings.Http.RESPONSE)),
    tslib_1.__param(3, core_1.inject(application_service_1.CURRENT_CONTEXT)),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, String, Object, application_service_1.CurrentContext]),
    tslib_1.__metadata("design:returntype", Promise)
], ActionEntityController.prototype, "generateNodeView", null);
tslib_1.__decorate([
    rest_1.get('/object-nodes/{id}/view/{viewId}/{arg1}'),
    tslib_1.__param(0, rest_1.param.path.string('id')),
    tslib_1.__param(1, rest_1.param.path.string('viewId')),
    tslib_1.__param(2, core_1.inject(rest_1.RestBindings.Http.RESPONSE)),
    tslib_1.__param(3, core_1.inject(application_service_1.CURRENT_CONTEXT)),
    tslib_1.__param(4, rest_1.param.path.string('arg1')),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, String, Object, application_service_1.CurrentContext, String]),
    tslib_1.__metadata("design:returntype", Promise)
], ActionEntityController.prototype, "generateNodeViewWith1Arg", null);
tslib_1.__decorate([
    rest_1.get('/object-nodes/{id}/view/{viewId}/{arg1}/{arg2}'),
    tslib_1.__param(0, rest_1.param.path.string('id')),
    tslib_1.__param(1, rest_1.param.path.string('viewId')),
    tslib_1.__param(2, core_1.inject(rest_1.RestBindings.Http.RESPONSE)),
    tslib_1.__param(3, core_1.inject(application_service_1.CURRENT_CONTEXT)),
    tslib_1.__param(4, rest_1.param.path.string('arg1')),
    tslib_1.__param(5, rest_1.param.path.string('arg2')),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, String, Object, application_service_1.CurrentContext, String, String]),
    tslib_1.__metadata("design:returntype", Promise)
], ActionEntityController.prototype, "generateNodeViewWith2Args", null);
tslib_1.__decorate([
    rest_1.get('/object-nodes/{id}/view/{viewId}/{arg1}/{arg2}/{arg3}'),
    tslib_1.__param(0, rest_1.param.path.string('id')),
    tslib_1.__param(1, rest_1.param.path.string('viewId')),
    tslib_1.__param(2, core_1.inject(rest_1.RestBindings.Http.RESPONSE)),
    tslib_1.__param(3, core_1.inject(application_service_1.CURRENT_CONTEXT)),
    tslib_1.__param(4, rest_1.param.path.string('arg1')),
    tslib_1.__param(5, rest_1.param.path.string('arg2')),
    tslib_1.__param(6, rest_1.param.path.string('arg3')),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, String, Object, application_service_1.CurrentContext, String, String, String]),
    tslib_1.__metadata("design:returntype", Promise)
], ActionEntityController.prototype, "generateNodeViewWith3Args", null);
tslib_1.__decorate([
    authorization_1.authorize({
        resource: access_rights_const_1.AccessRightsEntity.objectNodeContent,
        scopes: [access_rights_const_1.AccessRightsScope.view],
    }),
    rest_1.get('/object-trees/{id}/view/{viewId}'),
    rest_1.oas.response.file(),
    tslib_1.__param(0, rest_1.param.path.string('id')),
    tslib_1.__param(1, rest_1.param.path.string('viewId')),
    tslib_1.__param(2, core_1.inject(rest_1.RestBindings.Http.RESPONSE)),
    tslib_1.__param(3, core_1.inject(application_service_1.CURRENT_CONTEXT)),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, String, Object, application_service_1.CurrentContext]),
    tslib_1.__metadata("design:returntype", Promise)
], ActionEntityController.prototype, "generateTreeView", null);
tslib_1.__decorate([
    rest_1.get('/object-trees/{id}/view/{viewId}/{arg1}'),
    tslib_1.__param(0, rest_1.param.path.string('id')),
    tslib_1.__param(1, rest_1.param.path.string('viewId')),
    tslib_1.__param(2, core_1.inject(rest_1.RestBindings.Http.RESPONSE)),
    tslib_1.__param(3, core_1.inject(application_service_1.CURRENT_CONTEXT)),
    tslib_1.__param(4, rest_1.param.path.string('arg1')),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, String, Object, application_service_1.CurrentContext, String]),
    tslib_1.__metadata("design:returntype", Promise)
], ActionEntityController.prototype, "generateTreeViewWith1Arg", null);
tslib_1.__decorate([
    rest_1.get('/object-trees/{id}/view/{viewId}/{arg1}/{arg2}'),
    tslib_1.__param(0, rest_1.param.path.string('id')),
    tslib_1.__param(1, rest_1.param.path.string('viewId')),
    tslib_1.__param(2, core_1.inject(rest_1.RestBindings.Http.RESPONSE)),
    tslib_1.__param(3, core_1.inject(application_service_1.CURRENT_CONTEXT)),
    tslib_1.__param(4, rest_1.param.path.string('arg1')),
    tslib_1.__param(5, rest_1.param.path.string('arg2')),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, String, Object, application_service_1.CurrentContext, String, String]),
    tslib_1.__metadata("design:returntype", Promise)
], ActionEntityController.prototype, "generateTreeViewWith2Args", null);
tslib_1.__decorate([
    rest_1.get('/object-trees/{id}/view/{viewId}/{arg1}/{arg2}/{arg3}'),
    tslib_1.__param(0, rest_1.param.path.string('id')),
    tslib_1.__param(1, rest_1.param.path.string('viewId')),
    tslib_1.__param(2, core_1.inject(rest_1.RestBindings.Http.RESPONSE)),
    tslib_1.__param(3, core_1.inject(application_service_1.CURRENT_CONTEXT)),
    tslib_1.__param(4, rest_1.param.path.string('arg1')),
    tslib_1.__param(5, rest_1.param.path.string('arg2')),
    tslib_1.__param(6, rest_1.param.path.string('arg3')),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, String, Object, application_service_1.CurrentContext, String, String, String]),
    tslib_1.__metadata("design:returntype", Promise)
], ActionEntityController.prototype, "generateTreeViewWith3Args", null);
tslib_1.__decorate([
    authorization_1.authorize({
        resource: access_rights_const_1.AccessRightsEntity.objectNode,
        scopes: [access_rights_const_1.AccessRightsScope.method],
    }),
    rest_1.post('/object-nodes/{id}/method/{methodId}', {
        responses: {
            '200': {
                description: 'ObjectNode model instance',
                content: { 'application/json': { schema: rest_1.getModelSchemaRef(Object) } },
            },
        },
    }),
    tslib_1.__param(0, rest_1.param.path.string('id')),
    tslib_1.__param(1, rest_1.param.path.string('methodId')),
    tslib_1.__param(2, rest_1.requestBody({
        content: {
            'application/json': {
                schema: rest_1.getModelSchemaRef(Object, {
                    title: 'Argument',
                }),
            },
        },
    })),
    tslib_1.__param(3, core_1.inject(application_service_1.CURRENT_CONTEXT)),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, String, Object,
        application_service_1.CurrentContext]),
    tslib_1.__metadata("design:returntype", Promise)
], ActionEntityController.prototype, "runNodeAction", null);
tslib_1.__decorate([
    authorization_1.authorize({
        resource: access_rights_const_1.AccessRightsEntity.objectTree,
        scopes: [access_rights_const_1.AccessRightsScope.method],
    }),
    rest_1.post('/object-trees/{id}/method/{methodId}', {
        responses: {
            '200': {
                description: 'ObjectTree model instance',
                content: { 'application/json': { schema: rest_1.getModelSchemaRef(Object) } },
            },
        },
    }),
    tslib_1.__param(0, rest_1.param.path.string('id')),
    tslib_1.__param(1, rest_1.param.path.string('methodId')),
    tslib_1.__param(2, rest_1.requestBody({
        content: {
            'application/json': {
                schema: rest_1.getModelSchemaRef(Object, {
                    title: 'Argument',
                }),
            },
        },
    })),
    tslib_1.__param(3, core_1.inject(application_service_1.CURRENT_CONTEXT)),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, String, Object,
        application_service_1.CurrentContext]),
    tslib_1.__metadata("design:returntype", Promise)
], ActionEntityController.prototype, "runTreeAction", null);
ActionEntityController = tslib_1.__decorate([
    tslib_1.__param(0, core_1.service(action_entity_service_1.ActionEntityService)),
    tslib_1.__metadata("design:paramtypes", [action_entity_service_1.ActionEntityService])
], ActionEntityController);
exports.ActionEntityController = ActionEntityController;
//# sourceMappingURL=action-entity.controller.js.map