"use strict";
/**
 * Astra DB (DataStax) vector DB RAG parser.
 * Detects Astra spans and returns standard RAGCall[].
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.astraDbRagParser = void 0;
const utils_1 = require("../utils");
const SYSTEM_NAME = 'astra';
const DB_SYSTEM = 'db.system';
const DB_SYSTEM_NAME = 'db.system.name';
function isAstraSpan(span) {
    const attrs = span.attributes ?? {};
    const res = span.resourceAttributes ?? {};
    const sys = attrs[DB_SYSTEM_NAME] ?? attrs[DB_SYSTEM] ?? res[DB_SYSTEM_NAME] ?? res[DB_SYSTEM];
    if (sys != null && String(sys).toLowerCase().includes('astra'))
        return true;
    const name = (span.name ?? '').toLowerCase();
    const svc = (span.serviceName ?? '').toLowerCase();
    return name.includes('astra') || svc.includes('astra') || name.includes('datastax');
}
exports.astraDbRagParser = {
    name: 'astradb',
    canParse(spans) {
        return (spans ?? []).some(isAstraSpan);
    },
    parse(spans) {
        return (spans ?? [])
            .filter(isAstraSpan)
            .map((span) => (0, utils_1.buildRAGCall)(span, { systemName: SYSTEM_NAME }));
    },
};
//# sourceMappingURL=astraDb.js.map