"use strict";
/*
 * Copyright (c) 2021-2022.
 * Author Peter Placzek (tada5hi)
 * For the full copyright and license information,
 * view the LICENSE file that was distributed with this source code.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildFieldWithPath = exports.isFieldPathAllowedByRelations = exports.isFieldNonRelational = void 0;
const field_1 = require("./field");
function isFieldNonRelational(field) {
    const details = typeof field === 'string' ?
        (0, field_1.getFieldDetails)(field) :
        field;
    return typeof details.path === 'undefined';
}
exports.isFieldNonRelational = isFieldNonRelational;
function isFieldPathAllowedByRelations(field, includes) {
    if (typeof includes === 'undefined') {
        return true;
    }
    const details = typeof field === 'string' ?
        (0, field_1.getFieldDetails)(field) :
        field;
    if (typeof details.path === 'undefined') {
        return true;
    }
    return includes.some((include) => include.key === details.path);
}
exports.isFieldPathAllowedByRelations = isFieldPathAllowedByRelations;
function buildFieldWithPath(field, path) {
    const details = typeof field === 'string' ?
        (0, field_1.getFieldDetails)(field) :
        field;
    return details.path || path ?
        `${details.path || path}.${details.name}` :
        details.name;
}
exports.buildFieldWithPath = buildFieldWithPath;
//# sourceMappingURL=relation.js.map