adaptive-expressions package

Classes

Abs

Returns the absolute value of the specified number.

Accessor

Used to access the variable value corresponding to the path.

Add

Return the result from adding two or more numbers (pure number case) or concatting two or more strings (other case).

AddDays

Add a number of days to a timestamp.

AddHours

Add a number of hours to a timestamp.

AddMinutes

Add a number of minutes to a timestamp.

AddOrdinal

Return the ordinal number of the input number.

AddProperty

Add a property and its value, or name-value pair, to a JSON object, and return the updated object. If the object already exists at runtime the function throws an error.

AddSeconds

Add a number of seconds to a timestamp.

AddToTime

Add a number of time units to a timestamp.

All

Determines whether all elements of a sequence satisfy a condition.

And

Return true if all expressions are true or return false if at least one expression is false.

Any

Determines whether any element of a sequence satisfies a condition.

Average

Return the average of a numeric array.

Base64

Return the base64-encoded version of a string or byte array.

Base64ToBinary

Return the binary array of a base64-encoded string.

Base64ToString

Return the string version of a base64-encoded string, effectively decoding the base64 string.

Binary

Return the binary version of a string.

Bool

Return the Boolean version of a value.

Ceiling

Returns the smallest integral value that is greater than or equal to the specified number.

Coalesce

Return the first non-null value from one or more parameters. Empty strings, empty arrays, and empty objects are not null.

ComparisonEvaluator

Comparison operators. A comparison operator returns false if the comparison is false, or there is an error. This prevents errors from short-circuiting boolean expressions.

Concat

Combine two or more strings, and return the combined string.

Contains

Check whether a collection has a specific item. Return true if the item is found, or return false if not found. This function is case-sensitive.

ConvertFromUTC

Convert a timestamp from Universal Time Coordinated (UTC) to a target time zone.

ConvertToUTC

Convert a timestamp to Universal Time Coordinated (UTC) from the source time zone.

Count

Return the number of items in a collection.

CountWord

Return the number of words in a string.

CreateArray

Return an array from multiple inputs.

DataUri

Return a data uniform resource identifier (URI) of a string.

DataUriToBinary

Return the binary version of a data uniform resource identifier (URI).

DataUriToString

Return the string version of a data uniform resource identifier (URI).

DateFunc

Return the date of a specified timestamp in m/dd/yyyy format.

DateReadBack

Uses the date-time library to provide a date readback.

DateTimeDiff

Return a number of ticks that the two timestamps differ.

DayOfMonth

Return the day of the month from a timestamp.

DayOfWeek

Return the day of the week from a timestamp.

DayOfYear

Return the day of the year from a timestamp.

Divide

Return the integer result from dividing two numbers.

Element

The indexing operator ([ ]) selects a single element from a sequence. Support number index for list or string index for object.

Empty

Check whether an instance is empty. Return true if the input is empty. Empty means: 1.Input is null or undefined. 2.Input is a null or empty string. 3.Input is zero size collection. 4.Input is an object with no property.

EndsWith

Check whether a string ends with a specific substring. Return true if the substring is found, or return false if not found. This function is case-insensitive.

EOL

Return the newline string according to the environment.

Equal

Check whether both values, expressions, or objects are equivalent. Return true if both are equivalent, or return false if they're not equivalent.

Exists

Evaluates an expression for truthiness.

First

Return the first item from a string or array.

Flatten

Flatten an array into non-array values. You can optionally set the maximum depth to flatten to.

Float

Convert the string version of a floating-point number to a floating-point number.

Floor

Returns the largest integer less than or equal to the specified number.

Foreach

Operate on each element and return the new collection.

FormatDateTime

Return a timestamp in the specified format. Format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

FormatEpoch

Return a timestamp in the specified format from UNIX time (also know as Epoch time, POSIX time, UNIX Epoch time).

FormatNumber

Format number into required decimal numbers.

FormatTicks

Return a timestamp in the specified format from ticks.

GetFutureTime

Return the current timestamp plus the specified time units.

GetNextViableDate

Return the next viable date of a timex expression based on the current date and user's timezone.

GetNextViableTime

Return the next viable time of a timex expression based on the current time and user's timezone.

GetPastTime

Return the current timestamp minus the specified time units.

GetPreviousViableDate

Return the previous viable date of a timex expression based on the current date and user's timezone.

GetPreviousViableTime

Return the previous viable time of a timex expression based on the current time and user's timezone.

GetProperty

Retrieve the value of the specified property from the JSON object.

GetTimeOfDay

Returns time of day for a given timestamp.

GreaterThan

Check whether the first value is greater than the second value. Return true if the first value is more, or return false if less.

GreaterThanOrEqual

Check whether the first value is greater than or equal to the second value. Return true when the first value is greater or equal, or return false if the first value is less.

