import { BooleanType, DateTimeType, EastType, IntegerType, NullType, Nullable, StringType } from '../types'; import { AsciiToBase64Function, Base64ToAsciiFunction, Base64ToHexFunction, EastFunction, HMACFunction, HashFunction, HashType, HexToBase64Function, StringJoinFunction, ToJsonFunction, URIDecodeFunction, URIEncodeFunction } from '../functions'; import { Expression } from './core'; /** * Parse an input string into an East value, using an optional format schema. The reverse of {@link Print}. * * @param from the string {@link Expression} to parse * @param format the format to expect (optional) * * @category Expression * * @example * ```typescript * Parse(IntegerType, integer_string) * Parse(DateTimeType, datetime_string) // defaults to ISO 8601 * Parse(DateTimeType, date_string, 'DD-MM-YYYY') // specify a custom datetime format * ``` */ export declare function Parse(type: DateTimeType, from: EastFunction, format: string): EastFunction; export declare function Parse(type: T, from: EastFunction): EastFunction; /** * Print a value to a string (with an optional format string). * * @param value the {@link Expression} to print * @param format the format to apply * * @category Expression * * @example * ```typescript * // ... * // print a date to string in a specific format * DateString: Print(Variable('Date', DateTimeType), 'DD-MM-YYYY'), * // ... * ``` */ export declare function Print(value: Expression, format?: string): EastFunction; /** * Return a substring of `value` between the characters `start` and `stop`. * * @param value the {@link Expression} for string * @param start the {@link Expression} giving the index of the first character to keep (starting at 0) * @param stop the {@link Expression} giving the index *after* the final character to keep * * @category Expression * * @example * ```typescript * // ... * // extract the first two characters of Id * Prefix: Substring(Variable('Id', StringType), 0, 2), * // ... * ``` */ export declare function Substring(value: EastFunction, start: number, stop: number): EastFunction; /** * Return a string repeated a given number of times. * * @param value the {@link Expression} for string * @param n the {@link Expression} for the number of repetitions * * @remarks if `n` is negative, the empty string is returned. * * @category Expression * * @example * ```typescript * // ... * // create a string containing six zeros * SixZeros: Repeat(Const("0"), Const(6n)), * // ... * ``` */ export declare function Repeat(value: EastFunction, n: EastFunction): EastFunction; /** * Return a string concatenating all the `values` strings with the optional `seperator`. Also able to be used as a tagged template string literal. * * @param values the {@link Expression} containing collection of strings * @param seperator the string to place between consecutive values (defaults to "") * * @category Expression * * @example * ```typescript * StringJoin`There are ${Variable("qty", IntegerType)} items` * ``` * is equivalent to: * * ```typescript * StringJoin(['There are ', Variable("qty", IntegerType), ' items']) * ``` * * @example * ```typescript * // ... * // create string with a comma seperated list of employee names from an array of employee names strings * EmployeeNamesString: StringJoin( * Variable(EmployeeNames, ArrayType), * ', '] * ) * // ... * ``` * * */ export declare function StringJoin(values: Expression[] | Record | TemplateStringsArray, seperator?: string | Expression, ...args: Expression[]): StringJoinFunction; /** * Return a string where `value`'s matches to the regular expression `search` string are replaced with value of `replace`. * * @param value the {@link Expression} with the string to modify * @param search the (fixed) regular expressionsearch string to search for * @param replace the {@link Expression} for the string to replace matches with * @param flags the regular expression flags to apply (default 'g' for global, also 'i' for case insensitive) * * @category Expression * * @example * ```typescript * // ... * // extract the part of the string before the colon : * FirstPart: RegexReplace( * Variable("ComplexString", StringType), * '.*:(.+)', * '$1' * ), * // ... * ``` */ export declare function RegexReplace(value: EastFunction, search: string, replace: Expression, flags?: string): EastFunction; /** * Return `true` if `value` matches the regular expression `search` string, or `false` otherwise. * * @param value the {@link Expression} with the string to modify * @param search the (fixed) regular expression search string to search for * @param flags the regular expression flags to apply (default 'i' for case insensitive) * * @category Expression * * @example * ```typescript * // ... * // Infer if product is a subscription product based on the * // presence of 'subscription' in the product's name * ProductIsSubscription: RegexContains( * Variable("ProductName", StringType), * 'subscription' * ), * // ... * ``` */ export declare function RegexContains(value: EastFunction, search: string, flags?: string): EastFunction : BooleanType>; /** * Return a string containing only uppercase characters. * * @param value the {@link Expression} with the input string * * @category Expression * * @example * ```typescript * UpperCase(string) * ``` */ export declare function UpperCase(value: EastFunction): EastFunction; /** * Return a string containing only lowercase characters. * * @param value the {@link Expression} with the input string * * @category Expression * * @example * ```typescript * LowerCase(string) * ``` */ export declare function LowerCase(value: EastFunction): EastFunction; /** * Return a string containing a JSON encoding the East value (similar to `JSON.stringify`). * * @param value the {@link Expression} with the value to encode as JSON * * @category Expression * * @example * ```typescript * ToJson(value) * ``` */ export declare function ToJson(value: EastFunction): ToJsonFunction; /** * Return an East value of type `type` decoded from a JSON string (similar to `JSON.parse`). * * Note: this expects the JSON to conform to some known schema compatible with `type`. * * @param type the {@link EastType} to decode to * @param value the {@link Expression} with the JSON string to decode * * @category Expression * * @example * ```typescript * // decode a JSON array of strings * FromJson(ArrayType(StringType), string) * ``` */ export declare function FromJson(type: T, value: EastFunction): EastFunction; /** * Return the hash of a string with specified algorithm and encoding. * * @param value the {@link Expression} for the string to hash * @param hash the {@link HashType} to employ ('md5', 'sha1', 'sha256', 'sha224', 'sha512', 'sha384', 'sha3' or 'ripemd160') * @param encoding the encoding the result should be use ('base64' or 'hex') * * @category Expression * * @example * ```typescript * Hash(string, 'sha256', 'base64') * ``` */ export declare function Hash(value: EastFunction, hash: HashType, encoding: "base64" | "hex"): HashFunction; /** * Return the HMAC for a string with a given key and specified hashing algorithm and encoding. * * @param value the {@link Expression} for the string to sign * @param key the {@link Expression} for the HMAC key * @param hash the {@link HashType} to employ ('md5', 'sha1', 'sha256', 'sha224', 'sha512', 'sha384', 'sha3' or 'ripemd160') * @param encoding the encoding the result should be use ('base64' or 'hex') * * @category Expression * * @example * ```typescript * HMAC(string, key, 'sha256', 'base64') * ``` */ export declare function HMAC(value: EastFunction, key: EastFunction, hash: HashType, encoding: "base64" | "hex"): HMACFunction; /** * Convert a Base64 string to an ASCII string. * * @param value the {@link Expression} for the input Base64 string * * @category Expression */ export declare function Base64ToAscii(value: EastFunction): Base64ToAsciiFunction; /** * Convert an ASCII string to Base64 encoding. * * @param value the {@link Expression} for the input ASCII string * * @category Expression */ export declare function AsciiToBase64(value: EastFunction): AsciiToBase64Function; /** * Convert a Base64 string to hexadecimal encoding. * * @param value the {@link Expression} for the input Base64 string * * @category Expression */ export declare function Base64ToHex(value: EastFunction): Base64ToHexFunction; /** * Convert a hexadecimal string to Base64 encoding. * * @param value the {@link Expression} for the input hexadecimal string * * @category Expression */ export declare function HexToBase64(value: EastFunction): HexToBase64Function; /** * Encode a string suitable for placing as a component inside a URI. * * @param value the {@link Expression} for the input string * * @category Expression */ export declare function URIEncode(value: EastFunction): URIEncodeFunction; /** * Decode a string from a compoment of a URI. * * @param value the {@link Expression} for the URI string * * @category Expression */ export declare function URIDecode(value: EastFunction): URIDecodeFunction;