sec-edgar-api 0.4.2 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +6 -2
  2. package/build/index.d.ts +4 -2
  3. package/build/index.js +5 -16
  4. package/build/services/DocumentParser/DocumentParser.d.ts +1 -1
  5. package/build/services/DocumentParser/XBRLParser/InstanceParser.d.ts +1 -1
  6. package/build/services/DocumentParser/XBRLParser/LinkbaseParser.d.ts +1 -1
  7. package/build/services/DocumentParser/XBRLParser/SchemaParser.d.ts +1 -1
  8. package/build/services/DocumentParser/XBRLParser/XBRLParser.d.ts +1 -1
  9. package/build/services/DocumentParser/XMLParser.d.ts +8 -1
  10. package/build/services/DocumentParser/XMLParser.js +24 -5
  11. package/build/services/DocumentParser/parsers/parse-companies.d.ts +1 -2
  12. package/build/services/DocumentParser/parsers/parse-companies.js +23 -41
  13. package/build/services/DocumentParser/parsers/parse-current-filings-xbrl.js +8 -0
  14. package/build/services/DocumentParser/parsers/parse-insider-transaction.d.ts +1 -2
  15. package/build/services/DocumentParser/parsers/parse-xbrl.d.ts +2 -2
  16. package/build/services/DocumentParser/parsers/parse-xbrl.js +12 -8
  17. package/build/services/ReportParser/ReportParser.d.ts +19 -6
  18. package/build/services/ReportParser/ReportParser.js +53 -22
  19. package/build/services/ReportParser/ReportResolvable.d.ts +50 -0
  20. package/build/services/ReportParser/ReportResolvable.js +135 -0
  21. package/build/services/ReportParser/ReportTranslatedProxy.d.ts +1 -1
  22. package/build/services/ReportParser/ReportWrapper.d.ts +1 -1
  23. package/build/services/ReportParser/resolvers/resolve-ebit.js +6 -0
  24. package/build/services/ReportParser/resolvers/resolve-q4-fiscal-year-matching-properties.js +0 -1
  25. package/build/services/ReportRawBuilder/FactFiscalCalculator.d.ts +8 -0
  26. package/build/services/ReportRawBuilder/FactFiscalCalculator.js +34 -1
  27. package/build/services/ReportRawBuilder/FactGrouper.d.ts +1 -1
  28. package/build/services/ReportRawBuilder/FactPeriodResolver.d.ts +1 -1
  29. package/build/services/ReportRawBuilder/FactRecordBuilder.d.ts +1 -1
  30. package/build/services/ReportRawBuilder/FactSplitAdjuster.d.ts +1 -1
  31. package/build/services/ReportRawBuilder/ReportRawBuilder.d.ts +2 -3
  32. package/build/services/SecEdgarApi/FilingMapper.d.ts +1 -1
  33. package/build/services/SecEdgarApi/RequestWrapper.d.ts +1 -1
  34. package/build/services/SecEdgarApi/SecEdgarApi.d.ts +23 -4
  35. package/build/services/SecEdgarApi/SecEdgarApi.js +34 -2
  36. package/build/types/calculation-map.type.d.ts +13 -0
  37. package/build/types/calculation-map.type.js +2 -0
  38. package/build/types/common.type.d.ts +1 -10
  39. package/build/types/company-facts.type.d.ts +6 -1
  40. package/build/types/company-search.type.d.ts +3 -1
  41. package/build/types/current-filings.type.d.ts +1 -0
  42. package/build/types/index.d.ts +11 -9
  43. package/build/types/index.js +0 -23
  44. package/build/types/insider-transaction.type.d.ts +47 -1
  45. package/build/types/parsed-filings.type.d.ts +1 -47
  46. package/build/types/report-translated.type.d.ts +6 -3
  47. package/build/util/calculation-map.d.ts +2 -0
  48. package/build/util/calculation-map.js +292 -0
  49. package/build/util/key-translations.d.ts +1 -1
  50. package/build/util/key-translations.js +6 -6
  51. package/build/util/util-map.d.ts +12 -0
  52. package/build/util/util-map.js +50 -0
  53. package/package.json +1 -1
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var ReportResolvable = /** @class */ (function () {
4
+ function ReportResolvable(args) {
5
+ this.calculationMap = {};
6
+ this.keyStack = new Set();
7
+ this.calculatedValues = new Map();
8
+ this.usedGroupIndexesByKey = new Map();
9
+ this.depth = 0;
10
+ var report = args.report, calculationMap = args.calculationMap;
11
+ this.calculationMap = calculationMap !== null && calculationMap !== void 0 ? calculationMap : {};
12
+ this.report = report;
13
+ this.usedGroupIndexesByKey = new Map();
14
+ }
15
+ ReportResolvable.prototype.getMap = function () {
16
+ return this.calculationMap;
17
+ };
18
+ ReportResolvable.prototype.clearCache = function () {
19
+ this.calculatedValues.clear();
20
+ };
21
+ /**
22
+ * Used when testing to remove groups that are not being used.
23
+ */
24
+ ReportResolvable.prototype.getUsedGroupIndexesByKey = function () {
25
+ var obj = {};
26
+ this.usedGroupIndexesByKey.forEach(function (indexes, key) { return (obj[key] = Array.from(indexes)); });
27
+ return obj;
28
+ };
29
+ /**
30
+ * Gets value from report, or calculates it using calculationMap.
31
+ */
32
+ ReportResolvable.prototype.get = function (key) {
33
+ this.depth = 0;
34
+ return this._get(key);
35
+ };
36
+ /**
37
+ * Returns 0 for non-numeric values
38
+ */
39
+ ReportResolvable.prototype.getNumber = function (key) {
40
+ return Number(this.get(key)) || 0;
41
+ };
42
+ ReportResolvable.prototype.getCalculatedFromGroup = function (params) {
43
+ this.depth = 0;
44
+ return this._getCalculatedFromGroup(params);
45
+ };
46
+ ReportResolvable.prototype._get = function (key, parentKey) {
47
+ var _a, _b;
48
+ return (_a = this.report[key]) !== null && _a !== void 0 ? _a : ((_b = this._getCalculated(key, parentKey)) !== null && _b !== void 0 ? _b : {}).value;
49
+ };
50
+ ReportResolvable.prototype._getCalculatedFromGroup = function (params, parentKey, skipSingleMatch) {
51
+ var _a;
52
+ if (skipSingleMatch === void 0) { skipSingleMatch = false; }
53
+ var group = params.group, _b = params.breakIfMissingRequiredKey, breakIfMissingRequiredKey = _b === void 0 ? true : _b;
54
+ var calculation = group.calculation;
55
+ var hasAtLeastOneKey = false;
56
+ var isMissingRequiredKey = false;
57
+ var missingKeys = [];
58
+ var finalSum = 0;
59
+ for (var _i = 0, calculation_1 = calculation; _i < calculation_1.length; _i++) {
60
+ var item = calculation_1[_i];
61
+ if (skipSingleMatch && calculation.length < 2)
62
+ continue;
63
+ var childKey = item.key, weight = item.weight, isRequired = item.isRequired;
64
+ var value = (_a = this._get(childKey, parentKey)) !== null && _a !== void 0 ? _a : null;
65
+ var hasKey = typeof value === 'number';
66
+ hasAtLeastOneKey = hasAtLeastOneKey || hasKey;
67
+ isMissingRequiredKey = isMissingRequiredKey || (isRequired && !hasKey);
68
+ if (!hasKey) {
69
+ missingKeys.push(childKey);
70
+ }
71
+ if (isMissingRequiredKey && breakIfMissingRequiredKey) {
72
+ break;
73
+ }
74
+ var valueAdjusted = (Number(value) || 0) * weight;
75
+ finalSum += valueAdjusted;
76
+ }
77
+ return { hasAtLeastOneKey: hasAtLeastOneKey, isMissingRequiredKey: isMissingRequiredKey, missingKeys: missingKeys, value: hasAtLeastOneKey ? finalSum : null };
78
+ };
79
+ /**
80
+ * @param skipSingleMatch When true, skips groups that match only one key. Used for testing groups.
81
+ */
82
+ ReportResolvable.prototype.getCalculated = function (key, skipSingleMatch) {
83
+ var _a;
84
+ if (skipSingleMatch === void 0) { skipSingleMatch = false; }
85
+ this.depth = 0;
86
+ return (_a = this._getCalculated(key, undefined, skipSingleMatch)) !== null && _a !== void 0 ? _a : { value: null, groupIndex: -1 };
87
+ };
88
+ ReportResolvable.prototype._getCalculated = function (key, parentKey, skipSingleMatch) {
89
+ var _a, _b, _c, _d, _e;
90
+ if (skipSingleMatch === void 0) { skipSingleMatch = false; }
91
+ this.depth++;
92
+ if (this.report[key] !== undefined && !skipSingleMatch) {
93
+ return { value: this.report[key], groupIndex: -1 };
94
+ }
95
+ if (this.calculatedValues.has(key)) {
96
+ var calculatedValue = this.calculatedValues.get(key);
97
+ var calculatedLength = (_b = (_a = this.calculationMap[key]) === null || _a === void 0 ? void 0 : _a.groups[calculatedValue === null || calculatedValue === void 0 ? void 0 : calculatedValue.groupIndex]) === null || _b === void 0 ? void 0 : _b.calculation.length;
98
+ if (!skipSingleMatch || calculatedLength > 1)
99
+ return calculatedValue;
100
+ }
101
+ if (this.keyStack.has(key) || this.depth >= 50) {
102
+ return null;
103
+ }
104
+ this.keyStack.add(key);
105
+ var calculationOptions = (_c = this.calculationMap[key]) !== null && _c !== void 0 ? _c : { isTranslation: true, groups: [] };
106
+ var result = null;
107
+ var calculationGroups = (_d = calculationOptions.groups) !== null && _d !== void 0 ? _d : [];
108
+ for (var i = 0; i < calculationGroups.length; i++) {
109
+ var group = calculationGroups[i];
110
+ var _f = this._getCalculatedFromGroup({
111
+ group: group,
112
+ breakIfMissingRequiredKey: true,
113
+ }, key, skipSingleMatch), hasAtLeastOneKey = _f.hasAtLeastOneKey, isMissingRequiredKey = _f.isMissingRequiredKey, value = _f.value;
114
+ if (!hasAtLeastOneKey || isMissingRequiredKey || typeof value !== 'number') {
115
+ continue;
116
+ }
117
+ var groupResult = { value: value, groupIndex: i };
118
+ // used for dev purposes to see which groups are being used.
119
+ var indexBucket = ((_e = this.usedGroupIndexesByKey.get(key)) !== null && _e !== void 0 ? _e : this.usedGroupIndexesByKey.set(key, new Set()).get(key));
120
+ indexBucket.add(i);
121
+ result = groupResult;
122
+ break;
123
+ }
124
+ if (parentKey === undefined && !skipSingleMatch) {
125
+ this.calculatedValues.set(key, result);
126
+ }
127
+ this.keyStack.delete(key);
128
+ return result;
129
+ };
130
+ ReportResolvable.prototype.toJSON = function () {
131
+ return this.report;
132
+ };
133
+ return ReportResolvable;
134
+ }());
135
+ exports.default = ReportResolvable;
@@ -1,4 +1,4 @@
1
- import { ReportTranslated } from '../../types';
1
+ import type { ReportTranslated } from '../../types';
2
2
  type ExtendableReportProxy = {
3
3
  new (report: ReportTranslated): ReportTranslated;
4
4
  };
