sec-edgar-api 0.2.2 → 0.2.4
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 +5 -3
- package/build/services/DocumentParser/XMLParser.d.ts +5 -20
- package/build/services/DocumentParser/XMLParser.js +118 -122
- package/build/services/DocumentParser/parsers/index.d.ts +3 -5
- package/build/services/DocumentParser/parsers/index.js +3 -5
- package/build/services/DocumentParser/parsers/parse-form-13g.js +2 -2
- package/build/services/DocumentParser/parsers/parse-form-4.d.ts +1 -6
- package/build/services/DocumentParser/parsers/parse-form-4.js +204 -134
- package/build/services/DocumentParser/parsers/parse-form-def14a.d.ts +2 -1
- package/build/services/DocumentParser/parsers/parse-form-def14a.js +106 -157
- package/build/services/ReportBuilder/FactFiscalCalculator.d.ts +4 -0
- package/build/services/ReportBuilder/FactFiscalCalculator.js +4 -0
- package/build/services/ReportBuilder/FactPeriodResolver.d.ts +6 -2
- package/build/services/ReportBuilder/FactPeriodResolver.js +6 -1
- package/build/services/ReportBuilder/FactRecordBuilder.d.ts +4 -1
- package/build/services/ReportBuilder/FactRecordBuilder.js +26 -4
- package/build/services/ReportBuilder/FactSplitAdjuster.d.ts +12 -1
- package/build/services/ReportBuilder/FactSplitAdjuster.js +41 -19
- package/build/services/ReportBuilder/ReportBuilder.d.ts +3 -0
- package/build/services/ReportBuilder/ReportBuilder.js +33 -13
- package/build/services/ReportParser/ReportParser.d.ts +3 -3
- package/build/services/ReportParser/ReportParser.js +7 -4
- package/build/services/ReportParser/ReportRawParser.d.ts +3 -9
- package/build/services/ReportParser/ReportRawParser.js +5 -33
- package/build/services/ReportParser/ReportWrapper.js +2 -0
- package/build/services/ReportParser/resolvers/resolve-fiscal-year-cumulative-properties.js +2 -1
- package/build/services/SecEdgarApi/SecEdgarApi.d.ts +45 -84
- package/build/services/SecEdgarApi/SecEdgarApi.js +108 -246
- package/build/types/index.d.ts +2 -2
- package/build/types/index.js +2 -2
- package/build/types/parsed-filings.type.d.ts +5 -144
- package/build/types/report-raw.type.d.ts +3 -1
- package/build/types/report-translated.type.d.ts +4 -1
- package/build/types/submission.type.d.ts +2 -3
- package/build/util/key-translations.js +5 -1
- package/package.json +2 -5
- package/build/services/DocumentParser/HtmlTableExtractor.d.ts +0 -41
- package/build/services/DocumentParser/HtmlTableExtractor.js +0 -408
- package/build/services/DocumentParser/parsers/parse-current-filings.d.ts +0 -3
- package/build/services/DocumentParser/parsers/parse-current-filings.js +0 -98
- package/build/services/DocumentParser/parsers/parse-form-13f.d.ts +0 -6
- package/build/services/DocumentParser/parsers/parse-form-13f.js +0 -91
- package/build/services/ReportParser/FactItem.d.ts +0 -66
- package/build/services/ReportParser/FactItem.js +0 -50
- package/build/services/ReportParser/FactItemFactory.d.ts +0 -22
- package/build/services/ReportParser/FactItemFactory.js +0 -150
- package/build/services/ReportParser/FactIterator.d.ts +0 -18
- package/build/services/ReportParser/FactIterator.js +0 -35
- package/build/services/ReportParser/FactSplitMap.d.ts +0 -16
- package/build/services/ReportParser/FactSplitMap.js +0 -101
- package/build/types/current-filings-xml.type.d.ts +0 -74
- package/build/types/current-filings-xml.type.js +0 -6
- package/build/types/current-filings.type.d.ts +0 -44
- package/build/types/current-filings.type.js +0 -2
- package/build/types/form-13f-xml.type.d.ts +0 -105
- package/build/types/form-13f-xml.type.js +0 -2
- package/build/types/form-4-xml.type.d.ts +0 -132
- package/build/types/form-4-xml.type.js +0 -2
|
@@ -1,408 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var XMLParser_1 = require("./XMLParser");
|
|
4
|
-
var HtmlTableExtractor = /** @class */ (function () {
|
|
5
|
-
function HtmlTableExtractor() {
|
|
6
|
-
}
|
|
7
|
-
HtmlTableExtractor.prototype.extractTables = function (html, options) {
|
|
8
|
-
var _a;
|
|
9
|
-
var tablesOpen = [];
|
|
10
|
-
var tableIndex = -1;
|
|
11
|
-
var htmlBefore = '';
|
|
12
|
-
var tablesData = [];
|
|
13
|
-
for (var i = 0; i < html.length; i++) {
|
|
14
|
-
var isTableStart = html.substring(i, i + 6).toLowerCase() === '<table';
|
|
15
|
-
var isTableEnd = html.substring(i - 7, i + 1).toLowerCase() === '</table>';
|
|
16
|
-
var parentTable = tablesOpen[tablesOpen.length - 1];
|
|
17
|
-
if (isTableStart) {
|
|
18
|
-
tableIndex++;
|
|
19
|
-
tablesOpen.push({
|
|
20
|
-
tableIndex: tableIndex,
|
|
21
|
-
parentTableIndex: (_a = parentTable === null || parentTable === void 0 ? void 0 : parentTable.tableIndex) !== null && _a !== void 0 ? _a : null,
|
|
22
|
-
childTableIndexes: [],
|
|
23
|
-
positionStart: i,
|
|
24
|
-
positionEnd: -1,
|
|
25
|
-
htmlBefore: htmlBefore,
|
|
26
|
-
html: '',
|
|
27
|
-
rows: [],
|
|
28
|
-
});
|
|
29
|
-
parentTable === null || parentTable === void 0 ? void 0 : parentTable.childTableIndexes.push(tableIndex);
|
|
30
|
-
htmlBefore = '';
|
|
31
|
-
}
|
|
32
|
-
if (tablesOpen.length === 0) {
|
|
33
|
-
htmlBefore += html[i];
|
|
34
|
-
}
|
|
35
|
-
for (var a = tablesOpen.length - 1; a >= 0; a--) {
|
|
36
|
-
tablesOpen[a].html += html[i];
|
|
37
|
-
}
|
|
38
|
-
if (isTableEnd && tablesOpen.length > 0) {
|
|
39
|
-
tablesOpen[tablesOpen.length - 1].positionEnd = i;
|
|
40
|
-
var tableData = tablesOpen.pop();
|
|
41
|
-
tablesData[tableData.tableIndex] = tableData;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
this.addTableCells(tablesData);
|
|
45
|
-
this.addTableCellValues(tablesData, options);
|
|
46
|
-
this.addMissingNameCol(tablesData);
|
|
47
|
-
this.removeEmptyColumns(tablesData);
|
|
48
|
-
this.mergeHeaderRows(tablesData);
|
|
49
|
-
return tablesData.filter(Boolean);
|
|
50
|
-
};
|
|
51
|
-
HtmlTableExtractor.prototype.mergeHeaderRows = function (tables) {
|
|
52
|
-
var _a;
|
|
53
|
-
for (var _i = 0, tables_1 = tables; _i < tables_1.length; _i++) {
|
|
54
|
-
var table = tables_1[_i];
|
|
55
|
-
var bodyRowIndex = table.rows.findIndex(function (row) { return row.some(function (col) { return !col.isHeaderRowCell; }); });
|
|
56
|
-
var headerRowIndex = bodyRowIndex - 1;
|
|
57
|
-
var bodyRow = table.rows[bodyRowIndex];
|
|
58
|
-
var headerRow = table.rows[headerRowIndex];
|
|
59
|
-
if (!bodyRow || headerRowIndex < 0)
|
|
60
|
-
continue;
|
|
61
|
-
for (var i = 0; i < bodyRow.length; i++) {
|
|
62
|
-
var headerCol = headerRow[i];
|
|
63
|
-
var bodyCol = bodyRow[i];
|
|
64
|
-
headerCol.valueParsed = (_a = bodyCol.headerCol) !== null && _a !== void 0 ? _a : headerCol.valueParsed;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
HtmlTableExtractor.prototype.removeEmptyColumns = function (tables) {
|
|
69
|
-
var _loop_1 = function (table) {
|
|
70
|
-
var emptyColumns = new Set();
|
|
71
|
-
var _loop_2 = function (c) {
|
|
72
|
-
var isAllEmpty = table.rows.every(function (row) { var _a, _b; return ((_a = row[c]) === null || _a === void 0 ? void 0 : _a.valueParsed) === null || ((_b = row[c]) === null || _b === void 0 ? void 0 : _b.isHeaderRowCell); });
|
|
73
|
-
if (isAllEmpty) {
|
|
74
|
-
emptyColumns.add(c);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
for (var c = 0; c < table.rows[0].length; c++) {
|
|
78
|
-
_loop_2(c);
|
|
79
|
-
}
|
|
80
|
-
for (var r = 0; r < table.rows.length; r++) {
|
|
81
|
-
var row = table.rows[r];
|
|
82
|
-
table.rows[r] = row.filter(function (_, i) { return !emptyColumns.has(i); });
|
|
83
|
-
}
|
|
84
|
-
table.rows = table.rows.filter(function (row) { return row.some(function (col) { return col.valueParsed !== null; }); });
|
|
85
|
-
};
|
|
86
|
-
for (var _i = 0, tables_2 = tables; _i < tables_2.length; _i++) {
|
|
87
|
-
var table = tables_2[_i];
|
|
88
|
-
_loop_1(table);
|
|
89
|
-
}
|
|
90
|
-
return tables;
|
|
91
|
-
};
|
|
92
|
-
HtmlTableExtractor.prototype.addTableCells = function (tables) {
|
|
93
|
-
var tablesByIndex = new Map(tables.map(function (t) { return [t.tableIndex, t]; }));
|
|
94
|
-
tablesByIndex.forEach(function (table) {
|
|
95
|
-
var _a, _b;
|
|
96
|
-
var skipIndexMap = new Map(table.childTableIndexes.map(function (childIndex) {
|
|
97
|
-
var _a, _b;
|
|
98
|
-
var child = tablesByIndex.get(childIndex);
|
|
99
|
-
return [
|
|
100
|
-
((_a = child === null || child === void 0 ? void 0 : child.positionStart) !== null && _a !== void 0 ? _a : 0) - table.positionStart,
|
|
101
|
-
((_b = child === null || child === void 0 ? void 0 : child.positionEnd) !== null && _b !== void 0 ? _b : 0) - table.positionStart,
|
|
102
|
-
];
|
|
103
|
-
}));
|
|
104
|
-
var grid = [];
|
|
105
|
-
var isInCell = false;
|
|
106
|
-
var isInCellAtts = false;
|
|
107
|
-
var cellAtts = '';
|
|
108
|
-
var cellHTML = '';
|
|
109
|
-
var rowIndex = -1;
|
|
110
|
-
var tableCellIndex = -1;
|
|
111
|
-
var createCell = function (html, atts) {
|
|
112
|
-
var _a, _b, _c, _d, _e, _f;
|
|
113
|
-
var attributePairs = atts
|
|
114
|
-
.toLowerCase()
|
|
115
|
-
.split(' ')
|
|
116
|
-
.map(function (att) { return att.split('='); });
|
|
117
|
-
var rowSpan = Number((_b = (_a = attributePairs.find(function (_a) {
|
|
118
|
-
var key = _a[0];
|
|
119
|
-
return key === 'rowspan';
|
|
120
|
-
})) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.replace(/[^0-9]/g, '')) || 1;
|
|
121
|
-
var colSpan = Number((_d = (_c = attributePairs.find(function (_a) {
|
|
122
|
-
var key = _a[0];
|
|
123
|
-
return key === 'colspan';
|
|
124
|
-
})) === null || _c === void 0 ? void 0 : _c[1]) === null || _d === void 0 ? void 0 : _d.replace(/[^0-9]/g, '')) || 1;
|
|
125
|
-
var cell = {
|
|
126
|
-
attributes: atts.length > 4 ? atts.substring(4, atts.length - 1) : '',
|
|
127
|
-
html: html,
|
|
128
|
-
colSpan: colSpan,
|
|
129
|
-
rowSpan: rowSpan,
|
|
130
|
-
tableCellIndex: tableCellIndex,
|
|
131
|
-
rowIndex: rowIndex,
|
|
132
|
-
colIndex: -1,
|
|
133
|
-
isHeaderRowCell: false,
|
|
134
|
-
isBodyTitleRowCell: false,
|
|
135
|
-
valueParsed: null,
|
|
136
|
-
headerCol: null,
|
|
137
|
-
headerRowIndex: null,
|
|
138
|
-
};
|
|
139
|
-
// const hasCopies = cell.colSpan > 1 || cell.rowSpan > 1
|
|
140
|
-
var curRow = (_e = grid[rowIndex]) !== null && _e !== void 0 ? _e : [];
|
|
141
|
-
var nextEmptyCellIndex = curRow.findIndex(function (cell) { return !cell; });
|
|
142
|
-
var idxStart = nextEmptyCellIndex === -1 ? curRow.length : nextEmptyCellIndex;
|
|
143
|
-
for (var r = rowIndex; r < rowIndex + rowSpan; r++) {
|
|
144
|
-
grid[r] = (_f = grid[r]) !== null && _f !== void 0 ? _f : [];
|
|
145
|
-
for (var c = idxStart; c < idxStart + colSpan; c++) {
|
|
146
|
-
cell.colIndex = cell.colIndex > -1 ? cell.colIndex : c;
|
|
147
|
-
grid[r][c] = cell;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
for (var i = 0; i < table.html.length; i++) {
|
|
152
|
-
var skipIndex = (_a = skipIndexMap.get(i)) !== null && _a !== void 0 ? _a : null;
|
|
153
|
-
if (skipIndex) {
|
|
154
|
-
cellHTML += table.html.substring(i, skipIndex + 1);
|
|
155
|
-
i = skipIndex;
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
var prev5Chars = table.html.substring(i - 4, i + 1).toLowerCase();
|
|
159
|
-
var next3Chars = table.html.substring(i, i + 3).toLowerCase();
|
|
160
|
-
var isCellAttsStart = ['<td', '<th'].includes(next3Chars);
|
|
161
|
-
var isSelfEnclosed = isInCellAtts && table.html[i - 1] === '/' && table.html[i] === '>';
|
|
162
|
-
var isCellAttsEnd = (isInCell && table.html[i] === '>') || isSelfEnclosed;
|
|
163
|
-
var isCellEnd = ['</td>', '</th>'].includes(prev5Chars);
|
|
164
|
-
var isRowStart = next3Chars === '<tr';
|
|
165
|
-
if (isRowStart) {
|
|
166
|
-
rowIndex++;
|
|
167
|
-
grid[rowIndex] = (_b = grid[rowIndex]) !== null && _b !== void 0 ? _b : [];
|
|
168
|
-
}
|
|
169
|
-
if (isCellAttsStart) {
|
|
170
|
-
tableCellIndex++;
|
|
171
|
-
isInCell = true;
|
|
172
|
-
isInCellAtts = true;
|
|
173
|
-
}
|
|
174
|
-
if (isInCellAtts) {
|
|
175
|
-
cellAtts += table.html[i];
|
|
176
|
-
}
|
|
177
|
-
if (isInCell) {
|
|
178
|
-
cellHTML += table.html[i];
|
|
179
|
-
}
|
|
180
|
-
if (isCellAttsEnd) {
|
|
181
|
-
isInCellAtts = false;
|
|
182
|
-
}
|
|
183
|
-
if (isCellEnd || isSelfEnclosed) {
|
|
184
|
-
isInCell = false;
|
|
185
|
-
isInCellAtts = false;
|
|
186
|
-
createCell(cellHTML, cellAtts);
|
|
187
|
-
cellHTML = '';
|
|
188
|
-
cellAtts = '';
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
table.rows = grid;
|
|
192
|
-
});
|
|
193
|
-
};
|
|
194
|
-
HtmlTableExtractor.prototype.addMissingNameCol = function (tables) {
|
|
195
|
-
var _a, _b;
|
|
196
|
-
var _loop_3 = function (table) {
|
|
197
|
-
var bodyIndex = table.rows.findIndex(function (row) { return row.some(function (col) { return !col.isHeaderRowCell; }); });
|
|
198
|
-
// get the first column index that has a value
|
|
199
|
-
var firstPopulatedColIndex = Infinity;
|
|
200
|
-
for (var i = bodyIndex; i < table.rows.length; i++) {
|
|
201
|
-
var row = table.rows[i];
|
|
202
|
-
var populatedIndex = row.findIndex(function (col) { return col.valueParsed; });
|
|
203
|
-
var isFirstPopulatedIndex = populatedIndex > -1 && populatedIndex < firstPopulatedColIndex;
|
|
204
|
-
if (isFirstPopulatedIndex)
|
|
205
|
-
firstPopulatedColIndex = populatedIndex;
|
|
206
|
-
if (firstPopulatedColIndex === 0)
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
var shouldAddName = table.rows.some(function (row) {
|
|
210
|
-
var firstCol = row[firstPopulatedColIndex];
|
|
211
|
-
var headerCol = firstCol === null || firstCol === void 0 ? void 0 : firstCol.headerCol;
|
|
212
|
-
// skip if the first column has a header col, or if there is no header row
|
|
213
|
-
if (!firstCol || headerCol || firstCol.headerRowIndex === null) {
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
216
|
-
// if the first col is a string, assume it's a name
|
|
217
|
-
return typeof firstCol.valueParsed === 'string';
|
|
218
|
-
});
|
|
219
|
-
if (shouldAddName) {
|
|
220
|
-
for (var _c = 0, _d = table.rows; _c < _d.length; _c++) {
|
|
221
|
-
var row = _d[_c];
|
|
222
|
-
var col = row[firstPopulatedColIndex];
|
|
223
|
-
if (!col)
|
|
224
|
-
continue;
|
|
225
|
-
var isEmptyRow = row.every(function (col) { return col.valueParsed === null; });
|
|
226
|
-
// for header rows, add to valueParsed, body rows, set headerCol
|
|
227
|
-
if (!isEmptyRow && col.isHeaderRowCell) {
|
|
228
|
-
col.valueParsed = (_a = col.valueParsed) !== null && _a !== void 0 ? _a : '[name]';
|
|
229
|
-
}
|
|
230
|
-
else if (!col.isHeaderRowCell) {
|
|
231
|
-
col.headerCol = (_b = col.headerCol) !== null && _b !== void 0 ? _b : '[name]';
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
for (var _i = 0, tables_3 = tables; _i < tables_3.length; _i++) {
|
|
237
|
-
var table = tables_3[_i];
|
|
238
|
-
_loop_3(table);
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
HtmlTableExtractor.prototype.addTableCellValues = function (tables, options) {
|
|
242
|
-
var _this = this;
|
|
243
|
-
var _a;
|
|
244
|
-
var getHeaderRowIndex = function (rows) {
|
|
245
|
-
var bodyIndex = rows.findIndex(function (row, r) {
|
|
246
|
-
var _a;
|
|
247
|
-
var prevRow = (_a = rows[r - 1]) !== null && _a !== void 0 ? _a : [];
|
|
248
|
-
var hadUnderlines = prevRow.some(function (col) { return col.attributes.includes('border') && col.attributes.includes('bottom'); });
|
|
249
|
-
var hasUnderline = row.some(function (col) { return col.attributes.includes('border') && col.attributes.includes('bottom'); });
|
|
250
|
-
if (hadUnderlines && !hasUnderline) {
|
|
251
|
-
return true;
|
|
252
|
-
}
|
|
253
|
-
return row.some(function (col) {
|
|
254
|
-
var valueParsed = _this.parseValue(col.html, options);
|
|
255
|
-
var isNumber = typeof valueParsed === 'number';
|
|
256
|
-
var isYear = isNumber && valueParsed > 1900 && valueParsed < 2100;
|
|
257
|
-
var isCol = isNumber && !isYear;
|
|
258
|
-
return isCol;
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
return bodyIndex - 1;
|
|
262
|
-
};
|
|
263
|
-
var getNextCell = function (row, colIndex) {
|
|
264
|
-
var startingCol = row[colIndex];
|
|
265
|
-
for (var i = colIndex; i < row.length; i++) {
|
|
266
|
-
if (row[i].tableCellIndex !== (startingCol === null || startingCol === void 0 ? void 0 : startingCol.tableCellIndex)) {
|
|
267
|
-
return row[i];
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return null;
|
|
271
|
-
};
|
|
272
|
-
var completedCells = new Set();
|
|
273
|
-
var _loop_4 = function (table) {
|
|
274
|
-
var headerRowIndex = getHeaderRowIndex(table.rows);
|
|
275
|
-
var _loop_5 = function (rowIndex) {
|
|
276
|
-
var row = table.rows[rowIndex];
|
|
277
|
-
var countUniqueCells = new Set(row.map(function (c) { return c.tableCellIndex; })).size;
|
|
278
|
-
// skip titles in the middle of the body
|
|
279
|
-
var isBodyTitleRow = rowIndex > headerRowIndex && countUniqueCells === 1 && ((_a = row[0]) === null || _a === void 0 ? void 0 : _a.colSpan) > 0;
|
|
280
|
-
var isHeaderRow = rowIndex <= headerRowIndex;
|
|
281
|
-
var headerByIndex = new Map();
|
|
282
|
-
var getHeaderCol = function (c) {
|
|
283
|
-
var _a, _b, _c;
|
|
284
|
-
if (headerByIndex.has(c)) {
|
|
285
|
-
return (_a = headerByIndex.get(c)) !== null && _a !== void 0 ? _a : null;
|
|
286
|
-
}
|
|
287
|
-
if (isHeaderRow) {
|
|
288
|
-
return null;
|
|
289
|
-
}
|
|
290
|
-
for (var r = 0; r <= headerRowIndex; r++) {
|
|
291
|
-
var row_1 = table.rows[r];
|
|
292
|
-
for (var c_1 = 0; c_1 < row_1.length; c_1++) {
|
|
293
|
-
var col = row_1[c_1];
|
|
294
|
-
var headerCurrent = (_b = headerByIndex.get(c_1)) !== null && _b !== void 0 ? _b : '';
|
|
295
|
-
var value = headerCurrent.endsWith("".concat(col.valueParsed || ''))
|
|
296
|
-
? headerCurrent
|
|
297
|
-
: "".concat(headerCurrent, " ").concat(col.valueParsed || '').trim();
|
|
298
|
-
headerByIndex.set(c_1, value);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
return (_c = headerByIndex.get(c)) !== null && _c !== void 0 ? _c : null;
|
|
302
|
-
};
|
|
303
|
-
for (var colIndex = 0; colIndex < row.length; colIndex++) {
|
|
304
|
-
var cell = row[colIndex];
|
|
305
|
-
if (completedCells.has(cell)) {
|
|
306
|
-
continue;
|
|
307
|
-
}
|
|
308
|
-
cell.headerRowIndex = headerRowIndex > -1 ? headerRowIndex : null;
|
|
309
|
-
cell.isBodyTitleRowCell = isBodyTitleRow;
|
|
310
|
-
cell.isHeaderRowCell = isHeaderRow;
|
|
311
|
-
// sometimes there is a rogue percent sign that is not in a column, so we need to check the next column
|
|
312
|
-
var nextCell = getNextCell(row, colIndex);
|
|
313
|
-
// const isMissingPercentSign =
|
|
314
|
-
// nextCell?.html.includes('%') && this.parseValue(nextCell?.html) === null
|
|
315
|
-
var isMissingParenthesis = (nextCell === null || nextCell === void 0 ? void 0 : nextCell.html.includes(')')) && cell.html.includes('(') && !cell.html.includes(')');
|
|
316
|
-
var colValue = isMissingParenthesis ? "".concat(cell.html.trim(), ")") : cell.html.trim();
|
|
317
|
-
// colValue = isMissingPercentSign ? `${colValue}` : colValue
|
|
318
|
-
colValue = this_1.parseValue(colValue, options);
|
|
319
|
-
colValue = typeof colValue === 'string' ? colValue.replace(/\s+/g, ' ') : colValue;
|
|
320
|
-
// add parsed value
|
|
321
|
-
cell.valueParsed = colValue;
|
|
322
|
-
cell.headerCol = getHeaderCol(colIndex);
|
|
323
|
-
completedCells.add(cell);
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
for (var rowIndex = 0; rowIndex < table.rows.length; rowIndex++) {
|
|
327
|
-
_loop_5(rowIndex);
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
var this_1 = this;
|
|
331
|
-
for (var _i = 0, tables_4 = tables; _i < tables_4.length; _i++) {
|
|
332
|
-
var table = tables_4[_i];
|
|
333
|
-
_loop_4(table);
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
HtmlTableExtractor.prototype.stripHtml = function (str, options) {
|
|
337
|
-
var _a = options !== null && options !== void 0 ? options : {}, _b = _a.tagsToExclude, tagsToExclude = _b === void 0 ? [] : _b, _c = _a.tagsToInclude, tagsToInclude = _c === void 0 ? [] : _c;
|
|
338
|
-
var strNew = '';
|
|
339
|
-
var iterator = new XMLParser_1.default();
|
|
340
|
-
var isAllowedPath = true;
|
|
341
|
-
var updateAllowedPath = function (data) {
|
|
342
|
-
var openTags = data.path.split('.');
|
|
343
|
-
if (tagsToInclude.length > 0) {
|
|
344
|
-
isAllowedPath = tagsToInclude.some(function (t) { return openTags.includes(t); });
|
|
345
|
-
}
|
|
346
|
-
else if (tagsToExclude.length > 0) {
|
|
347
|
-
isAllowedPath = !tagsToExclude.some(function (t) { return openTags.includes(t); });
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
iterator.iterateXML({
|
|
351
|
-
xml: str,
|
|
352
|
-
onOpenTag: function (data) {
|
|
353
|
-
updateAllowedPath(data);
|
|
354
|
-
},
|
|
355
|
-
onCloseTag: function (data) {
|
|
356
|
-
strNew += isAllowedPath && !strNew.endsWith('\n') ? '\n' : '';
|
|
357
|
-
updateAllowedPath(data);
|
|
358
|
-
},
|
|
359
|
-
onCharacter: function (data) {
|
|
360
|
-
if (isAllowedPath) {
|
|
361
|
-
strNew += data.char;
|
|
362
|
-
}
|
|
363
|
-
},
|
|
364
|
-
});
|
|
365
|
-
return strNew;
|
|
366
|
-
};
|
|
367
|
-
HtmlTableExtractor.prototype.parseValue = function (str, options) {
|
|
368
|
-
var _a;
|
|
369
|
-
if (str === null)
|
|
370
|
-
return null;
|
|
371
|
-
if (typeof str === 'number')
|
|
372
|
-
return str;
|
|
373
|
-
var _b = options !== null && options !== void 0 ? options : {}, _c = _b.stripHtml, stripHtml = _c === void 0 ? true : _c, _d = _b.tagsToExclude, tagsToExclude = _d === void 0 ? [] : _d, _e = _b.tagsToInclude, tagsToInclude = _e === void 0 ? [] : _e, _f = _b.stripParenthesis, stripParenthesis = _f === void 0 ? false : _f;
|
|
374
|
-
var strNew = stripHtml ? this.stripHtml(str, { tagsToExclude: tagsToExclude, tagsToInclude: tagsToInclude }) : str;
|
|
375
|
-
var text = strNew
|
|
376
|
-
.replace(/ | |\n/g, ' ')
|
|
377
|
-
.replace(/®|☐/g, '')
|
|
378
|
-
.replace(/–|—|—|—/g, '-')
|
|
379
|
-
.replace(/’|“|”|’/g, "'");
|
|
380
|
-
if (stripParenthesis) {
|
|
381
|
-
text = text.replace(/\(.*?\)/g, '');
|
|
382
|
-
}
|
|
383
|
-
text = text
|
|
384
|
-
.replace(/\s+/, ' ')
|
|
385
|
-
.replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/g, ' ')
|
|
386
|
-
.trim();
|
|
387
|
-
if (str.replace(/–|—|—/g, '-') === '-')
|
|
388
|
-
return '-';
|
|
389
|
-
if (text === '')
|
|
390
|
-
return null;
|
|
391
|
-
var colNum = text.replace(/,|\(|\)|\%/g, '').trim();
|
|
392
|
-
if (colNum === '-' || colNum === '$')
|
|
393
|
-
return null;
|
|
394
|
-
colNum = colNum.replace(/\-|\$/g, '');
|
|
395
|
-
var hasNumBeforeParenthesis = Boolean(/\d+\s*(?=\()/.test(text));
|
|
396
|
-
colNum = hasNumBeforeParenthesis ? (_a = colNum.split(' ')[0]) === null || _a === void 0 ? void 0 : _a.trim() : colNum;
|
|
397
|
-
if (!isNaN(Number(colNum))) {
|
|
398
|
-
if (text.includes('%'))
|
|
399
|
-
return text.replace(/[^a-zA-Z\d\s:]/g, '') === '' ? null : text;
|
|
400
|
-
return (text.trim().includes('(') && !hasNumBeforeParenthesis) || text.includes('-')
|
|
401
|
-
? Number(colNum) * -1
|
|
402
|
-
: Number(colNum);
|
|
403
|
-
}
|
|
404
|
-
return text;
|
|
405
|
-
};
|
|
406
|
-
return HtmlTableExtractor;
|
|
407
|
-
}());
|
|
408
|
-
exports.default = HtmlTableExtractor;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCurrentFilings = void 0;
|
|
4
|
-
var fast_xml_parser_1 = require("fast-xml-parser");
|
|
5
|
-
function parseCurrentFilings(params) {
|
|
6
|
-
var _a;
|
|
7
|
-
var parser = new fast_xml_parser_1.XMLParser({ ignoreAttributes: false });
|
|
8
|
-
var json = parser.parse(params.xml);
|
|
9
|
-
var toArray = function (value) { return (Array.isArray(value) ? value : [value]).filter(Boolean); };
|
|
10
|
-
var toObject = function (value) {
|
|
11
|
-
value = Array.isArray(value) ? value[0] : value;
|
|
12
|
-
return (value && typeof value === 'object' ? value : {});
|
|
13
|
-
};
|
|
14
|
-
var toString = function (value) { return String(value || ''); };
|
|
15
|
-
var toNumber = function (value) { return Number(value) || 0; };
|
|
16
|
-
var toBoolean = function (value) {
|
|
17
|
-
var isFalseStr = ['false', '0', 'no', 'null', 'undefined'].includes(String(value).toLowerCase());
|
|
18
|
-
return isFalseStr ? false : Boolean(value);
|
|
19
|
-
};
|
|
20
|
-
var toDateStr = function (value) {
|
|
21
|
-
var _a = value.split('/'), month = _a[0], day = _a[1], year = _a[2];
|
|
22
|
-
return "".concat(year, "-").concat(month, "-").concat(day);
|
|
23
|
-
};
|
|
24
|
-
var parseConcatDate = function (value) {
|
|
25
|
-
var acceptanceDateTime = toString(toNumber(value));
|
|
26
|
-
var year = acceptanceDateTime.slice(0, 4);
|
|
27
|
-
var month = acceptanceDateTime.slice(4, 6);
|
|
28
|
-
var day = acceptanceDateTime.slice(6, 8);
|
|
29
|
-
var hour = acceptanceDateTime.slice(8, 10);
|
|
30
|
-
var minute = acceptanceDateTime.slice(10, 12);
|
|
31
|
-
var second = acceptanceDateTime.slice(12, 14);
|
|
32
|
-
return acceptanceDateTime.length < 9
|
|
33
|
-
? "".concat(year, "-").concat(month, "-").concat(day)
|
|
34
|
-
: "".concat(year, "-").concat(month, "-").concat(day, " ").concat(hour, ":").concat(minute, ":").concat(second);
|
|
35
|
-
};
|
|
36
|
-
var parseFiscalYearEnd = function (value) {
|
|
37
|
-
var str = toString(value).padStart(4, '0');
|
|
38
|
-
var month = str.slice(0, 2);
|
|
39
|
-
var day = str.slice(2, 4);
|
|
40
|
-
return "".concat(month, "-").concat(day);
|
|
41
|
-
};
|
|
42
|
-
var channelXML = toObject((_a = json === null || json === void 0 ? void 0 : json.rss) === null || _a === void 0 ? void 0 : _a.channel);
|
|
43
|
-
var description = channelXML.description, item = channelXML.item, language = channelXML.language, lastBuildDate = channelXML.lastBuildDate, link = channelXML.link, pubDate = channelXML.pubDate, title = channelXML.title;
|
|
44
|
-
var atomLink = toObject(channelXML['atom:link']);
|
|
45
|
-
var itemsXML = toArray(item);
|
|
46
|
-
return {
|
|
47
|
-
title: toString(title),
|
|
48
|
-
link: toString(link),
|
|
49
|
-
href: toString(atomLink['@_href']),
|
|
50
|
-
description: toString(description),
|
|
51
|
-
language: toString(language),
|
|
52
|
-
pubDate: toString(pubDate),
|
|
53
|
-
lastBuildDate: toString(lastBuildDate),
|
|
54
|
-
items: itemsXML.map(function (itemXML) {
|
|
55
|
-
var _a;
|
|
56
|
-
itemXML = toObject(itemXML);
|
|
57
|
-
var enclosure = toObject(itemXML.enclosure);
|
|
58
|
-
var filing = toObject(itemXML['edgar:xbrlFiling']);
|
|
59
|
-
var xbrlFilesXML = toArray((_a = filing['edgar:xbrlFiles']) === null || _a === void 0 ? void 0 : _a['edgar:xbrlFile']);
|
|
60
|
-
return {
|
|
61
|
-
title: toString(itemXML.title),
|
|
62
|
-
link: toString(itemXML.link),
|
|
63
|
-
guid: toString(itemXML.guid),
|
|
64
|
-
enclosureUrl: toString(enclosure['@_url']),
|
|
65
|
-
enclosureLength: toString(enclosure['@_length']),
|
|
66
|
-
enclosureType: toString(enclosure['@_type']),
|
|
67
|
-
description: toString(itemXML.description),
|
|
68
|
-
pubDate: toString(itemXML.pubDate),
|
|
69
|
-
filing: {
|
|
70
|
-
companyName: toString(filing['edgar:companyName']),
|
|
71
|
-
formType: toString(filing['edgar:formType']),
|
|
72
|
-
filingDate: toDateStr(filing['edgar:filingDate']),
|
|
73
|
-
cikNumber: toNumber(filing['edgar:cikNumber']),
|
|
74
|
-
accessionNumber: toString(filing['edgar:accessionNumber']),
|
|
75
|
-
fileNumber: toString(filing['edgar:fileNumber']),
|
|
76
|
-
acceptanceDatetime: parseConcatDate(filing['edgar:acceptanceDatetime']),
|
|
77
|
-
period: parseConcatDate(filing['edgar:period']),
|
|
78
|
-
assistantDirector: toString(filing['edgar:assistantDirector']),
|
|
79
|
-
assignedSic: toNumber(filing['edgar:assignedSic']),
|
|
80
|
-
fiscalYearEnd: parseFiscalYearEnd(filing['edgar:fiscalYearEnd']),
|
|
81
|
-
xbrlFiles: xbrlFilesXML.map(function (xbrlFileXML) {
|
|
82
|
-
xbrlFileXML = toObject(xbrlFileXML);
|
|
83
|
-
return {
|
|
84
|
-
sequence: toNumber(xbrlFileXML['@_edgar:sequence']),
|
|
85
|
-
file: toString(xbrlFileXML['@_edgar:file']),
|
|
86
|
-
type: toString(xbrlFileXML['@_edgar:type']),
|
|
87
|
-
size: toNumber(xbrlFileXML['@_edgar:size']),
|
|
88
|
-
description: toString(xbrlFileXML['@_edgar:description']),
|
|
89
|
-
inlineXBRL: toBoolean(xbrlFileXML['@_edgar:inlineXBRL']),
|
|
90
|
-
url: toString(xbrlFileXML['@_edgar:url']),
|
|
91
|
-
};
|
|
92
|
-
}),
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
}),
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
exports.parseCurrentFilings = parseCurrentFilings;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseForm13f = void 0;
|
|
4
|
-
var XMLParser_1 = require("../XMLParser");
|
|
5
|
-
/**
|
|
6
|
-
* Form 13F - Holdings Report
|
|
7
|
-
*/
|
|
8
|
-
function parseForm13f(params, xmlParser) {
|
|
9
|
-
var _a, _b;
|
|
10
|
-
if (xmlParser === void 0) { xmlParser = new XMLParser_1.default(); }
|
|
11
|
-
var json = xmlParser.parse(params.xml);
|
|
12
|
-
var informationTable = xmlParser.extractJsonKey(json, 'informationTable');
|
|
13
|
-
var edgarSubmission = xmlParser.extractJsonKey(json, 'edgarSubmission');
|
|
14
|
-
var toArray = function (value) { return (Array.isArray(value) ? value : [value]).filter(Boolean); };
|
|
15
|
-
var formData = edgarSubmission.formData, headerData = edgarSubmission.headerData;
|
|
16
|
-
var _c = headerData !== null && headerData !== void 0 ? headerData : {}, filerInfo = _c.filerInfo, submissionType = _c.submissionType;
|
|
17
|
-
var _d = filerInfo !== null && filerInfo !== void 0 ? filerInfo : {}, filer = _d.filer, flags = _d.flags, _e = _d.liveTestFlag, liveTestFlag = _e === void 0 ? '' : _e, periodOfReport = _d.periodOfReport;
|
|
18
|
-
var _f = flags !== null && flags !== void 0 ? flags : {}, _g = _f.confirmingCopyFlag, confirmingCopyFlag = _g === void 0 ? false : _g, _h = _f.overrideInternetFlag, overrideInternetFlag = _h === void 0 ? false : _h, _j = _f.returnCopyFlag, returnCopyFlag = _j === void 0 ? false : _j;
|
|
19
|
-
var _k = (_a = filer === null || filer === void 0 ? void 0 : filer.credentials) !== null && _a !== void 0 ? _a : {}, _l = _k.ccc, ccc = _l === void 0 ? '' : _l, _m = _k.cik, cik = _m === void 0 ? 0 : _m;
|
|
20
|
-
var coverPage = formData.coverPage, signatureBlock = formData.signatureBlock, summaryPage = formData.summaryPage;
|
|
21
|
-
var _o = coverPage !== null && coverPage !== void 0 ? coverPage : {}, filingManager = _o.filingManager, form13FFileNumber = _o.form13FFileNumber, otherManagersInfo = _o.otherManagersInfo, provideInfoForInstruction5 = _o.provideInfoForInstruction5, reportCalendarOrQuarter = _o.reportCalendarOrQuarter, reportType = _o.reportType;
|
|
22
|
-
var _p = filingManager !== null && filingManager !== void 0 ? filingManager : {}, address = _p.address, filingManagerName = _p.name;
|
|
23
|
-
var _q = summaryPage !== null && summaryPage !== void 0 ? summaryPage : {}, isConfidentialOmitted = _q.isConfidentialOmitted, otherIncludedManagersCount = _q.otherIncludedManagersCount, otherManagers2Info = _q.otherManagers2Info, tableEntryTotal = _q.tableEntryTotal, tableValueTotal = _q.tableValueTotal;
|
|
24
|
-
var _r = signatureBlock !== null && signatureBlock !== void 0 ? signatureBlock : {}, city = _r.city, signatureName = _r.name, phone = _r.phone, signature = _r.signature, signatureDate = _r.signatureDate, stateOrCountry = _r.stateOrCountry, title = _r.title;
|
|
25
|
-
var otherManager = (otherManagersInfo !== null && otherManagersInfo !== void 0 ? otherManagersInfo : {}).otherManager;
|
|
26
|
-
var otherManagers2 = (_b = otherManagers2Info.otherManager2) !== null && _b !== void 0 ? _b : [];
|
|
27
|
-
return {
|
|
28
|
-
submissionType: String(submissionType || ''),
|
|
29
|
-
periodOfReport: String(periodOfReport || ''),
|
|
30
|
-
cik: Number(cik) || 0,
|
|
31
|
-
ccc: String(ccc || ''),
|
|
32
|
-
form13FFileNumber: String(form13FFileNumber || ''),
|
|
33
|
-
liveTestFlag: String(liveTestFlag || ''),
|
|
34
|
-
reportCalendarOrQuarter: String(reportCalendarOrQuarter || ''),
|
|
35
|
-
reportType: String(reportType || ''),
|
|
36
|
-
confirmingCopyFlag: Boolean(confirmingCopyFlag),
|
|
37
|
-
overrideInternetFlag: Boolean(overrideInternetFlag),
|
|
38
|
-
returnCopyFlag: Boolean(returnCopyFlag),
|
|
39
|
-
filingManager: {
|
|
40
|
-
name: String(filingManagerName || ''),
|
|
41
|
-
ns1City: String(address['ns1:city'] || ''),
|
|
42
|
-
ns1StateOrCountry: String(address['ns1:stateOrCountry'] || ''),
|
|
43
|
-
ns1Street1: String(address['ns1:street1'] || ''),
|
|
44
|
-
ns1ZipCode: String(address['ns1:zipCode'] || 0),
|
|
45
|
-
},
|
|
46
|
-
otherManagers: toArray(otherManager).map(function (otherManager) { return ({
|
|
47
|
-
sequenceNumber: Number(otherManager.sequenceNumber) || -1,
|
|
48
|
-
form13FFileNumber: String(otherManager.form13FFileNumber || ''),
|
|
49
|
-
name: String(otherManager.name || ''),
|
|
50
|
-
}); }),
|
|
51
|
-
provideInfoForInstruction5: String(provideInfoForInstruction5 || ''),
|
|
52
|
-
signatureBlock: {
|
|
53
|
-
city: String(city || ''),
|
|
54
|
-
name: String(signatureName || ''),
|
|
55
|
-
phone: String(phone || ''),
|
|
56
|
-
signature: String(signature || ''),
|
|
57
|
-
signatureDate: String(signatureDate || ''),
|
|
58
|
-
stateOrCountry: String(stateOrCountry || ''),
|
|
59
|
-
title: String(title || ''),
|
|
60
|
-
},
|
|
61
|
-
otherManagers2: toArray(otherManagers2).map(function (otherManager) { return ({
|
|
62
|
-
sequenceNumber: Number(otherManager.sequenceNumber) || -1,
|
|
63
|
-
name: String(otherManager.otherManager.name || ''),
|
|
64
|
-
form13FFileNumber: String(otherManager.otherManager.form13FFileNumber || ''),
|
|
65
|
-
}); }),
|
|
66
|
-
otherIncludedManagersCount: Number(otherIncludedManagersCount || 0),
|
|
67
|
-
tableEntryTotal: Number(tableEntryTotal || 0),
|
|
68
|
-
tableValueTotal: Number(tableValueTotal || 0),
|
|
69
|
-
isConfidentialOmitted: Boolean(isConfidentialOmitted),
|
|
70
|
-
infoTable: toArray(informationTable.infoTable).map(function (infoTable) {
|
|
71
|
-
var _a = infoTable !== null && infoTable !== void 0 ? infoTable : {}, cusip = _a.cusip, investmentDiscretion = _a.investmentDiscretion, nameOfIssuer = _a.nameOfIssuer, otherManager = _a.otherManager, shrsOrPrnAmt = _a.shrsOrPrnAmt, titleOfClass = _a.titleOfClass, value = _a.value, votingAuthority = _a.votingAuthority;
|
|
72
|
-
var _b = votingAuthority !== null && votingAuthority !== void 0 ? votingAuthority : {}, votingAuthorityNone = _b.None, votingAuthorityShared = _b.Shared, votingAuthoritySole = _b.Sole;
|
|
73
|
-
return {
|
|
74
|
-
nameOfIssuer: String(nameOfIssuer || ''),
|
|
75
|
-
titleOfClass: String(titleOfClass || ''),
|
|
76
|
-
cusip: String(cusip || ''),
|
|
77
|
-
value: Number(value) || 0,
|
|
78
|
-
sharesOrPrincipalAmount: Number((shrsOrPrnAmt === null || shrsOrPrnAmt === void 0 ? void 0 : shrsOrPrnAmt.sshPrnamt) || 0) || 0,
|
|
79
|
-
isPrincipalAmount: (shrsOrPrnAmt === null || shrsOrPrnAmt === void 0 ? void 0 : shrsOrPrnAmt.sshPrnamtType) !== 'SH',
|
|
80
|
-
investmentDiscretion: String(investmentDiscretion || ''),
|
|
81
|
-
votingAuthoritySole: Number(votingAuthoritySole) || 0,
|
|
82
|
-
votingAuthorityShared: Number(votingAuthorityShared) || 0,
|
|
83
|
-
votingAuthorityNone: Number(votingAuthorityNone) || 0,
|
|
84
|
-
otherManagers: String(otherManager || '')
|
|
85
|
-
.split(',')
|
|
86
|
-
.map(Number),
|
|
87
|
-
};
|
|
88
|
-
}),
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
exports.parseForm13f = parseForm13f;
|