UNPKG

@proofkit/fmodata

Version:

FileMaker OData API client

65 lines (64 loc) 3.03 kB
import { FMTable } from './orm/table.js'; /** * Transforms field names to FileMaker field IDs (FMFID) in an object * @param data - Object with field names as keys * @param table - FMTable instance to get field IDs from * @returns Object with FMFID keys instead of field names */ export declare function transformFieldNamesToIds<T extends Record<string, any>>(data: T, table: FMTable<any, any>): Record<string, any>; /** * Transforms FileMaker field IDs (FMFID) to field names in an object * @param data - Object with FMFID keys * @param table - FMTable instance to get field names from * @returns Object with field names as keys instead of FMFIDs */ export declare function transformFieldIdsToNames<T extends Record<string, any>>(data: T, table: FMTable<any, any>): Record<string, any>; /** * Transforms a field name to FMFID or returns the field name if not using IDs * @param fieldName - The field name to transform * @param table - FMTable instance to get field ID from * @returns The FMFID or field name */ export declare function transformFieldName(fieldName: string, table: FMTable<any, any>): string; /** * Transforms a table name to FMTID or returns the name if not using IDs * @param table - FMTable instance to get table ID from * @returns The FMTID or table name */ export declare function transformTableName(table: FMTable<any, any>): string; /** * Gets both table name and ID from a table * @param table - FMTable instance * @returns Object with name (always present) and id (may be undefined if not using IDs) */ export declare function getTableIdentifiers(table: FMTable<any, any>): { name: string; id: string | undefined; }; /** * Transforms response data by converting field IDs back to field names recursively. * Handles both single records and arrays of records, as well as nested expand relationships. * * @param data - Response data from FileMaker (can be single record, array, or wrapped in value property) * @param table - FMTable instance for the main table * @param expandConfigs - Configuration for expanded relations (optional) * @returns Transformed data with field names instead of IDs */ export declare function transformResponseFields(data: any, table: FMTable<any, any>, expandConfigs?: Array<{ relation: string; table?: FMTable<any, any>; }>): any; /** * Transforms an array of field names to FMFIDs * @param fieldNames - Array of field names * @param table - FMTable instance to get field IDs from * @returns Array of FMFIDs or field names */ export declare function transformFieldNamesArray(fieldNames: string[], table: FMTable<any, any>): string[]; /** * Transforms a field name in an orderBy string (e.g., "name desc" -> "FMFID:1 desc") * @param orderByString - The orderBy string (field name with optional asc/desc) * @param table - FMTable instance to get field ID from * @returns Transformed orderBy string with FMFID */ export declare function transformOrderByField(orderByString: string, table: FMTable<any, any> | undefined): string;