UNPKG

@crnk/angular-ngrx

Version:

Angular helper library for ngrx-json-api and crnk:

245 lines (244 loc) 7.95 kB
export interface Expression<T> { /** * @return true if the given object is a literal expression. */ isConstant(): boolean; /** * @return true if the given object is a path expression. */ isPath(): boolean; } export interface ExpressionAccessor { setExpression(expression: Expression<any>): any; } /** * Refers to a property of an object. */ export interface Path<T> extends Expression<T> { /** * @return string representation of this expression. */ toString(): string; /** * @return the value of this path if it is bound to an data object (see {@link BeanBinding}. */ getValue(): any; /** * Sets a new value for the given path. * * @param newValue */ setValue(value: any): any; /** * @return name to use for forFormElement elements to uniquely identity this path. This current corresponds * to toString, will later be extended to include resource$ identifiers to support complex forFormElement with * multiple editors (TODO). */ toFormName(): string; /** * Underlying resource holding the values. * * @returns {any} */ getResource(): any; /** * Pointer of this path from the resource. */ getSourcePointer(): String; /** * @returns {string} path used for sorting and filtering (excludes any 'relationships' and 'attributes' in the path) */ toQueryPath(): string; } export declare const OPERATION_EQ = "EQ"; export declare const OPERATION_NEQ = "NEQ"; export declare const OPERATION_LIKE = "LIKE"; export declare const OPERATION_GT = "GT"; export declare const OPERATION_LT = "LT"; export declare const OPERATION_GE = "GE"; export declare const OPERATION_LE = "LE"; /** * Base implementation for a {@link Expression} providing a EQ and NEQ operation. */ export declare class SimpleExpression<T> implements Expression<T> { eq(right: T): BooleanExpression; neq(right: T): BooleanExpression; isConstant(): boolean; isPath(): boolean; } /** * Base implementation for a {@link Expression} providing equals and compare operations. */ export declare abstract class ComparableExpression<T> extends SimpleExpression<T> { lt(right: T): BooleanExpression; le(right: T): BooleanExpression; gt(right: T): BooleanExpression; ge(right: T): BooleanExpression; } /** * Base implementation for {@link Expression} bound to a string. */ export declare abstract class StringExpression extends ComparableExpression<string> { like(right: string): BooleanExpression; } /** * Base implementation for {@link Expression} bound to a number. */ export declare abstract class NumberExpression extends ComparableExpression<number> { } /** * Base implementation for {@link Expression} bound to a boolean. */ export declare abstract class BooleanExpression extends ComparableExpression<boolean> { } /** * Represents a boolean operation comparing two expressions with the provided operation. */ export declare class BooleanOperation extends BooleanExpression { operation: string; expressions: Expression<any>[]; constructor(operation: string, left: Expression<any>, right: Expression<any>); } /** * Helper methods to create expressions. */ export declare class ExpressionFactory { static toBeanPath<T>(object: any, attributeNames: Array<string>): BeanPath<any>; static toLiteral<T>(value: any): Constant<T>; static concat(parent: Expression<any>, value1: string): string; } /** * Represents a constant expression. */ export interface Constant<T> extends Expression<T> { value: T; } export declare class BooleanConstant extends BooleanExpression implements Constant<boolean> { value: boolean; constructor(value: boolean); isConstant(): boolean; toString(): string; } export declare class NumberConstant extends NumberExpression implements Constant<number> { value: number; constructor(literal: number); isConstant(): boolean; toString(): string; } export declare class StringConstant extends StringExpression implements Constant<string> { value: string; constructor(value: string); isConstant(): boolean; toString(): string; } /** * Represents a path accessing a object property. */ export declare class BeanPath<T> extends SimpleExpression<T> implements Path<T> { parentPath: BeanPath<any>; private property; constructor(parentPath: BeanPath<any>, property?: string); protected add<P extends Path<any>>(path: P): P; protected createString(property: string): StringPath; protected createBoolean(property: string): BooleanPath; protected createNumber(property: string): NumberPath; toString(): string; isPath(): boolean; getValue(): any; setValue(newValue: any): any; getResource(): any; toFormName(): string; getSourcePointer(): string; toQueryPath(): string; } /** * Represents a path accessing a string property. */ export declare class StringPath extends StringExpression implements Path<string> { private parent; private property; constructor(parent: BeanPath<any>, property: string); toString(): string; isPath(): boolean; getValue(): any; setValue(newValue: any): Error; toFormName(): string; getResource(): any; getSourcePointer(): string; toQueryPath(): string; } export declare class ArrayPath<Q extends Expression<T>, T> extends SimpleExpression<Array<T>> implements Path<Array<T>> { private parent; private property; private _referenceType; constructor(parent: BeanPath<any>, property: string, _referenceType: new (...args: any[]) => Q); getElement(index: number): Q; toString(): string; isPath(): boolean; isConstant(): boolean; getValue(): any; setValue(newValue: any): Error; toFormName(): string; getResource(): any; getSourcePointer(): string; toQueryPath(): string; } export declare class MapPath<Q extends Expression<T>, T> extends SimpleExpression<Array<T>> implements Path<Array<T>> { private parent; private property; private _referenceType; constructor(parent: BeanPath<any>, property: string, _referenceType: new (...args: any[]) => Q); getElement(key: any): Q; toString(): string; isPath(): boolean; isConstant(): boolean; getValue(): any; setValue(newValue: any): Error; toFormName(): string; getResource(): any; getSourcePointer(): string; toQueryPath(): string; } /** * Represents a path accessing a number property. */ export declare class NumberPath extends NumberExpression implements Path<number> { private parent; private property; constructor(parent: BeanPath<any>, property: string); toString(): string; isPath(): boolean; getValue(): any; setValue(newValue: any): Error; toFormName(): string; getResource(): any; getSourcePointer(): string; toQueryPath(): string; } /** * Represents a path accessing a boolean property. */ export declare class BooleanPath extends BooleanExpression implements Path<boolean> { private parent; private property; constructor(parent: BeanPath<any>, property: string); toString(): string; isPath(): boolean; getValue(): any; setValue(newValue: any): Error; toFormName(): string; getResource(): any; getSourcePointer(): string; toQueryPath(): string; } /** * Represents a direct refresh to object. Sits at the root of an expression chain. */ export declare class BeanBinding extends BeanPath<any> { bean: any; constructor(bean: any); toString(): string; getValue(): any; setValue(value: any): void; getResource(): any; }