@sourceloop/ctrl-plane-tenant-management-service
Version:
Tenant Management microservice for SaaS control plane
260 lines • 10.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TenantMgmtConfigController = void 0;
const tslib_1 = require("tslib");
const repository_1 = require("@loopback/repository");
const rest_1 = require("@loopback/rest");
const models_1 = require("../models");
const repositories_1 = require("../repositories");
const loopback4_authentication_1 = require("loopback4-authentication");
const loopback4_authorization_1 = require("loopback4-authorization");
const permissions_1 = require("../permissions");
const core_1 = require("@sourceloop/core");
const basePath = '/tenant-configs';
let TenantMgmtConfigController = class TenantMgmtConfigController {
constructor(tenantConfigRepository) {
this.tenantConfigRepository = tenantConfigRepository;
}
async create(tenantConfig) {
return this.tenantConfigRepository.create(tenantConfig);
}
async count(where) {
return this.tenantConfigRepository.count(where);
}
async find(filter) {
return this.tenantConfigRepository.find(filter);
}
async updateAll(tenantConfig, where) {
return this.tenantConfigRepository.updateAll(tenantConfig, where);
}
async findById(id, filter) {
return this.tenantConfigRepository.findById(id, filter);
}
async updateById(id, tenantConfig) {
await this.tenantConfigRepository.updateById(id, tenantConfig);
}
async replaceById(id, tenantConfig) {
await this.tenantConfigRepository.replaceById(id, tenantConfig);
}
async deleteById(id) {
await this.tenantConfigRepository.deleteById(id);
}
};
exports.TenantMgmtConfigController = TenantMgmtConfigController;
tslib_1.__decorate([
(0, loopback4_authorization_1.authorize)({
permissions: [permissions_1.PermissionKey.CreateTenantConfig],
}),
(0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, {
passReqToCallback: true,
}),
(0, rest_1.post)(basePath, {
security: core_1.OPERATION_SECURITY_SPEC,
responses: {
[200 /* STATUS_CODE.OK */]: {
description: 'Tenant Config model instance',
content: {
[core_1.CONTENT_TYPE.JSON]: { schema: (0, rest_1.getModelSchemaRef)(models_1.TenantMgmtConfig) },
},
},
},
}),
tslib_1.__param(0, (0, rest_1.requestBody)({
content: {
'application/json': {
schema: (0, rest_1.getModelSchemaRef)(models_1.TenantMgmtConfig, {
title: 'NewTenantConfig',
exclude: ['id'],
}),
},
},
})),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Object]),
tslib_1.__metadata("design:returntype", Promise)
], TenantMgmtConfigController.prototype, "create", null);
tslib_1.__decorate([
(0, loopback4_authorization_1.authorize)({
permissions: [permissions_1.PermissionKey.ViewTenantConfig],
}),
(0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, {
passReqToCallback: true,
}),
(0, rest_1.get)(`${basePath}/count`, {
security: core_1.OPERATION_SECURITY_SPEC,
responses: {
[200 /* STATUS_CODE.OK */]: {
description: 'Tenant Config model count',
content: { [core_1.CONTENT_TYPE.JSON]: { schema: repository_1.CountSchema } },
},
},
}),
tslib_1.__param(0, rest_1.param.where(models_1.TenantMgmtConfig)),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Object]),
tslib_1.__metadata("design:returntype", Promise)
], TenantMgmtConfigController.prototype, "count", null);
tslib_1.__decorate([
(0, loopback4_authorization_1.authorize)({
permissions: [permissions_1.PermissionKey.ViewTenantConfig],
}),
(0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, {
passReqToCallback: true,
}),
(0, rest_1.get)(basePath, {
security: core_1.OPERATION_SECURITY_SPEC,
responses: {
[200 /* STATUS_CODE.OK */]: {
description: 'Array of TenantConfig model instances',
content: {
[core_1.CONTENT_TYPE.JSON]: {
schema: {
type: 'array',
items: (0, rest_1.getModelSchemaRef)(models_1.TenantMgmtConfig, {
includeRelations: true,
}),
},
},
},
},
},
}),
tslib_1.__param(0, rest_1.param.filter(models_1.TenantMgmtConfig)),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Object]),
tslib_1.__metadata("design:returntype", Promise)
], TenantMgmtConfigController.prototype, "find", null);
tslib_1.__decorate([
(0, loopback4_authorization_1.authorize)({
permissions: [permissions_1.PermissionKey.UpdateTenantConfig],
}),
(0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, {
passReqToCallback: true,
}),
(0, rest_1.patch)(basePath, {
security: core_1.OPERATION_SECURITY_SPEC,
responses: {
[200 /* STATUS_CODE.OK */]: {
description: 'Tenant Config PATCH success',
content: {
[core_1.CONTENT_TYPE.JSON]: {
schema: (0, rest_1.getModelSchemaRef)(models_1.TenantMgmtConfig),
},
},
},
},
}),
tslib_1.__param(0, (0, rest_1.requestBody)({
content: {
'application/json': {
schema: (0, rest_1.getModelSchemaRef)(models_1.TenantMgmtConfig, { partial: true }),
},
},
})),
tslib_1.__param(1, rest_1.param.where(models_1.TenantMgmtConfig)),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [models_1.TenantMgmtConfig, Object]),
tslib_1.__metadata("design:returntype", Promise)
], TenantMgmtConfigController.prototype, "updateAll", null);
tslib_1.__decorate([
(0, loopback4_authorization_1.authorize)({
permissions: [permissions_1.PermissionKey.ViewTenantConfig],
}),
(0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, {
passReqToCallback: true,
}),
(0, rest_1.get)(`${basePath}/{id}`, {
security: core_1.OPERATION_SECURITY_SPEC,
responses: {
[200 /* STATUS_CODE.OK */]: {
description: 'Tenant Config model instance',
content: {
[core_1.CONTENT_TYPE.JSON]: { schema: (0, rest_1.getModelSchemaRef)(models_1.TenantMgmtConfig) },
},
},
},
}),
tslib_1.__param(0, rest_1.param.path.string('id')),
tslib_1.__param(1, rest_1.param.filter(models_1.TenantMgmtConfig, { exclude: 'where' })),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [String, Object]),
tslib_1.__metadata("design:returntype", Promise)
], TenantMgmtConfigController.prototype, "findById", null);
tslib_1.__decorate([
(0, loopback4_authorization_1.authorize)({
permissions: [permissions_1.PermissionKey.UpdateTenantConfig],
}),
(0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, {
passReqToCallback: true,
}),
(0, rest_1.patch)(`${basePath}/{id}`, {
security: core_1.OPERATION_SECURITY_SPEC,
responses: {
[204 /* STATUS_CODE.NO_CONTENT */]: {
description: 'Tenant Config PATCH success',
content: {
[core_1.CONTENT_TYPE.JSON]: {
schema: (0, rest_1.getModelSchemaRef)(models_1.TenantMgmtConfig),
},
},
},
},
}),
tslib_1.__param(0, rest_1.param.path.string('id')),
tslib_1.__param(1, (0, rest_1.requestBody)({
content: {
'application/json': {
schema: (0, rest_1.getModelSchemaRef)(models_1.TenantMgmtConfig, { partial: true }),
},
},
})),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [String, models_1.TenantMgmtConfig]),
tslib_1.__metadata("design:returntype", Promise)
], TenantMgmtConfigController.prototype, "updateById", null);
tslib_1.__decorate([
(0, loopback4_authorization_1.authorize)({
permissions: [permissions_1.PermissionKey.UpdateTenantConfig],
}),
(0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, {
passReqToCallback: true,
}),
(0, rest_1.put)(`${basePath}/{id}`, {
security: core_1.OPERATION_SECURITY_SPEC,
responses: {
[204 /* STATUS_CODE.NO_CONTENT */]: {
description: 'Tenant Config PUT success',
},
},
}),
tslib_1.__param(0, rest_1.param.path.string('id')),
tslib_1.__param(1, (0, rest_1.requestBody)()),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [String, models_1.TenantMgmtConfig]),
tslib_1.__metadata("design:returntype", Promise)
], TenantMgmtConfigController.prototype, "replaceById", null);
tslib_1.__decorate([
(0, loopback4_authorization_1.authorize)({
permissions: [permissions_1.PermissionKey.DeleteTenantConfig],
}),
(0, loopback4_authentication_1.authenticate)("bearer" /* STRATEGY.BEARER */, {
passReqToCallback: true,
}),
(0, rest_1.del)(`${basePath}/{id}`, {
security: core_1.OPERATION_SECURITY_SPEC,
responses: {
[204 /* STATUS_CODE.NO_CONTENT */]: {
description: 'Tenant DELETE success',
},
},
}),
tslib_1.__param(0, rest_1.param.path.string('id')),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [String]),
tslib_1.__metadata("design:returntype", Promise)
], TenantMgmtConfigController.prototype, "deleteById", null);
exports.TenantMgmtConfigController = TenantMgmtConfigController = tslib_1.__decorate([
tslib_1.__param(0, (0, repository_1.repository)(repositories_1.TenantMgmtConfigRepository)),
tslib_1.__metadata("design:paramtypes", [repositories_1.TenantMgmtConfigRepository])
], TenantMgmtConfigController);
//# sourceMappingURL=tenant-mgmt-config.controller.js.map