@wootapa/polygraph-ol
Version:
Extension of @wootapa/polygraph for OpenLayers 7+.
322 lines (321 loc) • 9.16 kB
TypeScript
import { IComparison } from './comparison';
import { ClassDict, IPolygraphOpts, IDictionary, IJsonDump, IReportSummary, IRuntimeOperatorCallback, Primitive, PrimitiveThing } from './contracts';
import { Logical } from './logical';
export interface IPolygraph {
}
export declare abstract class PolygraphBase<T extends PolygraphBase<T>> implements IPolygraph, IComparison<T> {
protected _logical: Logical;
protected _this: T;
protected abstract _getPolygraph(): T;
protected abstract _getClassDict(): ClassDict;
protected abstract _setConfiguration(config: IPolygraphOpts): void;
protected abstract _getConfiguration(): IPolygraphOpts;
constructor();
/**
* Creates new polygraph from JSON.
*
* @param json - JSON (or stringified) output from an polygraph
* @returns Polygraph
*/
static fromJson<T extends PolygraphBase<T>>(this: {
new (): T;
}, json: IJsonDump | string): T;
/**
* Creates a new polygraph with a root `and` operator (True when all child operators are true).
*
* @returns Polygraph
*/
static and<T extends PolygraphBase<T>>(this: {
new (): T;
}): T;
/**
* Creates a new polygraph with a root `or` operator (True when any child operator is true).
*
* @returns Polygraph
*/
static or<T extends PolygraphBase<T>>(this: {
new (): T;
}): T;
/**
* Creates a new polygraph with a root `not` operator (True when all child operators are false).
*
* @returns Polygraph
*/
static not<T extends PolygraphBase<T>>(this: {
new (): T;
}): T;
/**
* Defines a custom operator.
*
* @param alias - The name of the operator
* @param func - The function to be called
*/
static define<T extends PolygraphBase<T>>(alias: string, func: IRuntimeOperatorCallback): void;
/**
* Returns array of all operator aliases.
*
* @returns All operator aliases
*/
static getOperatorAlias(): string[];
/**
* Serializes polygraph as JSON.
*
* @returns polygraph as JSON
*/
asJson(): IJsonDump;
/**
* Returns polygraph as a human readable tree.
*
* @returns polygraph as a human readable tree
*/
asTree(): string;
/**
* Returns a report with evaluation statistics.
*
* @returns A report with evaluation statistics
*/
getReport(): IReportSummary;
/**
* Resets report statistics.
*
* @returns Polygraph
*/
resetReport(): T;
/**
* Evaluates object.
*
* @param obj - The object to evaluate
*
* @returns True if object passed all child operators
*/
evaluate(obj: PrimitiveThing): boolean;
/**
* Clears all operators in current logical and below.
*
* @returns Polygraph
*/
clear(): T;
/**
* Moves to root logical.
*
* @returns Polygraph
*/
done(): T;
/**
* Moves to parent logical (if any).
*
* @returns Polygraph
*/
up(): T;
/**
* Moves to first child logical.
*
* @returns Polygraph
*/
down(): T;
/**
* Moves to next logical sibling (if any).
*
* @returns Polygraph
*/
next(): T;
/**
* Moves to previous logical sibling (if any).
*
* @returns Polygraph
*/
prev(): T;
/**
* Returns a clone of polygraph.
*
* @returns A new Polygraph
*/
clone(): T;
/**
* Adds another polygraph.
*
* @param polygraph - The polygraph to add
*
* @returns Polygraph
*/
addPolygraph(polygraph: T): T;
/**
* Returns keys and values for non logical operators.
*
* @returns Keys and values for non logical operators
*/
getKeysAndValues(): IDictionary<Primitive>;
/**
* Returns true when all child operators are true.
*
* @returns Polygraph
*/
and(): T;
/**
* Returns true when at least one child operator is true.
*
* @returns Polygraph
*/
or(): T;
/**
* Returns true when all child operators are false.
*
* @returns Polygraph
*/
not(): T;
/**
* Returns true when object[key] is equal to value.
*
* @param key - The key/property to evaluate
* @param value - The value to compare
*
* @returns Polygraph
*/
equals(key: string, value: PrimitiveThing): T;
/**
* Returns true when object[key] is equal to value.
*
* @param key - The key/property to evaluate
* @param value - The value to compare
*
* @returns Polygraph
*/
eq(key: string, value: PrimitiveThing): T;
/**
* Returns true when object[key] is null or undefined.
*
* @param key - The key/property to evaluate
*
* @returns Polygraph
*/
isNull(key: string): T;
/**
* Returns true when object[key] is greater than value.
*
* @param key - The key/property to evaluate
* @param value - The value to compare
*
* @returns Polygraph
*/
greaterThan(key: string, value: PrimitiveThing): T;
/**
* Returns true when object[key] is greater than value.
*
* @param key - The key/property to evaluate
* @param value - The value to compare
*
* @returns Polygraph
*/
gt(key: string, value: PrimitiveThing): T;
/**
* Returns true when object[key] is greater or equal to value.
*
* @param key - The key/property to evaluate
* @param value - The value to compare
*
* @returns Polygraph
*/
greaterThanEquals(key: string, value: PrimitiveThing): T;
/**
* Returns true when object[key] is greater or equal to value.
*
* @param key - The key/property to evaluate
* @param value - The value to compare
*
* @returns Polygraph
*/
gte(key: string, value: PrimitiveThing): T;
/**
* Returns true when object[key] is less than value.
*
* @param key - The key/property to evaluate
* @param value - The value to compare
*
* @returns Polygraph
*/
lessThan(key: string, value: PrimitiveThing): T;
/**
* Returns true when object[key] is less than value.
*
* @param key - The key/property to evaluate
* @param value - The value to compare
*
* @returns Polygraph
*/
lt(key: string, value: PrimitiveThing): T;
/**
* Returns true when object[key] is less or equal to value.
*
* @param key - The key/property to evaluate
* @param value - The value to compare
*
* @returns Polygraph
*/
lessThanEquals(key: string, value: PrimitiveThing): T;
/**
* Returns true when object[key] is less or equal to value.
*
* @param key - The key/property to evaluate
* @param value - The value to compare
*
* @returns Polygraph
*/
lte(key: string, value: PrimitiveThing): T;
/**
* Returns true when object[key] is similar to value.
* Case sensitive.
*
* @param key - The key/property to evaluate
* @param value - The value/pattern to compare
*
* @returns Polygraph
*/
like(key: string, value: PrimitiveThing): T;
/**
* Returns true when object[key] is similar to value.
* Case insensitive.
*
* @param key - The key/property to evaluate
* @param value - The value/pattern to compare
*
* @returns Polygraph
*/
ilike(key: string, value: PrimitiveThing): T;
/**
* Returns true when object[key] is found in values.
*
* @param key - The key/property to evaluate
* @param values - The values to compare
*
* @returns Polygraph
*/
any(key: string, values: Primitive[]): T;
/**
* Adds an operator by its alias
*
* @param alias - Alias of the operator
* @param key - The key/property to evaluate
* @param value - Optional value to compare
* @param opts - Optional operator options
*
* @returns Polygraph
*/
operator(alias: string, key: string, value?: PrimitiveThing, opts?: unknown): T;
/**
* Adds an operator by its alias
*
* @param alias - Alias of the operator
* @param key - The key/property to evaluate
* @param value - Optional value to compare
* @param opts - Optional operator options
*
* @returns Polygraph
*/
op(alias: string, key: string, value?: PrimitiveThing, opts?: unknown): T;
}
export declare class PolygraphCore extends PolygraphBase<PolygraphCore> {
protected _setConfiguration(): void;
protected _getConfiguration(): IPolygraphOpts;
protected _getClassDict(): ClassDict;
protected _getPolygraph(): PolygraphCore;
}