claire-framework
Version:
- được viết bằng TypeScript - hỗ trợ websocket và HTTP request - hỗ trợ CLI để generate base project (claire-cli)
56 lines • 2.02 kB
TypeScript
import { AbstractDatabaseAdapter, HttpRequest } from "..";
export declare enum ConditionValueType {
/**
* Any string value. Constraint is a regex.
*/
STRING = 0,
/**
* Numerical value. Constraint is {from: number, to: number, integer: boolean} encoded into string.
*/
NUMBER = 1,
/**
* Yes or No. No constraint.
*/
BOOLEAN = 2,
/**
* An unlimited list of string values. Constraint is whether emptiness is allowed.
*/
LIST = 3,
/**
* A list of choices. Constraint is the list of choices.
*/
CHOICES = 4,
/**
* A list of mutual exclusive choices. Constraint is the list of choices.
*/
MUTEXCHOICES = 5
}
export interface ConditionPrototype {
/**
* Distinguishable name of this condition type.
*/
operator: string;
/**
* Type of condition value. This is to guide the frontend to better display the input.
*/
valueType: ConditionValueType;
/**
* Constraint for the condition value, encoded to string. This is to guide the frontend to better display the input.
*/
valueConstraint?: any;
}
export interface IAccessCondition<T extends any> {
getConditionPrototype(): ConditionPrototype;
validate(requestedValue: T, permittedValue: T): Promise<boolean>;
}
export declare abstract class AbstractAccessCondition<T extends any> implements IAccessCondition<T> {
protected databaseAdapter: AbstractDatabaseAdapter;
/**
* This resolver will resolve to the request value to be supplied to the validate function.
*/
requestedValueResolver: (request: HttpRequest, databaseAdapter: AbstractDatabaseAdapter) => Promise<T>;
protected constructor(requestedValueResolver: (request: HttpRequest, databaseAdapter: AbstractDatabaseAdapter) => Promise<T>);
abstract getConditionPrototype(): ConditionPrototype;
abstract validate(requestedValue: T, permittedValue: T): Promise<boolean>;
}
//# sourceMappingURL=AbstractAccessCondition.d.ts.map