If

Check whether an expression is true or false. Based on the result, return a specified value.

Ignore

Mark a clause so that MostSpecificSelector will ignore it. MostSpecificSelector considers A & B to be more specific than A, but some clauses are unique and incomparable.

IndexOf

Returns the index of the first occurrence of a value in an array. The zero-based index position of value if that value is found, or -1 if it is not.

IndicesAndValues

Turn an array or object into an array of objects with index and value properties. For arrays, the index is the position in the array. For objects, it is the key for the value.

Int

Return the integer version of a string.

Intersection

Return a collection that has only the common items across the specified collections. To appear in the result, an item must appear in all the collections passed to this function. If one or more items have the same name, the last item with that name appears in the result.

IsArray

Return true if a given input is an array.

IsBoolean

Return true if a given input is a Boolean.

IsDate

Return true if a given TimexProperty or timex string refers to a valid date. Valid dates contain the month and dayOfMonth, or contain the dayOfWeek.

IsDateRange

Return true if a given TimexProperty or Timex expression refers to a valid date range.

IsDateTime

Return true if a given input is a UTC ISO format (YYYY-MM-DDTHH:mm:ss.fffZ) timestamp string.

IsDefinite

Return true if a given TimexProperty or Timex expression refers to a valid date. Valid dates contain the year, month and dayOfMonth.

IsDuration

Return true if a given TimexProperty or Timex expression refers to a valid duration.

IsFloat

Return true if a given input is a floating-point number. Due to the alignment between C# and JavaScript, a number with an non-zero residue of its modulo 1 will be treated as a floating-point number.

IsInteger

Return true if a given input is an integer number. Due to the alignment between C# and JavaScript, a number with a zero residue of its modulo 1 will be treated as an integer number.

IsMatch

Return true if a given string matches a specified regular expression pattern.

IsObject

Return true if a given input is a complex object or return false if it is a primitive object. Primitive objects include strings, numbers, and Booleans; complex types, contain properties.

IsPresent

Return true if a given TimexProperty or Timex expression refers to the present.

IsString

Return true if a given input is a string.

IsTime

Return true if a given TimexProperty or Timex expression refers to a valid time. Valid time contains hours, minutes and seconds.

IsTimeRange

Return true if a given TimexProperty or Timex string refers to a valid time range Valid time ranges contain partOfDay.

JPath

Check JSON or a JSON string for nodes or values that match a path expression, and return the matching nodes.

Join

Return a string that has all the items from an array, with each character separated by a delimiter.

Json

Return the JavaScript Object Notation (JSON) type value or object of a string or XML.

JsonStringify

Return the string version of a value.

Last

Return the last item from a collection.

LastIndexOf

Returns the index of the last occurrence of a specified value in an array. The zero-based index position of value if that value is found, or -1 if it is not.

Length

Return the length of a string.

LessThan

Check whether the first value is less than the second value. Return true if the first value is less, or return false if the first value is more.

LessThanOrEqual

Check whether the first value is less than or equal to the second value. Return true if the first value is less than or equal, or return false if the first value is more.

Max

Return the highest value from an array. The array is inclusive at both ends.

Merge

Merge multiple object(json) into one object(json). If the item is array, the elements of the array are merged as well.

Min

Return the lowest value from a set of numbers in an array.

Mod

Return the remainder from dividing two numbers.

Month

Return the month of the specified timestamp.

Multiply

Return the product from multiplying any number of numbers.

MultivariateNumericEvaluator

Numeric operators that can have 2 or more args.

NewGuid

Return a new Guid string.

Not

Check whether an expression is false. Return true if the expression is false, or return false if true.

NotEqual

Return true if the two items are not equal.

NumberTransformEvaluator

Evaluator that transforms a number to another number.

NumericEvaluator

Numeric operators that can have 1 or more args.

Optional

For the MostSpecificSelector, this is a short hand so that instead of having to do A & B || A you can do A & optional(B) to mean the same thing.

Or

Check whether at least one expression is true. Return true if at least one expression is true, or return false if all are false.

Power

Return exponentiation of one number to another.

Rand

Return a random integer from a specified range, which is inclusive only at the starting end.

Range

Return an integer array that starts from a specified integer with the given length.

RemoveProperty

Remove a property from an object and return the updated object.

Replace

Replace a substring with the specified string, and return the result string. This function is case-sensitive.

ReplaceIgnoreCase

Replace a substring with the specified string, and return the result string. This function is case-insensitive.

Reverse

Reverses the order of the elements in a String or Array.

Round

Rounds a number value to the nearest integer.

Select

Operate on each element and return the new collection of transformed elements.

SentenceCase

Capitalizing only the first word and leave others lowercase.

