@nucypher/taco
Version:
### [`nucypher/taco-web`](../../README.md)
39 lines • 1.9 kB
JavaScript
import { ContractCondition, ContractConditionType, } from './base/contract';
import { JsonApiCondition, JsonApiConditionType, } from './base/json-api';
import { JsonRpcCondition, JsonRpcConditionType, } from './base/json-rpc';
import { JWTCondition, JWTConditionType } from './base/jwt';
import { RpcCondition, RpcConditionType } from './base/rpc';
import { TimeCondition, TimeConditionType, } from './base/time';
import { CompoundCondition, CompoundConditionType, } from './compound-condition';
import { IfThenElseCondition, IfThenElseConditionType, } from './if-then-else-condition';
import { SequentialCondition, SequentialConditionType, } from './sequential';
const ERR_INVALID_CONDITION_TYPE = (type) => `Invalid condition type: ${type}`;
export class ConditionFactory {
static conditionFromProps(props) {
switch (props.conditionType) {
// Base Conditions
case RpcConditionType:
return new RpcCondition(props);
case TimeConditionType:
return new TimeCondition(props);
case ContractConditionType:
return new ContractCondition(props);
case JsonApiConditionType:
return new JsonApiCondition(props);
case JsonRpcConditionType:
return new JsonRpcCondition(props);
case JWTConditionType:
return new JWTCondition(props);
// Logical Conditions
case CompoundConditionType:
return new CompoundCondition(props);
case SequentialConditionType:
return new SequentialCondition(props);
case IfThenElseConditionType:
return new IfThenElseCondition(props);
default:
throw new Error(ERR_INVALID_CONDITION_TYPE(props.conditionType));
}
}
}
//# sourceMappingURL=condition-factory.js.map