sec-edgar-api 0.5.9 → 0.5.11
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.
- package/build/services/DocumentParser/parsers/parse-xbrl.js +35 -9
- package/build/services/ReportRawBuilder/FactFiscalCalculator.js +3 -0
- package/build/services/ReportRawBuilder/ReportRawBuilder.js +1 -1
- package/build/services/SecEdgarApi/SecEdgarApi.d.ts +12 -0
- package/build/services/SecEdgarApi/SecEdgarApi.js +12 -0
- package/package.json +1 -1
|
@@ -150,11 +150,11 @@ function buildReportsFromFacts(params) {
|
|
|
150
150
|
return { reportFocus: reportFocus, reportByDateRange: reportByDateRange, factsFiltered: Array.from(factByName.values()) };
|
|
151
151
|
}
|
|
152
152
|
function parseXbrl(params) {
|
|
153
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
153
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
154
154
|
var parser = new XBRLParser_1.default();
|
|
155
|
-
var xml = params.xml,
|
|
155
|
+
var xml = params.xml, _p = params.includeReport, includeReport = _p === void 0 ? true : _p, options = __rest(params, ["xml", "includeReport"]);
|
|
156
156
|
var response = parser.parse(xml, options);
|
|
157
|
-
var
|
|
157
|
+
var _q = (_b = (_a = response.instance) === null || _a === void 0 ? void 0 : _a.xbrl) !== null && _b !== void 0 ? _b : {}, _r = _q.contexts, contexts = _r === void 0 ? [] : _r, _s = _q.factElements, factElements = _s === void 0 ? [] : _s;
|
|
158
158
|
var contextById = new Map();
|
|
159
159
|
contexts.forEach(function (context) { return contextById.set(context.id, context); });
|
|
160
160
|
var cik = response.header.cik;
|
|
@@ -197,16 +197,20 @@ function parseXbrl(params) {
|
|
|
197
197
|
month: Number(response.header.fiscalYearEnd.substring(0, 2)),
|
|
198
198
|
},
|
|
199
199
|
});
|
|
200
|
-
var
|
|
200
|
+
var reportDate = (_g = response.header.reportDate) !== null && _g !== void 0 ? _g : (_j = (_h = response.instance) === null || _h === void 0 ? void 0 : _h.xbrl.factElements.find(function (f) { return f.name === 'dei:DocumentPeriodEndDate'; })) === null || _j === void 0 ? void 0 : _j.text;
|
|
201
|
+
if (!reportDate) {
|
|
202
|
+
throw new Error("Report date not found. Unable to determine fiscal year and period. accn: ".concat(accessionNumber));
|
|
203
|
+
}
|
|
204
|
+
var _t = fiscalCalculator.getFiscalYearQuarter({ dateStr: reportDate !== null && reportDate !== void 0 ? reportDate : '' }), quarter = _t.quarter, year = _t.year;
|
|
201
205
|
fiscalYear = year;
|
|
202
206
|
fiscalPeriod = (quarter === 4 ? 'FY' : "Q".concat(quarter));
|
|
203
207
|
}
|
|
204
208
|
var factsForBuilder = includeReport ? facts : [];
|
|
205
|
-
var
|
|
209
|
+
var _u = buildReportsFromFacts({
|
|
206
210
|
facts: factsForBuilder,
|
|
207
211
|
pathSeparator: '>',
|
|
208
|
-
fiscalPeriod: (
|
|
209
|
-
fiscalYear: Number((
|
|
212
|
+
fiscalPeriod: (_k = factsForBuilder.find(function (f) { return f.name === 'dei:DocumentFiscalPeriodFocus'; })) === null || _k === void 0 ? void 0 : _k.value,
|
|
213
|
+
fiscalYear: Number((_m = (_l = factsForBuilder.find(function (f) { return f.name === 'dei:DocumentFiscalYearFocus'; })) === null || _l === void 0 ? void 0 : _l.value) !== null && _m !== void 0 ? _m : 0),
|
|
210
214
|
cik: response.header.cik,
|
|
211
215
|
filing: {
|
|
212
216
|
acceptanceDateTime: response.header.acceptanceDatetime,
|
|
@@ -226,7 +230,29 @@ function parseXbrl(params) {
|
|
|
226
230
|
url: "https://www.sec.gov/Archives/edgar/data/".concat(cik, "/").concat(accessionNumberNoHyphens, "/").concat(accessionNumber, ".txt"),
|
|
227
231
|
urlPrimaryDocument: '',
|
|
228
232
|
},
|
|
229
|
-
}), factsFiltered =
|
|
230
|
-
|
|
233
|
+
}), factsFiltered = _u.factsFiltered, reportFocus = _u.reportFocus, reportByDateRange = _u.reportByDateRange;
|
|
234
|
+
// Some concepts have members, but do not have a sum. add the sum to the report.
|
|
235
|
+
var periodReports = Object.values(reportByDateRange);
|
|
236
|
+
for (var _v = 0, periodReports_1 = periodReports; _v < periodReports_1.length; _v++) {
|
|
237
|
+
var report = periodReports_1[_v];
|
|
238
|
+
for (var key in report) {
|
|
239
|
+
if (!key.includes('>'))
|
|
240
|
+
continue;
|
|
241
|
+
var parts = key.split('>');
|
|
242
|
+
var concept = parts.shift();
|
|
243
|
+
var center = parts.slice(0, -1).join('>');
|
|
244
|
+
if (!concept || report[concept] !== undefined)
|
|
245
|
+
continue;
|
|
246
|
+
var sum = 0;
|
|
247
|
+
for (var k in report) {
|
|
248
|
+
var prefix = "".concat(concept, ">").concat(center, ">");
|
|
249
|
+
if (k.startsWith(prefix) && !((_o = k.split(prefix).pop()) === null || _o === void 0 ? void 0 : _o.includes('>'))) {
|
|
250
|
+
sum += Number(typeof report[k] === 'number' ? report[k] : 0);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
report[concept] = sum;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return __assign(__assign({}, response), { fiscalYear: fiscalYear, fiscalPeriod: fiscalPeriod, facts: factsFiltered, report: factsFiltered.length > 0 ? reportFocus : null, xml: xml, periodReports: periodReports });
|
|
231
257
|
}
|
|
232
258
|
exports.parseXbrl = parseXbrl;
|
|
@@ -239,6 +239,9 @@ var FactFiscalCalculator = /** @class */ (function () {
|
|
|
239
239
|
var _a;
|
|
240
240
|
var dateStr = params.dateStr, endDateByYearProp = params.endDateByYear, fiscalYearEnd = params.fiscalYearEnd;
|
|
241
241
|
var endDateByYear = endDateByYearProp !== null && endDateByYearProp !== void 0 ? endDateByYearProp : new Map();
|
|
242
|
+
if (!dateStr) {
|
|
243
|
+
throw new Error('No date provided, cannot determine fiscal year and quarter');
|
|
244
|
+
}
|
|
242
245
|
if (fiscalYearEnd) {
|
|
243
246
|
var month = fiscalYearEnd.month, day = fiscalYearEnd.day;
|
|
244
247
|
var year = new Date().getFullYear();
|
|
@@ -48,7 +48,7 @@ var ReportRawBuilder = /** @class */ (function () {
|
|
|
48
48
|
}
|
|
49
49
|
var reportsCik = Number(facts[0].cik);
|
|
50
50
|
var fiscalCalculator = new FactFiscalCalculator_1.default({
|
|
51
|
-
filings: filings === null || filings === void 0 ? void 0 : filings.filter(function (f) { return constants_1.FORMS_EARNINGS.includes(f.form); }),
|
|
51
|
+
filings: filings === null || filings === void 0 ? void 0 : filings.filter(function (f) { return constants_1.FORMS_EARNINGS.includes(f.form) && Boolean(f.reportDate); }),
|
|
52
52
|
facts: facts,
|
|
53
53
|
fiscalYearEnd: fiscalYearEnd,
|
|
54
54
|
});
|
|
@@ -292,6 +292,8 @@ export default class SecEdgarApi {
|
|
|
292
292
|
/**
|
|
293
293
|
* Gets list of filings for a day up to 5 days ago.
|
|
294
294
|
*
|
|
295
|
+
* NOTE: This has not been updated since 2014 and has had issues with not returning data.
|
|
296
|
+
*
|
|
295
297
|
* @see https://www.sec.gov/edgar/searchedgar/currentevents
|
|
296
298
|
*/
|
|
297
299
|
getCurrentFilingsDaily(params?: {
|
|
@@ -310,8 +312,16 @@ export default class SecEdgarApi {
|
|
|
310
312
|
filedDate: string;
|
|
311
313
|
}[];
|
|
312
314
|
}>;
|
|
315
|
+
/**
|
|
316
|
+
* Lists all types of current filings including non XBRL. If fetching earnings reports,
|
|
317
|
+
* use getCurrentFilingsXbrl instead.
|
|
318
|
+
*
|
|
319
|
+
* @see https://www.sec.gov/cgi-bin/browse-edgar?action=getcurrent
|
|
320
|
+
*/
|
|
313
321
|
getCurrentFilings(params?: GetCurrentFilingsParams): Promise<import("../../types").CurrentFilingsList>;
|
|
314
322
|
/**
|
|
323
|
+
* Fetches XBRL filings using the RSS feeds provided by the SEC.
|
|
324
|
+
*
|
|
315
325
|
* @see https://www.sec.gov/structureddata/rss-feeds-submitted-filings
|
|
316
326
|
*/
|
|
317
327
|
getCurrentFilingsXbrl(params?: {
|
|
@@ -334,6 +344,8 @@ export default class SecEdgarApi {
|
|
|
334
344
|
* Search for companies from by name, sic code, or state.
|
|
335
345
|
*
|
|
336
346
|
* example at https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&owner=exclude&&start=0&count=100&hidefilings=0&company=Apple&match=contains
|
|
347
|
+
*
|
|
348
|
+
* TODO: Switch this to use output=atom in the url
|
|
337
349
|
*/
|
|
338
350
|
searchCompanies(params: SearchCompaniesParams): Promise<{
|
|
339
351
|
items: import("../../types").CompanySearchResult[];
|
|
@@ -588,6 +588,8 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
588
588
|
/**
|
|
589
589
|
* Gets list of filings for a day up to 5 days ago.
|
|
590
590
|
*
|
|
591
|
+
* NOTE: This has not been updated since 2014 and has had issues with not returning data.
|
|
592
|
+
*
|
|
591
593
|
* @see https://www.sec.gov/edgar/searchedgar/currentevents
|
|
592
594
|
*/
|
|
593
595
|
SecEdgarApi.prototype.getCurrentFilingsDaily = function (params) {
|
|
@@ -620,6 +622,12 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
620
622
|
});
|
|
621
623
|
});
|
|
622
624
|
};
|
|
625
|
+
/**
|
|
626
|
+
* Lists all types of current filings including non XBRL. If fetching earnings reports,
|
|
627
|
+
* use getCurrentFilingsXbrl instead.
|
|
628
|
+
*
|
|
629
|
+
* @see https://www.sec.gov/cgi-bin/browse-edgar?action=getcurrent
|
|
630
|
+
*/
|
|
623
631
|
SecEdgarApi.prototype.getCurrentFilings = function (params) {
|
|
624
632
|
var _a;
|
|
625
633
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -648,6 +656,8 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
648
656
|
});
|
|
649
657
|
};
|
|
650
658
|
/**
|
|
659
|
+
* Fetches XBRL filings using the RSS feeds provided by the SEC.
|
|
660
|
+
*
|
|
651
661
|
* @see https://www.sec.gov/structureddata/rss-feeds-submitted-filings
|
|
652
662
|
*/
|
|
653
663
|
SecEdgarApi.prototype.getCurrentFilingsXbrl = function (params) {
|
|
@@ -703,6 +713,8 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
703
713
|
* Search for companies from by name, sic code, or state.
|
|
704
714
|
*
|
|
705
715
|
* example at https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&owner=exclude&&start=0&count=100&hidefilings=0&company=Apple&match=contains
|
|
716
|
+
*
|
|
717
|
+
* TODO: Switch this to use output=atom in the url
|
|
706
718
|
*/
|
|
707
719
|
SecEdgarApi.prototype.searchCompanies = function (params) {
|
|
708
720
|
return __awaiter(this, void 0, void 0, function () {
|
package/package.json
CHANGED