UNPKG

@copado/copado-cli

Version:

Copado Developer CLI

32 lines 1.47 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const sObjectSelector_1 = __importDefault(require("./sObjectSelector")); const contentDocumentLinks_1 = __importDefault(require("./contentDocumentLinks")); const restConnections_1 = require("../service/restConnections"); class ContentVersionSelector extends sObjectSelector_1.default { constructor() { super(...arguments); this.fields = [ 'Id', 'Title' ]; this.sObject = 'ContentVersion'; this.orderby = 'CreatedDate Desc'; } async byParentId(recordId, fileName) { const documentLinks = await new contentDocumentLinks_1.default().byParentId(recordId, fileName); if (!documentLinks || !documentLinks.length) { throw new Error(`No log file exists with name ${fileName}`); } const contentVersion = await this.getRecords(`ContentDocumentId = '${documentLinks[0].ContentDocumentId}' and IsLatest = true`); if (!contentVersion.length) { throw new Error('No log file exists'); } return restConnections_1.RestConnections.get(`/services/data/v51.0/sobjects/ContentVersion/${contentVersion[0].Id}/VersionData`); } } exports.default = ContentVersionSelector; //# sourceMappingURL=contentVersion.js.map