sec-edgar-api 0.0.6 → 0.0.7
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/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
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
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;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
|
-
var t = {};
|
|
51
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
-
t[p] = s[p];
|
|
53
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
-
t[p[i]] = s[p[i]];
|
|
57
|
-
}
|
|
58
|
-
return t;
|
|
59
|
-
};
|
|
60
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
-
var fs = require("fs");
|
|
62
|
-
var Client_1 = require("./Client");
|
|
63
|
-
var Downlaoder = /** @class */ (function () {
|
|
64
|
-
function Downlaoder(args) {
|
|
65
|
-
if (args === void 0) { args = { client: new Client_1.default(), fileManager: fs }; }
|
|
66
|
-
var client = args.client, fileManager = args.fileManager;
|
|
67
|
-
this.client = client;
|
|
68
|
-
this.fileManager = fileManager;
|
|
69
|
-
}
|
|
70
|
-
Downlaoder.prototype.download = function (params) {
|
|
71
|
-
var _this = this;
|
|
72
|
-
var filename = params.filename, onSuccess = params.onSuccess, onError = params.onError, _a = params.createDirIfNotExists, createDirIfNotExists = _a === void 0 ? false : _a, rest = __rest(params, ["filename", "onSuccess", "onError", "createDirIfNotExists"]);
|
|
73
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
74
|
-
var dir, file;
|
|
75
|
-
return __generator(this, function (_a) {
|
|
76
|
-
dir = filename.substring(0, filename.lastIndexOf('/'));
|
|
77
|
-
if (dir.length > 0 && createDirIfNotExists && !this.fileManager.existsSync(dir)) {
|
|
78
|
-
this.fileManager.mkdirSync(dir);
|
|
79
|
-
}
|
|
80
|
-
file = this.fileManager.createWriteStream(filename);
|
|
81
|
-
file.on('close', function () { return resolve(true); });
|
|
82
|
-
file.on('finish', function () { return file.close(); });
|
|
83
|
-
file.on('error', function (err) {
|
|
84
|
-
file.destroy();
|
|
85
|
-
onError === null || onError === void 0 ? void 0 : onError(err);
|
|
86
|
-
reject(false);
|
|
87
|
-
});
|
|
88
|
-
this.client
|
|
89
|
-
.request(__assign(__assign({ onError: onError }, rest), { onResponse: function (res) {
|
|
90
|
-
var _a;
|
|
91
|
-
res.pipe(file);
|
|
92
|
-
(_a = rest.onResponse) === null || _a === void 0 ? void 0 : _a.call(rest, res);
|
|
93
|
-
} }))
|
|
94
|
-
.then(function (res) { return onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(res); })
|
|
95
|
-
.catch(function () { return reject(false); });
|
|
96
|
-
return [2 /*return*/];
|
|
97
|
-
});
|
|
98
|
-
}); });
|
|
99
|
-
};
|
|
100
|
-
return Downlaoder;
|
|
101
|
-
}());
|
|
102
|
-
exports.default = Downlaoder;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IDownloader } from './Downloader';
|
|
3
|
-
import Unzipper from './Unzipper';
|
|
4
|
-
interface FactsDownloaderArgs {
|
|
5
|
-
downloader: IDownloader;
|
|
6
|
-
unzipper: Unzipper;
|
|
7
|
-
}
|
|
8
|
-
interface OnChunkData {
|
|
9
|
-
percentComplete: number;
|
|
10
|
-
chunk: Buffer;
|
|
11
|
-
stage: 'download' | 'unzip';
|
|
12
|
-
}
|
|
13
|
-
export interface DownloadCompanyFactsDirectoryParams {
|
|
14
|
-
outputDirname: string;
|
|
15
|
-
unzip?: boolean;
|
|
16
|
-
onChunk?: (data: OnChunkData) => void;
|
|
17
|
-
onDownloadComplete?: () => void;
|
|
18
|
-
onComplete?: () => void;
|
|
19
|
-
onError?: (err: Error) => void;
|
|
20
|
-
}
|
|
21
|
-
export interface IFactsDownloader {
|
|
22
|
-
downloadCompanyFactsDirectory(params: DownloadCompanyFactsDirectoryParams): Promise<boolean>;
|
|
23
|
-
}
|
|
24
|
-
export default class FactsDownloader implements IFactsDownloader {
|
|
25
|
-
private readonly unzipper;
|
|
26
|
-
private readonly downloader;
|
|
27
|
-
constructor(args?: FactsDownloaderArgs);
|
|
28
|
-
downloadCompanyFactsDirectory(params: DownloadCompanyFactsDirectoryParams): Promise<boolean>;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
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;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
var Downloader_1 = require("./Downloader");
|
|
51
|
-
var Unzipper_1 = require("./Unzipper");
|
|
52
|
-
var FactsDownloader = /** @class */ (function () {
|
|
53
|
-
function FactsDownloader(args) {
|
|
54
|
-
if (args === void 0) { args = {
|
|
55
|
-
downloader: new Downloader_1.default(),
|
|
56
|
-
unzipper: new Unzipper_1.default(),
|
|
57
|
-
}; }
|
|
58
|
-
var unzipper = args.unzipper, downloader = args.downloader;
|
|
59
|
-
this.unzipper = unzipper;
|
|
60
|
-
this.downloader = downloader;
|
|
61
|
-
}
|
|
62
|
-
FactsDownloader.prototype.downloadCompanyFactsDirectory = function (params) {
|
|
63
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
-
var outputDirname, onChunk, onDownloadComplete, onError, onComplete, _a, unzip;
|
|
65
|
-
var _this = this;
|
|
66
|
-
return __generator(this, function (_b) {
|
|
67
|
-
outputDirname = params.outputDirname, onChunk = params.onChunk, onDownloadComplete = params.onDownloadComplete, onError = params.onError, onComplete = params.onComplete, _a = params.unzip, unzip = _a === void 0 ? true : _a;
|
|
68
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
69
|
-
var filename, e_1;
|
|
70
|
-
return __generator(this, function (_a) {
|
|
71
|
-
switch (_a.label) {
|
|
72
|
-
case 0:
|
|
73
|
-
filename = "".concat(outputDirname, ".zip");
|
|
74
|
-
_a.label = 1;
|
|
75
|
-
case 1:
|
|
76
|
-
_a.trys.push([1, 5, , 6]);
|
|
77
|
-
// download from sec
|
|
78
|
-
return [4 /*yield*/, this.downloader.download({
|
|
79
|
-
url: 'https://www.sec.gov/Archives/edgar/daily-index/xbrl/companyfacts.zip',
|
|
80
|
-
filename: filename,
|
|
81
|
-
createDirIfNotExists: true,
|
|
82
|
-
resolveData: false,
|
|
83
|
-
headers: {
|
|
84
|
-
'Accept-Encoding': 'gzip, deflate',
|
|
85
|
-
},
|
|
86
|
-
onError: function (err) { return reject(err); },
|
|
87
|
-
onChunk: onChunk ? function (data) { return onChunk === null || onChunk === void 0 ? void 0 : onChunk(__assign(__assign({}, data), { stage: 'download' })); } : undefined,
|
|
88
|
-
})];
|
|
89
|
-
case 2:
|
|
90
|
-
// download from sec
|
|
91
|
-
_a.sent();
|
|
92
|
-
onDownloadComplete === null || onDownloadComplete === void 0 ? void 0 : onDownloadComplete();
|
|
93
|
-
if (!unzip) return [3 /*break*/, 4];
|
|
94
|
-
// unzip companyfacts.zip
|
|
95
|
-
return [4 /*yield*/, this.unzipper.unzip({
|
|
96
|
-
inputFilename: filename,
|
|
97
|
-
outputDirname: outputDirname,
|
|
98
|
-
deleteOriginal: true,
|
|
99
|
-
onError: function (err) { return reject(err); },
|
|
100
|
-
onChunk: onChunk ? function (data) { return onChunk === null || onChunk === void 0 ? void 0 : onChunk(__assign(__assign({}, data), { stage: 'unzip' })); } : undefined,
|
|
101
|
-
})];
|
|
102
|
-
case 3:
|
|
103
|
-
// unzip companyfacts.zip
|
|
104
|
-
_a.sent();
|
|
105
|
-
_a.label = 4;
|
|
106
|
-
case 4:
|
|
107
|
-
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
108
|
-
resolve(true);
|
|
109
|
-
return [3 /*break*/, 6];
|
|
110
|
-
case 5:
|
|
111
|
-
e_1 = _a.sent();
|
|
112
|
-
onError === null || onError === void 0 ? void 0 : onError(e_1);
|
|
113
|
-
reject(e_1);
|
|
114
|
-
return [3 /*break*/, 6];
|
|
115
|
-
case 6: return [2 /*return*/];
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}); })];
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
return FactsDownloader;
|
|
123
|
-
}());
|
|
124
|
-
exports.default = FactsDownloader;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { CompanyFactFrame, CompanyFactListData, MultiCompanyFactFrame } from '../../types';
|
|
2
|
-
import { SubmissionList } from '../../types/submission.type';
|
|
3
|
-
import { IClient } from '../Client';
|
|
4
|
-
import { IThrottler } from './Throttler';
|
|
5
|
-
interface SecApiArgs {
|
|
6
|
-
throttler: IThrottler;
|
|
7
|
-
client: IClient;
|
|
8
|
-
cikBySymbol: Record<string, number>;
|
|
9
|
-
}
|
|
10
|
-
export interface GetSymbolParams {
|
|
11
|
-
symbol: string;
|
|
12
|
-
}
|
|
13
|
-
export interface GetFactParams {
|
|
14
|
-
symbol: string;
|
|
15
|
-
fact: string;
|
|
16
|
-
taxonomy?: 'us-gaap' | 'dei' | 'invest' | string;
|
|
17
|
-
}
|
|
18
|
-
export interface GetFactFrameParams {
|
|
19
|
-
fact: string;
|
|
20
|
-
frame: string;
|
|
21
|
-
unit?: 'pure' | 'USD' | 'shares' | string;
|
|
22
|
-
taxonomy?: 'us-gaap' | 'dei' | 'invest' | string;
|
|
23
|
-
}
|
|
24
|
-
export interface ISecConnector {
|
|
25
|
-
getSubmissions(params: GetSymbolParams): Promise<SubmissionList>;
|
|
26
|
-
getFact(params: GetFactParams): Promise<CompanyFactFrame>;
|
|
27
|
-
getFacts(params: GetSymbolParams): Promise<CompanyFactListData>;
|
|
28
|
-
getFactFrame(params: GetFactFrameParams): Promise<MultiCompanyFactFrame>;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Gets reports from companies filed with the SEC
|
|
32
|
-
*
|
|
33
|
-
* @see https://www.sec.gov/edgar/sec-api-documentation
|
|
34
|
-
*/
|
|
35
|
-
export default class SecConnector implements ISecConnector {
|
|
36
|
-
private readonly throttler;
|
|
37
|
-
private readonly client;
|
|
38
|
-
private readonly cikBySymbol;
|
|
39
|
-
constructor(args?: SecApiArgs);
|
|
40
|
-
private getCikString;
|
|
41
|
-
private request;
|
|
42
|
-
getSubmissions(params: GetSymbolParams): Promise<SubmissionList>;
|
|
43
|
-
getFact(params: GetFactParams): Promise<CompanyFactFrame>;
|
|
44
|
-
getFacts(params: GetSymbolParams): Promise<CompanyFactListData>;
|
|
45
|
-
getFactFrame(params: GetFactFrameParams): Promise<MultiCompanyFactFrame>;
|
|
46
|
-
}
|
|
47
|
-
export {};
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
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
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var cik_by_symbol_1 = require("../../util/cik-by-symbol");
|
|
40
|
-
var Client_1 = require("../Client");
|
|
41
|
-
var Throttler_1 = require("./Throttler");
|
|
42
|
-
/**
|
|
43
|
-
* Gets reports from companies filed with the SEC
|
|
44
|
-
*
|
|
45
|
-
* @see https://www.sec.gov/edgar/sec-api-documentation
|
|
46
|
-
*/
|
|
47
|
-
var SecConnector = /** @class */ (function () {
|
|
48
|
-
function SecConnector(args) {
|
|
49
|
-
if (args === void 0) { args = { client: new Client_1.default(), throttler: new Throttler_1.default(), cikBySymbol: cik_by_symbol_1.default }; }
|
|
50
|
-
var client = args.client, throttler = args.throttler, cikBySymbol = args.cikBySymbol;
|
|
51
|
-
this.client = client;
|
|
52
|
-
this.throttler = throttler;
|
|
53
|
-
this.cikBySymbol = cikBySymbol;
|
|
54
|
-
}
|
|
55
|
-
SecConnector.prototype.getCikString = function (symbol) {
|
|
56
|
-
var _a;
|
|
57
|
-
var cik = (_a = this.cikBySymbol[symbol]) !== null && _a !== void 0 ? _a : '';
|
|
58
|
-
return cik.toString().padStart(10, '0');
|
|
59
|
-
};
|
|
60
|
-
SecConnector.prototype.request = function (path) {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
-
var baseUrl;
|
|
63
|
-
var _this = this;
|
|
64
|
-
return __generator(this, function (_a) {
|
|
65
|
-
baseUrl = 'https://data.sec.gov';
|
|
66
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
67
|
-
var _this = this;
|
|
68
|
-
return __generator(this, function (_a) {
|
|
69
|
-
this.throttler.add(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
70
|
-
var response, responseData, e_1;
|
|
71
|
-
var _a, _b;
|
|
72
|
-
return __generator(this, function (_c) {
|
|
73
|
-
switch (_c.label) {
|
|
74
|
-
case 0:
|
|
75
|
-
_c.trys.push([0, 2, , 3]);
|
|
76
|
-
return [4 /*yield*/, this.client.request({
|
|
77
|
-
url: "".concat(baseUrl).concat(path),
|
|
78
|
-
onError: function (err) { return reject(err); },
|
|
79
|
-
})];
|
|
80
|
-
case 1:
|
|
81
|
-
response = _c.sent();
|
|
82
|
-
responseData = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.toString('utf-8')) !== null && _b !== void 0 ? _b : null;
|
|
83
|
-
if (response.statusCode >= 400 || typeof responseData !== 'string') {
|
|
84
|
-
reject("Request failed with status ".concat(response.statusCode, " ").concat(response.message));
|
|
85
|
-
}
|
|
86
|
-
resolve(JSON.parse(responseData));
|
|
87
|
-
return [3 /*break*/, 3];
|
|
88
|
-
case 2:
|
|
89
|
-
e_1 = _c.sent();
|
|
90
|
-
reject(e_1);
|
|
91
|
-
return [3 /*break*/, 3];
|
|
92
|
-
case 3: return [2 /*return*/];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}); });
|
|
96
|
-
return [2 /*return*/];
|
|
97
|
-
});
|
|
98
|
-
}); })];
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
SecConnector.prototype.getSubmissions = function (params) {
|
|
103
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
-
var symbol, cik;
|
|
105
|
-
return __generator(this, function (_a) {
|
|
106
|
-
symbol = params.symbol;
|
|
107
|
-
cik = this.getCikString(symbol);
|
|
108
|
-
return [2 /*return*/, this.request("/submissions/CIK".concat(cik, ".json"))];
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
SecConnector.prototype.getFact = function (params) {
|
|
113
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
-
var symbol, fact, _a, taxonomy, cik;
|
|
115
|
-
return __generator(this, function (_b) {
|
|
116
|
-
symbol = params.symbol, fact = params.fact, _a = params.taxonomy, taxonomy = _a === void 0 ? 'us-gaap' : _a;
|
|
117
|
-
cik = this.getCikString(symbol);
|
|
118
|
-
return [2 /*return*/, this.request("/api/xbrl/companyconcept/CIK".concat(cik, "/").concat(taxonomy, "/").concat(fact, ".json"))];
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
SecConnector.prototype.getFacts = function (params) {
|
|
123
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
124
|
-
var symbol, cik;
|
|
125
|
-
return __generator(this, function (_a) {
|
|
126
|
-
symbol = params.symbol;
|
|
127
|
-
cik = this.getCikString(symbol);
|
|
128
|
-
return [2 /*return*/, this.request("/api/xbrl/companyfacts/CIK".concat(cik, ".json"))];
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
SecConnector.prototype.getFactFrame = function (params) {
|
|
133
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
134
|
-
var fact, frame, _a, taxonomy, _b, unit;
|
|
135
|
-
return __generator(this, function (_c) {
|
|
136
|
-
fact = params.fact, frame = params.frame, _a = params.taxonomy, taxonomy = _a === void 0 ? 'us-gaap' : _a, _b = params.unit, unit = _b === void 0 ? 'pure' : _b;
|
|
137
|
-
return [2 /*return*/, this.request("/api/xbrl/frames/".concat(taxonomy, "/").concat(fact, "/").concat(unit, "/").concat(frame, ".json"))];
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
return SecConnector;
|
|
142
|
-
}());
|
|
143
|
-
exports.default = SecConnector;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import * as fs from 'fs';
|
|
4
|
-
import { ReadStream } from 'fs';
|
|
5
|
-
import { ParseStream } from 'unzipper';
|
|
6
|
-
interface IFileManager {
|
|
7
|
-
createReadStream(path: string): ReadStream;
|
|
8
|
-
unlinkSync(path: string): void;
|
|
9
|
-
statSync(path: string): fs.Stats;
|
|
10
|
-
}
|
|
11
|
-
interface IFileUnzipper {
|
|
12
|
-
Extract(options: {
|
|
13
|
-
path: string;
|
|
14
|
-
}): ParseStream;
|
|
15
|
-
}
|
|
16
|
-
interface UnzipperArgs {
|
|
17
|
-
unzipper: IFileUnzipper;
|
|
18
|
-
fileManager: IFileManager;
|
|
19
|
-
}
|
|
20
|
-
interface OnChunkData {
|
|
21
|
-
percentComplete: number;
|
|
22
|
-
chunk: Buffer;
|
|
23
|
-
}
|
|
24
|
-
interface UnzipParams {
|
|
25
|
-
inputFilename: string;
|
|
26
|
-
outputDirname: string;
|
|
27
|
-
onChunk?: (data: OnChunkData) => void;
|
|
28
|
-
onError?: (err: Error) => void;
|
|
29
|
-
deleteOriginal?: boolean;
|
|
30
|
-
}
|
|
31
|
-
export interface IUnzipper {
|
|
32
|
-
unzip(params: UnzipParams): Promise<any>;
|
|
33
|
-
}
|
|
34
|
-
export default class Unzipper implements IUnzipper {
|
|
35
|
-
private readonly fileManager;
|
|
36
|
-
private readonly unzipper;
|
|
37
|
-
constructor(args?: UnzipperArgs);
|
|
38
|
-
unzip(params: UnzipParams): Promise<unknown>;
|
|
39
|
-
}
|
|
40
|
-
export {};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var fs = require("fs");
|
|
4
|
-
var _unzipper = require("unzipper");
|
|
5
|
-
var Unzipper = /** @class */ (function () {
|
|
6
|
-
function Unzipper(args) {
|
|
7
|
-
if (args === void 0) { args = { fileManager: fs, unzipper: _unzipper }; }
|
|
8
|
-
var fileManager = args.fileManager, unzipper = args.unzipper;
|
|
9
|
-
this.fileManager = fileManager;
|
|
10
|
-
this.unzipper = unzipper;
|
|
11
|
-
}
|
|
12
|
-
Unzipper.prototype.unzip = function (params) {
|
|
13
|
-
var _this = this;
|
|
14
|
-
var inputFilename = params.inputFilename, outputDirname = params.outputDirname, onChunk = params.onChunk, onError = params.onError, _a = params.deleteOriginal, deleteOriginal = _a === void 0 ? false : _a;
|
|
15
|
-
return new Promise(function (resolve, reject) {
|
|
16
|
-
var file = _this.fileManager.createReadStream(inputFilename);
|
|
17
|
-
var filesize = _this.fileManager.statSync(inputFilename).size;
|
|
18
|
-
var unzipped = _this.unzipper.Extract({ path: outputDirname });
|
|
19
|
-
var lengthCurrent = 0;
|
|
20
|
-
file.on('data', function (chunk) {
|
|
21
|
-
lengthCurrent += chunk.length;
|
|
22
|
-
var percentComplete = lengthCurrent / filesize;
|
|
23
|
-
onChunk === null || onChunk === void 0 ? void 0 : onChunk({ percentComplete: percentComplete, chunk: chunk });
|
|
24
|
-
});
|
|
25
|
-
file.pipe(unzipped);
|
|
26
|
-
file.on('end', function () {
|
|
27
|
-
if (deleteOriginal) {
|
|
28
|
-
_this.fileManager.unlinkSync(inputFilename);
|
|
29
|
-
}
|
|
30
|
-
resolve(true);
|
|
31
|
-
});
|
|
32
|
-
file.on('error', function (err) {
|
|
33
|
-
onError === null || onError === void 0 ? void 0 : onError(err);
|
|
34
|
-
reject(false);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
return Unzipper;
|
|
39
|
-
}());
|
|
40
|
-
exports.default = Unzipper;
|