@sourceloop/ctrl-plane-orchestrator-service
Version:
ARC SaaS Orchestrator service.
66 lines • 3.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrchestratorServiceComponent = void 0;
const tslib_1 = require("tslib");
const core_1 = require("@loopback/core");
const types_1 = require("./services/types");
const services_1 = require("./services");
const controllers_1 = require("./controllers");
const rest_1 = require("@loopback/rest");
const logging_1 = require("@loopback/logging");
let OrchestratorServiceComponent = class OrchestratorServiceComponent {
constructor(application) {
this.application = application;
this.providers = {};
this.controllers = [];
this.bindings = [];
application.configure(logging_1.LoggingBindings.COMPONENT).to({
enableFluent: false,
enableHttpAccessLog: true,
});
application.component(logging_1.LoggingComponent);
// Bind Providers if not provided by consumer of the component
this.bindProviders({
[types_1.OrchestratorServiceBindings.TIER_DETAILS_PROVIDER.key]: services_1.TierDetailsProvider,
[types_1.OrchestratorServiceBindings.TENANT_PROVISIONING_HANDLER.key]: services_1.TenantProvisioningHandlerProvider,
[types_1.OrchestratorServiceBindings.TENANT_DEPROVISIONING_HANDLER.key]: services_1.TenantDeprovisioningHandlerProvider,
[types_1.OrchestratorServiceBindings.TENANT_PROVISIONING_SUCCESS_HANDLER.key]: services_1.TenantProvisioningSuccessHandlerProvider,
[types_1.OrchestratorServiceBindings.TENANT_PROVISIONING_FAILURE_HANDLER.key]: services_1.TenantProvisioningFailureHandlerProvider,
[types_1.OrchestratorServiceBindings.TENANT_DEPLOYMENT_HANDLER.key]: services_1.TenantDeploymentHandlerProvider,
});
// Bind Service Classes if not provided by consumer of the component
this.bindServiceClasses({
[types_1.OrchestratorServiceBindings.ORCHESTRATOR_SERVICE.key]: services_1.OrchestratorService,
[types_1.OrchestratorServiceBindings.BUILDER_SERVICE.key]: services_1.BuilderService,
});
this.controllers = [controllers_1.EventController];
}
bindProviders(providersObject) {
for (const key in providersObject) {
this.addProviderIfNotPresent(key, providersObject[key]);
}
}
bindServiceClasses(serviceObject) {
for (const key in serviceObject) {
this.addClassBindingIfNotPresent(key, serviceObject[key]);
}
}
addClassBindingIfNotPresent(key, cls) {
if (!this.application.isBound(key)) {
this.bindings.push((0, core_1.createBindingFromClass)(cls, {
key: key,
}));
}
}
addProviderIfNotPresent(key, provider) {
if (!this.application.isBound(key)) {
this.providers[key] = provider;
}
}
};
exports.OrchestratorServiceComponent = OrchestratorServiceComponent;
exports.OrchestratorServiceComponent = OrchestratorServiceComponent = tslib_1.__decorate([
tslib_1.__param(0, (0, core_1.inject)(core_1.CoreBindings.APPLICATION_INSTANCE)),
tslib_1.__metadata("design:paramtypes", [rest_1.RestApplication])
], OrchestratorServiceComponent);
//# sourceMappingURL=component.js.map