Skip to content

routier-collection


routier-collection / core/src / ValueExpression

Class: ValueExpression ​

Defined in: core/src/expressions/types.ts:405

A class representing a literal value.

Extends ​

Constructors ​

Constructor ​

new ValueExpression(options): ValueExpression

Defined in: core/src/expressions/types.ts:411

Parameters ​

options ​
value ​

unknown

Returns ​

ValueExpression

Overrides ​

Expression.constructor

Properties ​

left? ​

optional left: Expression

Defined in: core/src/expressions/types.ts:123

The left-hand side of the expression (if applicable).

Inherited from ​

Expression.left


optional right: Expression

Defined in: core/src/expressions/types.ts:125

The right-hand side of the expression (if applicable).

Inherited from ​

Expression.right


type ​

readonly type: "value"

Defined in: core/src/expressions/types.ts:407

The type of the expression (always 'value').

Overrides ​

Expression.type


value ​

value: unknown

Defined in: core/src/expressions/types.ts:409

The literal value.

Accessors ​

EMPTY ​

Get Signature ​

get static EMPTY(): EmptyExpression

Defined in: core/src/expressions/types.ts:132

Returns ​

EmptyExpression

Inherited from ​

Expression.EMPTY


NOT_PARSABLE ​

Get Signature ​

get static NOT_PARSABLE(): NotParsableExpression

Defined in: core/src/expressions/types.ts:136

Returns ​

NotParsableExpression

Inherited from ​

Expression.NOT_PARSABLE

Methods ​

notParsable() ​

static notParsable(reason): NotParsableExpression

Defined in: core/src/expressions/types.ts:141

NOT_PARSABLE, carrying what the parser refused.

Parameters ​

reason ​

string

Returns ​

NotParsableExpression

Inherited from ​

Expression.notParsable


isEmpty() ​

static isEmpty(expression): boolean

Defined in: core/src/expressions/types.ts:145

Parameters ​

expression ​

Expression

Returns ​

boolean

Inherited from ​

Expression.isEmpty


isNotParsable() ​

static isNotParsable(expression): boolean

Defined in: core/src/expressions/types.ts:149

Parameters ​

expression ​

Expression

Returns ​

boolean

Inherited from ​

Expression.isNotParsable


toJson() ​

static toJson(expression): SerializedExpression

Defined in: core/src/expressions/types.ts:175

Turns a tree into plain JSON, so a whole query can cross a wire.

On the class rather than beside it, because this is the type's own REPRESENTATION — there is one right answer and it belongs with the thing being represented, next to EMPTY and isEmpty. Rendering a tree into some other language (toSql, toMql, evaluate) is a different kind of thing: there are many, each belongs to its consumer, and none of them is canonical.

Why it is this small ​

Of the seven node types a bound tree can contain, exactly one holds anything JSON cannot carry: PropertyExpression, whose live PropertyInfo has functions, a parent chain and caches. It reduces to a property PATH — PropertyInfo.id IS the dotted path, and getProperty is keyed by exactly that — so rebinding is one lookup.

ParamReferenceExpression never appears: it is a parse-time placeholder that binding replaces with a plain ValueExpression holding the resolved value. A serialized tree is always already bound, so there is no params object to send alongside it.

Switches on type rather than using the isXExpression guards, which live in ../assertions and import this module — the guards test the same discriminant, so nothing is lost.

Parameters ​

expression ​

Expression

Returns ​

SerializedExpression

Inherited from ​

Expression.toJson


fromJson() ​

static fromJson(json, schema): Expression

Defined in: core/src/expressions/types.ts:252

Rebuilds a tree from JSON, rebinding every property against schema.

The schema is SUPPLIED rather than read out of the payload. A filter always belongs to a known collection, and the RECEIVER's schema is the authority on what its properties are — taking an id from the payload would mean rebinding against a schema the sender chose, which is backwards for anything crossing a trust boundary.

Parameters ​

json ​

SerializedExpression

schema ​

CompiledSchemaCore<any>

Returns ​

Expression

Throws ​

when a property path is not declared by schema. Not NOT_PARSABLE: on a receiver, a filter that silently stops filtering returns rows the requester excluded, which is the one failure here worse than an error.

Inherited from ​

Expression.fromJson

Released under the MIT License.