sec-edgar-api 0.0.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 (84) hide show
  1. package/README.md +27 -0
  2. package/build/index.d.ts +21 -0
  3. package/build/index.js +26 -0
  4. package/build/services/FactFileReader/FactFileReader.d.ts +30 -0
  5. package/build/services/FactFileReader/FactFileReader.js +36 -0
  6. package/build/services/FactFileReader/index.d.ts +2 -0
  7. package/build/services/FactFileReader/index.js +4 -0
  8. package/build/services/ReportParser/FactIterator.d.ts +18 -0
  9. package/build/services/ReportParser/FactIterator.js +35 -0
  10. package/build/services/ReportParser/PropertyResolver.d.ts +25 -0
  11. package/build/services/ReportParser/PropertyResolver.js +44 -0
  12. package/build/services/ReportParser/ReportParser.d.ts +53 -0
  13. package/build/services/ReportParser/ReportParser.js +97 -0
  14. package/build/services/ReportParser/ReportRawParser.d.ts +34 -0
  15. package/build/services/ReportParser/ReportRawParser.js +154 -0
  16. package/build/services/ReportParser/ReportTranslatedProxy.d.ts +9 -0
  17. package/build/services/ReportParser/ReportTranslatedProxy.js +40 -0
  18. package/build/services/ReportParser/ReportWrapper.d.ts +27 -0
  19. package/build/services/ReportParser/ReportWrapper.js +89 -0
  20. package/build/services/ReportParser/index.d.ts +2 -0
  21. package/build/services/ReportParser/index.js +4 -0
  22. package/build/services/ReportParser/resolvers/helpers.d.ts +21 -0
  23. package/build/services/ReportParser/resolvers/helpers.js +49 -0
  24. package/build/services/ReportParser/resolvers/index.d.ts +31 -0
  25. package/build/services/ReportParser/resolvers/index.js +33 -0
  26. package/build/services/ReportParser/resolvers/resolve-asset-current.d.ts +2 -0
  27. package/build/services/ReportParser/resolvers/resolve-asset-current.js +20 -0
  28. package/build/services/ReportParser/resolvers/resolve-asset-non-current-ppe-gross.d.ts +2 -0
  29. package/build/services/ReportParser/resolvers/resolve-asset-non-current-ppe-gross.js +20 -0
  30. package/build/services/ReportParser/resolvers/resolve-cash-flow-capex.d.ts +5 -0
  31. package/build/services/ReportParser/resolvers/resolve-cash-flow-capex.js +37 -0
  32. package/build/services/ReportParser/resolvers/resolve-cash-flow-free.d.ts +2 -0
  33. package/build/services/ReportParser/resolvers/resolve-cash-flow-free.js +23 -0
  34. package/build/services/ReportParser/resolvers/resolve-cash-flow-operating.d.ts +2 -0
  35. package/build/services/ReportParser/resolvers/resolve-cash-flow-operating.js +39 -0
  36. package/build/services/ReportParser/resolvers/resolve-cash-flow-working-capital-non-cash.d.ts +2 -0
  37. package/build/services/ReportParser/resolvers/resolve-cash-flow-working-capital-non-cash.js +22 -0
  38. package/build/services/ReportParser/resolvers/resolve-ebit.d.ts +2 -0
  39. package/build/services/ReportParser/resolvers/resolve-ebit.js +25 -0
  40. package/build/services/ReportParser/resolvers/resolve-expense-depreciation.d.ts +2 -0
  41. package/build/services/ReportParser/resolvers/resolve-expense-depreciation.js +96 -0
  42. package/build/services/ReportParser/resolvers/resolve-expense-operating.d.ts +2 -0
  43. package/build/services/ReportParser/resolvers/resolve-expense-operating.js +22 -0
  44. package/build/services/ReportParser/resolvers/resolve-expense-total.d.ts +2 -0
  45. package/build/services/ReportParser/resolvers/resolve-expense-total.js +20 -0
  46. package/build/services/ReportParser/resolvers/resolve-fiscal-year-cumulative-properties.d.ts +5 -0
  47. package/build/services/ReportParser/resolvers/resolve-fiscal-year-cumulative-properties.js +70 -0
  48. package/build/services/ReportParser/resolvers/resolve-liability-current.d.ts +2 -0
  49. package/build/services/ReportParser/resolvers/resolve-liability-current.js +20 -0
  50. package/build/services/ReportParser/resolvers/resolve-q4-fiscal-year-matching-properties.d.ts +5 -0
  51. package/build/services/ReportParser/resolvers/resolve-q4-fiscal-year-matching-properties.js +24 -0
  52. package/build/services/ReportParser/resolvers/resolve-revenue-total.d.ts +2 -0
  53. package/build/services/ReportParser/resolvers/resolve-revenue-total.js +20 -0
  54. package/build/services/SecEdgarApi/Client.d.ts +44 -0
  55. package/build/services/SecEdgarApi/Client.js +104 -0
  56. package/build/services/SecEdgarApi/Downloader.d.ts +26 -0
  57. package/build/services/SecEdgarApi/Downloader.js +102 -0
  58. package/build/services/SecEdgarApi/FactsDownloader.d.ts +30 -0
  59. package/build/services/SecEdgarApi/FactsDownloader.js +125 -0
  60. package/build/services/SecEdgarApi/SecConnector.d.ts +47 -0
  61. package/build/services/SecEdgarApi/SecConnector.js +143 -0
  62. package/build/services/SecEdgarApi/SecEdgarApi.d.ts +92 -0
  63. package/build/services/SecEdgarApi/SecEdgarApi.js +184 -0
  64. package/build/services/SecEdgarApi/Throttler.d.ts +34 -0
  65. package/build/services/SecEdgarApi/Throttler.js +111 -0
  66. package/build/services/SecEdgarApi/Unzipper.d.ts +40 -0
  67. package/build/services/SecEdgarApi/Unzipper.js +40 -0
  68. package/build/services/SecEdgarApi/index.d.ts +3 -0
  69. package/build/services/SecEdgarApi/index.js +19 -0
  70. package/build/types/company-facts.type.d.ts +53 -0
  71. package/build/types/company-facts.type.js +2 -0
  72. package/build/types/index.d.ts +4 -0
  73. package/build/types/index.js +20 -0
  74. package/build/types/report-raw.type.d.ts +23 -0
  75. package/build/types/report-raw.type.js +2 -0
  76. package/build/types/report-translated.type.d.ts +58 -0
  77. package/build/types/report-translated.type.js +2 -0
  78. package/build/types/submission.type.d.ts +70 -0
  79. package/build/types/submission.type.js +2 -0
  80. package/build/util/cik-by-symbol.d.ts +5 -0
  81. package/build/util/cik-by-symbol.js +9632 -0
  82. package/build/util/key-translations.d.ts +7 -0
  83. package/build/util/key-translations.js +174 -0
  84. package/package.json +41 -0
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var _ReportTranslatedProxy = /** @class */ (function () {
4
+ function _ReportTranslatedProxy(report) {
5
+ this.changedKeys = new Set();
6
+ var reportKeys = new Set(Object.keys(report));
7
+ return new Proxy(this, {
8
+ // when accessing property of report, return the value of the report instead of the wrapper
9
+ get: function (target, key, receiver) {
10
+ return reportKeys.has(String(key)) ? Reflect.get(report, key) : Reflect.get(target, key, receiver);
11
+ },
12
+ // record changed properties
13
+ set: function (target, key, value, receiver) {
14
+ if (reportKeys.has(String(key))) {
15
+ target.changedKeys.add(String(key));
16
+ return Reflect.set(report, key, value);
17
+ }
18
+ return Reflect.set(target, key, value, receiver);
19
+ },
20
+ // makes Object.keys return report keys
21
+ ownKeys: function () {
22
+ return Reflect.ownKeys(report);
23
+ },
24
+ getOwnPropertyDescriptor: function (target, key) {
25
+ return reportKeys.has(String(key))
26
+ ? Reflect.getOwnPropertyDescriptor(report, key)
27
+ : Reflect.getOwnPropertyDescriptor(target, key);
28
+ },
29
+ });
30
+ }
31
+ _ReportTranslatedProxy.prototype.getChangedKeys = function () {
32
+ return Array.from(this.changedKeys);
33
+ };
34
+ return _ReportTranslatedProxy;
35
+ }());
36
+ /**
37
+ * Used to make ReportWrapper implement ReportTranslated interface via proxy
38
+ */
39
+ var ReportTranslatedProxy = _ReportTranslatedProxy;
40
+ exports.default = ReportTranslatedProxy;
@@ -0,0 +1,27 @@
1
+ import { FiscalPeriod, ReportRaw, ReportTranslated } from '../../types';
2
+ import ReportTranslatedProxy from './ReportTranslatedProxy';
3
+ /**
4
+ * Contains translated report and raw report with methods to access other reports
5
+ */
6
+ export default class ReportWrapper extends ReportTranslatedProxy implements ReportTranslated {
7
+ private readonly report;
8
+ private readonly reportMap;
9
+ private readonly reportRaw;
10
+ constructor(report: ReportTranslated, reportRaw?: ReportRaw, reportMap?: Map<string, ReportWrapper>);
11
+ /**
12
+ * when using JSON.stringify on this class instance, it will stringify the report
13
+ */
14
+ toJSON(): ReportTranslated;
15
+ getReportRaw(): ReportRaw;
16
+ getReport(): ReportTranslated;
17
+ /**
18
+ * Gets report wrapper for prev or future report
19
+ *
20
+ * @param offset positive number returns future report, negative returns past
21
+ */
22
+ getReportOffset(offset: number, reportType: 'QUARTERLY' | 'ANNUAL'): ReportWrapper | null;
23
+ /**
24
+ * Gets report wrappers in the same fiscal year as this report
25
+ */
26
+ getReportsFiscalYearByPeriod(fiscalYear?: number): Record<FiscalPeriod, ReportWrapper | null>;
27
+ }
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ var ReportTranslatedProxy_1 = require("./ReportTranslatedProxy");
19
+ /**
20
+ * Contains translated report and raw report with methods to access other reports
21
+ */
22
+ var ReportWrapper = /** @class */ (function (_super) {
23
+ __extends(ReportWrapper, _super);
24
+ function ReportWrapper(report, reportRaw, reportMap) {
25
+ var _this = this;
26
+ var _a;
27
+ _this = _super.call(this, report) || this;
28
+ _this.report = report;
29
+ _this.reportMap = reportMap !== null && reportMap !== void 0 ? reportMap : new Map();
30
+ _this.reportRaw = reportRaw !== null && reportRaw !== void 0 ? reportRaw : {
31
+ dateFiled: report.dateFiled,
32
+ dateReport: report.dateReport,
33
+ form: report.form,
34
+ isTTM: report.isTTM,
35
+ frame: '',
36
+ taxonomy: '',
37
+ reportType: report.isTTM ? 'ANNUAL' : 'QUARTERLY',
38
+ fiscalPeriod: (_a = report.fiscalPeriod) !== null && _a !== void 0 ? _a : '',
39
+ fiscalYear: report.fiscalYear,
40
+ };
41
+ return _this;
42
+ }
43
+ /**
44
+ * when using JSON.stringify on this class instance, it will stringify the report
45
+ */
46
+ ReportWrapper.prototype.toJSON = function () {
47
+ return this.report;
48
+ };
49
+ ReportWrapper.prototype.getReportRaw = function () {
50
+ return this.reportRaw;
51
+ };
52
+ ReportWrapper.prototype.getReport = function () {
53
+ return this.report;
54
+ };
55
+ /**
56
+ * Gets report wrapper for prev or future report
57
+ *
58
+ * @param offset positive number returns future report, negative returns past
59
+ */
60
+ ReportWrapper.prototype.getReportOffset = function (offset, reportType) {
61
+ var _a, _b;
62
+ var _c = this.report, fiscalPeriod = _c.fiscalPeriod, fiscalYear = _c.fiscalYear;
63
+ if (reportType === 'ANNUAL') {
64
+ return (_a = this.reportMap.get("".concat(fiscalYear + offset, "_FY"))) !== null && _a !== void 0 ? _a : null;
65
+ }
66
+ var period = fiscalPeriod === 'FY' ? 'Q4' : fiscalPeriod;
67
+ var currentQuarter = Number(period.substring(1));
68
+ var isCeilOffsetYear = currentQuarter + (offset % 4) > 4 || (offset < 0 && currentQuarter + (offset % 4) > 0);
69
+ var targetYear = isCeilOffsetYear ? fiscalYear + Math.ceil(offset / 4) : fiscalYear + Math.floor(offset / 4);
70
+ var targetQuarter = Math.abs(currentQuarter + offset < 0 ? ((currentQuarter + offset) % 4) + 4 : (currentQuarter + offset) % 4 || 4);
71
+ return (_b = this.reportMap.get("".concat(targetYear, "_Q").concat(targetQuarter))) !== null && _b !== void 0 ? _b : null;
72
+ };
73
+ /**
74
+ * Gets report wrappers in the same fiscal year as this report
75
+ */
76
+ ReportWrapper.prototype.getReportsFiscalYearByPeriod = function (fiscalYear) {
77
+ var _a, _b, _c, _d, _e;
78
+ if (fiscalYear === void 0) { fiscalYear = this.report.fiscalYear; }
79
+ return {
80
+ FY: (_a = this.reportMap.get("".concat(fiscalYear, "_FY"))) !== null && _a !== void 0 ? _a : null,
81
+ Q1: (_b = this.reportMap.get("".concat(fiscalYear, "_Q1"))) !== null && _b !== void 0 ? _b : null,
82
+ Q2: (_c = this.reportMap.get("".concat(fiscalYear, "_Q2"))) !== null && _c !== void 0 ? _c : null,
83
+ Q3: (_d = this.reportMap.get("".concat(fiscalYear, "_Q3"))) !== null && _d !== void 0 ? _d : null,
84
+ Q4: (_e = this.reportMap.get("".concat(fiscalYear, "_Q4"))) !== null && _e !== void 0 ? _e : null,
85
+ };
86
+ };
87
+ return ReportWrapper;
88
+ }(ReportTranslatedProxy_1.default));
89
+ exports.default = ReportWrapper;
@@ -0,0 +1,2 @@
1
+ import ReportParser from './ReportParser';
2
+ export default ReportParser;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var ReportParser_1 = require("./ReportParser");
4
+ exports.default = ReportParser_1.default;
@@ -0,0 +1,21 @@
1
+ import { ReportTranslated } from '../../../types';
2
+ interface SplitValueBetweenReportsParams {
3
+ key: keyof ReportTranslated;
4
+ value: number;
5
+ reports: ReportTranslated[];
6
+ roundToPlaces: number;
7
+ }
8
+ export type ExcludeNulls<T> = {
9
+ [K in keyof T]: Exclude<T[K], null>;
10
+ };
11
+ export declare function getSingleNullKey<T>(obj: T): keyof T | null;
12
+ export declare function round(num: number, places: number): number;
13
+ /**
14
+ * returns the number of places the number is rounded to
15
+ */
16
+ export declare function getRoundToPlaces(num: number): 1 | 1000000 | 1000;
17
+ /**
18
+ * distributes a value between each report evenly, and rounds to the nearest roundToPlaces. gives remainder to last report
19
+ */
20
+ export declare function splitValueBetweenReports(params: SplitValueBetweenReportsParams): void;
21
+ export {};
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitValueBetweenReports = exports.getRoundToPlaces = exports.round = exports.getSingleNullKey = void 0;
4
+ function getSingleNullKey(obj) {
5
+ var singleNullKey = null;
6
+ for (var key in obj) {
7
+ if (obj[key] !== null)
8
+ continue;
9
+ if (singleNullKey === null)
10
+ singleNullKey = key;
11
+ else
12
+ return null;
13
+ }
14
+ return singleNullKey;
15
+ }
16
+ exports.getSingleNullKey = getSingleNullKey;
17
+ function round(num, places) {
18
+ return Math.round(num / places) * places;
19
+ }
20
+ exports.round = round;
21
+ /**
22
+ * returns the number of places the number is rounded to
23
+ */
24
+ function getRoundToPlaces(num) {
25
+ if (num.toString().endsWith('000000'))
26
+ return 1000000;
27
+ if (num.toString().endsWith('000'))
28
+ return 1000;
29
+ return 1;
30
+ }
31
+ exports.getRoundToPlaces = getRoundToPlaces;
32
+ /**
33
+ * distributes a value between each report evenly, and rounds to the nearest roundToPlaces. gives remainder to last report
34
+ */
35
+ function splitValueBetweenReports(params) {
36
+ var _a;
37
+ var key = params.key, value = params.value, roundToPlaces = params.roundToPlaces;
38
+ var reports = params.reports;
39
+ var remainder = ((value / roundToPlaces) % reports.length) * roundToPlaces;
40
+ var valueToDistribute = (value - remainder) / reports.length;
41
+ reports.forEach(function (report) {
42
+ var _a;
43
+ var diffAdded = round(((_a = report[key]) !== null && _a !== void 0 ? _a : 0) + valueToDistribute, roundToPlaces);
44
+ report[key] = diffAdded;
45
+ });
46
+ var reportLast = reports[reports.length - 1];
47
+ reportLast[key] = ((_a = reportLast[key]) !== null && _a !== void 0 ? _a : 0) + remainder;
48
+ }
49
+ exports.splitValueBetweenReports = splitValueBetweenReports;
@@ -0,0 +1,31 @@
1
+ import { resolveAssetCurrent } from './resolve-asset-current';
2
+ import { resolveAssetNonCurrentPPEGross } from './resolve-asset-non-current-ppe-gross';
3
+ import { resolveCashFlowCapex } from './resolve-cash-flow-capex';
4
+ import { resolveCashFlowFree } from './resolve-cash-flow-free';
5
+ import { resolveCashFlowOperating } from './resolve-cash-flow-operating';
6
+ import { resolveCashFlowWorkingCapitalNonCash } from './resolve-cash-flow-working-capital-non-cash';
7
+ import { resolveEbit } from './resolve-ebit';
8
+ import { resolveExpenseDepreciation } from './resolve-expense-depreciation';
9
+ import { resolveExpenseOperating } from './resolve-expense-operating';
10
+ import { resolveExpenseTotal } from './resolve-expense-total';
11
+ import { resolveFiscalYearCumulativeProperties } from './resolve-fiscal-year-cumulative-properties';
12
+ import { resolveLiabilityCurrent } from './resolve-liability-current';
13
+ import { resolveQ4FiscalYearMatchingProperties } from './resolve-q4-fiscal-year-matching-properties';
14
+ import { resolveRevenueTotal } from './resolve-revenue-total';
15
+ declare const resolvers: {
16
+ resolveAssetNonCurrentPPEGross: typeof resolveAssetNonCurrentPPEGross;
17
+ resolveExpenseDepreciation: typeof resolveExpenseDepreciation;
18
+ resolveExpenseOperating: typeof resolveExpenseOperating;
19
+ resolveCashFlowFree: typeof resolveCashFlowFree;
20
+ resolveEbit: typeof resolveEbit;
21
+ resolveAssetCurrent: typeof resolveAssetCurrent;
22
+ resolveCashFlowCapex: typeof resolveCashFlowCapex;
23
+ resolveFiscalYearCumulativeProperties: typeof resolveFiscalYearCumulativeProperties;
24
+ resolveRevenueTotal: typeof resolveRevenueTotal;
25
+ resolveExpenseTotal: typeof resolveExpenseTotal;
26
+ resolveCashFlowOperating: typeof resolveCashFlowOperating;
27
+ resolveLiabilityCurrent: typeof resolveLiabilityCurrent;
28
+ resolveQ4FiscalYearMatchingProperties: typeof resolveQ4FiscalYearMatchingProperties;
29
+ resolveCashFlowWorkingCapitalNonCash: typeof resolveCashFlowWorkingCapitalNonCash;
30
+ };
31
+ export default resolvers;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var resolve_asset_current_1 = require("./resolve-asset-current");
4
+ var resolve_asset_non_current_ppe_gross_1 = require("./resolve-asset-non-current-ppe-gross");
5
+ var resolve_cash_flow_capex_1 = require("./resolve-cash-flow-capex");
6
+ var resolve_cash_flow_free_1 = require("./resolve-cash-flow-free");
7
+ var resolve_cash_flow_operating_1 = require("./resolve-cash-flow-operating");
8
+ var resolve_cash_flow_working_capital_non_cash_1 = require("./resolve-cash-flow-working-capital-non-cash");
9
+ var resolve_ebit_1 = require("./resolve-ebit");
10
+ var resolve_expense_depreciation_1 = require("./resolve-expense-depreciation");
11
+ var resolve_expense_operating_1 = require("./resolve-expense-operating");
12
+ var resolve_expense_total_1 = require("./resolve-expense-total");
13
+ var resolve_fiscal_year_cumulative_properties_1 = require("./resolve-fiscal-year-cumulative-properties");
14
+ var resolve_liability_current_1 = require("./resolve-liability-current");
15
+ var resolve_q4_fiscal_year_matching_properties_1 = require("./resolve-q4-fiscal-year-matching-properties");
16
+ var resolve_revenue_total_1 = require("./resolve-revenue-total");
17
+ var resolvers = {
18
+ resolveAssetNonCurrentPPEGross: resolve_asset_non_current_ppe_gross_1.resolveAssetNonCurrentPPEGross,
19
+ resolveExpenseDepreciation: resolve_expense_depreciation_1.resolveExpenseDepreciation,
20
+ resolveExpenseOperating: resolve_expense_operating_1.resolveExpenseOperating,
21
+ resolveCashFlowFree: resolve_cash_flow_free_1.resolveCashFlowFree,
22
+ resolveEbit: resolve_ebit_1.resolveEbit,
23
+ resolveAssetCurrent: resolve_asset_current_1.resolveAssetCurrent,
24
+ resolveCashFlowCapex: resolve_cash_flow_capex_1.resolveCashFlowCapex,
25
+ resolveFiscalYearCumulativeProperties: resolve_fiscal_year_cumulative_properties_1.resolveFiscalYearCumulativeProperties,
26
+ resolveRevenueTotal: resolve_revenue_total_1.resolveRevenueTotal,
27
+ resolveExpenseTotal: resolve_expense_total_1.resolveExpenseTotal,
28
+ resolveCashFlowOperating: resolve_cash_flow_operating_1.resolveCashFlowOperating,
29
+ resolveLiabilityCurrent: resolve_liability_current_1.resolveLiabilityCurrent,
30
+ resolveQ4FiscalYearMatchingProperties: resolve_q4_fiscal_year_matching_properties_1.resolveQ4FiscalYearMatchingProperties,
31
+ resolveCashFlowWorkingCapitalNonCash: resolve_cash_flow_working_capital_non_cash_1.resolveCashFlowWorkingCapitalNonCash,
32
+ };
33
+ exports.default = resolvers;
@@ -0,0 +1,2 @@
1
+ import ReportWrapper from '../ReportWrapper';
2
+ export declare function resolveAssetCurrent(report: ReportWrapper): void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveAssetCurrent = void 0;
4
+ var helpers_1 = require("./helpers");
5
+ function resolveAssetCurrent(report) {
6
+ var _a = report, assetCurrent = _a.assetCurrent, assetNonCurrent = _a.assetNonCurrent, assetTotal = _a.assetTotal;
7
+ var nullKey = (0, helpers_1.getSingleNullKey)({ assetCurrent: assetCurrent, assetNonCurrent: assetNonCurrent, assetTotal: assetTotal });
8
+ switch (nullKey) {
9
+ case 'assetCurrent':
10
+ report.assetCurrent = assetTotal - assetNonCurrent;
11
+ break;
12
+ case 'assetNonCurrent':
13
+ report.assetNonCurrent = assetTotal - assetCurrent;
14
+ break;
15
+ case 'assetTotal':
16
+ report.assetTotal = assetCurrent + assetNonCurrent;
17
+ break;
18
+ }
19
+ }
20
+ exports.resolveAssetCurrent = resolveAssetCurrent;
@@ -0,0 +1,2 @@
1
+ import ReportWrapper from '../ReportWrapper';
2
+ export declare function resolveAssetNonCurrentPPEGross(report: ReportWrapper): void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveAssetNonCurrentPPEGross = void 0;
4
+ var helpers_1 = require("./helpers");
5
+ function resolveAssetNonCurrentPPEGross(report) {
6
+ var _a = report, expenseDepreciationAccumulated = _a.expenseDepreciationAccumulated, assetNonCurrentPPEGross = _a.assetNonCurrentPPEGross, assetNonCurrentPPENet = _a.assetNonCurrentPPENet;
7
+ var nullKey = (0, helpers_1.getSingleNullKey)({ expenseDepreciationAccumulated: expenseDepreciationAccumulated, assetNonCurrentPPEGross: assetNonCurrentPPEGross, assetNonCurrentPPENet: assetNonCurrentPPENet });
8
+ switch (nullKey) {
9
+ case 'assetNonCurrentPPEGross':
10
+ report.assetNonCurrentPPEGross = assetNonCurrentPPENet + expenseDepreciationAccumulated;
11
+ break;
12
+ case 'assetNonCurrentPPENet':
13
+ report.assetNonCurrentPPENet = assetNonCurrentPPEGross - expenseDepreciationAccumulated;
14
+ break;
15
+ case 'expenseDepreciationAccumulated':
16
+ report.expenseDepreciationAccumulated = assetNonCurrentPPEGross - assetNonCurrentPPENet;
17
+ break;
18
+ }
19
+ }
20
+ exports.resolveAssetNonCurrentPPEGross = resolveAssetNonCurrentPPEGross;
@@ -0,0 +1,5 @@
1
+ import ReportWrapper from '../ReportWrapper';
2
+ /**
3
+ * This only an estimate. splits remaining capex between quarters if FY has capex, or adds quarterly capex if Quarters have it
4
+ */
5
+ export declare function resolveCashFlowCapex(report: ReportWrapper): void;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveCashFlowCapex = void 0;
4
+ var helpers_1 = require("./helpers");
5
+ /**
6
+ * This only an estimate. splits remaining capex between quarters if FY has capex, or adds quarterly capex if Quarters have it
7
+ */
8
+ function resolveCashFlowCapex(report) {
9
+ var _a, _b, _c;
10
+ if (report.fiscalYear !== 2022 || report.cashFlowCapex !== null)
11
+ return;
12
+ var reportPrev = report.getReportOffset(-1, report.isTTM ? 'ANNUAL' : 'QUARTERLY');
13
+ var _d = report.getReportsFiscalYearByPeriod(), FY = _d.FY, Q1 = _d.Q1, Q2 = _d.Q2, Q3 = _d.Q3, Q4 = _d.Q4;
14
+ if (FY === null) {
15
+ report.cashFlowCapex = (_a = reportPrev === null || reportPrev === void 0 ? void 0 : reportPrev.cashFlowCapex) !== null && _a !== void 0 ? _a : null;
16
+ return;
17
+ }
18
+ var sumQuarters = [Q1, Q2, Q3, Q4].reduce(function (sum, rep) { var _a; return sum + ((_a = rep === null || rep === void 0 ? void 0 : rep.cashFlowCapex) !== null && _a !== void 0 ? _a : 0); }, 0);
19
+ var reportsQuarterlyWithoutCapex = [Q1, Q2, Q3, Q4].filter(function (rep) { return rep && rep.cashFlowCapex === null; });
20
+ if (report.isTTM) {
21
+ if (reportsQuarterlyWithoutCapex.length === 0)
22
+ report.cashFlowCapex = sumQuarters;
23
+ return;
24
+ }
25
+ var reportTTMOrPrev = (_c = (_b = report.getReportOffset(0, 'ANNUAL')) !== null && _b !== void 0 ? _b : report.getReportOffset(-1, 'ANNUAL')) !== null && _c !== void 0 ? _c : report.getReportOffset(-1, 'QUARTERLY');
26
+ var roundToPlaces = (0, helpers_1.getRoundToPlaces)(Number(reportTTMOrPrev === null || reportTTMOrPrev === void 0 ? void 0 : reportTTMOrPrev.cashFlowCapex));
27
+ var cashFlowCapexFY = FY.cashFlowCapex;
28
+ if (cashFlowCapexFY !== null) {
29
+ (0, helpers_1.splitValueBetweenReports)({
30
+ key: 'cashFlowCapex',
31
+ reports: reportsQuarterlyWithoutCapex,
32
+ roundToPlaces: roundToPlaces,
33
+ value: cashFlowCapexFY - sumQuarters,
34
+ });
35
+ }
36
+ }
37
+ exports.resolveCashFlowCapex = resolveCashFlowCapex;
@@ -0,0 +1,2 @@
1
+ import ReportWrapper from '../ReportWrapper';
2
+ export declare function resolveCashFlowFree(report: ReportWrapper): void;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveCashFlowFree = void 0;
4
+ var helpers_1 = require("./helpers");
5
+ function resolveCashFlowFree(report) {
6
+ var _a = report, cashFlowFree = _a.cashFlowFree, cashFlowOperating = _a.cashFlowOperating, cashFlowCapex = _a.cashFlowCapex;
7
+ var nullKey = (0, helpers_1.getSingleNullKey)({ cashFlowFree: cashFlowFree, cashFlowOperating: cashFlowOperating, cashFlowCapex: cashFlowCapex });
8
+ if (cashFlowOperating !== null && cashFlowCapex !== null) {
9
+ report.cashFlowFree = cashFlowOperating - cashFlowCapex;
10
+ }
11
+ switch (nullKey) {
12
+ case 'cashFlowFree':
13
+ report.cashFlowFree = cashFlowOperating - cashFlowCapex;
14
+ break;
15
+ case 'cashFlowCapex':
16
+ report.cashFlowCapex = cashFlowOperating - cashFlowFree;
17
+ break;
18
+ case 'cashFlowOperating':
19
+ report.cashFlowOperating = cashFlowFree + cashFlowCapex;
20
+ break;
21
+ }
22
+ }
23
+ exports.resolveCashFlowFree = resolveCashFlowFree;
@@ -0,0 +1,2 @@
1
+ import ReportWrapper from '../ReportWrapper';
2
+ export declare function resolveCashFlowOperating(report: ReportWrapper): void;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveCashFlowOperating = void 0;
4
+ var helpers_1 = require("./helpers");
5
+ // TODO: make this more accurate.
6
+ function resolveCashFlowOperating(report) {
7
+ if (report.cashFlowOperating !== null)
8
+ return;
9
+ var _a = report.getReportsFiscalYearByPeriod(), FY = _a.FY, Q1 = _a.Q1, Q2 = _a.Q2, Q3 = _a.Q3, Q4 = _a.Q4;
10
+ var cashFlowOperatingFY = FY ? FY.cashFlowOperating : null;
11
+ if (cashFlowOperatingFY !== null) {
12
+ var roundToPlaces = (0, helpers_1.getRoundToPlaces)(cashFlowOperatingFY);
13
+ // all reports that get estimated must be resolved to make sure the estimated values add up to the TTM value
14
+ for (var _i = 0, _b = [Q1, Q2, Q3, Q4]; _i < _b.length; _i++) {
15
+ var rep = _b[_i];
16
+ if (rep && rep.cashFlowOperating === null) {
17
+ var cashFlowOperating = getCashFlowOperating(rep);
18
+ if (cashFlowOperating === null)
19
+ continue;
20
+ report.cashFlowOperating = (0, helpers_1.round)(cashFlowOperating, roundToPlaces);
21
+ }
22
+ }
23
+ }
24
+ else {
25
+ report.cashFlowOperating = getCashFlowOperating(report);
26
+ }
27
+ }
28
+ exports.resolveCashFlowOperating = resolveCashFlowOperating;
29
+ function getCashFlowOperating(report) {
30
+ var reportPrev = report.getReportOffset(-1, report.isTTM ? 'ANNUAL' : 'QUARTERLY');
31
+ if (!reportPrev)
32
+ return null;
33
+ var _a = report, incomeNet = _a.incomeNet, expenseDepreciation = _a.expenseDepreciation, cashFlowWorkingCapitalNonCash = _a.cashFlowWorkingCapitalNonCash;
34
+ var cashFlowWorkingCapitalNonCashPrev = reportPrev.cashFlowWorkingCapitalNonCash;
35
+ if (cashFlowWorkingCapitalNonCash === null || cashFlowWorkingCapitalNonCashPrev === null)
36
+ return null;
37
+ var changeInWorkingCapitalNonCash = cashFlowWorkingCapitalNonCash - cashFlowWorkingCapitalNonCashPrev;
38
+ return incomeNet + expenseDepreciation - changeInWorkingCapitalNonCash;
39
+ }
@@ -0,0 +1,2 @@
1
+ import ReportWrapper from '../ReportWrapper';
2
+ export declare function resolveCashFlowWorkingCapitalNonCash(report: ReportWrapper): void;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveCashFlowWorkingCapitalNonCash = void 0;
4
+ // TODO: See if this can be more accurate to improve the accuracy of cashFlowOperating
5
+ function resolveCashFlowWorkingCapitalNonCash(report) {
6
+ if (report.cashFlowWorkingCapitalNonCash !== null)
7
+ return;
8
+ // the previous report is used to calculate the change in working capital in resolveCashFlowOperating
9
+ var reportWrapperPrev = report.getReportOffset(-1, report.isTTM ? 'ANNUAL' : 'QUARTERLY');
10
+ var _a = report.getReportsFiscalYearByPeriod(), FY = _a.FY, Q1 = _a.Q1, Q2 = _a.Q2, Q3 = _a.Q3, Q4 = _a.Q4;
11
+ for (var _i = 0, _b = [FY, Q1, Q2, Q3, Q4, reportWrapperPrev]; _i < _b.length; _i++) {
12
+ var report_1 = _b[_i];
13
+ var _c = report_1 !== null && report_1 !== void 0 ? report_1 : {}, assetCurrent = _c.assetCurrent, assetCurrentCashEquivalents = _c.assetCurrentCashEquivalents, liabilityCurrent = _c.liabilityCurrent, liabilityCurrentDebt = _c.liabilityCurrentDebt;
14
+ var isMissingProps = !report_1 || !assetCurrent || !assetCurrentCashEquivalents || !liabilityCurrent;
15
+ if (isMissingProps || report_1.cashFlowWorkingCapitalNonCash !== null)
16
+ continue;
17
+ var assetsCurrentLessCash = assetCurrent - assetCurrentCashEquivalents;
18
+ var liabilitiesCurrentLessDebt = liabilityCurrent - (liabilityCurrentDebt !== null && liabilityCurrentDebt !== void 0 ? liabilityCurrentDebt : 0);
19
+ report_1.cashFlowWorkingCapitalNonCash = assetsCurrentLessCash - liabilitiesCurrentLessDebt;
20
+ }
21
+ }
22
+ exports.resolveCashFlowWorkingCapitalNonCash = resolveCashFlowWorkingCapitalNonCash;
@@ -0,0 +1,2 @@
1
+ import ReportWrapper from '../ReportWrapper';
2
+ export declare function resolveEbit(report: ReportWrapper): void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveEbit = void 0;
4
+ var helpers_1 = require("./helpers");
5
+ function resolveEbit(report) {
6
+ if (report.incomeOperating) {
7
+ report.ebit = report.incomeOperating;
8
+ return;
9
+ }
10
+ var _a = report, ebit = _a.ebit, expenseDepreciation = _a.expenseDepreciation, ebitda = _a.ebitda;
11
+ var nullKey = (0, helpers_1.getSingleNullKey)({ ebit: ebit, expenseDepreciation: expenseDepreciation, ebitda: ebitda });
12
+ switch (nullKey) {
13
+ case 'ebit':
14
+ report.ebit = expenseDepreciation + ebitda;
15
+ break;
16
+ case 'ebitda':
17
+ report.ebitda = ebit - expenseDepreciation;
18
+ break;
19
+ case 'expenseDepreciation':
20
+ report.expenseDepreciation = ebit - ebitda;
21
+ break;
22
+ }
23
+ report.incomeOperating = report.ebit;
24
+ }
25
+ exports.resolveEbit = resolveEbit;
@@ -0,0 +1,2 @@
1
+ import ReportWrapper from '../ReportWrapper';
2
+ export declare function resolveExpenseDepreciation(report: ReportWrapper): void;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveExpenseDepreciation = void 0;
4
+ var helpers_1 = require("./helpers");
5
+ function resolveExpenseDepreciation(report) {
6
+ var _a, _b, _c;
7
+ // return if both values are already set
8
+ if (report.expenseDepreciation !== null && report.assetNonCurrentPPEGross !== null)
9
+ return;
10
+ var reportTTMCurrentYear = report.getReportOffset(0, 'ANNUAL');
11
+ // get report to get value for, prioritizing TTM current year. Used to get percent of depreciation relative to PPE
12
+ var reportTTMOrPrev = (_a = reportTTMCurrentYear !== null && reportTTMCurrentYear !== void 0 ? reportTTMCurrentYear : report.getReportOffset(-1, 'ANNUAL')) !== null && _a !== void 0 ? _a : report.getReportOffset(-1, 'QUARTERLY');
13
+ var expenseDepreciationTTMOrPrev = (_b = reportTTMOrPrev === null || reportTTMOrPrev === void 0 ? void 0 : reportTTMOrPrev.expenseDepreciation) !== null && _b !== void 0 ? _b : null;
14
+ var assetNonCurrentPPEGrossTTMOrPrev = (_c = reportTTMOrPrev === null || reportTTMOrPrev === void 0 ? void 0 : reportTTMOrPrev.assetNonCurrentPPEGross) !== null && _c !== void 0 ? _c : null;
15
+ // both values must be set to resolve
16
+ if (expenseDepreciationTTMOrPrev === null || assetNonCurrentPPEGrossTTMOrPrev === null) {
17
+ return;
18
+ }
19
+ var percentOfPPE = getDepreciationPercentOfPPE(report);
20
+ if (percentOfPPE === null)
21
+ return;
22
+ var _d = report, expenseDepreciation = _d.expenseDepreciation, assetNonCurrentPPEGross = _d.assetNonCurrentPPEGross;
23
+ var nullKey = (0, helpers_1.getSingleNullKey)({ expenseDepreciation: expenseDepreciation, assetNonCurrentPPEGross: assetNonCurrentPPEGross });
24
+ if (!nullKey)
25
+ return;
26
+ var valueTTMOrPrev = nullKey === 'expenseDepreciation' ? expenseDepreciationTTMOrPrev : assetNonCurrentPPEGrossTTMOrPrev;
27
+ // follow the same rounding as the other report values
28
+ var roundToPlaces = (0, helpers_1.getRoundToPlaces)(valueTTMOrPrev);
29
+ var resolveReport = function (rep) {
30
+ var _a = rep, expenseDepreciation = _a.expenseDepreciation, assetNonCurrentPPEGross = _a.assetNonCurrentPPEGross;
31
+ var nullKeyRep = (0, helpers_1.getSingleNullKey)({ expenseDepreciation: expenseDepreciation, assetNonCurrentPPEGross: assetNonCurrentPPEGross });
32
+ if (nullKey !== nullKeyRep)
33
+ return false;
34
+ switch (nullKey) {
35
+ case 'expenseDepreciation':
36
+ rep.expenseDepreciation = (0, helpers_1.round)(assetNonCurrentPPEGross * percentOfPPE, roundToPlaces);
37
+ break;
38
+ case 'assetNonCurrentPPEGross':
39
+ rep.assetNonCurrentPPEGross = (0, helpers_1.round)(expenseDepreciation / percentOfPPE, roundToPlaces);
40
+ break;
41
+ }
42
+ return true;
43
+ };
44
+ // if we have all reports for the year and we know the value of TTM, need to make sure the estimated values add up to the TTM value
45
+ if (reportTTMCurrentYear) {
46
+ var _e = report.getReportsFiscalYearByPeriod(), Q1 = _e.Q1, Q2 = _e.Q2, Q3 = _e.Q3, Q4 = _e.Q4;
47
+ var reportsEstimated = [];
48
+ // all reports that get estimated must be resolved to make sure the estimated values add up to the TTM value
49
+ var didResolveAllEstimated = true;
50
+ for (var _i = 0, _f = [Q1, Q2, Q3, Q4]; _i < _f.length; _i++) {
51
+ var rep = _f[_i];
52
+ if (rep && (rep === null || rep === void 0 ? void 0 : rep[nullKey]) === null) {
53
+ didResolveAllEstimated = resolveReport(rep) && didResolveAllEstimated;
54
+ reportsEstimated.push(rep);
55
+ }
56
+ }
57
+ if (didResolveAllEstimated && reportsEstimated.length > 0 && Q1 && Q2 && Q3 && Q4) {
58
+ // const
59
+ var estimationDifference = [Q1, Q2, Q3, Q4].reduce(function (remainingDiff, rep) { var _a; return remainingDiff - Number((_a = rep[nullKey]) !== null && _a !== void 0 ? _a : 0); }, Number(reportTTMCurrentYear[nullKey]));
60
+ // divide as evenly as possible between the reports, and give the leftover to the last estimated report
61
+ (0, helpers_1.splitValueBetweenReports)({
62
+ key: nullKey,
63
+ reports: reportsEstimated,
64
+ roundToPlaces: roundToPlaces,
65
+ value: estimationDifference,
66
+ });
67
+ }
68
+ }
69
+ else {
70
+ resolveReport(report);
71
+ }
72
+ }
73
+ exports.resolveExpenseDepreciation = resolveExpenseDepreciation;
74
+ function getDepreciationPercentOfPPE(report) {
75
+ var _a, _b, _c, _d;
76
+ var reportTTMOrPrev = (_b = (_a = report.getReportOffset(0, 'ANNUAL')) !== null && _a !== void 0 ? _a : report.getReportOffset(-1, 'ANNUAL')) !== null && _b !== void 0 ? _b : report.getReportOffset(-1, 'QUARTERLY');
77
+ var expenseDepreciationTTMOrPrev = (_c = reportTTMOrPrev === null || reportTTMOrPrev === void 0 ? void 0 : reportTTMOrPrev.expenseDepreciation) !== null && _c !== void 0 ? _c : null;
78
+ var assetNonCurrentPPEGrossTTMOrPrev = (_d = reportTTMOrPrev === null || reportTTMOrPrev === void 0 ? void 0 : reportTTMOrPrev.assetNonCurrentPPEGross) !== null && _d !== void 0 ? _d : null;
79
+ if (!reportTTMOrPrev || expenseDepreciationTTMOrPrev === null || assetNonCurrentPPEGrossTTMOrPrev === null) {
80
+ return null;
81
+ }
82
+ // if checking depreciation using an annual report, we need to get the sum of the quarters
83
+ var ppeDenominator = assetNonCurrentPPEGrossTTMOrPrev;
84
+ if (reportTTMOrPrev.isTTM && !report.isTTM) {
85
+ var _e = reportTTMOrPrev.getReportsFiscalYearByPeriod(), Q1 = _e.Q1, Q2 = _e.Q2, Q3 = _e.Q3, Q4 = _e.Q4;
86
+ ppeDenominator = 0;
87
+ for (var _i = 0, _f = [Q1, Q2, Q3, Q4]; _i < _f.length; _i++) {
88
+ var rep = _f[_i];
89
+ var assetNonCurrentPPEGross = rep === null || rep === void 0 ? void 0 : rep.assetNonCurrentPPEGross;
90
+ if (typeof assetNonCurrentPPEGross !== 'number')
91
+ return null;
92
+ ppeDenominator += assetNonCurrentPPEGross;
93
+ }
94
+ }
95
+ return expenseDepreciationTTMOrPrev / ppeDenominator;
96
+ }
@@ -0,0 +1,2 @@
1
+ import ReportWrapper from '../ReportWrapper';
2
+ export declare function resolveExpenseOperating(report: ReportWrapper): void;