sec-edgar-api 0.0.6 → 0.1.0
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/README.md +2 -0
- package/build/index.js +5 -1
- package/build/services/Client/Client.d.ts +2 -1
- package/build/services/Client/index.js +5 -1
- package/build/services/DocumentParser/DocumentParser.d.ts +1 -0
- package/build/services/DocumentParser/DocumentParser.js +3 -0
- package/build/services/DocumentParser/XMLNode/ColNode.d.ts +18 -0
- package/build/services/DocumentParser/XMLNode/ColNode.js +74 -0
- package/build/services/DocumentParser/XMLNode/DocumentNode.d.ts +3 -0
- package/build/services/DocumentParser/XMLNode/DocumentNode.js +27 -0
- package/build/services/DocumentParser/XMLNode/HRNode.d.ts +3 -0
- package/build/services/DocumentParser/XMLNode/HRNode.js +27 -0
- package/build/services/DocumentParser/XMLNode/NonTableNode.d.ts +3 -0
- package/build/services/DocumentParser/XMLNode/NonTableNode.js +27 -0
- package/build/services/DocumentParser/XMLNode/RowNode.d.ts +30 -0
- package/build/services/DocumentParser/XMLNode/RowNode.js +177 -0
- package/build/services/DocumentParser/XMLNode/TableNode.d.ts +20 -0
- package/build/services/DocumentParser/XMLNode/TableNode.js +132 -0
- package/build/services/DocumentParser/XMLNode/XMLNode.d.ts +37 -0
- package/build/services/DocumentParser/XMLNode/XMLNode.js +154 -0
- package/build/services/DocumentParser/XMLParser.d.ts +15 -0
- package/build/services/DocumentParser/XMLParser.js +180 -52
- 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-form-10k.d.ts +3 -0
- package/build/services/DocumentParser/parsers/parse-form-10k.js +78 -0
- package/build/services/ReportParser/ReportParser.d.ts +3 -3
- package/build/services/ReportParser/ReportParser.js +8 -4
- package/build/services/ReportParser/ReportTranslatedProxy.d.ts +1 -1
- package/build/services/ReportParser/ReportWrapper.js +2 -1
- package/build/services/ReportParser/resolvers/helpers.d.ts +1 -1
- package/build/services/SecEdgarApi/RequestWrapper.d.ts +19 -12
- package/build/services/SecEdgarApi/RequestWrapper.js +52 -38
- package/build/services/SecEdgarApi/SecEdgarApi.d.ts +22 -9
- package/build/services/SecEdgarApi/SecEdgarApi.js +48 -25
- package/build/services/SecEdgarApi/Throttler.js +1 -1
- package/build/services/SecEdgarApi/index.js +5 -1
- package/build/types/index.js +5 -1
- package/build/types/parsed-filings.type.d.ts +11 -3
- package/build/types/report-raw.type.d.ts +3 -3
- package/package.json +1 -1
- package/build/.DS_Store +0 -0
- package/build/downloader.d.ts +0 -6
- package/build/downloader.js +0 -9
- package/build/services/FactFileReader/FactFileReader.d.ts +0 -30
- package/build/services/FactFileReader/FactFileReader.js +0 -36
- package/build/services/FactFileReader/index.d.ts +0 -2
- package/build/services/FactFileReader/index.js +0 -4
- package/build/services/FactsDownloader/Downloader.d.ts +0 -26
- package/build/services/FactsDownloader/Downloader.js +0 -102
- package/build/services/FactsDownloader/FactsDownloader.d.ts +0 -37
- package/build/services/FactsDownloader/FactsDownloader.js +0 -131
- package/build/services/FactsDownloader/Unzipper.d.ts +0 -40
- package/build/services/FactsDownloader/Unzipper.js +0 -40
- package/build/services/FactsDownloader/index.d.ts +0 -2
- package/build/services/FactsDownloader/index.js +0 -4
- package/build/services/SecEdgarApi/Client.d.ts +0 -44
- package/build/services/SecEdgarApi/Client.js +0 -104
- package/build/services/SecEdgarApi/Downloader.d.ts +0 -26
- package/build/services/SecEdgarApi/Downloader.js +0 -102
- package/build/services/SecEdgarApi/FactsDownloader.d.ts +0 -30
- package/build/services/SecEdgarApi/FactsDownloader.js +0 -124
- package/build/services/SecEdgarApi/SecConnector.d.ts +0 -47
- package/build/services/SecEdgarApi/SecConnector.js +0 -143
- package/build/services/SecEdgarApi/Unzipper.d.ts +0 -40
- package/build/services/SecEdgarApi/Unzipper.js +0 -40
|
@@ -21,16 +21,18 @@ var ReportParser = /** @class */ (function () {
|
|
|
21
21
|
*
|
|
22
22
|
* @param companyFactListData This is the json file contents of CIK[number].json file from the SEC website. You can find these using their API or by downloading the companyfacts.zip file: https://www.sec.gov/edgar/sec-api-documentation
|
|
23
23
|
*/
|
|
24
|
-
ReportParser.prototype.parseReports = function (companyFactListData) {
|
|
24
|
+
ReportParser.prototype.parseReports = function (companyFactListData, usePropertyResolver) {
|
|
25
|
+
if (usePropertyResolver === void 0) { usePropertyResolver = true; }
|
|
25
26
|
var reportsRaw = this.reportRawParser.parseReports(companyFactListData, {
|
|
26
27
|
reportsToInclude: ['ANNUAL', 'QUARTERLY'],
|
|
27
28
|
});
|
|
28
|
-
return this.parseReportsFromRaw(reportsRaw);
|
|
29
|
+
return this.parseReportsFromRaw(reportsRaw, usePropertyResolver);
|
|
29
30
|
};
|
|
30
31
|
/**
|
|
31
32
|
* Same as parseReports but accepts ReportRaw[] instead of CompanyFactListData
|
|
32
33
|
*/
|
|
33
|
-
ReportParser.prototype.parseReportsFromRaw = function (reportsRaw) {
|
|
34
|
+
ReportParser.prototype.parseReportsFromRaw = function (reportsRaw, usePropertyResolver) {
|
|
35
|
+
if (usePropertyResolver === void 0) { usePropertyResolver = true; }
|
|
34
36
|
var reportByYearQuarter = new Map();
|
|
35
37
|
var reportsRawFiltered = reportsRaw.filter(function (reportRaw) {
|
|
36
38
|
return reportRaw.reportType === 'ANNUAL' || reportRaw.reportType === 'QUARTERLY';
|
|
@@ -42,7 +44,9 @@ var ReportParser = /** @class */ (function () {
|
|
|
42
44
|
return report;
|
|
43
45
|
});
|
|
44
46
|
var reportWrappers = Array.from(reportByYearQuarter.values());
|
|
45
|
-
|
|
47
|
+
if (usePropertyResolver) {
|
|
48
|
+
this.propertyResolver.resolveAll(reportWrappers);
|
|
49
|
+
}
|
|
46
50
|
return reportWrappers;
|
|
47
51
|
};
|
|
48
52
|
/**
|
|
@@ -22,8 +22,9 @@ var ReportTranslatedProxy_1 = require("./ReportTranslatedProxy");
|
|
|
22
22
|
var ReportWrapper = /** @class */ (function (_super) {
|
|
23
23
|
__extends(ReportWrapper, _super);
|
|
24
24
|
function ReportWrapper(report, reportRaw, reportMap) {
|
|
25
|
+
var _this = this;
|
|
25
26
|
var _a;
|
|
26
|
-
|
|
27
|
+
_this = _super.call(this, report) || this;
|
|
27
28
|
_this.report = report;
|
|
28
29
|
_this.reportMap = reportMap !== null && reportMap !== void 0 ? reportMap : new Map();
|
|
29
30
|
_this.reportRaw = reportRaw !== null && reportRaw !== void 0 ? reportRaw : {
|
|
@@ -5,7 +5,7 @@ interface SplitValueBetweenReportsParams {
|
|
|
5
5
|
reports: ReportTranslated[];
|
|
6
6
|
roundToPlaces: number;
|
|
7
7
|
}
|
|
8
|
-
export
|
|
8
|
+
export type ExcludeNulls<T> = {
|
|
9
9
|
[K in keyof T]: Exclude<T[K], null>;
|
|
10
10
|
};
|
|
11
11
|
export declare function getSingleNullKey<T>(obj: T): keyof T | null;
|
|
@@ -1,30 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
import { FilingListItemTranslated } from '../../types/submission.type';
|
|
2
|
+
export interface SubmissionRequestWrapperOptions {
|
|
2
3
|
maxRequests?: number;
|
|
3
4
|
}
|
|
4
5
|
export interface SendRequestParams {
|
|
5
6
|
url: string;
|
|
6
7
|
}
|
|
7
|
-
interface
|
|
8
|
-
|
|
9
|
-
options?:
|
|
10
|
-
sendRequest: (params: SendRequestParams) => Promise<T
|
|
8
|
+
interface SubmissionRequestWrapperArgs<T> {
|
|
9
|
+
submissions: FilingListItemTranslated[];
|
|
10
|
+
options?: SubmissionRequestWrapperOptions;
|
|
11
|
+
sendRequest: (params: SendRequestParams) => Promise<T>;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
interface SubmissionRequestWrapperResult<T> {
|
|
14
|
+
result: T | null;
|
|
15
|
+
error: string | null;
|
|
16
|
+
submission: FilingListItemTranslated;
|
|
17
|
+
}
|
|
18
|
+
export default class SubmissionRequestWrapper<T> {
|
|
13
19
|
private results;
|
|
14
20
|
private readonly options;
|
|
15
|
-
private readonly
|
|
21
|
+
private readonly submissions;
|
|
16
22
|
private readonly errors;
|
|
17
23
|
private readonly sendRequest;
|
|
18
24
|
private requestCount;
|
|
19
25
|
private isDone;
|
|
20
|
-
constructor(args:
|
|
21
|
-
setOptions(options:
|
|
22
|
-
requestNext(): Promise<T
|
|
26
|
+
constructor(args: SubmissionRequestWrapperArgs<T>);
|
|
27
|
+
setOptions(options: SubmissionRequestWrapperOptions): void;
|
|
28
|
+
requestNext(): Promise<SubmissionRequestWrapperResult<T>>;
|
|
23
29
|
skip(count?: number): void;
|
|
24
|
-
requestAll(): Promise<T[]>;
|
|
30
|
+
requestAll(): Promise<SubmissionRequestWrapperResult<T>[]>;
|
|
25
31
|
clearResults(): void;
|
|
26
|
-
getResults(): T[];
|
|
32
|
+
getResults(): SubmissionRequestWrapperResult<T>[];
|
|
27
33
|
getErrors(): string[];
|
|
28
34
|
getSize(): number;
|
|
35
|
+
getSubmissions(): FilingListItemTranslated[];
|
|
29
36
|
}
|
|
30
37
|
export {};
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -36,35 +36,42 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var
|
|
40
|
-
function
|
|
41
|
-
var
|
|
39
|
+
var SubmissionRequestWrapper = /** @class */ (function () {
|
|
40
|
+
function SubmissionRequestWrapper(args) {
|
|
41
|
+
var submissions = args.submissions, _a = args.options, options = _a === void 0 ? {} : _a, sendRequest = args.sendRequest;
|
|
42
42
|
this.options = options;
|
|
43
|
-
this.
|
|
43
|
+
this.submissions = submissions;
|
|
44
44
|
this.results = [];
|
|
45
45
|
this.errors = [];
|
|
46
46
|
this.sendRequest = sendRequest;
|
|
47
47
|
this.requestCount = 0;
|
|
48
48
|
this.isDone = (options === null || options === void 0 ? void 0 : options.maxRequests) === 0;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
SubmissionRequestWrapper.prototype.setOptions = function (options) {
|
|
51
51
|
for (var key in options) {
|
|
52
|
-
this.options[key] =
|
|
52
|
+
this.options[key] =
|
|
53
|
+
options[key];
|
|
53
54
|
}
|
|
54
55
|
};
|
|
55
|
-
|
|
56
|
+
SubmissionRequestWrapper.prototype.requestNext = function () {
|
|
56
57
|
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
-
var _a, maxRequests, url, result,
|
|
58
|
-
var _this = this;
|
|
58
|
+
var _a, maxRequests, submission, isComplete, url, result, data, e_1, error;
|
|
59
59
|
return __generator(this, function (_b) {
|
|
60
60
|
switch (_b.label) {
|
|
61
61
|
case 0:
|
|
62
62
|
_a = this.options.maxRequests, maxRequests = _a === void 0 ? Infinity : _a;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
submission = this.submissions[this.requestCount];
|
|
64
|
+
isComplete = this.requestCount >= maxRequests || this.isDone;
|
|
65
|
+
if (isComplete || !submission) {
|
|
66
|
+
return [2 /*return*/, {
|
|
67
|
+
submission: submission,
|
|
68
|
+
error: isComplete ? 'max requests reached' : 'no submission found',
|
|
69
|
+
result: null,
|
|
70
|
+
}];
|
|
71
|
+
}
|
|
72
|
+
url = submission.url;
|
|
66
73
|
this.requestCount++;
|
|
67
|
-
if (this.requestCount >= this.
|
|
74
|
+
if (this.requestCount >= this.submissions.length || this.requestCount >= maxRequests) {
|
|
68
75
|
this.isDone = true;
|
|
69
76
|
}
|
|
70
77
|
_b.label = 1;
|
|
@@ -73,61 +80,68 @@ var RequestWrapper = /** @class */ (function () {
|
|
|
73
80
|
return [4 /*yield*/, this.sendRequest({ url: url })];
|
|
74
81
|
case 2:
|
|
75
82
|
result = _b.sent();
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
data = {
|
|
84
|
+
submission: submission,
|
|
85
|
+
error: null,
|
|
86
|
+
result: result,
|
|
87
|
+
};
|
|
88
|
+
this.results.push(data);
|
|
89
|
+
return [2 /*return*/, data];
|
|
79
90
|
case 3:
|
|
80
91
|
e_1 = _b.sent();
|
|
81
92
|
error = e_1;
|
|
82
93
|
this.errors.push(error.message);
|
|
83
|
-
return [
|
|
84
|
-
|
|
94
|
+
return [2 /*return*/, {
|
|
95
|
+
submission: submission,
|
|
96
|
+
error: error.message,
|
|
97
|
+
result: null,
|
|
98
|
+
}];
|
|
99
|
+
case 4: return [2 /*return*/];
|
|
85
100
|
}
|
|
86
101
|
});
|
|
87
102
|
});
|
|
88
103
|
};
|
|
89
|
-
|
|
104
|
+
SubmissionRequestWrapper.prototype.skip = function (count) {
|
|
90
105
|
if (count === void 0) { count = 1; }
|
|
91
106
|
this.requestCount += count;
|
|
92
107
|
};
|
|
93
|
-
|
|
108
|
+
SubmissionRequestWrapper.prototype.requestAll = function () {
|
|
94
109
|
var _a;
|
|
95
110
|
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
-
var promises, maxRequests, i,
|
|
111
|
+
var promises, maxRequests, i, results;
|
|
112
|
+
var _this = this;
|
|
97
113
|
return __generator(this, function (_b) {
|
|
98
114
|
switch (_b.label) {
|
|
99
115
|
case 0:
|
|
100
116
|
promises = [];
|
|
101
|
-
maxRequests = (_a = this.options.maxRequests) !== null && _a !== void 0 ? _a : this.
|
|
117
|
+
maxRequests = (_a = this.options.maxRequests) !== null && _a !== void 0 ? _a : this.submissions.length;
|
|
102
118
|
for (i = 0; i < maxRequests; i++) {
|
|
103
119
|
promises.push(this.requestNext());
|
|
104
120
|
}
|
|
105
121
|
return [4 /*yield*/, Promise.all(promises)];
|
|
106
122
|
case 1:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
results === null || results === void 0 ? void 0 : results.forEach(function (result) { return resultsFlat.push(result); });
|
|
111
|
-
});
|
|
112
|
-
this.clearResults();
|
|
113
|
-
this.results = resultsFlat;
|
|
114
|
-
return [2 /*return*/, resultsFlat];
|
|
123
|
+
results = _b.sent();
|
|
124
|
+
results.forEach(function (result) { return _this.results.push(result); });
|
|
125
|
+
return [2 /*return*/, results];
|
|
115
126
|
}
|
|
116
127
|
});
|
|
117
128
|
});
|
|
118
129
|
};
|
|
119
|
-
|
|
130
|
+
SubmissionRequestWrapper.prototype.clearResults = function () {
|
|
120
131
|
this.results = [];
|
|
121
132
|
};
|
|
122
|
-
|
|
133
|
+
SubmissionRequestWrapper.prototype.getResults = function () {
|
|
123
134
|
return this.results;
|
|
124
135
|
};
|
|
125
|
-
|
|
136
|
+
SubmissionRequestWrapper.prototype.getErrors = function () {
|
|
126
137
|
return this.errors;
|
|
127
138
|
};
|
|
128
|
-
|
|
129
|
-
return this.
|
|
139
|
+
SubmissionRequestWrapper.prototype.getSize = function () {
|
|
140
|
+
return this.submissions.length;
|
|
141
|
+
};
|
|
142
|
+
SubmissionRequestWrapper.prototype.getSubmissions = function () {
|
|
143
|
+
return this.submissions;
|
|
130
144
|
};
|
|
131
|
-
return
|
|
145
|
+
return SubmissionRequestWrapper;
|
|
132
146
|
}());
|
|
133
|
-
exports.default =
|
|
147
|
+
exports.default = SubmissionRequestWrapper;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { CompanyFactFrame, CompanyFactListData, CompanyTickerItem, FieldDataResponse, Holder, InsiderTransaction, MultiCompanyFactFrame, ReportRaw, ReportTranslated } from '../../types';
|
|
1
|
+
import { CompanyFactFrame, CompanyFactListData, CompanyTickerItem, FieldDataResponse, Holder, InsiderTransaction, MultiCompanyFactFrame, ReportRaw, ReportTranslated, TableData } from '../../types';
|
|
2
2
|
import { FilingListDetails, FilingListItemTranslated, SubmissionList } from '../../types/submission.type';
|
|
3
3
|
import { IClient } from '../Client';
|
|
4
4
|
import DocumentParser from '../DocumentParser';
|
|
5
5
|
import ReportParser from '../ReportParser';
|
|
6
6
|
import { ParseReportsOptions } from '../ReportParser/ReportRawParser';
|
|
7
7
|
import ReportWrapper from '../ReportParser/ReportWrapper';
|
|
8
|
-
import
|
|
8
|
+
import SubmissionRequestWrapper from './RequestWrapper';
|
|
9
9
|
import { IThrottler } from './Throttler';
|
|
10
10
|
interface SecApiArgs {
|
|
11
11
|
throttler: IThrottler;
|
|
@@ -30,6 +30,7 @@ export interface GetReportsParams {
|
|
|
30
30
|
/** symbol or cik */
|
|
31
31
|
symbol: string | number;
|
|
32
32
|
withWrapper?: boolean;
|
|
33
|
+
usePropertyResolver?: boolean;
|
|
33
34
|
}
|
|
34
35
|
export interface GetFactParams {
|
|
35
36
|
/** symbol or cik */
|
|
@@ -70,7 +71,7 @@ export default class SecEdgarApi {
|
|
|
70
71
|
constructor(args?: SecApiArgs);
|
|
71
72
|
private request;
|
|
72
73
|
private mapFilingListDetails;
|
|
73
|
-
private
|
|
74
|
+
private getCreateRequestSubmissions;
|
|
74
75
|
/**
|
|
75
76
|
* If symbol is not in cikBySymbol, assume it is a cik. does not make a request
|
|
76
77
|
*/
|
|
@@ -186,11 +187,11 @@ export default class SecEdgarApi {
|
|
|
186
187
|
* const submissions = await secEdgarApi.getSubmissions({ symbol: 'AAPL' })
|
|
187
188
|
* const requestWrapper = secEdgarApi.createRequestInsiderTransactions({ symbol: 'AAPL', filings: submissions.filings.recent })
|
|
188
189
|
*
|
|
189
|
-
* const transactions1 = await requestWrapper.requestNext() // array of transactions from most recent doc
|
|
190
|
-
* const transactions2 = await requestWrapper.requestNext() // array of transactions from second most recent doc
|
|
190
|
+
* const transactions1 = (await requestWrapper.requestNext()).result // array of transactions from most recent doc
|
|
191
|
+
* const transactions2 = (await requestWrapper.requestNext()).result // array of transactions from second most recent doc
|
|
191
192
|
* ```
|
|
192
193
|
*/
|
|
193
|
-
createRequestInsiderTransactions(params: CreateRequestWrapperParams):
|
|
194
|
+
createRequestInsiderTransactions(params: CreateRequestWrapperParams): SubmissionRequestWrapper<InsiderTransaction[]>;
|
|
194
195
|
/**
|
|
195
196
|
* Used for getting institutional holders. extracts holders urls from submission list response, and parses the xml doc.
|
|
196
197
|
*
|
|
@@ -198,10 +199,22 @@ export default class SecEdgarApi {
|
|
|
198
199
|
* const submissions = await secEdgarApi.getSubmissions({ symbol: 'AAPL' })
|
|
199
200
|
* const requestWrapper = secEdgarApi.createRequestHolders({ symbol: 'AAPL', filings: submissions.filings.recent })
|
|
200
201
|
*
|
|
201
|
-
* const holders1 = await requestWrapper.requestNext() // array of holders from most recent doc
|
|
202
|
-
* const holders2 = await requestWrapper.requestNext() // array of holders from second most recent doc
|
|
202
|
+
* const holders1 = (await requestWrapper.requestNext()).result // array of holders from most recent doc
|
|
203
|
+
* const holders2 = (await requestWrapper.requestNext()).result // array of holders from second most recent doc
|
|
203
204
|
* ```
|
|
204
205
|
*/
|
|
205
|
-
createRequestHolders(params: CreateRequestWrapperParams):
|
|
206
|
+
createRequestHolders(params: CreateRequestWrapperParams): SubmissionRequestWrapper<Holder[]>;
|
|
207
|
+
/**
|
|
208
|
+
* Used for getting earnings report tables from submission files.
|
|
209
|
+
*
|
|
210
|
+
* ```ts
|
|
211
|
+
* const submissions = await secEdgarApi.getSubmissions({ symbol: 'AAPL' })
|
|
212
|
+
* const requestWrapper = secEdgarApi.createRequesEarningsReports({ symbol: 'AAPL', filings: submissions.filings.recent })
|
|
213
|
+
*
|
|
214
|
+
* const tables1 = (await requestWrapper.requestNext()).result // array of tables from most recent doc
|
|
215
|
+
* const tables2 = (await requestWrapper.requestNext()).result // array of tables from second most recent doc
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
createRequestEarningsReports(params: CreateRequestWrapperParams): SubmissionRequestWrapper<TableData[]>;
|
|
206
219
|
}
|
|
207
220
|
export {};
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -126,22 +126,14 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
126
126
|
}
|
|
127
127
|
return filings;
|
|
128
128
|
};
|
|
129
|
-
SecEdgarApi.prototype.
|
|
129
|
+
SecEdgarApi.prototype.getCreateRequestSubmissions = function (params, forms) {
|
|
130
130
|
var symbol = params.symbol, filings = params.filings, _a = params.cutoffDate, cutoffDate = _a === void 0 ? new Date('1970-01-01') : _a;
|
|
131
131
|
var cik = this.getCikString(symbol);
|
|
132
132
|
var filingsArr = Array.isArray(filings) ? filings : this.mapFilingListDetails(cik, filings);
|
|
133
|
-
|
|
133
|
+
return filingsArr.filter(function (_a) {
|
|
134
134
|
var form = _a.form, filingDate = _a.filingDate;
|
|
135
135
|
return forms.includes(form) && new Date(filingDate).getTime() > cutoffDate.getTime();
|
|
136
136
|
});
|
|
137
|
-
var urls = filingsFiltered.filter(function (_a) {
|
|
138
|
-
var form = _a.form;
|
|
139
|
-
return forms.includes(form);
|
|
140
|
-
}).map(function (_a) {
|
|
141
|
-
var url = _a.url;
|
|
142
|
-
return url;
|
|
143
|
-
});
|
|
144
|
-
return urls;
|
|
145
137
|
};
|
|
146
138
|
/**
|
|
147
139
|
* If symbol is not in cikBySymbol, assume it is a cik. does not make a request
|
|
@@ -175,6 +167,7 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
175
167
|
return [4 /*yield*/, this.request("".concat(this.baseUrlEdgar, "/submissions/CIK").concat(cik, ".json"))];
|
|
176
168
|
case 1:
|
|
177
169
|
submissions = _a.sent();
|
|
170
|
+
submissions.cik = Number(submissions.cik);
|
|
178
171
|
if (!includeTranslated)
|
|
179
172
|
return [2 /*return*/, submissions];
|
|
180
173
|
submissions.filings.recentTranslated = this.mapFilingListDetails(cik, submissions.filings.recent);
|
|
@@ -258,15 +251,15 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
258
251
|
*/
|
|
259
252
|
SecEdgarApi.prototype.getReports = function (params) {
|
|
260
253
|
return __awaiter(this, void 0, void 0, function () {
|
|
261
|
-
var symbol, _a, withWrapper, facts, reports;
|
|
262
|
-
return __generator(this, function (
|
|
263
|
-
switch (
|
|
254
|
+
var symbol, _a, withWrapper, _b, usePropertyResolver, facts, reports;
|
|
255
|
+
return __generator(this, function (_c) {
|
|
256
|
+
switch (_c.label) {
|
|
264
257
|
case 0:
|
|
265
|
-
symbol = params.symbol, _a = params.withWrapper, withWrapper = _a === void 0 ? false : _a;
|
|
258
|
+
symbol = params.symbol, _a = params.withWrapper, withWrapper = _a === void 0 ? false : _a, _b = params.usePropertyResolver, usePropertyResolver = _b === void 0 ? true : _b;
|
|
266
259
|
return [4 /*yield*/, this.getFacts({ symbol: symbol })];
|
|
267
260
|
case 1:
|
|
268
|
-
facts =
|
|
269
|
-
reports = this.reportParser.parseReports(facts);
|
|
261
|
+
facts = _c.sent();
|
|
262
|
+
reports = this.reportParser.parseReports(facts, usePropertyResolver);
|
|
270
263
|
return [2 /*return*/, withWrapper ? reports : reports.map(function (report) { return report.getReport(); })];
|
|
271
264
|
}
|
|
272
265
|
});
|
|
@@ -373,13 +366,13 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
373
366
|
* const submissions = await secEdgarApi.getSubmissions({ symbol: 'AAPL' })
|
|
374
367
|
* const requestWrapper = secEdgarApi.createRequestInsiderTransactions({ symbol: 'AAPL', filings: submissions.filings.recent })
|
|
375
368
|
*
|
|
376
|
-
* const transactions1 = await requestWrapper.requestNext() // array of transactions from most recent doc
|
|
377
|
-
* const transactions2 = await requestWrapper.requestNext() // array of transactions from second most recent doc
|
|
369
|
+
* const transactions1 = (await requestWrapper.requestNext()).result // array of transactions from most recent doc
|
|
370
|
+
* const transactions2 = (await requestWrapper.requestNext()).result // array of transactions from second most recent doc
|
|
378
371
|
* ```
|
|
379
372
|
*/
|
|
380
373
|
SecEdgarApi.prototype.createRequestInsiderTransactions = function (params) {
|
|
381
374
|
var _this = this;
|
|
382
|
-
var
|
|
375
|
+
var submissions = this.getCreateRequestSubmissions(params, ['4', '4/A', '5', '5/A']);
|
|
383
376
|
var options = { maxRequests: params.maxRequests };
|
|
384
377
|
var sendRequest = function (params) { return __awaiter(_this, void 0, void 0, function () {
|
|
385
378
|
var _a, _b;
|
|
@@ -394,7 +387,7 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
394
387
|
}
|
|
395
388
|
});
|
|
396
389
|
}); };
|
|
397
|
-
return new RequestWrapper_1.default({
|
|
390
|
+
return new RequestWrapper_1.default({ submissions: submissions, options: options, sendRequest: sendRequest });
|
|
398
391
|
};
|
|
399
392
|
/**
|
|
400
393
|
* Used for getting institutional holders. extracts holders urls from submission list response, and parses the xml doc.
|
|
@@ -403,13 +396,13 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
403
396
|
* const submissions = await secEdgarApi.getSubmissions({ symbol: 'AAPL' })
|
|
404
397
|
* const requestWrapper = secEdgarApi.createRequestHolders({ symbol: 'AAPL', filings: submissions.filings.recent })
|
|
405
398
|
*
|
|
406
|
-
* const holders1 = await requestWrapper.requestNext() // array of holders from most recent doc
|
|
407
|
-
* const holders2 = await requestWrapper.requestNext() // array of holders from second most recent doc
|
|
399
|
+
* const holders1 = (await requestWrapper.requestNext()).result // array of holders from most recent doc
|
|
400
|
+
* const holders2 = (await requestWrapper.requestNext()).result // array of holders from second most recent doc
|
|
408
401
|
* ```
|
|
409
402
|
*/
|
|
410
403
|
SecEdgarApi.prototype.createRequestHolders = function (params) {
|
|
411
404
|
var _this = this;
|
|
412
|
-
var
|
|
405
|
+
var submissions = this.getCreateRequestSubmissions(params, ['SC 13G', 'SC 13G/A']);
|
|
413
406
|
var options = { maxRequests: params.maxRequests };
|
|
414
407
|
var sendRequest = function (params) { return __awaiter(_this, void 0, void 0, function () {
|
|
415
408
|
var _a, _b;
|
|
@@ -424,7 +417,37 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
424
417
|
}
|
|
425
418
|
});
|
|
426
419
|
}); };
|
|
427
|
-
return new RequestWrapper_1.default({
|
|
420
|
+
return new RequestWrapper_1.default({ submissions: submissions, options: options, sendRequest: sendRequest });
|
|
421
|
+
};
|
|
422
|
+
/**
|
|
423
|
+
* Used for getting earnings report tables from submission files.
|
|
424
|
+
*
|
|
425
|
+
* ```ts
|
|
426
|
+
* const submissions = await secEdgarApi.getSubmissions({ symbol: 'AAPL' })
|
|
427
|
+
* const requestWrapper = secEdgarApi.createRequesEarningsReports({ symbol: 'AAPL', filings: submissions.filings.recent })
|
|
428
|
+
*
|
|
429
|
+
* const tables1 = (await requestWrapper.requestNext()).result // array of tables from most recent doc
|
|
430
|
+
* const tables2 = (await requestWrapper.requestNext()).result // array of tables from second most recent doc
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
SecEdgarApi.prototype.createRequestEarningsReports = function (params) {
|
|
434
|
+
var _this = this;
|
|
435
|
+
var submissions = this.getCreateRequestSubmissions(params, ['10-Q', '10-Q/A', '10-K', '10-K/A']);
|
|
436
|
+
var options = { maxRequests: params.maxRequests };
|
|
437
|
+
var sendRequest = function (params) { return __awaiter(_this, void 0, void 0, function () {
|
|
438
|
+
var _a, _b;
|
|
439
|
+
var _c;
|
|
440
|
+
return __generator(this, function (_d) {
|
|
441
|
+
switch (_d.label) {
|
|
442
|
+
case 0:
|
|
443
|
+
_b = (_a = this.documentParser).parseEarningsTables;
|
|
444
|
+
_c = {};
|
|
445
|
+
return [4 /*yield*/, this.getDocumentXMLByUrl(params)];
|
|
446
|
+
case 1: return [2 /*return*/, _b.apply(_a, [(_c.xml = _d.sent(), _c)])];
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
}); };
|
|
450
|
+
return new RequestWrapper_1.default({ submissions: submissions, options: options, sendRequest: sendRequest });
|
|
428
451
|
};
|
|
429
452
|
return SecEdgarApi;
|
|
430
453
|
}());
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/build/types/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -19,9 +19,9 @@ interface TransactionDescriptionByCode {
|
|
|
19
19
|
K: 'Equity Swap';
|
|
20
20
|
U: 'Disposition Change in Control';
|
|
21
21
|
}
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
22
|
+
export type TransactionType = 'Acquire' | 'Dispose';
|
|
23
|
+
export type TransactionCode = keyof TransactionDescriptionByCode;
|
|
24
|
+
export type TransactionDescription = TransactionDescriptionByCode[TransactionCode];
|
|
25
25
|
export interface InsiderTransaction {
|
|
26
26
|
filerName: string;
|
|
27
27
|
filerPosition: string;
|
|
@@ -55,4 +55,12 @@ export interface Holder {
|
|
|
55
55
|
dispositivePowerShared: string | null;
|
|
56
56
|
typeOfReportingPerson: string | null;
|
|
57
57
|
}
|
|
58
|
+
export interface TableData {
|
|
59
|
+
title: string;
|
|
60
|
+
textBefore: string | null;
|
|
61
|
+
textAfter: string | null;
|
|
62
|
+
hasHeader: boolean;
|
|
63
|
+
sectionIndex: number;
|
|
64
|
+
rows: (string | number | null)[][];
|
|
65
|
+
}
|
|
58
66
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Contains all keys matched from the report, along with the added keys dateEnd, dateFiled, fiscalPeriod, fiscalYear.
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type ReportRaw = {
|
|
5
5
|
[key: string]: string | number | boolean;
|
|
6
6
|
dateReport: string;
|
|
7
7
|
dateFiled: string;
|
|
@@ -19,5 +19,5 @@ export declare type ReportRaw = {
|
|
|
19
19
|
*
|
|
20
20
|
* for dei, see https://www.sec.gov/structureddata/announcement/osd-announcement-2212-new-2022q4-taxonomies
|
|
21
21
|
*/
|
|
22
|
-
export
|
|
23
|
-
export
|
|
22
|
+
export type ReportType = 'QUARTERLY' | 'ANNUAL' | '8K' | 'DOCUMENT_ENTITY_INFO';
|
|
23
|
+
export type FiscalPeriod = 'Q1' | 'Q2' | 'Q3' | 'Q4' | 'FY';
|
package/package.json
CHANGED
package/build/.DS_Store
DELETED
|
Binary file
|
package/build/downloader.d.ts
DELETED
package/build/downloader.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.factsDownloader = void 0;
|
|
4
|
-
var FactsDownloader_1 = require("./services/FactsDownloader");
|
|
5
|
-
/**
|
|
6
|
-
* Downloads companyfacts.zip from sec.gov and extracts the directory
|
|
7
|
-
*/
|
|
8
|
-
var factsDownloader = new FactsDownloader_1.default();
|
|
9
|
-
exports.factsDownloader = factsDownloader;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { CompanyFactListData } from '../../types/company-facts.type';
|
|
2
|
-
interface FileManager {
|
|
3
|
-
readFileSync(path: string, encoding: string | object): string;
|
|
4
|
-
}
|
|
5
|
-
interface FactFileReaderArgs {
|
|
6
|
-
companyFactsDirname?: string;
|
|
7
|
-
cikBySymbol?: Record<string, number>;
|
|
8
|
-
fileManager?: FileManager;
|
|
9
|
-
}
|
|
10
|
-
interface ReadFactFileParams {
|
|
11
|
-
symbol: string;
|
|
12
|
-
companyFactsDirname: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Reads files from companyfacts folder from sec
|
|
16
|
-
*/
|
|
17
|
-
export default class FactFileReader {
|
|
18
|
-
private readonly fileManager;
|
|
19
|
-
private readonly cikBySymbol;
|
|
20
|
-
constructor(args?: FactFileReaderArgs);
|
|
21
|
-
getCikBySymbol(): Record<string, number>;
|
|
22
|
-
/**
|
|
23
|
-
* opens fact file from companyfacts directory
|
|
24
|
-
*
|
|
25
|
-
* @param symbol ex: AAPL
|
|
26
|
-
* @param companyFactsDirname ex: path.resolve(__dirname, './downloads/companyfacts')
|
|
27
|
-
*/
|
|
28
|
-
readFactFile(params: ReadFactFileParams): CompanyFactListData;
|
|
29
|
-
}
|
|
30
|
-
export {};
|