SetPathToValue

Set path in a JSON object to value.

SetProperty

Set the value of an object's property and return the updated object.

Skip

Remove items from the front of a collection, and return all the other items.

SortBy

Sort elements in the collection in ascending order and return the sorted collection.

SortByDescending

Sort elements in the collection in descending order, and return the sorted collection.

Split

Return an array that contains substrings, separated by commas, based on the specified delimiter character in the original string.

Sqrt

Returns the square root of a specified number.

StartOfDay

Return the start of the day for a timestamp.

StartOfHour

Return the start of the hour for a timestamp.

StartOfMonth

Return the start of the month for a timestamp.

StartsWith

Check whether a string starts with a specific substring. Return true if the substring is found, or return false if not found. This function is case-insensitive.

String

Return the string version of a value.

StringOrValue

Wrap string interpolation to get real value. For example: stringOrValue('${1}'), would get number 1 stringOrValue('${1} item'), would get string "1 item".

StringTransformEvaluator

Evaluator that transforms a string to another string.

SubArray

Returns a subarray from specified start and end positions. Index values start with the number 0.

Substring

Return characters from a string, starting from the specified position or index. Index values start with the number 0.

Subtract

Return the result from subtracting the next number from the previous number.

SubtractFromTime

Subtract a number of time units from a timestamp.

Sum

Return the result from adding numbers in an array.

Take

Return items from the front of an array or take the specific prefix from a string.

Ticks

Return the ticks property value of a specified timestamp. A tick is 100-nanosecond interval.

TicksToDays

Convert ticks to number of days.

TicksToHours

Convert ticks to number of hours.

TicksToMinutes

Convert ticks to number of minutes.

TimeTransformEvaluator

Evaluator that transforms a datetime to another datetime.

TimexResolve

Return true if a given TimexProperty or Timex expression refers to a valid time.

TitleCase

Converts the specified string to title case.

ToLower

Return a string in lowercase format. If a character in the string doesn't have a lowercase version, that character stays unchanged in the returned string.

ToUpper

Return a string in uppercase format. If a character in the string doesn't have an uppercase version, that character stays unchanged in the returned string.

Trim

Remove leading and trailing whitespace from a string, and return the updated string.

Union

Return a collection that has all the items from the specified collections. To appear in the result, an item can appear in any collection passed to this function. If one or more items have the same name, the last item with that name appears in the result.

Unique

Remove all duplicates from an array.

UriComponent

Return the binary version of a uniform resource identifier (URI) component.

UriComponentToString

Return the string version of a uniform resource identifier (URI) encoded string, effectively decoding the URI-encoded string.

UriHost

Return the host value of a unified resource identifier (URI).

UriPath

Return the path value of a unified resource identifier (URI).

UriPathAndQuery

Return the path and query value of a unified resource identifier (URI).

UriPort

Return the port value of a unified resource identifier (URI).

UriQuery

Return the query value of a unified resource identifier (URI).

UriScheme

Return the scheme value of a unified resource identifier (URI).

UtcNow

Return the current timestamp.

Where

Filter on each element and return the new collection of filtered elements which match a specific condition.

XML

Return the newline string according to the environment.

XPath

Return the newline string according to the environment.

Year

Return the year of the specified timestamp.

CommonRegex

Convert PCRE regex string to RegExp PCRE ref: http://www.pcre.org/. PCRE antlr g4 file: CommonRegex.g4.

Constant

Construct an expression constant.

ArrayExpressionConverter

array to json ArrayExpression converter.

BoolExpressionConverter

any value to json BoolExpression converter.

EnumExpressionConverter

string to json EnumExpression converter.

ExpressionConverter

string to json Expression converter.

IntExpressionConverter

string or number to json IntExpression converter.

NumberExpressionConverter

string or number to json NumberExpression converter.

ObjectExpressionConverter

any value to json ObjectExpressionConverter converter.

StringExpressionConverter

string to json StringExpression converter.

ValueExpressionConverter

any value to json ValueExpression converter.

Expression

An expression which can be analyzed or evaluated to produce a value. This provides an open-ended wrapper that supports a number of built-in functions and can also be extended at runtime. It also supports validation of the correctness of an expression and evaluation that should be exception free.

ExpressionEvaluator

Information on how to evaluate an expression.

ExpressionFunctions Definition of default built-in functions for expressions.
ArrayExpression

Represents a property which is either a value of array of T or a string expression to bind to a array of T.

BoolExpression

Represents a property which is either a boolean or a string expression which resolves to a boolean.

EnumExpression

EnumExpression - represents a property which is either an enum of T or a string expression which resolves to an enum.

ExpressionProperty

Base class which defines an Expression or value for a property.

IntExpression

Represents a property which is either a int or a string expression which resolves to a int.

