sec-edgar-api 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) 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/parsers/parse-companies.d.ts +1 -2
  10. package/build/services/DocumentParser/parsers/parse-insider-transaction.d.ts +1 -2
  11. package/build/services/DocumentParser/parsers/parse-xbrl.d.ts +2 -2
  12. package/build/services/DocumentParser/parsers/parse-xbrl.js +12 -8
  13. package/build/services/ReportParser/ReportParser.d.ts +19 -6
  14. package/build/services/ReportParser/ReportParser.js +53 -22
  15. package/build/services/ReportParser/ReportResolvable.d.ts +52 -0
  16. package/build/services/ReportParser/ReportResolvable.js +135 -0
  17. package/build/services/ReportParser/ReportTranslatedProxy.d.ts +1 -1
  18. package/build/services/ReportParser/ReportWrapper.d.ts +1 -1
  19. package/build/services/ReportParser/resolvers/resolve-ebit.js +6 -0
  20. package/build/services/ReportParser/resolvers/resolve-q4-fiscal-year-matching-properties.js +0 -1
  21. package/build/services/ReportRawBuilder/FactFiscalCalculator.d.ts +8 -0
  22. package/build/services/ReportRawBuilder/FactFiscalCalculator.js +34 -1
  23. package/build/services/ReportRawBuilder/FactGrouper.d.ts +1 -1
  24. package/build/services/ReportRawBuilder/FactPeriodResolver.d.ts +1 -1
  25. package/build/services/ReportRawBuilder/FactRecordBuilder.d.ts +1 -1
  26. package/build/services/ReportRawBuilder/FactSplitAdjuster.d.ts +1 -1
  27. package/build/services/ReportRawBuilder/ReportRawBuilder.d.ts +2 -3
  28. package/build/services/SecEdgarApi/FilingMapper.d.ts +1 -1
  29. package/build/services/SecEdgarApi/RequestWrapper.d.ts +1 -1
  30. package/build/services/SecEdgarApi/SecEdgarApi.d.ts +22 -5
  31. package/build/services/SecEdgarApi/SecEdgarApi.js +35 -5
  32. package/build/types/calculation-map.type.d.ts +13 -0
  33. package/build/types/calculation-map.type.js +2 -0
  34. package/build/types/common.type.d.ts +1 -10
  35. package/build/types/company-facts.type.d.ts +6 -1
  36. package/build/types/index.d.ts +11 -9
  37. package/build/types/index.js +0 -23
  38. package/build/types/report-translated.type.d.ts +6 -3
  39. package/build/util/calculation-map.d.ts +2 -0
  40. package/build/util/calculation-map.js +292 -0
  41. package/build/util/key-translations.d.ts +1 -1
  42. package/build/util/key-translations.js +6 -6
  43. package/build/util/util-map.d.ts +12 -0
  44. package/build/util/util-map.js +50 -0
  45. package/package.json +1 -1
