sec-edgar-api 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/services/Client/Client.d.ts +2 -0
- package/build/services/Client/Client.js +6 -1
- package/build/services/SecEdgarApi/SecEdgarApi.d.ts +12 -2
- package/build/services/SecEdgarApi/SecEdgarApi.js +7 -3
- package/build/util/build-report-trees.d.ts +29 -2
- package/build/util/build-report-trees.js +125 -33
- package/package.json +1 -1
|
@@ -34,12 +34,14 @@ export interface ClientArgs {
|
|
|
34
34
|
export interface IClient {
|
|
35
35
|
request(params: RequestParams): Promise<ClientResponse>;
|
|
36
36
|
setDefaultHeaders?(headers: Record<string, string>): void;
|
|
37
|
+
setUserAgent?(userAgent: string): void;
|
|
37
38
|
}
|
|
38
39
|
export default class Client implements IClient {
|
|
39
40
|
private readonly httpClient;
|
|
40
41
|
private defaultHeaders;
|
|
41
42
|
constructor(args?: ClientArgs);
|
|
42
43
|
setDefaultHeaders(headers: Record<string, string>): void;
|
|
44
|
+
setUserAgent(userAgent: string): void;
|
|
43
45
|
request(params: RequestParams): Promise<ClientResponse>;
|
|
44
46
|
}
|
|
45
47
|
export {};
|
|
@@ -18,7 +18,9 @@ var Client = /** @class */ (function () {
|
|
|
18
18
|
httpClient: https,
|
|
19
19
|
defaultHeaders: {
|
|
20
20
|
// this can be any user agent, just not empty
|
|
21
|
-
'
|
|
21
|
+
'Accept-Encoding': 'gzip, deflate',
|
|
22
|
+
Host: 'www.sec.gov',
|
|
23
|
+
'User-Agent': 'Sample Company Name AdminContact@samplecompanydomain.com',
|
|
22
24
|
},
|
|
23
25
|
}; }
|
|
24
26
|
var httpClient = args.httpClient, defaultHeaders = args.defaultHeaders;
|
|
@@ -28,6 +30,9 @@ var Client = /** @class */ (function () {
|
|
|
28
30
|
Client.prototype.setDefaultHeaders = function (headers) {
|
|
29
31
|
this.defaultHeaders = headers;
|
|
30
32
|
};
|
|
33
|
+
Client.prototype.setUserAgent = function (userAgent) {
|
|
34
|
+
this.defaultHeaders['User-Agent'] = userAgent;
|
|
35
|
+
};
|
|
31
36
|
Client.prototype.request = function (params) {
|
|
32
37
|
var _this = this;
|
|
33
38
|
var url = params.url, data = params.data, headers = params.headers, onChunk = params.onChunk, onResponse = params.onResponse, onError = params.onError, onSuccess = params.onSuccess, _a = params.resolveData, resolveData = _a === void 0 ? true : _a, _b = params.method, method = _b === void 0 ? 'GET' : _b, _c = params.timeout, timeout = _c === void 0 ? 86400000 : _c;
|
|
@@ -6,7 +6,7 @@ import ReportWrapper from '../ReportParser/ReportWrapper';
|
|
|
6
6
|
import FilingMapper from './FilingMapper';
|
|
7
7
|
import SubmissionRequestWrapper from './RequestWrapper';
|
|
8
8
|
import { IThrottler } from './Throttler';
|
|
9
|
-
interface
|
|
9
|
+
interface SecApiDeps {
|
|
10
10
|
throttler: IThrottler;
|
|
11
11
|
client: IClient;
|
|
12
12
|
cikBySymbol: Record<string, number>;
|
|
@@ -14,6 +14,16 @@ interface SecApiArgs {
|
|
|
14
14
|
documentParser: DocumentParser;
|
|
15
15
|
filingMapper?: FilingMapper;
|
|
16
16
|
}
|
|
17
|
+
interface SecApiArgs {
|
|
18
|
+
/**
|
|
19
|
+
* Highly recommended as this is required by the SEC.
|
|
20
|
+
*
|
|
21
|
+
* @see https://www.sec.gov/about/webmaster-frequently-asked-questions#developers
|
|
22
|
+
*
|
|
23
|
+
* @example "Sample Company Name AdminContact@samplecompanydomain.com"
|
|
24
|
+
*/
|
|
25
|
+
userAgent?: string;
|
|
26
|
+
}
|
|
17
27
|
export interface CreateRequestWrapperParams {
|
|
18
28
|
/** symbol or cik */
|
|
19
29
|
symbol: string | number;
|
|
@@ -101,7 +111,7 @@ export default class SecEdgarApi {
|
|
|
101
111
|
readonly cikBySymbol: Record<string, number>;
|
|
102
112
|
readonly reportParser: ReportParser;
|
|
103
113
|
readonly documentParser: DocumentParser;
|
|
104
|
-
constructor(args?: SecApiArgs);
|
|
114
|
+
constructor(args?: SecApiArgs, deps?: SecApiDeps);
|
|
105
115
|
private request;
|
|
106
116
|
private mapFilingListDetails;
|
|
107
117
|
private getCreateRequestSubmissions;
|
|
@@ -71,8 +71,9 @@ var Throttler_1 = require("./Throttler");
|
|
|
71
71
|
* @see https://www.sec.gov/edgar/sec-api-documentation
|
|
72
72
|
*/
|
|
73
73
|
var SecEdgarApi = /** @class */ (function () {
|
|
74
|
-
function SecEdgarApi(args) {
|
|
75
|
-
if (args === void 0) { args = {
|
|
74
|
+
function SecEdgarApi(args, deps) {
|
|
75
|
+
if (args === void 0) { args = {}; }
|
|
76
|
+
if (deps === void 0) { deps = {
|
|
76
77
|
client: new Client_1.default(),
|
|
77
78
|
throttler: new Throttler_1.default(),
|
|
78
79
|
cikBySymbol: cik_by_symbol_1.default,
|
|
@@ -80,7 +81,10 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
80
81
|
documentParser: new DocumentParser_1.default(),
|
|
81
82
|
filingMapper: new FilingMapper_1.default(),
|
|
82
83
|
}; }
|
|
83
|
-
var
|
|
84
|
+
var _a;
|
|
85
|
+
var _b = args.userAgent, userAgent = _b === void 0 ? 'Sample Company Name AdminContact@samplecompanydomain.com' : _b;
|
|
86
|
+
var client = deps.client, throttler = deps.throttler, cikBySymbol = deps.cikBySymbol, reportParser = deps.reportParser, documentParser = deps.documentParser, _c = deps.filingMapper, filingMapper = _c === void 0 ? new FilingMapper_1.default() : _c;
|
|
87
|
+
(_a = client.setUserAgent) === null || _a === void 0 ? void 0 : _a.call(client, userAgent);
|
|
84
88
|
this.client = client;
|
|
85
89
|
this.throttler = throttler;
|
|
86
90
|
this.cikBySymbol = cikBySymbol;
|
|
@@ -5,7 +5,8 @@ export interface XbrlFilingSummaryReportWithTrees extends XbrlFilingSummaryRepor
|
|
|
5
5
|
presentationTree: TreeNode[];
|
|
6
6
|
}
|
|
7
7
|
export type MemberInclusionRule = 'always' | 'inReportsWherePresent' | 'never';
|
|
8
|
-
|
|
8
|
+
export type RowLabelType = 'preferredLabel' | 'descriptiveLabel';
|
|
9
|
+
export interface TreeNode {
|
|
9
10
|
label: string;
|
|
10
11
|
value: number | string | null;
|
|
11
12
|
unit: string;
|
|
@@ -16,10 +17,11 @@ interface TreeNode {
|
|
|
16
17
|
members?: MemberFact[];
|
|
17
18
|
children?: TreeNode[];
|
|
18
19
|
}
|
|
19
|
-
interface MemberFact {
|
|
20
|
+
export interface MemberFact {
|
|
20
21
|
segments: {
|
|
21
22
|
dimension: string;
|
|
22
23
|
value: string;
|
|
24
|
+
label: string;
|
|
23
25
|
}[];
|
|
24
26
|
value: string | number | null;
|
|
25
27
|
}
|
|
@@ -31,6 +33,31 @@ export interface BuildReportTreesParams {
|
|
|
31
33
|
* @default 'inReportsWherePresent'
|
|
32
34
|
*/
|
|
33
35
|
memberInclusionRule?: MemberInclusionRule;
|
|
36
|
+
/**
|
|
37
|
+
* Which label type to use for row labels.
|
|
38
|
+
*
|
|
39
|
+
* @default 'preferredLabel'
|
|
40
|
+
*/
|
|
41
|
+
rowLabelType?: RowLabelType;
|
|
42
|
+
/**
|
|
43
|
+
* Disable inclusion of period start facts in the tree.
|
|
44
|
+
*
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
disablePeriodStartFacts?: boolean;
|
|
34
48
|
}
|
|
35
49
|
export declare function buildReportTrees(params: BuildReportTreesParams): XbrlFilingSummaryReportWithTrees[];
|
|
50
|
+
export interface TraverseTreeNodeData<T extends AnyTreeNode> {
|
|
51
|
+
node: T;
|
|
52
|
+
parentNode: T | null;
|
|
53
|
+
/** Root level = 0 */
|
|
54
|
+
depth: number;
|
|
55
|
+
}
|
|
56
|
+
interface AnyTreeNode {
|
|
57
|
+
children?: AnyTreeNode[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Traverse through a tree structure (depth first)
|
|
61
|
+
*/
|
|
62
|
+
export declare function traverseTree<T extends AnyTreeNode>(rootNodes: T[], callback: (data: TraverseTreeNodeData<T>) => void): void;
|
|
36
63
|
export {};
|
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.buildReportTrees = void 0;
|
|
14
|
+
exports.traverseTree = exports.buildReportTrees = void 0;
|
|
15
15
|
function hrefToKey(href) {
|
|
16
16
|
var fragment = href.split('#').pop() || '';
|
|
17
17
|
return fragment.replace('_', ':');
|
|
@@ -69,12 +69,13 @@ function extractMemberFacts(facts, memberInclusionRule, allowedMembers) {
|
|
|
69
69
|
return [];
|
|
70
70
|
var allMembers = facts
|
|
71
71
|
.filter(function (f) { var _a, _b; return ((_b = (_a = f.segments) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0; })
|
|
72
|
-
.map(function (f) { return ({
|
|
72
|
+
.map(function (f) { return ({
|
|
73
|
+
value: f.value,
|
|
74
|
+
segments: f.segments.map(function (s) { return ({ dimension: s.dimension, value: s.value, label: f.label }); }),
|
|
75
|
+
}); });
|
|
73
76
|
if (memberInclusionRule === 'always')
|
|
74
77
|
return allMembers;
|
|
75
|
-
return allMembers.filter(function (m) {
|
|
76
|
-
return m.segments.every(function (s) { return (allowedMembers === null || allowedMembers === void 0 ? void 0 : allowedMembers.has(s.value)) && (allowedMembers === null || allowedMembers === void 0 ? void 0 : allowedMembers.has(s.dimension)); });
|
|
77
|
-
});
|
|
78
|
+
return allMembers.filter(function (m) { var _a; return (_a = m.segments) === null || _a === void 0 ? void 0 : _a.every(function (s) { return (allowedMembers === null || allowedMembers === void 0 ? void 0 : allowedMembers.has(s.value)) && (allowedMembers === null || allowedMembers === void 0 ? void 0 : allowedMembers.has(s.dimension)); }); });
|
|
78
79
|
}
|
|
79
80
|
function extractPrimaryFact(facts) {
|
|
80
81
|
var _a;
|
|
@@ -82,7 +83,7 @@ function extractPrimaryFact(facts) {
|
|
|
82
83
|
}
|
|
83
84
|
function buildTemplateHierarchyFlat(params) {
|
|
84
85
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
85
|
-
var arcs = params.arcs, labelByHref = params.labelByHref, locByLabel = params.locByLabel, factsByConcept = params.factsByConcept, allowedMembers = params.allowedMembers,
|
|
86
|
+
var arcs = params.arcs, labelByHref = params.labelByHref, locByLabel = params.locByLabel, factsByConcept = params.factsByConcept, allowedMembers = params.allowedMembers, memberInclusionRule = params.memberInclusionRule, rowLabelType = params.rowLabelType, disablePeriodStartFacts = params.disablePeriodStartFacts;
|
|
86
87
|
var itemsById = new Map();
|
|
87
88
|
for (var _i = 0, arcs_1 = arcs; _i < arcs_1.length; _i++) {
|
|
88
89
|
var arc = arcs_1[_i];
|
|
@@ -91,6 +92,9 @@ function buildTemplateHierarchyFlat(params) {
|
|
|
91
92
|
var keyFrom = hrefToKey(hrefFrom);
|
|
92
93
|
var keyTo = hrefToKey(hrefTo);
|
|
93
94
|
var isPeriodStart = (_f = (_e = arc.preferredLabel) === null || _e === void 0 ? void 0 : _e.endsWith('periodStartLabel')) !== null && _f !== void 0 ? _f : false;
|
|
95
|
+
if (isPeriodStart && disablePeriodStartFacts) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
94
98
|
if (!itemsById.has(arc.from)) {
|
|
95
99
|
var periodFactsFrom = getPeriodFacts({ conceptKey: keyFrom, factsByConcept: factsByConcept, isPeriodStart: isPeriodStart });
|
|
96
100
|
var membersFrom = extractMemberFacts(periodFactsFrom, memberInclusionRule, allowedMembers);
|
|
@@ -102,7 +106,11 @@ function buildTemplateHierarchyFlat(params) {
|
|
|
102
106
|
parentKey: null,
|
|
103
107
|
weight: 1,
|
|
104
108
|
order: 0,
|
|
105
|
-
label: (_g = getBestLabel({
|
|
109
|
+
label: (_g = getBestLabel({
|
|
110
|
+
href: hrefFrom,
|
|
111
|
+
labelByHref: labelByHref,
|
|
112
|
+
preferredLabel: rowLabelType === 'preferredLabel' ? arc.preferredLabel : undefined,
|
|
113
|
+
})) !== null && _g !== void 0 ? _g : keyFrom,
|
|
106
114
|
isPeriodStart: isPeriodStart,
|
|
107
115
|
period: (primaryFactFrom === null || primaryFactFrom === void 0 ? void 0 : primaryFactFrom.period) || 0,
|
|
108
116
|
value: (_h = primaryFactFrom === null || primaryFactFrom === void 0 ? void 0 : primaryFactFrom.value) !== null && _h !== void 0 ? _h : null,
|
|
@@ -121,7 +129,11 @@ function buildTemplateHierarchyFlat(params) {
|
|
|
121
129
|
parentKey: arc.from ? hrefToKey(hrefFrom) : null,
|
|
122
130
|
weight: arc.weight || 1,
|
|
123
131
|
order: arc.order || 0,
|
|
124
|
-
label: (_k = getBestLabel({
|
|
132
|
+
label: (_k = getBestLabel({
|
|
133
|
+
href: hrefTo,
|
|
134
|
+
labelByHref: labelByHref,
|
|
135
|
+
preferredLabel: rowLabelType === 'preferredLabel' ? arc.preferredLabel : undefined,
|
|
136
|
+
})) !== null && _k !== void 0 ? _k : keyTo,
|
|
125
137
|
isPeriodStart: isPeriodStart,
|
|
126
138
|
period: (primaryFactTo === null || primaryFactTo === void 0 ? void 0 : primaryFactTo.period) || 0,
|
|
127
139
|
value: (_l = primaryFactTo === null || primaryFactTo === void 0 ? void 0 : primaryFactTo.value) !== null && _l !== void 0 ? _l : null,
|
|
@@ -139,6 +151,29 @@ function buildTemplateHierarchyFlat(params) {
|
|
|
139
151
|
}
|
|
140
152
|
return itemsById;
|
|
141
153
|
}
|
|
154
|
+
function deepNestByKeys(itemsById) {
|
|
155
|
+
var itemsWithChildrenByKey = new Map();
|
|
156
|
+
itemsById.forEach(function (item) {
|
|
157
|
+
var _a;
|
|
158
|
+
var currentItem = itemsWithChildrenByKey.get(item.key);
|
|
159
|
+
if (!currentItem && ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
160
|
+
itemsWithChildrenByKey.set(item.key, item);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
itemsById.forEach(function (item) {
|
|
164
|
+
var _a;
|
|
165
|
+
(_a = item.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child, i) {
|
|
166
|
+
var _a;
|
|
167
|
+
var currentItem = itemsWithChildrenByKey.get(child.key);
|
|
168
|
+
if (!((_a = child.children) === null || _a === void 0 ? void 0 : _a.length) && currentItem) {
|
|
169
|
+
item.children[i] = currentItem;
|
|
170
|
+
currentItem.parentId = item.id;
|
|
171
|
+
currentItem.parentKey = item.key;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
return itemsById;
|
|
176
|
+
}
|
|
142
177
|
function hierarchyToTree(itemsById) {
|
|
143
178
|
itemsById.forEach(function (item) {
|
|
144
179
|
var _a, _b;
|
|
@@ -160,7 +195,7 @@ function hierarchyToTree(itemsById) {
|
|
|
160
195
|
}
|
|
161
196
|
function buildReportTrees(params) {
|
|
162
197
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
163
|
-
var xbrlJson = params.xbrlJson, _h = params.memberInclusionRule, memberInclusionRule = _h === void 0 ? 'inReportsWherePresent' : _h;
|
|
198
|
+
var xbrlJson = params.xbrlJson, _h = params.memberInclusionRule, memberInclusionRule = _h === void 0 ? 'inReportsWherePresent' : _h, _j = params.rowLabelType, rowLabelType = _j === void 0 ? 'preferredLabel' : _j, _k = params.disablePeriodStartFacts, disablePeriodStartFacts = _k === void 0 ? false : _k;
|
|
164
199
|
var filingSummary = xbrlJson.filingSummary;
|
|
165
200
|
if (!filingSummary)
|
|
166
201
|
return [];
|
|
@@ -175,35 +210,92 @@ function buildReportTrees(params) {
|
|
|
175
210
|
var presentationLinks = (_g = (_f = (_e = xbrlJson.linkbasePresentation) === null || _e === void 0 ? void 0 : _e.xbrl) === null || _f === void 0 ? void 0 : _f.presentationLink) !== null && _g !== void 0 ? _g : [];
|
|
176
211
|
// Iterate through the xbrl reports and build tree structures
|
|
177
212
|
var reports = filingSummary.reports.map(function (report) {
|
|
178
|
-
var
|
|
179
|
-
var
|
|
180
|
-
var presentationLink = presentationLinks.find(function (link) { return link.role === report.role; });
|
|
181
|
-
var locatorByLabelCalc = new Map((_b = (_a = calculationLink === null || calculationLink === void 0 ? void 0 : calculationLink.loc) === null || _a === void 0 ? void 0 : _a.map(function (l) { return [l.label, l]; })) !== null && _b !== void 0 ? _b : []);
|
|
182
|
-
var locatorByLabelPres = new Map((_d = (_c = presentationLink === null || presentationLink === void 0 ? void 0 : presentationLink.loc) === null || _c === void 0 ? void 0 : _c.map(function (l) { return [l.label, l]; })) !== null && _d !== void 0 ? _d : []);
|
|
213
|
+
var calculationLinksReport = calculationLinks.filter(function (link) { return link.role === report.role; });
|
|
214
|
+
var presentationLinksReport = presentationLinks.filter(function (link) { return link.role === report.role; });
|
|
183
215
|
var allowedMembers = new Set();
|
|
184
|
-
|
|
185
|
-
var _a, _b, _c
|
|
186
|
-
|
|
187
|
-
|
|
216
|
+
presentationLinksReport.forEach(function (presentationLink) {
|
|
217
|
+
var _a, _b, _c;
|
|
218
|
+
var locatorByLabelPres = new Map((_b = (_a = presentationLink === null || presentationLink === void 0 ? void 0 : presentationLink.loc) === null || _a === void 0 ? void 0 : _a.map(function (l) { return [l.label, l]; })) !== null && _b !== void 0 ? _b : []);
|
|
219
|
+
(_c = presentationLink === null || presentationLink === void 0 ? void 0 : presentationLink.presentationArc) === null || _c === void 0 ? void 0 : _c.forEach(function (arc) {
|
|
220
|
+
var _a, _b, _c, _d;
|
|
221
|
+
allowedMembers.add(hrefToKey((_b = (_a = locatorByLabelPres.get(arc.to)) === null || _a === void 0 ? void 0 : _a.href) !== null && _b !== void 0 ? _b : ''));
|
|
222
|
+
allowedMembers.add(hrefToKey((_d = (_c = locatorByLabelPres.get(arc.from)) === null || _c === void 0 ? void 0 : _c.href) !== null && _d !== void 0 ? _d : ''));
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
var calculationTreeNodes = [];
|
|
226
|
+
var presentationTreeNodes = [];
|
|
227
|
+
var calculationHierarchiesFlat = [];
|
|
228
|
+
var presentationHierarchiesFlat = [];
|
|
229
|
+
calculationLinksReport.forEach(function (calculationLink) {
|
|
230
|
+
var _a, _b;
|
|
231
|
+
var locatorByLabelCalc = new Map((_b = (_a = calculationLink === null || calculationLink === void 0 ? void 0 : calculationLink.loc) === null || _a === void 0 ? void 0 : _a.map(function (l) { return [l.label, l]; })) !== null && _b !== void 0 ? _b : []);
|
|
232
|
+
var hierarchyCalc = buildTemplateHierarchyFlat({
|
|
233
|
+
arcs: (calculationLink === null || calculationLink === void 0 ? void 0 : calculationLink.calculationArc) || [],
|
|
234
|
+
labelByHref: labelByHref,
|
|
235
|
+
locByLabel: locatorByLabelCalc,
|
|
236
|
+
factsByConcept: factsByConcept,
|
|
237
|
+
allowedMembers: allowedMembers,
|
|
238
|
+
memberInclusionRule: memberInclusionRule,
|
|
239
|
+
rowLabelType: rowLabelType,
|
|
240
|
+
disablePeriodStartFacts: disablePeriodStartFacts,
|
|
241
|
+
});
|
|
242
|
+
calculationHierarchiesFlat.push(hierarchyCalc);
|
|
188
243
|
});
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
244
|
+
presentationLinksReport.forEach(function (presentationLink) {
|
|
245
|
+
var _a, _b;
|
|
246
|
+
var locatorByLabelPres = new Map((_b = (_a = presentationLink === null || presentationLink === void 0 ? void 0 : presentationLink.loc) === null || _a === void 0 ? void 0 : _a.map(function (l) { return [l.label, l]; })) !== null && _b !== void 0 ? _b : []);
|
|
247
|
+
var hierarchyPres = buildTemplateHierarchyFlat({
|
|
248
|
+
arcs: (presentationLink === null || presentationLink === void 0 ? void 0 : presentationLink.presentationArc) || [],
|
|
249
|
+
labelByHref: labelByHref,
|
|
250
|
+
locByLabel: locatorByLabelPres,
|
|
251
|
+
factsByConcept: factsByConcept,
|
|
252
|
+
allowedMembers: allowedMembers,
|
|
253
|
+
memberInclusionRule: memberInclusionRule,
|
|
254
|
+
rowLabelType: rowLabelType,
|
|
255
|
+
disablePeriodStartFacts: disablePeriodStartFacts,
|
|
256
|
+
});
|
|
257
|
+
presentationHierarchiesFlat.push(hierarchyPres);
|
|
196
258
|
});
|
|
197
|
-
var
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
locByLabel: locatorByLabelPres,
|
|
201
|
-
factsByConcept: factsByConcept,
|
|
202
|
-
allowedMembers: allowedMembers,
|
|
203
|
-
memberInclusionRule: memberInclusionRule,
|
|
259
|
+
var labelByKey = new Map();
|
|
260
|
+
presentationHierarchiesFlat.forEach(function (hierarchyPres) {
|
|
261
|
+
hierarchyPres.forEach(function (item) { return labelByKey.set(item.key, item.label); });
|
|
204
262
|
});
|
|
205
|
-
|
|
263
|
+
// Need to add member labels
|
|
264
|
+
var mapMembers = function (hierarchyFlat) {
|
|
265
|
+
hierarchyFlat.forEach(function (item) {
|
|
266
|
+
var _a;
|
|
267
|
+
if (!item.members)
|
|
268
|
+
return;
|
|
269
|
+
item.members = item.members.filter(function (m) { var _a; return (_a = m.segments) === null || _a === void 0 ? void 0 : _a.every(function (s) { return labelByKey.has(s.value); }); });
|
|
270
|
+
(_a = item.members) === null || _a === void 0 ? void 0 : _a.forEach(function (member) {
|
|
271
|
+
member.segments.forEach(function (segment) {
|
|
272
|
+
segment.label = labelByKey.get(segment.value) || segment.value;
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
presentationHierarchiesFlat.forEach(function (hierarchyPres) {
|
|
278
|
+
mapMembers(hierarchyPres);
|
|
279
|
+
presentationTreeNodes.push.apply(presentationTreeNodes, hierarchyToTree(hierarchyPres));
|
|
280
|
+
});
|
|
281
|
+
calculationHierarchiesFlat.forEach(function (hierarchyCalc) {
|
|
282
|
+
mapMembers(hierarchyCalc);
|
|
283
|
+
calculationTreeNodes.push.apply(calculationTreeNodes, hierarchyToTree(deepNestByKeys(hierarchyCalc)));
|
|
284
|
+
});
|
|
285
|
+
return __assign(__assign({}, report), { calculationTree: calculationTreeNodes, presentationTree: presentationTreeNodes });
|
|
206
286
|
});
|
|
207
287
|
return reports;
|
|
208
288
|
}
|
|
209
289
|
exports.buildReportTrees = buildReportTrees;
|
|
290
|
+
/**
|
|
291
|
+
* Traverse through a tree structure (depth first)
|
|
292
|
+
*/
|
|
293
|
+
function traverseTree(rootNodes, callback) {
|
|
294
|
+
var traverse = function (node, parentNode, depth) {
|
|
295
|
+
var _a;
|
|
296
|
+
callback({ node: node, parentNode: parentNode, depth: depth });
|
|
297
|
+
(_a = node.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) { return traverse(child, node, depth + 1); });
|
|
298
|
+
};
|
|
299
|
+
rootNodes.forEach(function (rootNode) { return traverse(rootNode, null, 0); });
|
|
300
|
+
}
|
|
301
|
+
exports.traverseTree = traverseTree;
|
package/package.json
CHANGED