UNPKG

@proofkit/fmodata

Version:
66 lines (65 loc) 3.34 kB
import { BaseTable } from './client/base-table.js'; import { TableOccurrence } from './client/table-occurrence.js'; /** * Transforms field names to FileMaker field IDs (FMFID) in an object * @param data - Object with field names as keys * @param baseTable - BaseTable 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, baseTable: BaseTable<any, any, any, any>): Record<string, any>; /** * Transforms FileMaker field IDs (FMFID) to field names in an object * @param data - Object with FMFID keys * @param baseTable - BaseTable 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, baseTable: BaseTable<any, any, 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 baseTable - BaseTable instance to get field ID from * @returns The FMFID or field name */ export declare function transformFieldName(fieldName: string, baseTable: BaseTable<any, any, any, any>): string; /** * Transforms a table occurrence name to FMTID or returns the name if not using IDs * @param occurrence - TableOccurrence instance to get table ID from * @returns The FMTID or table name */ export declare function transformTableName(occurrence: TableOccurrence<any, any, any, any>): string; /** * Gets both table name and ID from an occurrence * @param occurrence - TableOccurrence instance * @returns Object with name (always present) and id (may be undefined if not using IDs) */ export declare function getTableIdentifiers(occurrence: TableOccurrence<any, any, 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 baseTable - BaseTable 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, baseTable: BaseTable<any, any, any, any>, expandConfigs?: Array<{ relation: string; occurrence?: TableOccurrence<any, any, any, any>; }>): any; /** * Transforms an array of field names to FMFIDs * @param fieldNames - Array of field names * @param baseTable - BaseTable instance to get field IDs from * @returns Array of FMFIDs or field names */ export declare function transformFieldNamesArray(fieldNames: string[], baseTable: BaseTable<any, any, 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 baseTable - BaseTable instance to get field ID from * @returns Transformed orderBy string with FMFID */ export declare function transformOrderByField(orderByString: string, baseTable: BaseTable<any, any, any, any>): string;