lambdaorm-base
Version:
35 lines • 1.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RouteService = void 0;
const domain_1 = require("../../domain");
class RouteService {
// eslint-disable-next-line no-useless-constructor
constructor(stageConfigService, exp) {
this.stageConfigService = stageConfigService;
this.exp = exp;
}
eval(source, info) {
if (source.condition === undefined)
return true;
return this.exp.eval(source.condition, info);
}
getSource(info, stage) {
// const contextInfo = this.getContextInfo(clauseInfo)
const _stage = this.stageConfigService.get(stage);
for (const i in _stage.sources) {
const source = _stage.sources[i];
if (source.condition === undefined) {
return source.name;
}
else {
const result = this.exp.eval(source.condition, info);
if (result) {
return source.name;
}
}
}
throw new domain_1.SchemaError(`Undefined data source on stage ${_stage.name}`);
}
}
exports.RouteService = RouteService;
//# sourceMappingURL=routeService.js.map