@vulcan-sql/build
Version:
VulcanSQL package for building projects
38 lines • 1.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CheckProfile = void 0;
const tslib_1 = require("tslib");
const middleware_1 = require("./middleware");
const core_1 = require("@vulcan-sql/core");
const inversify_1 = require("inversify");
let CheckProfile = class CheckProfile extends middleware_1.SchemaParserMiddleware {
constructor(dataSourceFactory) {
super();
this.dataSourceFactory = dataSourceFactory;
}
handle(schemas, next) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (!schemas.profiles && schemas.profile) {
schemas.profiles = [schemas.profile];
}
yield next();
const transformedSchemas = schemas;
if (!transformedSchemas.profiles)
throw new core_1.ConfigurationError(`The profile of schema ${transformedSchemas.urlPath} is not defined`);
for (const profile of transformedSchemas.profiles) {
try {
this.dataSourceFactory(profile);
}
catch (e) {
throw new core_1.ConfigurationError(`The profile ${profile} of schema ${transformedSchemas.urlPath} is invalid: ${e === null || e === void 0 ? void 0 : e.message}`);
}
}
});
}
};
CheckProfile = tslib_1.__decorate([
tslib_1.__param(0, (0, inversify_1.inject)(core_1.TYPES.Factory_DataSource)),
tslib_1.__metadata("design:paramtypes", [Function])
], CheckProfile);
exports.CheckProfile = CheckProfile;
//# sourceMappingURL=checkProfile.js.map