All files / Cognigy-CLI/build/commands/knowledgeAI/source createKnowledgeSourceCMD.js

0% Statements 0/12
0% Branches 0/13
0% Functions 0/1
0% Lines 0/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18                                   
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createKnowledgeSourceCMD = void 0;
const knowledgeAI_1 = require("../../../lib/knowledgeAI");
const createKnowledgeSourceCMD = (knowledgeStoreId, name, description, type, url) => {
    if (!knowledgeStoreId || knowledgeStoreId === '' || !name || name === '') {
        throw new Error(`Missing required parameters for the command 'cognigy knowdledge-ai create source',  wrong parameters: ${knowledgeStoreId}, ${name}`);
    }
    if (['pdf', 'docx', 'txt', 'ctxt'].includes(type)) {
        throw new Error(`For creating an knowlege Source with the Type = "pdf", "docx", "txt" or "ctxt" use the 'cognigy knowleddge-ai ingest' command`);
    }
    if (type === 'url' && (!url || url === '')) {
        throw new Error('For creating an knowlegeAI Source with the Type = url you need to pass a url');
    }
    return (0, knowledgeAI_1.createKnowledgeSource)(knowledgeStoreId, name, description, type, url);
};
exports.createKnowledgeSourceCMD = createKnowledgeSourceCMD;