sec-edgar-api 0.3.0 → 0.3.1
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/DocumentParser.d.ts +12 -0
- package/build/services/DocumentParser/DocumentParser.js +3 -0
- package/build/services/DocumentParser/parsers/index.d.ts +2 -0
- package/build/services/DocumentParser/parsers/index.js +2 -0
- package/build/services/DocumentParser/parsers/parse-current-filings-daily.d.ts +13 -0
- package/build/services/DocumentParser/parsers/parse-current-filings-daily.js +37 -0
- package/build/services/ReportParser/ReportParser.d.ts +4 -1
- package/build/services/ReportParser/ReportParser.js +2 -2
- package/build/services/ReportRawBuilder/FactPeriodResolver.js +2 -1
- package/build/services/SecEdgarApi/SecEdgarApi.d.ts +22 -3
- package/build/services/SecEdgarApi/SecEdgarApi.js +37 -3
- package/build/types/parsed-filings.type.d.ts +1 -0
- package/package.json +1 -1
|
@@ -13,5 +13,17 @@ export default class DocumentParser {
|
|
|
13
13
|
parseForm13g(params: XMLParams): import("../../types").Form13GData;
|
|
14
14
|
parseForm10k(params: XMLParams): import("../../types").Form10KData;
|
|
15
15
|
parseFormDef14a(params: XMLParams): import("../../types").FormDef14aData;
|
|
16
|
+
parseCurrentFilingsDaily(params: XMLParams): {
|
|
17
|
+
date: string;
|
|
18
|
+
matchCount: number;
|
|
19
|
+
totalCount: number;
|
|
20
|
+
entries: {
|
|
21
|
+
accessionNumber: string;
|
|
22
|
+
form: string;
|
|
23
|
+
companyCik: number;
|
|
24
|
+
companyName: string;
|
|
25
|
+
filedDate: string;
|
|
26
|
+
}[];
|
|
27
|
+
};
|
|
16
28
|
}
|
|
17
29
|
export {};
|
|
@@ -20,6 +20,9 @@ var DocumentParser = /** @class */ (function () {
|
|
|
20
20
|
DocumentParser.prototype.parseFormDef14a = function (params) {
|
|
21
21
|
return this.parsersByName.parseFormDef14a(params, this.parser);
|
|
22
22
|
};
|
|
23
|
+
DocumentParser.prototype.parseCurrentFilingsDaily = function (params) {
|
|
24
|
+
return this.parsersByName.parseCurrentFilingsDaily(params);
|
|
25
|
+
};
|
|
23
26
|
return DocumentParser;
|
|
24
27
|
}());
|
|
25
28
|
exports.default = DocumentParser;
|
|
@@ -2,10 +2,12 @@ import { parseForm4 } from './parse-form-4';
|
|
|
2
2
|
import { parseForm13g } from './parse-form-13g';
|
|
3
3
|
import { parseForm10k } from './parse-form-10k';
|
|
4
4
|
import { parseFormDef14a } from './parse-form-def14a';
|
|
5
|
+
import { parseCurrentFilingsDaily } from './parse-current-filings-daily';
|
|
5
6
|
declare const parsers: {
|
|
6
7
|
parseForm4: typeof parseForm4;
|
|
7
8
|
parseForm13g: typeof parseForm13g;
|
|
8
9
|
parseForm10k: typeof parseForm10k;
|
|
9
10
|
parseFormDef14a: typeof parseFormDef14a;
|
|
11
|
+
parseCurrentFilingsDaily: typeof parseCurrentFilingsDaily;
|
|
10
12
|
};
|
|
11
13
|
export default parsers;
|
|
@@ -4,10 +4,12 @@ var parse_form_4_1 = require("./parse-form-4");
|
|
|
4
4
|
var parse_form_13g_1 = require("./parse-form-13g");
|
|
5
5
|
var parse_form_10k_1 = require("./parse-form-10k");
|
|
6
6
|
var parse_form_def14a_1 = require("./parse-form-def14a");
|
|
7
|
+
var parse_current_filings_daily_1 = require("./parse-current-filings-daily");
|
|
7
8
|
var parsers = {
|
|
8
9
|
parseForm4: parse_form_4_1.parseForm4,
|
|
9
10
|
parseForm13g: parse_form_13g_1.parseForm13g,
|
|
10
11
|
parseForm10k: parse_form_10k_1.parseForm10k,
|
|
11
12
|
parseFormDef14a: parse_form_def14a_1.parseFormDef14a,
|
|
13
|
+
parseCurrentFilingsDaily: parse_current_filings_daily_1.parseCurrentFilingsDaily,
|
|
12
14
|
};
|
|
13
15
|
exports.default = parsers;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { XMLParams } from '../../../types';
|
|
2
|
+
export declare function parseCurrentFilingsDaily(params: XMLParams): {
|
|
3
|
+
date: string;
|
|
4
|
+
matchCount: number;
|
|
5
|
+
totalCount: number;
|
|
6
|
+
entries: {
|
|
7
|
+
accessionNumber: string;
|
|
8
|
+
form: string;
|
|
9
|
+
companyCik: number;
|
|
10
|
+
companyName: string;
|
|
11
|
+
filedDate: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCurrentFilingsDaily = void 0;
|
|
4
|
+
function parseCurrentFilingsDaily(params) {
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
6
|
+
var xml = params.xml;
|
|
7
|
+
var csv = (_a = xml.split('<hr>')[1]) !== null && _a !== void 0 ? _a : '';
|
|
8
|
+
var lines = csv.split('\n').slice(0, -1);
|
|
9
|
+
var _k = (_b = xml.match(/<strong>.{1,20}?<\/strong>/g)) !== null && _b !== void 0 ? _b : [], _l = _k[0], matchHtml = _l === void 0 ? '' : _l, _m = _k[1], totalHtml = _m === void 0 ? '' : _m;
|
|
10
|
+
var date = (_e = (_d = (_c = xml.split('of matches for')) === null || _c === void 0 ? void 0 : _c[1].split('is', 1)) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.trim();
|
|
11
|
+
var matchCount = Number((_g = (_f = matchHtml.split('>')[1]) === null || _f === void 0 ? void 0 : _f.split('<')[0]) === null || _g === void 0 ? void 0 : _g.trim()) || 0;
|
|
12
|
+
var totalCount = Number((_j = (_h = totalHtml.split('>')[1]) === null || _h === void 0 ? void 0 : _h.split('<')[0]) === null || _j === void 0 ? void 0 : _j.trim()) || 0;
|
|
13
|
+
var entries = lines.map(function (line) {
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
15
|
+
var parts = line.split('<a ');
|
|
16
|
+
var partDate = (_a = parts[0]) !== null && _a !== void 0 ? _a : '';
|
|
17
|
+
var partNameCik = (_b = parts[parts.length - 1]) !== null && _b !== void 0 ? _b : '';
|
|
18
|
+
var partAccessionForm = (_f = (_e = (_d = ((_c = parts[1]) !== null && _c !== void 0 ? _c : '').split('/Archives/edgar/data/')[1]) === null || _d === void 0 ? void 0 : _d.split('/')) === null || _e === void 0 ? void 0 : _e[1]) !== null && _f !== void 0 ? _f : '';
|
|
19
|
+
var partNameCikParts = partNameCik.split('</a>');
|
|
20
|
+
var _q = partAccessionForm === null || partAccessionForm === void 0 ? void 0 : partAccessionForm.split('>'), accession = _q[0], formUnfiltered = _q[1];
|
|
21
|
+
var accessionNumber = ((_g = accession === null || accession === void 0 ? void 0 : accession.substring(0, accession.lastIndexOf('-'))) !== null && _g !== void 0 ? _g : '').trim();
|
|
22
|
+
var form = ((_h = formUnfiltered === null || formUnfiltered === void 0 ? void 0 : formUnfiltered.replace(/</g, '')) !== null && _h !== void 0 ? _h : '').trim();
|
|
23
|
+
var companyCik = Number((_l = (_k = (_j = partNameCikParts[0]) === null || _j === void 0 ? void 0 : _j.split('>')[1]) === null || _k === void 0 ? void 0 : _k.trim()) !== null && _l !== void 0 ? _l : '');
|
|
24
|
+
var companyName = (_o = (_m = partNameCikParts[1]) === null || _m === void 0 ? void 0 : _m.trim()) !== null && _o !== void 0 ? _o : '';
|
|
25
|
+
var filedDate = (_p = partDate.trim()) !== null && _p !== void 0 ? _p : '';
|
|
26
|
+
var _r = filedDate.split('-'), month = _r[0], day = _r[1], year = _r[2];
|
|
27
|
+
return {
|
|
28
|
+
accessionNumber: accessionNumber,
|
|
29
|
+
form: form,
|
|
30
|
+
companyCik: companyCik,
|
|
31
|
+
companyName: companyName,
|
|
32
|
+
filedDate: "".concat(year, "-").concat(month, "-").concat(day),
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
return { date: date, matchCount: matchCount, totalCount: totalCount, entries: entries };
|
|
36
|
+
}
|
|
37
|
+
exports.parseCurrentFilingsDaily = parseCurrentFilingsDaily;
|
|
@@ -20,7 +20,10 @@ export default class ReportParser {
|
|
|
20
20
|
/**
|
|
21
21
|
* Same as parseReports but accepts ReportRaw[] instead of CompanyFactListData
|
|
22
22
|
*/
|
|
23
|
-
parseReportsFromRaw(
|
|
23
|
+
parseReportsFromRaw(params: {
|
|
24
|
+
reportsRaw: ReportRaw[];
|
|
25
|
+
usePropertyResolver?: boolean;
|
|
26
|
+
}): ReportWrapper[];
|
|
24
27
|
/**
|
|
25
28
|
* Parse raw reports
|
|
26
29
|
*
|
|
@@ -17,8 +17,8 @@ var ReportParser = /** @class */ (function () {
|
|
|
17
17
|
/**
|
|
18
18
|
* Same as parseReports but accepts ReportRaw[] instead of CompanyFactListData
|
|
19
19
|
*/
|
|
20
|
-
ReportParser.prototype.parseReportsFromRaw = function (
|
|
21
|
-
|
|
20
|
+
ReportParser.prototype.parseReportsFromRaw = function (params) {
|
|
21
|
+
var reportsRaw = params.reportsRaw, _a = params.usePropertyResolver, usePropertyResolver = _a === void 0 ? true : _a;
|
|
22
22
|
var reportByYearQuarter = new Map();
|
|
23
23
|
var reportsRawFiltered = reportsRaw;
|
|
24
24
|
this.translateReportsRaw(reportsRawFiltered, function (report, reportRaw) {
|
|
@@ -35,7 +35,8 @@ var FactPeriodResolver = /** @class */ (function () {
|
|
|
35
35
|
*/
|
|
36
36
|
FactPeriodResolver.isAverageShares = function (params) {
|
|
37
37
|
var propertyName = params.propertyName;
|
|
38
|
-
return propertyName.includes('
|
|
38
|
+
return (propertyName.includes('Average') &&
|
|
39
|
+
(propertyName.includes('SharesOutstanding') || propertyName.includes('SharesIssued')));
|
|
39
40
|
};
|
|
40
41
|
FactPeriodResolver.prototype.isAverageShares = function (params) {
|
|
41
42
|
return FactPeriodResolver.isAverageShares(params);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CompanyFactFrame, CompanyFactListData, CompanyTickerItem, FieldDataResponse, Form10KData, Form13GData, Form4Data, FormDef14aData, MultiCompanyFactFrame, ReportRaw, ReportTranslated } from '../../types';
|
|
1
|
+
import { CompanyFactFrame, CompanyFactListData, CompanyTickerItem, DailyFilingFormType, FieldDataResponse, Form10KData, Form13GData, Form4Data, FormDef14aData, MultiCompanyFactFrame, ReportRaw, ReportTranslated } from '../../types';
|
|
2
2
|
import { FilingListDetails, FilingListItemTranslated, SubmissionList } from '../../types/submission.type';
|
|
3
3
|
import { IClient } from '../Client';
|
|
4
4
|
import DocumentParser from '../DocumentParser';
|
|
@@ -143,8 +143,7 @@ export default class SecEdgarApi {
|
|
|
143
143
|
*/
|
|
144
144
|
getReports<T extends GetReportsParams>(params: T): Promise<T['withWrapper'] extends true ? ReportWrapper[] : ReportTranslated[]>;
|
|
145
145
|
/**
|
|
146
|
-
* Parses reports from company facts.
|
|
147
|
-
* for all reports.
|
|
146
|
+
* Parses reports from company facts.
|
|
148
147
|
*/
|
|
149
148
|
getReportsRaw(params: GetReportsRawParams): Promise<ReportRaw[]>;
|
|
150
149
|
/**
|
|
@@ -234,5 +233,25 @@ export default class SecEdgarApi {
|
|
|
234
233
|
* ```
|
|
235
234
|
*/
|
|
236
235
|
createRequestProxyStatement(params: CreateRequestWrapperParams): SubmissionRequestWrapper<FormDef14aData>;
|
|
236
|
+
/**
|
|
237
|
+
* Gets list of latest filings.
|
|
238
|
+
*
|
|
239
|
+
* @see https://www.sec.gov/edgar/searchedgar/currentevents
|
|
240
|
+
*/
|
|
241
|
+
getCurrentFilingsDaily(params?: {
|
|
242
|
+
formType?: DailyFilingFormType;
|
|
243
|
+
lookbackDays?: number;
|
|
244
|
+
}): Promise<{
|
|
245
|
+
date: string;
|
|
246
|
+
matchCount: number;
|
|
247
|
+
totalCount: number;
|
|
248
|
+
entries: {
|
|
249
|
+
accessionNumber: string;
|
|
250
|
+
form: string;
|
|
251
|
+
companyCik: number;
|
|
252
|
+
companyName: string;
|
|
253
|
+
filedDate: string;
|
|
254
|
+
}[];
|
|
255
|
+
}>;
|
|
237
256
|
}
|
|
238
257
|
export {};
|
|
@@ -270,15 +270,14 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
270
270
|
return [4 /*yield*/, this.getReportsRaw(__assign(__assign({}, params), { includeNamePrefix: false }))];
|
|
271
271
|
case 1:
|
|
272
272
|
reportsRaw = _c.sent();
|
|
273
|
-
reports = this.reportParser.parseReportsFromRaw(reportsRaw, usePropertyResolver);
|
|
273
|
+
reports = this.reportParser.parseReportsFromRaw({ reportsRaw: reportsRaw, usePropertyResolver: usePropertyResolver });
|
|
274
274
|
return [2 /*return*/, withWrapper ? reports : reports.map(function (report) { return report.getReport(); })];
|
|
275
275
|
}
|
|
276
276
|
});
|
|
277
277
|
});
|
|
278
278
|
};
|
|
279
279
|
/**
|
|
280
|
-
* Parses reports from company facts.
|
|
281
|
-
* for all reports.
|
|
280
|
+
* Parses reports from company facts.
|
|
282
281
|
*/
|
|
283
282
|
SecEdgarApi.prototype.getReportsRaw = function (params) {
|
|
284
283
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -496,6 +495,41 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
496
495
|
}); };
|
|
497
496
|
return new RequestWrapper_1.default({ submissions: submissions, options: options, sendRequest: sendRequest });
|
|
498
497
|
};
|
|
498
|
+
/**
|
|
499
|
+
* Gets list of latest filings.
|
|
500
|
+
*
|
|
501
|
+
* @see https://www.sec.gov/edgar/searchedgar/currentevents
|
|
502
|
+
*/
|
|
503
|
+
SecEdgarApi.prototype.getCurrentFilingsDaily = function (params) {
|
|
504
|
+
var _a;
|
|
505
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
506
|
+
var _b, _c, formType, _d, lookbackDays, indexByFormType, indexFormType, url, xml;
|
|
507
|
+
return __generator(this, function (_e) {
|
|
508
|
+
switch (_e.label) {
|
|
509
|
+
case 0:
|
|
510
|
+
_b = params !== null && params !== void 0 ? params : {}, _c = _b.formType, formType = _c === void 0 ? 'ALL' : _c, _d = _b.lookbackDays, lookbackDays = _d === void 0 ? 0 : _d;
|
|
511
|
+
if (lookbackDays > 5) {
|
|
512
|
+
throw new Error("lookbackDays must be <= 5. Received ".concat(lookbackDays));
|
|
513
|
+
}
|
|
514
|
+
indexByFormType = {
|
|
515
|
+
'10-K': 0,
|
|
516
|
+
'10-Q': 1,
|
|
517
|
+
'14': 2,
|
|
518
|
+
'485': 3,
|
|
519
|
+
'8-K': 4,
|
|
520
|
+
'S-8': 5,
|
|
521
|
+
ALL: 6,
|
|
522
|
+
};
|
|
523
|
+
indexFormType = (_a = indexByFormType[formType]) !== null && _a !== void 0 ? _a : 0;
|
|
524
|
+
url = "".concat(this.baseUrlSec, "/cgi-bin/current?q1=").concat(lookbackDays, "&q2=").concat(indexFormType);
|
|
525
|
+
return [4 /*yield*/, this.request(url, true)];
|
|
526
|
+
case 1:
|
|
527
|
+
xml = (_e.sent());
|
|
528
|
+
return [2 /*return*/, this.documentParser.parseCurrentFilingsDaily({ xml: xml })];
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
});
|
|
532
|
+
};
|
|
499
533
|
return SecEdgarApi;
|
|
500
534
|
}());
|
|
501
535
|
exports.default = SecEdgarApi;
|
package/package.json
CHANGED