"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NamedQueryInternalApi = void 0;
const ApiBase_1 = require("../Implementation/ApiBase");
class NamedQueryInternalApi extends ApiBase_1.ApiBase {
    /**
     * Returns the name of all the referenced Named Queries as an array of strings
     * @param expression query string
     */
    getReferencedNamedQueryNames(expression = '') {
        try {
            return this.getAdaptableApi()
                .internalApi.getQueryLanguageService()
                .getNamedQueryNamesFromExpression(expression);
        }
        catch (error) {
            // defensive programing, this should happen only if someone botched the predefined configs
            this.logWarn(`QueryApi.getReferencedNamedQueryNames received an invalid expression: ${expression}
                  Error: ${error}`);
            return [];
        }
    }
    /**
     * Returns all the references in the AdaptableState of the NamedQuery with the given name
     * @param namedQueryName namedQuery name
     */
    getNamedQueryModuleReferences(namedQueryName) {
        const references = [];
        this.getAdaptableInternalApi().getModules().forEach((module) => {
            if (module
                .getModuleNamedQueryReferences()
                .some((moduleReference) => moduleReference === namedQueryName)) {
                references.push(module.moduleInfo.FriendlyName);
            }
        });
        return references;
    }
}
exports.NamedQueryInternalApi = NamedQueryInternalApi;
