"use strict";
/**
 * RAG parser scaffold.
 * Detects which vector DB(s) are present in the trace and delegates to the appropriate parser(s).
 * Returns a unified RAGCall[] with standard metrics (top_k, duration, systemName, operationName, status, returnedRows, collectionName).
 *
 * Not included in frameworkParser — use this module when you need RAG/vector DB call extraction.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTopK = exports.getStatus = exports.getReturnedRows = exports.getDurationMs = exports.getDurationSeconds = exports.buildTraceRagDetailsCards = exports.buildRAGCall = exports.vectorDbParsers = void 0;
exports.detectVectorDb = detectVectorDb;
exports.parseRAG = parseRAG;
exports.parseRAGWithParser = parseRAGWithParser;
const parsers_1 = require("./parsers");
/** Order in which to try parsers (first match wins per span; we run all and merge by span id to avoid duplicates) */
const PARSER_ORDER = parsers_1.vectorDbParsers;
/**
 * Detect which vector DB parser(s) can handle the given spans.
 * Returns the first parser that canParse(spans), or undefined if none.
 */
function detectVectorDb(spans) {
    for (const parser of PARSER_ORDER) {
        if (parser.canParse(spans ?? []))
            return parser;
    }
    return undefined;
}
/**
 * Parse RAG/vector DB calls from spans.
 * Uses the first parser that canParse(spans); if none match, returns [].
 * Returned RAGCall[] is standard across all vector DBs.
 */
function parseRAG(spans) {
    const parser = detectVectorDb(spans ?? []);
    if (!parser)
        return [];
    return parser.parse(spans ?? []);
}
/**
 * Parse RAG using a specific vector DB parser by name.
 * Returns [] if the named parser is not found or cannot parse the spans.
 */
function parseRAGWithParser(spans, parserName) {
    const parser = PARSER_ORDER.find((p) => p.name.toLowerCase() === parserName.toLowerCase());
    if (!parser || !parser.canParse(spans ?? []))
        return [];
    return parser.parse(spans ?? []);
}
var parsers_2 = require("./parsers");
Object.defineProperty(exports, "vectorDbParsers", { enumerable: true, get: function () { return parsers_2.vectorDbParsers; } });
var utils_1 = require("./utils");
Object.defineProperty(exports, "buildRAGCall", { enumerable: true, get: function () { return utils_1.buildRAGCall; } });
Object.defineProperty(exports, "buildTraceRagDetailsCards", { enumerable: true, get: function () { return utils_1.buildTraceRagDetailsCards; } });
Object.defineProperty(exports, "getDurationSeconds", { enumerable: true, get: function () { return utils_1.getDurationSeconds; } });
Object.defineProperty(exports, "getDurationMs", { enumerable: true, get: function () { return utils_1.getDurationMs; } });
Object.defineProperty(exports, "getReturnedRows", { enumerable: true, get: function () { return utils_1.getReturnedRows; } });
Object.defineProperty(exports, "getStatus", { enumerable: true, get: function () { return utils_1.getStatus; } });
Object.defineProperty(exports, "getTopK", { enumerable: true, get: function () { return utils_1.getTopK; } });
//# sourceMappingURL=index.js.map