sec-edgar-api 0.5.8 → 0.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FactItemExtended, ReportRaw, XMLParams } from '../../../types';
|
|
1
|
+
import type { FactItemExtended, FiscalPeriod, ReportRaw, XMLParams } from '../../../types';
|
|
2
2
|
import { GetDocumentXbrlParams } from '../../SecEdgarApi';
|
|
3
3
|
import { XbrlParseResult } from '../XBRLParser/XBRLParser';
|
|
4
4
|
interface ReportWithPeriod extends ReportRaw {
|
|
@@ -9,6 +9,8 @@ interface ReportWithPeriod extends ReportRaw {
|
|
|
9
9
|
}
|
|
10
10
|
export interface DocumentXbrlResult extends XbrlParseResult {
|
|
11
11
|
report: ReportRaw | null;
|
|
12
|
+
fiscalYear: number;
|
|
13
|
+
fiscalPeriod: FiscalPeriod;
|
|
12
14
|
facts: FactItemExtended[];
|
|
13
15
|
xml: string;
|
|
14
16
|
/** Facts grouped into reports by their start and end dates */
|
|
@@ -106,10 +106,12 @@ function buildReportsFromFacts(params) {
|
|
|
106
106
|
var el = fact;
|
|
107
107
|
var scale = Number((_q = el.scale) !== null && _q !== void 0 ? _q : 0) || 0;
|
|
108
108
|
var decimals = Number((_r = el.decimals) !== null && _r !== void 0 ? _r : 0) || 0;
|
|
109
|
-
var suffix =
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
var suffix = fact.name.includes(pathSeparator)
|
|
110
|
+
? null
|
|
111
|
+
: (_s = fact === null || fact === void 0 ? void 0 : fact.segments) === null || _s === void 0 ? void 0 : _s.map(function (_a) {
|
|
112
|
+
var dimension = _a.dimension, value = _a.value;
|
|
113
|
+
return "".concat(dimension).concat(pathSeparator).concat(value);
|
|
114
|
+
}).join(pathSeparator);
|
|
113
115
|
var nameKey = suffix ? "".concat(fact.name).concat(pathSeparator).concat(suffix) : fact.name;
|
|
114
116
|
var roundPlaces = scale + decimals;
|
|
115
117
|
var prevFactKey = "".concat(nameKey, "-").concat(dateKey);
|
|
@@ -184,8 +186,23 @@ function parseXbrl(params) {
|
|
|
184
186
|
}
|
|
185
187
|
facts.push(factParsed);
|
|
186
188
|
}
|
|
189
|
+
var fiscalPeriodFact = facts.find(function (f) { return f.name === 'dei:DocumentFiscalPeriodFocus'; });
|
|
190
|
+
var fiscalYearFact = facts.find(function (f) { return f.name === 'dei:DocumentFiscalYearFocus'; });
|
|
191
|
+
var fiscalYear = fiscalYearFact ? Number(fiscalYearFact.value) : 0;
|
|
192
|
+
var fiscalPeriod = fiscalPeriodFact ? fiscalPeriodFact.value : 'FY';
|
|
193
|
+
if (!fiscalPeriodFact || !fiscalYearFact) {
|
|
194
|
+
var fiscalCalculator = new FactFiscalCalculator_1.default({
|
|
195
|
+
fiscalYearEnd: {
|
|
196
|
+
day: Number(response.header.fiscalYearEnd.substring(2)),
|
|
197
|
+
month: Number(response.header.fiscalYearEnd.substring(0, 2)),
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
var _p = fiscalCalculator.getFiscalYearQuarter({ dateStr: response.header.reportDate }), quarter = _p.quarter, year = _p.year;
|
|
201
|
+
fiscalYear = year;
|
|
202
|
+
fiscalPeriod = (quarter === 4 ? 'FY' : "Q".concat(quarter));
|
|
203
|
+
}
|
|
187
204
|
var factsForBuilder = includeReport ? facts : [];
|
|
188
|
-
var
|
|
205
|
+
var _q = buildReportsFromFacts({
|
|
189
206
|
facts: factsForBuilder,
|
|
190
207
|
pathSeparator: '>',
|
|
191
208
|
fiscalPeriod: (_g = factsForBuilder.find(function (f) { return f.name === 'dei:DocumentFiscalPeriodFocus'; })) === null || _g === void 0 ? void 0 : _g.value,
|
|
@@ -209,7 +226,7 @@ function parseXbrl(params) {
|
|
|
209
226
|
url: "https://www.sec.gov/Archives/edgar/data/".concat(cik, "/").concat(accessionNumberNoHyphens, "/").concat(accessionNumber, ".txt"),
|
|
210
227
|
urlPrimaryDocument: '',
|
|
211
228
|
},
|
|
212
|
-
}), factsFiltered =
|
|
213
|
-
return __assign(__assign({}, response), { facts: factsFiltered, report: factsFiltered.length > 0 ? reportFocus : null, xml: xml, periodReports: Object.values(reportByDateRange) });
|
|
229
|
+
}), factsFiltered = _q.factsFiltered, reportFocus = _q.reportFocus, reportByDateRange = _q.reportByDateRange;
|
|
230
|
+
return __assign(__assign({}, response), { fiscalYear: fiscalYear, fiscalPeriod: fiscalPeriod, facts: factsFiltered, report: factsFiltered.length > 0 ? reportFocus : null, xml: xml, periodReports: Object.values(reportByDateRange) });
|
|
214
231
|
}
|
|
215
232
|
exports.parseXbrl = parseXbrl;
|
package/package.json
CHANGED