sec-edgar-api
Version:
Fetch and parse SEC earnings reports and other filings. Useful for financial analysis.
57 lines (56 loc) • 4.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var XMLParser_1 = require("../XMLParser");
var util_xbrl_1 = require("./util-xbrl");
/**
* Parse FilingSummary.xml
*/
var FilingSummaryParser = /** @class */ (function () {
function FilingSummaryParser() {
this.xmlParser = new XMLParser_1.default();
}
FilingSummaryParser.prototype.toText = function (node) {
var _a;
return String(typeof node === 'object' && node !== null ? (_a = node['#text']) !== null && _a !== void 0 ? _a : '' : node || '');
};
FilingSummaryParser.prototype.parse = function (xml) {
var _this = this;
var _a, _b, _c, _d, _e, _f;
var parts = xml ? this.xmlParser.parse(xml) : null;
var filingSummary = parts === null || parts === void 0 ? void 0 : parts.FilingSummary;
if (!filingSummary)
return null;
var _g = filingSummary !== null && filingSummary !== void 0 ? filingSummary : {}, BaseTaxonomies = _g.BaseTaxonomies, ContextCount = _g.ContextCount, ElementCount = _g.ElementCount, EntityCount = _g.EntityCount, FootnotesReported = _g.FootnotesReported, HasCalculationLinkbase = _g.HasCalculationLinkbase, HasPresentationLinkbase = _g.HasPresentationLinkbase, InputFiles = _g.InputFiles, MyReports = _g.MyReports, ReportFormat = _g.ReportFormat, ScenarioCount = _g.ScenarioCount, SegmentCount = _g.SegmentCount, TuplesReported = _g.TuplesReported, UnitCount = _g.UnitCount, Version = _g.Version;
return {
version: util_xbrl_1.default.toString(this.toText(Version)) || '',
contextCount: util_xbrl_1.default.toNumber(this.toText(ContextCount)) || 0,
elementCount: util_xbrl_1.default.toNumber(this.toText(ElementCount)) || 0,
entityCount: util_xbrl_1.default.toNumber(this.toText(EntityCount)) || 0,
footnotesReported: util_xbrl_1.default.toBoolean(this.toText(FootnotesReported)) || false,
hasCalculationLinkbase: util_xbrl_1.default.toBoolean(this.toText(HasCalculationLinkbase)) || false,
hasPresentationLinkbase: util_xbrl_1.default.toBoolean(this.toText(HasPresentationLinkbase)) || false,
scenarioCount: util_xbrl_1.default.toNumber(this.toText(ScenarioCount)) || 0,
segmentCount: util_xbrl_1.default.toNumber(this.toText(SegmentCount)) || 0,
tuplesReported: util_xbrl_1.default.toBoolean(this.toText(TuplesReported)) || false,
unitCount: util_xbrl_1.default.toNumber(this.toText(UnitCount)) || 0,
reportFormat: util_xbrl_1.default.toString(this.toText(ReportFormat)) || '',
baseTaxonomies: (_b = (_a = BaseTaxonomies === null || BaseTaxonomies === void 0 ? void 0 : BaseTaxonomies.BaseTaxonomy) === null || _a === void 0 ? void 0 : _a.map(function (taxonomy) { return util_xbrl_1.default.toString(_this.toText(taxonomy)); })) !== null && _b !== void 0 ? _b : [],
inputFiles: (_d = (_c = InputFiles === null || InputFiles === void 0 ? void 0 : InputFiles.File) === null || _c === void 0 ? void 0 : _c.map(function (file) { return util_xbrl_1.default.toString(_this.toText(file)); })) !== null && _d !== void 0 ? _d : [],
reports: (_f = (_e = MyReports === null || MyReports === void 0 ? void 0 : MyReports.Report) === null || _e === void 0 ? void 0 : _e.map(function (report) { return ({
longName: util_xbrl_1.default.toString(_this.toText(report.LongName)) || '',
shortName: util_xbrl_1.default.toString(_this.toText(report.ShortName)) || '',
isDefault: util_xbrl_1.default.toBoolean(_this.toText(report.IsDefault)) || false,
hasEmbeddedReports: util_xbrl_1.default.toBoolean(_this.toText(report.HasEmbeddedReports)) || false,
htmlFileName: util_xbrl_1.default.toString(_this.toText(report.HtmlFileName)) || '',
reportType: util_xbrl_1.default.toString(_this.toText(report.ReportType)) || '',
role: util_xbrl_1.default.toString(_this.toText(report.Role)) || '',
menuCategory: util_xbrl_1.default.toString(_this.toText(report.MenuCategory)) || null,
position: util_xbrl_1.default.toNumber(_this.toText(report.Position)) || -1,
parentRole: util_xbrl_1.default.toString(_this.toText(report.ParentRole)) || null,
instance: util_xbrl_1.default.toString(_this.toText(report['@_instance'])) || '',
}); })) !== null && _f !== void 0 ? _f : [],
};
};
return FilingSummaryParser;
}());
exports.default = FilingSummaryParser;