UNPKG

@proofkit/fmodata

Version:

FileMaker OData API client

45 lines (44 loc) 1.54 kB
import { isUsingEntityIds, getTableName, getTableId } from "../../orm/table.js"; import { getAcceptHeader } from "../../types.js"; import { normalizeDatabasePath } from "../database-name.js"; function resolveTableId(table, fallbackTableName, useEntityIds) { if (!table) { return fallbackTableName; } if (useEntityIds) { if (!isUsingEntityIds(table)) { throw new Error(`useEntityIds is true but table "${getTableName(table)}" does not have entity IDs configured`); } return getTableId(table); } return getTableName(table); } function mergeEntityIdOptions(options, databaseDefault) { return { ...options, // biome-ignore lint/suspicious/noExplicitAny: Type assertion for optional property access useEntityIds: (options == null ? void 0 : options.useEntityIds) ?? databaseDefault }; } function mergeExecuteOptions(options, databaseUseEntityIds) { return mergeEntityIdOptions(options, databaseUseEntityIds); } function createODataRequest(baseUrl, config, options) { const fullUrl = `${baseUrl}${normalizeDatabasePath(config.url, { normalizeDatabaseName: (options == null ? void 0 : options.normalizeDatabaseName) ?? true })}`; return new Request(fullUrl, { method: config.method, headers: { "Content-Type": "application/json", Accept: getAcceptHeader(options == null ? void 0 : options.includeODataAnnotations) } }); } export { createODataRequest, mergeEntityIdOptions, mergeExecuteOptions, resolveTableId }; //# sourceMappingURL=table-utils.js.map