@vulcan-sql/core
Version:
Core package of VulcanSQL
36 lines • 1.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProfileLoader = void 0;
const tslib_1 = require("tslib");
const options_1 = require("../../../options/index");
const types_1 = require("../../../containers/types");
const inversify_1 = require("inversify");
const lodash_1 = require("lodash");
let ProfileLoader = class ProfileLoader {
constructor(profileReaderFactory, profilesLookupOptions) {
this.profileReaderFactory = profileReaderFactory;
this.profilesLookupOptions = profilesLookupOptions;
}
getProfiles() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const profiles = yield Promise.all(this.profilesLookupOptions.getLookups().map((lookup) => tslib_1.__awaiter(this, void 0, void 0, function* () {
const reader = this.profileReaderFactory(lookup.type);
yield reader.activate();
return reader.read(lookup.options);
})));
return (0, lodash_1.chain)(profiles)
.flatten()
.uniqBy((profile) => profile.name)
.reduce((prev, curr) => prev.set(curr.name, curr), new Map())
.value();
});
}
};
ProfileLoader = tslib_1.__decorate([
(0, inversify_1.injectable)(),
tslib_1.__param(0, (0, inversify_1.inject)(types_1.TYPES.Factory_ProfileReader)),
tslib_1.__param(1, (0, inversify_1.inject)(types_1.TYPES.ProfilesLookupOptions)),
tslib_1.__metadata("design:paramtypes", [Function, options_1.ProfilesLookupOptions])
], ProfileLoader);
exports.ProfileLoader = ProfileLoader;
//# sourceMappingURL=profileLoader.js.map