@proofkit/fmodata
Version:
FileMaker OData API client
75 lines (74 loc) • 2.25 kB
JavaScript
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);
function createNavigationGetters(navConfig) {
const result = {};
for (const key in navConfig) {
Object.defineProperty(result, key, {
get() {
const navItem = navConfig[key];
return typeof navItem === "function" ? navItem() : navItem;
},
enumerable: true,
configurable: true
});
}
return result;
}
class TableOccurrence {
constructor(config) {
__publicField(this, "name");
__publicField(this, "baseTable");
__publicField(this, "_navigationConfig");
__publicField(this, "navigation");
__publicField(this, "defaultSelect");
__publicField(this, "fmtId");
this.name = config.name;
this.baseTable = config.baseTable;
this._navigationConfig = config.navigation ?? {};
this.defaultSelect = config.defaultSelect ?? "schema";
this.fmtId = config.fmtId;
this.navigation = createNavigationGetters(this._navigationConfig);
}
addNavigation(nav) {
return new TableOccurrence({
name: this.name,
baseTable: this.baseTable,
navigation: { ...this._navigationConfig, ...nav },
defaultSelect: this.defaultSelect,
fmtId: this.fmtId
});
}
/**
* Returns the FileMaker table occurrence ID (FMTID) if available, or the table name.
* @returns The FMTID string or the table name
*/
getTableId() {
return this.fmtId ?? this.name;
}
/**
* Returns the table occurrence name.
* @returns The table name
*/
getTableName() {
return this.name;
}
/**
* Returns true if this TableOccurrence is using FileMaker table occurrence IDs.
*/
isUsingTableId() {
return this.fmtId !== void 0;
}
}
function createTableOccurrence(config) {
return new TableOccurrence(config);
}
function defineTableOccurrence(config) {
return new TableOccurrence(config);
}
export {
TableOccurrence,
createTableOccurrence,
defineTableOccurrence
};
//# sourceMappingURL=table-occurrence.js.map