@@ -1,4 +1,4 @@
1
- import { FiscalPeriod, ReportRaw, ReportTranslated } from '../../types';
1
+ import type { FiscalPeriod, ReportRaw, ReportTranslated } from '../../types';
2
2
  import ReportTranslatedProxy from './ReportTranslatedProxy';
3
3
  /**
4
4
  * Contains translated report and raw report with methods to access other reports
@@ -7,6 +7,12 @@ function resolveEbit(report) {
7
7
  report.ebit = report.incomeOperating;
8
8
  return;
9
9
  }
10
+ if (!report.ebit && report.incomeNet && report.expenseTax) {
11
+ report.ebit = report.incomeNet + report.expenseTax;
12
+ }
13
+ if (!report.ebitda && report.ebit && report.expenseDepreciation) {
14
+ report.ebitda = report.ebit + report.expenseDepreciation;
15
+ }
10
16
  var _a = report, ebit = _a.ebit, expenseDepreciation = _a.expenseDepreciation, ebitda = _a.ebitda;
11
17
  var nullKey = (0, helpers_1.getSingleNullKey)({ ebit: ebit, expenseDepreciation: expenseDepreciation, ebitda: ebitda });
12
18
  switch (nullKey) {
@@ -28,7 +28,6 @@ function resolveQ4FiscalYearMatchingProperties(reportWrapper) {
28
28
  'liabilityNonCurrentDebt',
29
29
  'liabilityTotal',
30
30
  'equityRetainedEarnings',
31
- 'equityStockPreferred',
32
31
  'equityTotal',
33
32
  'dateFiled',
34
33
  'dateReport',
@@ -1,3 +1,4 @@
1
+ import type { FactItem, FilingListItemTranslated } from '../../types';
1
2
  export interface SetReportDatesParams {
2
3
  year: number;
3
4
  quarter: number;
@@ -17,6 +18,13 @@ export default class FactFiscalCalculator {
17
18
  private readonly endDateCountMap;
18
19
  private readonly filedDateCountByEndDate;
19
20
  private didResolve;
21
+ constructor(params?: {
22
+ facts?: Pick<FactItem, 'end' | 'filed'>[];
23
+ filings?: Pick<FilingListItemTranslated, 'form' | 'reportDate' | 'filingDate' | 'accessionNumber'>[];
24
+ });
25
+ useFilingsForDates(params: {
26
+ filings: Pick<FilingListItemTranslated, 'form' | 'reportDate' | 'filingDate' | 'accessionNumber'>[];
27
+ }): void;
20
28
  add(fact: {
21
29
  end: string;
22
30
  filed: string;
@@ -5,7 +5,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  * Then measures the offset from the end date to the next/previous fiscal year end.
6
6
  */
