UNPKG

@sourceloop/ctrl-plane-orchestrator-service

Version:
56 lines 2.39 kB
"use strict"; 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 rest_1 = require("@loopback/rest"); const core_2 = require("@sourceloop/core"); const loopback4_message_bus_connector_1 = require("loopback4-message-bus-connector"); let OrchestratorServiceComponent = class OrchestratorServiceComponent { constructor(application) { this.application = application; this.providers = {}; this.controllers = []; this.bindings = []; application.component(core_2.CoreComponent); application.component(loopback4_message_bus_connector_1.EventStreamConnectorComponent); // Bind Providers if not provided by consumer of the component this.bindProviders({ [types_1.OrchestratorServiceBindings.TIER_DETAILS_PROVIDER.key]: services_1.TierDetailsProvider, }); // Bind Service Classes if not provided by consumer of the component this.bindServiceClasses({ [types_1.OrchestratorServiceBindings.BUILDER_SERVICE.key]: services_1.BuilderService, }); } 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