NumberExpression

Represents a property which is either a float or a string expression which resolves to a float.

ObjectExpression

Represents a property which is either an object of type T or a string expression which resolves to a object of type T.

StringExpression

Represents a property which is either a string value or a string expression.

ValueExpression

Represents a property which is an object of any kind or a string expression.

ExpressionType

Built-in expression types.

Extensions

Some util and extension functions

FunctionTable

FunctionTable is a dictionary which merges BuiltinFunctions.Functions with a CustomDictionary.

FunctionUtils

Utility functions in AdaptiveExpression.

InternalFunctionUtils

Utility functions only used internal

CommonRegexLexer
Alpha_numsContext
AlternationContext
AtomContext
CaptureContext
Cc_atomContext
Cc_literalContext
Character_classContext
CommonRegexParser
DigitContext
DigitsContext
ElementContext
ExprContext
LetterContext
LiteralContext
NameContext
Non_captureContext
Non_close_parenContext
Non_close_parensContext
NumberContext
Octal_charContext
Octal_digitContext
OptionContext
Option_flagContext
ParseContext
QuantifierContext
Quantifier_typeContext
Shared_atomContext
Shared_literalContext
SimpleObjectMemory

Simple implement of MemoryInterface

StackedMemory

Stack implements of MemoryInterface. Memory variables have a hierarchical relationship.

Options

Options used to define evaluation behaviors.

ExpressionParser

Parser to turn strings into Expression

ExpressionAntlrLexer
ArgsListContext
ArrayCreationExpContext
BinaryOpExpContext
ExpressionAntlrParser
ExpressionContext
FileContext
FuncInvokeExpContext
IdAtomContext
IndexAccessExpContext
JsonCreationExpContext
KeyContext
KeyValuePairContext
KeyValuePairListContext
LambdaContext
MemberAccessExpContext
NumericAtomContext
ParenthesisExpContext
PrimaryExpContext
PrimaryExpressionContext
StringAtomContext
StringInterpolationAtomContext
StringInterpolationContext
TextContentContext
TripleOpExpContext
UnaryOpExpContext
ParseErrorListener

Expression parser error listener.

Util

util class

RegexErrorListener

Error listener for Regex.

TimeZoneConverter

Time zone converter. (1) From Windows (.NET) timezone to iana timezone. (2) From iana timezone to windows (.NET) timezone. windows ref: https://support.microsoft.com/en-us/help/22803/daylight-saving-time. iana ref: https://www.iana.org/time-zones.

Clause

A canonical normal form expression.

Node

Node in a trigger tree.

Quantifier

Quantifier for allowing runtime expansion of expressions.

Trigger

A trigger is a combination of a trigger expression and the corresponding action.

TriggerTree

A trigger tree organizes evaluators according to generalization/specialization in order to make it easier to use rules.

Interfaces

ExpressionParserInterface

Interface to parse a string into an Expression

CommonRegexListener

This interface defines a complete listener for a parse tree produced by CommonRegexParser.

CommonRegexVisitor

This interface defines a complete generic visitor for a parse tree produced by CommonRegexParser.

MemoryInterface

Interface to parse a string into an Expression

ExpressionAntlrParserListener

This interface defines a complete listener for a parse tree produced by ExpressionAntlrParser.

ExpressionAntlrParserVisitor

This interface defines a complete generic visitor for a parse tree produced by ExpressionAntlrParser.

Optimizer

Optimize a clause by rewriting it.

PredicateComparer

Compare two predicates to identifiy the relationship between them.

Type Aliases

EvaluateExpressionDelegate

Delegate to evaluate an expression. Evaluators should verify runtime arguments when appropriate and return an error rather than throw exceptions if possible.

EvaluatorLookup

Delegate to lookup function information from the type.

ValidateExpressionDelegate

Delegate for doing static validation on an expression. Validators can and should throw exceptions if the expression is not valid.

ValueWithError

Value result with error.

VerifyExpression

Verify the result of an expression is of the appropriate type and return a string if not.

PredicateComparers

Enums

ReturnType

Type expected from evalating an expression.

QuantifierType

Type of quantifier for expanding trigger expressions.

RelationshipType

Relationship between trigger expressions.

Functions

convertCSharpDateTimeToDayjs(string)

Convert a CSharp style datetime format string to a Day.js style datetime format string. Ref: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

Function Details

convertCSharpDateTimeToDayjs(string)

Convert a CSharp style datetime format string to a Day.js style datetime format string. Ref: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

function convertCSharpDateTimeToDayjs(fmtString: string): string

Parameters

fmtString

string

A CSharp style datetime format string. Ref: https://day.js.org/docs/en/display/format

Returns

string

A Momengt.js style datetime format string.