@proofkit/fmodata
Version:
FileMaker OData API client
203 lines (202 loc) • 8.28 kB
TypeScript
import { Column, ColumnFunction } from './column.js';
/**
* FilterExpression represents a filter condition that can be used in where() clauses.
* Internal representation of operator expressions that get converted to OData filter syntax.
*/
export declare class FilterExpression {
readonly operator: string;
readonly operands: (Column | any | FilterExpression)[];
constructor(operator: string, operands: (Column | any | FilterExpression)[]);
/**
* Convert this expression to OData filter syntax.
* @internal Used by QueryBuilder
*/
toODataFilter(useEntityIds?: boolean): string;
private _binaryOp;
private _functionOp;
private _inOp;
private _notInOp;
private _isNullOp;
private _isNotNullOp;
private _logicalOp;
private _notOp;
private _formatTemporalValue;
private _operandToString;
}
/**
* Equal operator - checks if column equals a value or another column.
*
* @example
* eq(users.name, "John") // name equals "John"
* eq(users.id, contacts.id_user) // cross-table comparison
*/
export declare function eq<TOutput, TInput>(column1: Column<TOutput, TInput>, column2: Column<TOutput, TInput> | NoInfer<TInput>): FilterExpression;
/**
* Not equal operator - checks if column does not equal a value or another column.
*
* @example
* ne(users.status, "inactive") // status not equal to "inactive"
* ne(users.id, contacts.id_user) // cross-table comparison
*/
export declare function ne<TOutput, TInput>(column1: Column<TOutput, TInput>, column2: Column<TOutput, TInput> | NoInfer<TInput>): FilterExpression;
/**
* Greater than operator - checks if column is greater than a value.
*
* @example
* gt(users.age, 18) // age greater than 18
*/
export declare function gt<TOutput extends number | string | Date | null, TInput>(column: Column<TOutput, TInput>, value: NoInfer<TInput>): FilterExpression;
/**
* Greater than or equal operator - checks if column is >= a value.
*
* @example
* gte(users.age, 18) // age >= 18
*/
export declare function gte<TOutput extends number | string | Date | null, TInput>(column: Column<TOutput, TInput>, value: NoInfer<TInput>): FilterExpression;
/**
* Less than operator - checks if column is less than a value.
*
* @example
* lt(users.age, 65) // age less than 65
*/
export declare function lt<TOutput extends number | string | Date | null, TInput>(column: Column<TOutput, TInput>, value: NoInfer<TInput>): FilterExpression;
/**
* Less than or equal operator - checks if column is <= a value.
*
* @example
* lte(users.age, 65) // age <= 65
*/
export declare function lte<TOutput extends number | string | Date | null, TInput>(column: Column<TOutput, TInput>, value: NoInfer<TInput>): FilterExpression;
/**
* Contains operator - checks if a string column contains a substring.
*
* @example
* contains(users.name, "John") // name contains "John"
*/
export declare function contains<TOutput, TInput>(column: Column<TOutput, TInput>, value: NoInfer<TInput>): FilterExpression;
/**
* Starts with operator - checks if a string column starts with a prefix.
*
* @example
* startsWith(users.email, "admin") // email starts with "admin"
*/
export declare function startsWith<TOutput, TInput>(column: Column<TOutput, TInput>, value: NoInfer<TInput>): FilterExpression;
/**
* Ends with operator - checks if a string column ends with a suffix.
*
* @example
* endsWith(users.email, "@example.com") // email ends with "@example.com"
*/
export declare function endsWith<TOutput, TInput>(column: Column<TOutput, TInput>, value: NoInfer<TInput>): FilterExpression;
/**
* Matches pattern operator - checks if a string column matches a regex pattern.
*
* @example
* matchesPattern(users.name, "^A.*e$") // name matches regex pattern
*/
export declare function matchesPattern<TOutput extends string | null, TInput>(column: Column<TOutput, TInput>, pattern: string): FilterExpression;
/**
* Wraps a column with OData `tolower()` for case-insensitive comparisons.
*
* @example
* eq(tolower(users.name), "john") // tolower(name) eq 'john'
*/
export declare function tolower<TOutput extends string | null, TInput, TableName extends string, IsContainer extends boolean>(column: Column<TOutput, TInput, TableName, IsContainer>): ColumnFunction<TOutput, TInput, TableName, IsContainer>;
/**
* Wraps a column with OData `toupper()` for case-insensitive comparisons.
*
* @example
* eq(toupper(users.name), "JOHN") // toupper(name) eq 'JOHN'
*/
export declare function toupper<TOutput extends string | null, TInput, TableName extends string, IsContainer extends boolean>(column: Column<TOutput, TInput, TableName, IsContainer>): ColumnFunction<TOutput, TInput, TableName, IsContainer>;
/**
* Wraps a column with OData `trim()` to remove leading/trailing whitespace.
*
* @example
* eq(trim(users.name), "John") // trim(name) eq 'John'
*/
export declare function trim<TOutput extends string | null, TInput, TableName extends string, IsContainer extends boolean>(column: Column<TOutput, TInput, TableName, IsContainer>): ColumnFunction<TOutput, TInput, TableName, IsContainer>;
/**
* In array operator - checks if column value is in an array of values.
*
* @example
* inArray(users.status, ["active", "pending"]) // status is "active" or "pending"
*/
export declare function inArray<TOutput, TInput>(column: Column<TOutput, TInput>, values: NoInfer<TInput>[]): FilterExpression;
/**
* Not in array operator - checks if column value is not in an array of values.
*
* @example
* notInArray(users.status, ["deleted", "banned"]) // status is neither "deleted" nor "banned"
*/
export declare function notInArray<TOutput, TInput>(column: Column<TOutput, TInput>, values: NoInfer<TInput>[]): FilterExpression;
/**
* Is null operator - checks if column value is null.
*
* @example
* isNull(users.deletedAt) // deletedAt is null
*/
export declare function isNull<TOutput, TInput>(column: Column<TOutput, TInput>): FilterExpression;
/**
* Is not null operator - checks if column value is not null.
*
* @example
* isNotNull(users.email) // email is not null
*/
export declare function isNotNull<TOutput, TInput>(column: Column<TOutput, TInput>): FilterExpression;
/**
* AND operator - combines multiple filter expressions with logical AND.
* All expressions must be true for the record to match.
*
* @example
* and(
* eq(users.active, true),
* gt(users.age, 18)
* ) // active is true AND age > 18
*/
export declare function and(...expressions: FilterExpression[]): FilterExpression;
/**
* OR operator - combines multiple filter expressions with logical OR.
* At least one expression must be true for the record to match.
*
* @example
* or(
* eq(users.role, "admin"),
* eq(users.role, "moderator")
* ) // role is "admin" OR "moderator"
*/
export declare function or(...expressions: FilterExpression[]): FilterExpression;
/**
* NOT operator - negates a filter expression.
*
* @example
* not(eq(users.status, "deleted")) // status is NOT "deleted"
*/
export declare function not(expression: FilterExpression): FilterExpression;
/**
* OrderByExpression represents a sort order specification for a column.
* Used in orderBy() clauses to provide type-safe sorting with direction.
*/
export declare class OrderByExpression<TableName extends string = string> {
readonly column: Column<any, any, TableName>;
readonly direction: "asc" | "desc";
constructor(column: Column<any, any, TableName>, direction: "asc" | "desc");
}
/**
* Type guard to check if a value is an OrderByExpression instance.
*/
export declare function isOrderByExpression(value: any): value is OrderByExpression;
/**
* Ascending order operator - sorts a column in ascending order.
*
* @example
* asc(users.name) // Sort by name ascending
*/
export declare function asc<TableName extends string>(column: Column<any, any, TableName>): OrderByExpression<TableName>;
/**
* Descending order operator - sorts a column in descending order.
*
* @example
* desc(users.age) // Sort by age descending
*/
export declare function desc<TableName extends string>(column: Column<any, any, TableName>): OrderByExpression<TableName>;