@@ -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';
@@ -160,6 +159,19 @@ export default class SecEdgarApi {
160
159
  * endpoint `/api/xbrl/frames/${taxonomy}/${fact}/${unit}/${frame}.json`
161
160
  */
162
161
  getFactFrame(params: GetFactFrameParams): Promise<MultiCompanyFactFrame>;
162
+ /**
163
+ * Note: Properties that are not provied from report are calculated an may not be accurate,
164
+ * verify results finance.yahoo.com (ex: https://finance.yahoo.com/quote/AAPL/financials)
165
+ *
166
+ * Please contribute to improve resolving report properties: https://github.com/andyevers/sec-edgar-api
167
+ *
168
+ * Parses reports from company facts. Calculates missing properties and uses a single interface
169
+ * for all reports. This includes only 10-K and 10-Q annual and quarterly reports. To include
170
+ * all reports, use getReportsRaw.
171
+ *
172
+ * @deprecated Formerly getReports. This will be removed in a future version.
173
+ */
174
+ getReportsLegacy<T extends GetReportsParams>(params: T): Promise<T['withWrapper'] extends true ? ReportWrapper[] : ReportTranslated[]>;
163
175
  /**
164
176
  * Note: Properties that are not provied from report are calculated an may not be accurate,
165
177
  * verify results finance.yahoo.com (ex: https://finance.yahoo.com/quote/AAPL/financials)
@@ -170,7 +182,12 @@ export default class SecEdgarApi {
170
182
  * for all reports. This includes only 10-K and 10-Q annual and quarterly reports. To include
171
183
  * all reports, use getReportsRaw.
172
184
  */
173
- getReports<T extends GetReportsParams>(params: T): Promise<T['withWrapper'] extends true ? ReportWrapper[] : ReportTranslated[]>;
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
  /**
@@ -301,7 +318,7 @@ export default class SecEdgarApi {
301
318
  /**
302
319
  * @see https://www.sec.gov/structureddata/rss-feeds-submitted-filings
303
320
  */
304
- getCurrentFilingsXBRL(params?: {
321
+ getCurrentFilingsXbrl(params?: {
305
322
  taxonomy?: 'usGaap' | 'mutualFund' | 'inlineXbrl' | 'allXbrl';
306
323
  }): Promise<import("../../types").CurrentFilingsXBRL>;
307
324
  /**
@@ -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
  */
@@ -403,7 +433,7 @@ var SecEdgarApi = /** @class */ (function () {
403
433
  */
404
434
  SecEdgarApi.prototype.buildDocumentUrl = function (params) {
405
435
  var symbol = params.symbol, accessionNumber = params.accessionNumber, fileNameProp = params.fileName;
406
- var cik = this.getCikString(symbol);
436
+ var cik = Number(this.getCikString(symbol));
407
437
  var fileName = fileNameProp !== null && fileNameProp !== void 0 ? fileNameProp : "".concat(accessionNumber, ".txt");
408
438
  return "".concat(this.baseUrlSec, "/Archives/edgar/data/").concat(cik, "/").concat(accessionNumber.replace(/-/g, ''), "/").concat(fileName);
409
439
  };
@@ -598,7 +628,7 @@ var SecEdgarApi = /** @class */ (function () {
598
628
  switch (_e.label) {
599
629
  case 0:
600
630
  _b = params !== null && params !== void 0 ? params : {}, _c = _b.page, page = _c === void 0 ? 1 : _c, _d = _b.itemsPerPage, itemsPerPage = _d === void 0 ? 100 : _d, formType = _b.formType, searchType = _b.searchType, symbol = _b.symbol;
601
- type = (_a = formType === null || formType === void 0 ? void 0 : formType.replace(/\s/, '+')) !== null && _a !== void 0 ? _a : null;
631
+ type = (_a = formType === null || formType === void 0 ? void 0 : formType.trim().replace(/\s/g, '+')) !== null && _a !== void 0 ? _a : null;
602
632
  owner = searchType !== null && searchType !== void 0 ? searchType : ((formType === null || formType === void 0 ? void 0 : formType.includes(' ')) ? 'include' : 'only');
603
633
  offset = (page - 1) * Math.max(1, itemsPerPage || 100);
604
634
  cik = symbol ? Number(this.getCikString(symbol)) : null;
@@ -620,7 +650,7 @@ var SecEdgarApi = /** @class */ (function () {
620
650
  /**
621
651
  * @see https://www.sec.gov/structureddata/rss-feeds-submitted-filings
622
652
  */
623
- SecEdgarApi.prototype.getCurrentFilingsXBRL = function (params) {
653
+ SecEdgarApi.prototype.getCurrentFilingsXbrl = function (params) {
624
654
  return __awaiter(this, void 0, void 0, function () {
625
655
  var _a, taxonomy, urlByTaxonomy, url, xml;
626
656
  return __generator(this, function (_b) {
@@ -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,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,4 +1,4 @@
1
- import { FiscalPeriod } from './report-raw.type';
1
+ import type { FiscalPeriod } from './report-raw.type';
2
2
  export interface ReportTranslated {
3
3
  cik: number;
4
4
  url: string | null;
@@ -28,7 +28,6 @@ export interface ReportTranslated {
28
28
  liabilityNonCurrentDebt: number | null;
29
29
  equityTotal: number | null;
30
30
  equityRetainedEarnings: number | null;
31
- equityStockPreferred: number | null;
32
31
  sharesOutstanding: number | null;
33
32
  sharesOutstandingDiluted: number | null;
34
33
  eps: number | null;
@@ -48,13 +47,17 @@ export interface ReportTranslated {
48
47
  expenseDepreciationAccumulated: number | null;
49
48
  expenseStockCompensation: number | null;
50
49
  expenseNonCashOther: number | null;
50
+ expenseSellingGeneralAdministrative: number | null;
51
51
  incomeOperating: number | null;
52
52
  incomeNet: number | null;
53
+ incomePretax: number | null;
53
54
  cashFlowFree: number | null;
54
55
  cashFlowDividendsPaid: number | null;
55
56
  cashFlowDividendsPaidPreferred: number | null;
56
- cashFlowCapex: number | null;
57
57
  cashFlowOperating: number | null;
58
+ cashFlowInvesting: number | null;
59
+ cashFlowFinancing: number | null;
60
+ cashFlowCapex: number | null;
58
61
  cashFlowDeferredTax: number | null;
59
62
  cashFlowWorkingCapitalNonCash: number | null;
60
63
  }
@@ -0,0 +1,2 @@
1
+ import { CalculationMapCondensed, ReportTranslated } from '../types';
2
+ export declare const calculationMapCondensed: CalculationMapCondensed<ReportTranslated>;