UNPKG

@proofkit/fmodata

Version:
58 lines (57 loc) 1.84 kB
var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); class BaseTable { constructor(config) { __publicField(this, "schema"); __publicField(this, "idField"); __publicField(this, "required"); __publicField(this, "readOnly"); __publicField(this, "fmfIds"); this.schema = config.schema; this.idField = config.idField; this.required = config.required; this.readOnly = config.readOnly; this.fmfIds = config.fmfIds; } /** * Returns the FileMaker field ID (FMFID) for a given field name, or the field name itself if not using IDs. * @param fieldName - The field name to get the ID for * @returns The FMFID string or the original field name */ getFieldId(fieldName) { if (this.fmfIds && fieldName in this.fmfIds) { return this.fmfIds[fieldName]; } return String(fieldName); } /** * Returns the field name for a given FileMaker field ID (FMFID), or the ID itself if not found. * @param fieldId - The FMFID to get the field name for * @returns The field name or the original ID */ getFieldName(fieldId) { if (this.fmfIds) { for (const [fieldName, fmfId] of Object.entries(this.fmfIds)) { if (fmfId === fieldId) { return fieldName; } } } return fieldId; } /** * Returns true if this BaseTable is using FileMaker field IDs. */ isUsingFieldIds() { return this.fmfIds !== void 0; } } function defineBaseTable(config) { return new BaseTable(config); } export { BaseTable, defineBaseTable }; //# sourceMappingURL=base-table.js.map