7
7
  var FactFiscalCalculator = /** @class */ (function () {
8
- function FactFiscalCalculator() {
8
+ function FactFiscalCalculator(params) {
9
+ var _this = this;
9
10
  this.endDateByYear = new Map();
10
11
  this.fiscalsByEndDate = new Map();
11
12
  this.datesByFiscals = new Map();
@@ -13,7 +14,39 @@ var FactFiscalCalculator = /** @class */ (function () {
13
14
  this.endDateCountMap = new Map();
14
15
  this.filedDateCountByEndDate = new Map();
15
16
  this.didResolve = false;
17
+ var _a = params !== null && params !== void 0 ? params : {}, _b = _a.facts, facts = _b === void 0 ? [] : _b, _c = _a.filings, filings = _c === void 0 ? [] : _c;
18
+ if (filings.length > 0) {
19
+ this.useFilingsForDates({ filings: filings });
20
+ }
21
+ facts.forEach(function (fact) { return _this.add(fact); });
16
22
  }
23
+ FactFiscalCalculator.prototype.useFilingsForDates = function (params) {
24
+ var _this = this;
25
+ var filings = params.filings;
26
+ var endDateByYear = new Map();
27
+ filings.forEach(function (_a) {
28
+ var reportDate = _a.reportDate, form = _a.form;
29
+ if (form === '10-K' || form === '20-F') {
30
+ endDateByYear.set(Number(reportDate.substring(0, 4)), new Date(reportDate));
31
+ }
32
+ });
33
+ filings.forEach(function (filing) {
34
+ if (filing.form === '10-K' || filing.form === '10-Q' || filing.form === '20-F' || filing.form === '40-F') {
35
+ var _a = _this.getFiscalYearQuarter({
36
+ dateStr: filing.reportDate,
37
+ endDateByYear: endDateByYear,
38
+ }), quarter = _a.quarter, year = _a.year;
39
+ _this.setReportDates({
40
+ accn: filing.accessionNumber,
41
+ end: filing.reportDate,
42
+ filed: filing.filingDate,
43
+ isAnnual: filing.form === '10-K' || filing.form === '20-F',
44
+ quarter: quarter,
45
+ year: year,
46
+ });
47
+ }
48
+ });
49
+ };
17
50
  FactFiscalCalculator.prototype.add = function (fact) {
18
51
  var _a, _b, _c;
19
52
  var end = fact.end, filed = fact.filed;
@@ -1,4 +1,4 @@
1
- import { FactItem, FactGroup, SplitData } from '../../types';
1
+ import type { FactItem, FactGroup, SplitData } from '../../types';
2
2
  import FactFiscalCalculator from './FactFiscalCalculator';
3
3
  /**
4
4
  * There are many facts properties for the same period but filed at different times.
@@ -1,4 +1,4 @@
1
- import { FiscalPeriod } from '../../types/report-raw.type';
1
+ import type { FiscalPeriod } from '../../types/report-raw.type';
2
2
  /**
3
3
  * Resolves quarterly and annual values for a property. This is because filers provide total values for the
4
4
  * current fiscal year, rather than values for the individual quarters
@@ -1,4 +1,4 @@
1
- import { CompanyFactListData, FactItem } from '../../types';
1
+ import type { CompanyFactListData, FactItem } from '../../types';
2
2
  /**
3
3
  * Builds an array of fact records.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { CompanyFactListData, FactGroup, FactItem, FactValue, SplitData } from '../../types';
1
+ import type { CompanyFactListData, FactGroup, FactItem, FactValue, SplitData } from '../../types';
2
2
  /**
3
3
  * Splits can be filed multiple times throughout different reports. There is no clear
4
4
  * indication on when the split is executed or what facts the split has been applied to. This
@@ -1,6 +1,6 @@
1
- import { CompanyFactListData, FactGroup, FactItem, ReportRaw, SplitData } from '../../types';
1
+ import type { CompanyFactListData, FactGroup, FactItem, ReportRaw, SplitData } from '../../types';
2
2
  import FactFiscalCalculator, { SetReportDatesParams } from './FactFiscalCalculator';
3
- interface BuildReportsParams {
3
+ export interface BuildReportsParams {
4
4
  facts: FactItem[];
5
5
  /**
6
6
  * for more accurate dates, add this. Otherwise, dates will be inferred
@@ -37,4 +37,3 @@ export default class ReportRawBuilder {
37
37
  cik: number;
38
38
  }): ReportRaw[];
39
39
  }
40
- export {};
@@ -1,4 +1,4 @@
1
- import { FilingListDetails, FilingListItemTranslated } from '../../types';
1
+ import type { FilingListDetails, FilingListItemTranslated } from '../../types';
2
2
  export default class FilingMapper {
3
3
  mapFilingListDetails(cik: string | number, filingListDetails: FilingListDetails): FilingListItemTranslated[];
4
4
  }
@@ -1,4 +1,4 @@
1
- import { FilingListItemTranslated } from '../../types/submission.type';
1
+ import type { FilingListItemTranslated } from '../../types/submission.type';
2
2
  export interface SubmissionRequestWrapperOptions {
3
3
  maxRequests?: number;
4
4
  }
@@ -1,5 +1,4 @@
1
- import { CompanyFactFrame, CompanyFactListData, CompanyTickerItem, DailyFilingFormType, FieldDataResponse, Form10KData, Form13GData, Form4Data, FormDef14aData, MultiCompanyFactFrame, ReportRaw, ReportTranslated } from '../../types';
2
- import { FilingListDetails, FilingListItemTranslated, SubmissionList } from '../../types/submission.type';
1
+ import type { CompanyFactFrame, CompanyFactListData, CompanyTickerItem, DailyFilingFormType, FieldDataResponse, Form10KData, Form13GData, Form4Data, FormDef14aData, MultiCompanyFactFrame, ReportRaw, ReportTranslated, FilingListDetails, FilingListItemTranslated, SubmissionList, CalculationMap } from '../../types';
3
2
  import { IClient } from '../Client';
4
3
  import DocumentParser from '../DocumentParser';
5
4
  import ReportParser from '../ReportParser';
@@ -169,8 +168,26 @@ export default class SecEdgarApi {
169
168
  * Parses reports from company facts. Calculates missing properties and uses a single interface
170
169
  * for all reports. This includes only 10-K and 10-Q annual and quarterly reports. To include
171
170
  * all reports, use getReportsRaw.
171
+ *
172
+ * @deprecated Formerly getReports. This will be removed in a future version.
172
173
  */
173
- getReports<T extends GetReportsParams>(params: T): Promise<T['withWrapper'] extends true ? ReportWrapper[] : ReportTranslated[]>;
174
+ getReportsLegacy<T extends GetReportsParams>(params: T): Promise<T['withWrapper'] extends true ? ReportWrapper[] : ReportTranslated[]>;
175
+ /**
176
+ * Note: Properties that are not provied from report are calculated an may not be accurate,
177
+ * verify results finance.yahoo.com (ex: https://finance.yahoo.com/quote/AAPL/financials)
178
+ *
179
+ * Please contribute to improve resolving report properties: https://github.com/andyevers/sec-edgar-api
180
+ *
181
+ * Parses reports from company facts. Calculates missing properties and uses a single interface
182
+ * for all reports. This includes only 10-K and 10-Q annual and quarterly reports. To include
183
+ * all reports, use getReportsRaw.
184
+ */
185
+ getReports<R = ReportTranslated>(params: {
186
+ symbol: string | number;
187
+ adjustForSplits?: boolean;
188
+ resolvePeriodValues?: boolean;
189
+ calculationMap?: CalculationMap<R>;
190
+ }): Promise<(typeof params.calculationMap extends undefined ? ReportTranslated : ReportRaw & R)[]>;
174
191
  /**
175
192
  * Parses reports from company facts.
176
193
  */
@@ -216,7 +233,7 @@ export default class SecEdgarApi {
216
233
  */
217
234
  getDocumentXbrl(params: GetDocumentXbrlParams): Promise<import("../DocumentParser/XBRLParser/XBRLParser").XbrlParseResult & {
218
235
  report: ReportRaw | null;
219
- facts: import("../../types").FactItem[];
236
+ facts: import("../../types").FactItemExtended[];
220
237
  xml: string;
221
238
  }>;
222
239
  /**
@@ -319,6 +336,8 @@ export default class SecEdgarApi {
319
336
  }>;
320
337
  /**
321
338
  * Search for companies from by name, sic code, or state.
339
+ *
340
+ * example at https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&owner=exclude&&start=0&count=100&hidefilings=0&company=Apple&match=contains
322
341
  */
323
342
  searchCompanies(params: SearchCompaniesParams): Promise<{
324
343
  items: import("../../types").CompanySearchResult[];
@@ -270,8 +270,10 @@ var SecEdgarApi = /** @class */ (function () {
270
270
  * Parses reports from company facts. Calculates missing properties and uses a single interface
271
271
  * for all reports. This includes only 10-K and 10-Q annual and quarterly reports. To include
272
272
  * all reports, use getReportsRaw.
273
+ *
274
+ * @deprecated Formerly getReports. This will be removed in a future version.
273
275
  */
274
- SecEdgarApi.prototype.getReports = function (params) {
276
+ SecEdgarApi.prototype.getReportsLegacy = function (params) {
275
277
  return __awaiter(this, void 0, void 0, function () {
276
278
  var _a, withWrapper, _b, usePropertyResolver, reportsRaw, reportsWithWrapper, reports;
277
279
  return __generator(this, function (_c) {
@@ -281,13 +283,41 @@ var SecEdgarApi = /** @class */ (function () {
281
283
  return [4 /*yield*/, this.getReportsRaw(__assign(__assign({}, params), { includeNamePrefix: false }))];
282
284
  case 1:
283
285
  reportsRaw = _c.sent();
284
- reportsWithWrapper = this.reportParser.parseReportsFromRaw({ reportsRaw: reportsRaw, usePropertyResolver: usePropertyResolver });
286
+ reportsWithWrapper = this.reportParser.parseReportsFromRawLegacy({ reportsRaw: reportsRaw, usePropertyResolver: usePropertyResolver });
285
287
  reports = withWrapper ? reportsWithWrapper : reportsWithWrapper.map(function (report) { return report.getReport(); });
286
288
  return [2 /*return*/, reports];
287
289
  }
288
290
  });
289
291
  });
290
292
  };
293
+ /**
294
+ * Note: Properties that are not provied from report are calculated an may not be accurate,
295
+ * verify results finance.yahoo.com (ex: https://finance.yahoo.com/quote/AAPL/financials)
296
+ *
297
+ * Please contribute to improve resolving report properties: https://github.com/andyevers/sec-edgar-api
298
+ *
299
+ * Parses reports from company facts. Calculates missing properties and uses a single interface
300
+ * for all reports. This includes only 10-K and 10-Q annual and quarterly reports. To include
301
+ * all reports, use getReportsRaw.
302
+ */
303
+ SecEdgarApi.prototype.getReports = function (params) {
304
+ return __awaiter(this, void 0, void 0, function () {
305
+ var calculationMap, reportsRaw;
306
+ return __generator(this, function (_a) {
307
+ switch (_a.label) {
308
+ case 0:
309
+ calculationMap = params.calculationMap;
310
+ return [4 /*yield*/, this.getReportsRaw(__assign(__assign({}, params), { includeNamePrefix: true }))];
311
+ case 1:
312
+ reportsRaw = _a.sent();
313
+ return [2 /*return*/, this.reportParser.parseReportsFromRaw({
314
+ reportsRaw: reportsRaw,
315
+ calculationMap: calculationMap,
316
+ })];
317
+ }
318
+ });
319
+ });
320
+ };
291
321
  /**
292
322
  * Parses reports from company facts.
293
323
  */
@@ -671,6 +701,8 @@ var SecEdgarApi = /** @class */ (function () {
671
701
  };
672
702
  /**
673
703
  * Search for companies from by name, sic code, or state.
704
+ *
705
+ * example at https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&owner=exclude&&start=0&count=100&hidefilings=0&company=Apple&match=contains
674
706
  */
675
707
  SecEdgarApi.prototype.searchCompanies = function (params) {
676
708
  return __awaiter(this, void 0, void 0, function () {
@@ -0,0 +1,13 @@
1
+ export type CalculationMap<T = any> = Record<keyof T, CalculationMapItem>;
2
+ export interface CalculationMapCalculationItem {
3
+ key: string;
4
+ weight: number;
5
+ isRequired: boolean;
6
+ }
7
+ export interface CalculationMapCalculation {
8
+ calculation: CalculationMapCalculationItem[];
9
+ }
10
+ export interface CalculationMapItem {
11
+ groups: CalculationMapCalculation[];
12
+ }
13
+ export type CalculationMapCondensed<T = object> = Record<keyof T, (string | number)[][][]>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
- import { FactItem } from './company-facts.type';
1
+ import type { FactItem } from './company-facts.type';
2
2
  export interface XMLParams {
3
3
  xml: string;
4
4
  }
@@ -42,12 +42,3 @@ export interface FactGroup {
42
42
  valueTrailingFirst: number | string | null;
43
43
  valueTrailingLast: number | string | null;
44
44
  }
45
- export interface FactItemExtended extends FactItem {
46
- period: number;
47
- year: number;
48
- quarter: number;
49
- periodValue: number | null;
50
- trailingValue: number | null;
51
- splitValue: number | null;
52
- splitsApplied: number[];
53
- }
@@ -1,4 +1,4 @@
1
- import { FiscalPeriod } from './report-raw.type';
1
+ import type { FiscalPeriod } from './report-raw.type';
2
2
  export interface CompanyFactListData {
3
3
  cik: number;
4
4
  entityName: string;
@@ -74,6 +74,11 @@ export interface FactItem {
74
74
  }[];
75
75
  uuid?: string;
76
76
  }
77
+ export interface FactItemExtended extends FactItem {
78
+ isUsedInReport?: boolean;
79
+ decimals?: number;
80
+ scale?: number;
81
+ }
77
82
  export interface FactItemWithFiscals extends FactItem {
78
83
  fiscalPeriod: FiscalPeriod;
79
84
  year: number;
@@ -1,5 +1,7 @@
1
1
  export interface CompanySearchResult {
2
2
  cik: number;
3
+ sic: number | null;
4
+ sicDescription: string | null;
3
5
  companyName: string;
4
- stateOrCountry: string;
6
+ stateOrCountry: string | null;
5
7
  }
@@ -11,6 +11,7 @@ export interface FilingItemXBRL {
11
11
  title: string;
12
12
  link: string;
13
13
  guid: string;
14
+ url: string;
14
15
  enclosureUrl: string;
15
16
  enclosureLength: number;
16
17
  enclosureType: string;
@@ -1,9 +1,11 @@
1
- export * from './company-facts.type';
2
- export * from './report-raw.type';
3
- export * from './report-translated.type';
4
- export * from './submission.type';
5
- export * from './parsed-filings.type';
6
- export * from './common.type';
7
- export * from './insider-transaction.type';
8
- export * from './company-search.type';
9
- export * from './current-filings.type';
1
+ export type * from './company-facts.type';
2
+ export type * from './report-raw.type';
3
+ export type * from './report-translated.type';
4
+ export type * from './submission.type';
5
+ export type * from './parsed-filings.type';
6
+ export type * from './common.type';
7
+ export type * from './insider-transaction.type';
8
+ export type * from './company-search.type';
9
+ export type * from './current-filings.type';
10
+ export type * from './xbrl.type';
11
+ export type * from './calculation-map.type';
@@ -1,25 +1,2 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
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);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./company-facts.type"), exports);
18
- __exportStar(require("./report-raw.type"), exports);
19
- __exportStar(require("./report-translated.type"), exports);
20
- __exportStar(require("./submission.type"), exports);
21
- __exportStar(require("./parsed-filings.type"), exports);
22
- __exportStar(require("./common.type"), exports);
23
- __exportStar(require("./insider-transaction.type"), exports);
24
- __exportStar(require("./company-search.type"), exports);
25
- __exportStar(require("./current-filings.type"), exports);
@@ -1,3 +1,4 @@
1
+ export type TransactionCode = 'S' | 'V' | 'A' | 'D' | 'F' | 'I' | 'M' | 'C' | 'E' | 'H' | 'O' | 'X' | 'G' | 'L' | 'W' | 'Z' | 'J' | 'K' | 'U';
1
2
  export interface Owner {
2
3
  ownerName: string;
3
4
  ownerCik: number;
@@ -22,7 +23,29 @@ export interface InsiderTransaction {
22
23
  isDirectOwnership: boolean;
23
24
  securityTitle: string;
24
25
  transactionDate: string;
25
- transactionCode: string;
26
+ /**
27
+ * ### Transaction Codes
28
+ * - S: Sale
29
+ * - V: Voluntary Reporting
30
+ * - A: Grant
31
+ * - D: Sale to Issuer
32
+ * - F: Payment of Exercise Price
33
+ * - I: Discretionary Transaction
34
+ * - M: Conversion of Derivative Exempt
35
+ * - C: Conversion of Derivative
36
+ * - E: Expiration of Short Derivative Position
37
+ * - H: Expiration of Long Derivative Position
38
+ * - O: Exercise of out-of-the-money Derivative
39
+ * - X: Exercise of in-the-money Derivative
40
+ * - G: Gift
41
+ * - L: Small Acquisition
42
+ * - W: Acquisition or Disposition By Will or Laws
43
+ * - Z: Voting Trust Deposit or Withdrawal
44
+ * - J: Other Acquisition or Disposition
45
+ * - K: Equity Swap
46
+ * - U: Disposition Change in Control
47
+ */
48
+ transactionCode: TransactionCode;
26
49
  transactionShares: number;
27
50
  sharesOwnedFollowingTransaction: number;
28
51
  lineNumber: number;
@@ -30,3 +53,26 @@ export interface InsiderTransaction {
30
53
  form: string;
31
54
  accessionNumber: string;
32
55
  }
56
+ export type TransactionType = 'Acquire' | 'Dispose';
57
+ export interface InsiderTransactionExtended {
58
+ filerName: string;
59
+ filerPosition: string;
60
+ filerPositionTypes: string[];
61
+ securityType: string;
62
+ securityTypeUnderlying: string | null;
63
+ category: 'Derivative' | 'Non-Derivative';
64
+ date: string;
65
+ dateExecuted: string | null;
66
+ dateExpiration: string | null;
67
+ dateExercisable: string | null;
68
+ transactionDescription: string | null;
69
+ transactionCode: TransactionCode | null;
70
+ transactionType: TransactionType | null;
71
+ sharesEnding: number | null;
72
+ shares: number | null;
73
+ sharesUnderlying: number | null;
74
+ price: number | null;
75
+ priceExcercised: number | null;
76
+ ownership: string;
77
+ explainationByKey: Partial<Record<keyof InsiderTransactionExtended, string>>;
78
+ }