@proofkit/fmodata
Version:
FileMaker OData API client
81 lines (80 loc) • 3.56 kB
TypeScript
import { StandardSchemaV1 } from '@standard-schema/spec';
/**
* Column represents a type-safe reference to a table field.
* Used in queries, filters, and operators to provide autocomplete and type checking.
*
* @template TOutput - The TypeScript type when reading from the database (output type)
* @template TInput - The TypeScript type when writing to the database (input type, for filters)
* @template TableName - The table name as a string literal type (for validation)
* @template IsContainer - Whether this column represents a container field (cannot be selected)
*/
export declare class Column<TOutput = any, TInput = TOutput, TableName extends string = string, IsContainer extends boolean = false> {
readonly fieldName: string;
readonly entityId?: `FMFID:${string}`;
readonly tableName: TableName;
readonly tableEntityId?: `FMTID:${string}`;
readonly inputValidator?: StandardSchemaV1<TInput, any>;
readonly fieldType?: string;
readonly _phantomOutput: TOutput;
readonly _phantomInput: TInput;
readonly _isContainer: IsContainer;
constructor(config: {
fieldName: string;
entityId?: `FMFID:${string}`;
tableName: TableName;
tableEntityId?: `FMTID:${string}`;
inputValidator?: StandardSchemaV1<TInput, any>;
fieldType?: string;
});
/**
* Get the field identifier (entity ID if available, otherwise field name).
* Used when building OData queries.
*/
getFieldIdentifier(useEntityIds?: boolean): string;
/**
* Get the table identifier (entity ID if available, otherwise table name).
* Used when building OData queries.
*/
getTableIdentifier(useEntityIds?: boolean): string;
/**
* Check if this column is from a specific table.
* Useful for validation in cross-table operations.
*/
isFromTable(tableName: string): boolean;
/**
* Create a string representation for debugging.
*/
toString(): string;
}
/**
* Type guard to check if a value is a Column instance.
*/
export declare function isColumn(value: any): value is Column<any, any, any, any>;
/**
* ColumnFunction wraps a Column with an OData string function (tolower, toupper, trim).
* Since it extends Column, it passes `isColumn()` checks and works with all existing operators.
* Supports nesting: `tolower(trim(col))` → `tolower(trim(name))`.
*/
export declare class ColumnFunction<TOutput = any, TInput = TOutput, TableName extends string = string, IsContainer extends boolean = false> extends Column<TOutput, TInput, TableName, IsContainer> {
readonly fnName: string;
readonly innerColumn: Column<TOutput, TInput, TableName, IsContainer>;
constructor(fnName: string, innerColumn: Column<TOutput, TInput, TableName, IsContainer>);
toFilterString(useEntityIds?: boolean): string;
}
/**
* Type guard to check if a value is a ColumnFunction instance.
*/
export declare function isColumnFunction(value: any): value is ColumnFunction<any, any, any, any>;
/**
* Create a Column with proper type inference from the inputValidator.
* This helper ensures TypeScript can infer TInput from the validator's input type.
* @internal
*/
export declare function createColumn<TOutput, TInput, TName extends string, IsContainer extends boolean = false>(config: {
fieldName: string;
entityId?: `FMFID:${string}`;
tableName: TName;
tableEntityId?: `FMTID:${string}`;
inputValidator?: StandardSchemaV1<TInput, any>;
fieldType?: string;
}): Column<TOutput, TInput, TName, IsContainer>;