@skmtc/core 0.33.0 → 0.34.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.
- package/esm/context/CoreContext.d.ts +8 -21
- package/esm/context/CoreContext.js +9 -22
- package/esm/context/GenerateContext.js +7 -7
- package/esm/context/ParseContext.d.ts +1 -1
- package/esm/context/ParseContext.js +2 -2
- package/esm/context/StackTrail.d.ts +30 -13
- package/esm/context/StackTrail.js +36 -14
- package/esm/helpers/ResultsLog.d.ts +19 -181
- package/esm/helpers/ResultsLog.js +46 -205
- package/package.json +1 -1
- package/script/context/CoreContext.d.ts +8 -21
- package/script/context/CoreContext.js +9 -22
- package/script/context/GenerateContext.js +7 -7
- package/script/context/ParseContext.d.ts +1 -1
- package/script/context/ParseContext.js +2 -2
- package/script/context/StackTrail.d.ts +30 -13
- package/script/context/StackTrail.js +36 -14
- package/script/helpers/ResultsLog.d.ts +19 -181
- package/script/helpers/ResultsLog.js +46 -208
|
@@ -1,200 +1,38 @@
|
|
|
1
|
+
import type { StackTrail } from '../context/StackTrail.js';
|
|
1
2
|
import type { ResultsItem, ResultType } from '../types/Results.js';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Records one result per stack trail and builds the `manifest.results` tree.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* intelligent result prioritization, ensuring that more severe results (errors)
|
|
8
|
-
* take precedence over less severe ones (success, warnings) when multiple results
|
|
9
|
-
* exist for the same path.
|
|
6
|
+
* When several results are captured at the same trail, the most severe one
|
|
7
|
+
* wins (see `resultRankings`).
|
|
10
8
|
*
|
|
11
|
-
*
|
|
12
|
-
* identifiers to organize results in a meaningful hierarchical structure that
|
|
13
|
-
* reflects the execution flow of the generation process.
|
|
14
|
-
*
|
|
15
|
-
* ## Key Features
|
|
16
|
-
*
|
|
17
|
-
* - **Result Prioritization**: Automatically prioritizes more severe results
|
|
18
|
-
* - **Hierarchical Organization**: Organizes results by stack trail paths
|
|
19
|
-
* - **Tree Structure**: Converts flat result logs into nested tree structures
|
|
20
|
-
* - **Duplicate Handling**: Prevents less severe results from overwriting more severe ones
|
|
21
|
-
*
|
|
22
|
-
* @example Basic usage
|
|
23
|
-
* ```typescript
|
|
24
|
-
* import { ResultsLog } from '@skmtc/core';
|
|
25
|
-
*
|
|
26
|
-
* const resultsLog = new ResultsLog();
|
|
27
|
-
*
|
|
28
|
-
* // Capture results from different parts of generation
|
|
29
|
-
* resultsLog.capture('models:User', 'success');
|
|
30
|
-
* resultsLog.capture('models:Product', 'error');
|
|
31
|
-
* resultsLog.capture('types:Status', 'success');
|
|
32
|
-
*
|
|
33
|
-
* // Convert to hierarchical structure
|
|
34
|
-
* const tree = resultsLog.toTree();
|
|
35
|
-
* console.log(tree);
|
|
36
|
-
* // {
|
|
37
|
-
* // models: {
|
|
38
|
-
* // User: 'success',
|
|
39
|
-
* // Product: 'error'
|
|
40
|
-
* // },
|
|
41
|
-
* // types: {
|
|
42
|
-
* // Status: 'success'
|
|
43
|
-
* // }
|
|
44
|
-
* // }
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* @example Result prioritization
|
|
9
|
+
* @example
|
|
48
10
|
* ```typescript
|
|
49
|
-
* const resultsLog = new ResultsLog()
|
|
11
|
+
* const resultsLog = new ResultsLog()
|
|
50
12
|
*
|
|
51
|
-
*
|
|
52
|
-
* resultsLog.capture('
|
|
13
|
+
* resultsLog.capture(new StackTrail(['generate', '/pets', 'get']), 'success')
|
|
14
|
+
* resultsLog.capture(new StackTrail(['generate', '/pets/{id}:archive', 'post']), 'error')
|
|
53
15
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* // Error takes precedence
|
|
58
|
-
* const tree = resultsLog.toTree();
|
|
59
|
-
* console.log(tree.api.createUser); // 'error'
|
|
60
|
-
*
|
|
61
|
-
* // But success won't overwrite error
|
|
62
|
-
* resultsLog.capture('api:createUser', 'success');
|
|
63
|
-
* console.log(resultsLog.toTree().api.createUser); // Still 'error'
|
|
64
|
-
* ```
|
|
65
|
-
*
|
|
66
|
-
* @example Complex nested paths
|
|
67
|
-
* ```typescript
|
|
68
|
-
* const resultsLog = new ResultsLog();
|
|
69
|
-
*
|
|
70
|
-
* resultsLog.capture('generation:models:User:properties:name', 'success');
|
|
71
|
-
* resultsLog.capture('generation:models:User:properties:email', 'warning');
|
|
72
|
-
* resultsLog.capture('generation:models:Product:validation', 'error');
|
|
73
|
-
* resultsLog.capture('generation:operations:createUser', 'success');
|
|
74
|
-
*
|
|
75
|
-
* const tree = resultsLog.toTree();
|
|
76
|
-
* console.log(tree);
|
|
77
|
-
* // {
|
|
78
|
-
* // generation: {
|
|
79
|
-
* // models: {
|
|
80
|
-
* // User: {
|
|
81
|
-
* // properties: {
|
|
82
|
-
* // name: 'success',
|
|
83
|
-
* // email: 'warning'
|
|
84
|
-
* // }
|
|
85
|
-
* // },
|
|
86
|
-
* // Product: {
|
|
87
|
-
* // validation: 'error'
|
|
88
|
-
* // }
|
|
89
|
-
* // },
|
|
90
|
-
* // operations: {
|
|
91
|
-
* // createUser: 'success'
|
|
92
|
-
* // }
|
|
93
|
-
* // }
|
|
94
|
-
* // }
|
|
95
|
-
* ```
|
|
96
|
-
*
|
|
97
|
-
* @example Integration with tracing
|
|
98
|
-
* ```typescript
|
|
99
|
-
* class TrackedGenerator {
|
|
100
|
-
* private resultsLog = new ResultsLog();
|
|
101
|
-
*
|
|
102
|
-
* generateModel(name: string, schema: OasSchema) {
|
|
103
|
-
* const stackPath = `models:${name}`;
|
|
104
|
-
*
|
|
105
|
-
* try {
|
|
106
|
-
* const model = this.processSchema(schema);
|
|
107
|
-
* this.resultsLog.capture(stackPath, 'success');
|
|
108
|
-
* return model;
|
|
109
|
-
* } catch (error) {
|
|
110
|
-
* this.resultsLog.capture(stackPath, 'error');
|
|
111
|
-
* throw error;
|
|
112
|
-
* }
|
|
113
|
-
* }
|
|
114
|
-
*
|
|
115
|
-
* generateOperation(operationId: string, operation: OasOperation) {
|
|
116
|
-
* const stackPath = `operations:${operationId}`;
|
|
117
|
-
*
|
|
118
|
-
* if (!this.supportsOperation(operation)) {
|
|
119
|
-
* this.resultsLog.capture(stackPath, 'notSupported');
|
|
120
|
-
* return null;
|
|
121
|
-
* }
|
|
122
|
-
*
|
|
123
|
-
* const result = this.processOperation(operation);
|
|
124
|
-
* this.resultsLog.capture(stackPath, 'success');
|
|
125
|
-
* return result;
|
|
126
|
-
* }
|
|
127
|
-
*
|
|
128
|
-
* getResults(): ResultsItem {
|
|
129
|
-
* return this.resultsLog.toTree();
|
|
130
|
-
* }
|
|
131
|
-
* }
|
|
16
|
+
* resultsLog.toTree()
|
|
17
|
+
* // { generate: { '/pets': { get: 'success' }, '/pets/{id}:archive': { post: 'error' } } }
|
|
132
18
|
* ```
|
|
133
19
|
*/
|
|
134
20
|
export declare class ResultsLog {
|
|
135
21
|
#private;
|
|
136
|
-
/**
|
|
137
|
-
* Creates a new ResultsLog instance.
|
|
138
|
-
*
|
|
139
|
-
* Initializes an empty results tracking system ready to capture
|
|
140
|
-
* generation outcomes from various parts of the pipeline.
|
|
141
|
-
*/
|
|
142
22
|
constructor();
|
|
143
23
|
/**
|
|
144
|
-
* Captures
|
|
145
|
-
*
|
|
146
|
-
* This method records the outcome of a generation operation, using intelligent
|
|
147
|
-
* prioritization to ensure that more severe results take precedence over less
|
|
148
|
-
* severe ones. For example, an error result will not be overwritten by a
|
|
149
|
-
* success result, but a success can be overwritten by an error.
|
|
150
|
-
*
|
|
151
|
-
* @param stackTrail - Colon-separated path identifying the operation location
|
|
152
|
-
* @param result - The result type to capture (error, warning, success, etc.)
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
* ```typescript
|
|
156
|
-
* const resultsLog = new ResultsLog();
|
|
24
|
+
* Captures `result` at `stackTrail`, unless a more severe result is
|
|
25
|
+
* already recorded there.
|
|
157
26
|
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* resultsLog.capture('models:User:validation', 'warning');
|
|
161
|
-
* resultsLog.capture('operations:createUser', 'error');
|
|
162
|
-
* ```
|
|
27
|
+
* Stores a copy of the frames: `StackTrail.trace` pops the live array
|
|
28
|
+
* after its callback returns.
|
|
163
29
|
*/
|
|
164
|
-
capture(stackTrail:
|
|
30
|
+
capture(stackTrail: StackTrail, result: ResultType): void;
|
|
165
31
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* operations. This makes it easier to understand and process results in
|
|
171
|
-
* a structured way.
|
|
172
|
-
*
|
|
173
|
-
* @returns Nested object structure representing the results hierarchy
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* ```typescript
|
|
177
|
-
* const resultsLog = new ResultsLog();
|
|
178
|
-
* resultsLog.capture('api:models:User', 'success');
|
|
179
|
-
* resultsLog.capture('api:operations:getUser', 'error');
|
|
180
|
-
* resultsLog.capture('types:Status', 'success');
|
|
181
|
-
*
|
|
182
|
-
* const tree = resultsLog.toTree();
|
|
183
|
-
* console.log(tree);
|
|
184
|
-
* // {
|
|
185
|
-
* // api: {
|
|
186
|
-
* // models: {
|
|
187
|
-
* // User: 'success'
|
|
188
|
-
* // },
|
|
189
|
-
* // operations: {
|
|
190
|
-
* // getUser: 'error'
|
|
191
|
-
* // }
|
|
192
|
-
* // },
|
|
193
|
-
* // types: {
|
|
194
|
-
* // Status: 'success'
|
|
195
|
-
* // }
|
|
196
|
-
* // }
|
|
197
|
-
* ```
|
|
32
|
+
* Nests the captured results by their frames, one object level per frame.
|
|
33
|
+
* Frames are used as own-property keys verbatim, so a frame such as
|
|
34
|
+
* `constructor`, `toString` or `0` is a key like any other. A result
|
|
35
|
+
* captured at the empty trail has no key and is left out.
|
|
198
36
|
*/
|
|
199
37
|
toTree(): ResultsItem;
|
|
200
38
|
}
|
|
@@ -10,222 +10,72 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
13
|
var _ResultsLog_instances, _ResultsLog_results, _ResultsLog_incomingResultIsWorse;
|
|
17
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
15
|
exports.ResultsLog = void 0;
|
|
19
|
-
const set_js_1 = __importDefault(require("lodash-es/set.js"));
|
|
20
16
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* `ResultsLog` tracks the outcomes of code generation operations, maintaining
|
|
24
|
-
* a hierarchical structure of results organized by stack trail paths. It implements
|
|
25
|
-
* intelligent result prioritization, ensuring that more severe results (errors)
|
|
26
|
-
* take precedence over less severe ones (success, warnings) when multiple results
|
|
27
|
-
* exist for the same path.
|
|
28
|
-
*
|
|
29
|
-
* The class is designed to work with the SKMTC tracing system, using stack trail
|
|
30
|
-
* identifiers to organize results in a meaningful hierarchical structure that
|
|
31
|
-
* reflects the execution flow of the generation process.
|
|
32
|
-
*
|
|
33
|
-
* ## Key Features
|
|
34
|
-
*
|
|
35
|
-
* - **Result Prioritization**: Automatically prioritizes more severe results
|
|
36
|
-
* - **Hierarchical Organization**: Organizes results by stack trail paths
|
|
37
|
-
* - **Tree Structure**: Converts flat result logs into nested tree structures
|
|
38
|
-
* - **Duplicate Handling**: Prevents less severe results from overwriting more severe ones
|
|
39
|
-
*
|
|
40
|
-
* @example Basic usage
|
|
41
|
-
* ```typescript
|
|
42
|
-
* import { ResultsLog } from '@skmtc/core';
|
|
43
|
-
*
|
|
44
|
-
* const resultsLog = new ResultsLog();
|
|
45
|
-
*
|
|
46
|
-
* // Capture results from different parts of generation
|
|
47
|
-
* resultsLog.capture('models:User', 'success');
|
|
48
|
-
* resultsLog.capture('models:Product', 'error');
|
|
49
|
-
* resultsLog.capture('types:Status', 'success');
|
|
50
|
-
*
|
|
51
|
-
* // Convert to hierarchical structure
|
|
52
|
-
* const tree = resultsLog.toTree();
|
|
53
|
-
* console.log(tree);
|
|
54
|
-
* // {
|
|
55
|
-
* // models: {
|
|
56
|
-
* // User: 'success',
|
|
57
|
-
* // Product: 'error'
|
|
58
|
-
* // },
|
|
59
|
-
* // types: {
|
|
60
|
-
* // Status: 'success'
|
|
61
|
-
* // }
|
|
62
|
-
* // }
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* @example Result prioritization
|
|
66
|
-
* ```typescript
|
|
67
|
-
* const resultsLog = new ResultsLog();
|
|
68
|
-
*
|
|
69
|
-
* // First capture a success
|
|
70
|
-
* resultsLog.capture('api:createUser', 'success');
|
|
71
|
-
*
|
|
72
|
-
* // Later encounter an error at the same path
|
|
73
|
-
* resultsLog.capture('api:createUser', 'error');
|
|
74
|
-
*
|
|
75
|
-
* // Error takes precedence
|
|
76
|
-
* const tree = resultsLog.toTree();
|
|
77
|
-
* console.log(tree.api.createUser); // 'error'
|
|
78
|
-
*
|
|
79
|
-
* // But success won't overwrite error
|
|
80
|
-
* resultsLog.capture('api:createUser', 'success');
|
|
81
|
-
* console.log(resultsLog.toTree().api.createUser); // Still 'error'
|
|
82
|
-
* ```
|
|
83
|
-
*
|
|
84
|
-
* @example Complex nested paths
|
|
85
|
-
* ```typescript
|
|
86
|
-
* const resultsLog = new ResultsLog();
|
|
87
|
-
*
|
|
88
|
-
* resultsLog.capture('generation:models:User:properties:name', 'success');
|
|
89
|
-
* resultsLog.capture('generation:models:User:properties:email', 'warning');
|
|
90
|
-
* resultsLog.capture('generation:models:Product:validation', 'error');
|
|
91
|
-
* resultsLog.capture('generation:operations:createUser', 'success');
|
|
17
|
+
* Records one result per stack trail and builds the `manifest.results` tree.
|
|
92
18
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* // {
|
|
96
|
-
* // generation: {
|
|
97
|
-
* // models: {
|
|
98
|
-
* // User: {
|
|
99
|
-
* // properties: {
|
|
100
|
-
* // name: 'success',
|
|
101
|
-
* // email: 'warning'
|
|
102
|
-
* // }
|
|
103
|
-
* // },
|
|
104
|
-
* // Product: {
|
|
105
|
-
* // validation: 'error'
|
|
106
|
-
* // }
|
|
107
|
-
* // },
|
|
108
|
-
* // operations: {
|
|
109
|
-
* // createUser: 'success'
|
|
110
|
-
* // }
|
|
111
|
-
* // }
|
|
112
|
-
* // }
|
|
113
|
-
* ```
|
|
19
|
+
* When several results are captured at the same trail, the most severe one
|
|
20
|
+
* wins (see `resultRankings`).
|
|
114
21
|
*
|
|
115
|
-
* @example
|
|
22
|
+
* @example
|
|
116
23
|
* ```typescript
|
|
117
|
-
*
|
|
118
|
-
* private resultsLog = new ResultsLog();
|
|
119
|
-
*
|
|
120
|
-
* generateModel(name: string, schema: OasSchema) {
|
|
121
|
-
* const stackPath = `models:${name}`;
|
|
122
|
-
*
|
|
123
|
-
* try {
|
|
124
|
-
* const model = this.processSchema(schema);
|
|
125
|
-
* this.resultsLog.capture(stackPath, 'success');
|
|
126
|
-
* return model;
|
|
127
|
-
* } catch (error) {
|
|
128
|
-
* this.resultsLog.capture(stackPath, 'error');
|
|
129
|
-
* throw error;
|
|
130
|
-
* }
|
|
131
|
-
* }
|
|
24
|
+
* const resultsLog = new ResultsLog()
|
|
132
25
|
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
26
|
+
* resultsLog.capture(new StackTrail(['generate', '/pets', 'get']), 'success')
|
|
27
|
+
* resultsLog.capture(new StackTrail(['generate', '/pets/{id}:archive', 'post']), 'error')
|
|
135
28
|
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* return null;
|
|
139
|
-
* }
|
|
140
|
-
*
|
|
141
|
-
* const result = this.processOperation(operation);
|
|
142
|
-
* this.resultsLog.capture(stackPath, 'success');
|
|
143
|
-
* return result;
|
|
144
|
-
* }
|
|
145
|
-
*
|
|
146
|
-
* getResults(): ResultsItem {
|
|
147
|
-
* return this.resultsLog.toTree();
|
|
148
|
-
* }
|
|
149
|
-
* }
|
|
29
|
+
* resultsLog.toTree()
|
|
30
|
+
* // { generate: { '/pets': { get: 'success' }, '/pets/{id}:archive': { post: 'error' } } }
|
|
150
31
|
* ```
|
|
151
32
|
*/
|
|
152
33
|
class ResultsLog {
|
|
153
|
-
/**
|
|
154
|
-
* Creates a new ResultsLog instance.
|
|
155
|
-
*
|
|
156
|
-
* Initializes an empty results tracking system ready to capture
|
|
157
|
-
* generation outcomes from various parts of the pipeline.
|
|
158
|
-
*/
|
|
159
34
|
constructor() {
|
|
160
35
|
_ResultsLog_instances.add(this);
|
|
36
|
+
/**
|
|
37
|
+
* Keyed by `StackTrail.toString()`. The key is one-to-one with the frames,
|
|
38
|
+
* except that `[]` and `['']` both give `''`.
|
|
39
|
+
*/
|
|
161
40
|
_ResultsLog_results.set(this, void 0);
|
|
162
|
-
__classPrivateFieldSet(this, _ResultsLog_results,
|
|
41
|
+
__classPrivateFieldSet(this, _ResultsLog_results, new Map(), "f");
|
|
163
42
|
}
|
|
164
43
|
/**
|
|
165
|
-
* Captures
|
|
166
|
-
*
|
|
167
|
-
* This method records the outcome of a generation operation, using intelligent
|
|
168
|
-
* prioritization to ensure that more severe results take precedence over less
|
|
169
|
-
* severe ones. For example, an error result will not be overwritten by a
|
|
170
|
-
* success result, but a success can be overwritten by an error.
|
|
171
|
-
*
|
|
172
|
-
* @param stackTrail - Colon-separated path identifying the operation location
|
|
173
|
-
* @param result - The result type to capture (error, warning, success, etc.)
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* ```typescript
|
|
177
|
-
* const resultsLog = new ResultsLog();
|
|
44
|
+
* Captures `result` at `stackTrail`, unless a more severe result is
|
|
45
|
+
* already recorded there.
|
|
178
46
|
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
* resultsLog.capture('models:User:validation', 'warning');
|
|
182
|
-
* resultsLog.capture('operations:createUser', 'error');
|
|
183
|
-
* ```
|
|
47
|
+
* Stores a copy of the frames: `StackTrail.trace` pops the live array
|
|
48
|
+
* after its callback returns.
|
|
184
49
|
*/
|
|
185
50
|
capture(stackTrail, result) {
|
|
186
|
-
|
|
187
|
-
|
|
51
|
+
const key = stackTrail.toString();
|
|
52
|
+
if (__classPrivateFieldGet(this, _ResultsLog_instances, "m", _ResultsLog_incomingResultIsWorse).call(this, __classPrivateFieldGet(this, _ResultsLog_results, "f").get(key)?.result, result)) {
|
|
53
|
+
__classPrivateFieldGet(this, _ResultsLog_results, "f").set(key, { frames: [...stackTrail.stackTrail], result });
|
|
188
54
|
}
|
|
189
55
|
}
|
|
190
56
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* operations. This makes it easier to understand and process results in
|
|
196
|
-
* a structured way.
|
|
197
|
-
*
|
|
198
|
-
* @returns Nested object structure representing the results hierarchy
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* ```typescript
|
|
202
|
-
* const resultsLog = new ResultsLog();
|
|
203
|
-
* resultsLog.capture('api:models:User', 'success');
|
|
204
|
-
* resultsLog.capture('api:operations:getUser', 'error');
|
|
205
|
-
* resultsLog.capture('types:Status', 'success');
|
|
206
|
-
*
|
|
207
|
-
* const tree = resultsLog.toTree();
|
|
208
|
-
* console.log(tree);
|
|
209
|
-
* // {
|
|
210
|
-
* // api: {
|
|
211
|
-
* // models: {
|
|
212
|
-
* // User: 'success'
|
|
213
|
-
* // },
|
|
214
|
-
* // operations: {
|
|
215
|
-
* // getUser: 'error'
|
|
216
|
-
* // }
|
|
217
|
-
* // },
|
|
218
|
-
* // types: {
|
|
219
|
-
* // Status: 'success'
|
|
220
|
-
* // }
|
|
221
|
-
* // }
|
|
222
|
-
* ```
|
|
57
|
+
* Nests the captured results by their frames, one object level per frame.
|
|
58
|
+
* Frames are used as own-property keys verbatim, so a frame such as
|
|
59
|
+
* `constructor`, `toString` or `0` is a key like any other. A result
|
|
60
|
+
* captured at the empty trail has no key and is left out.
|
|
223
61
|
*/
|
|
224
62
|
toTree() {
|
|
225
63
|
const tree = {};
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
|
|
64
|
+
__classPrivateFieldGet(this, _ResultsLog_results, "f").forEach(({ frames, result }) => {
|
|
65
|
+
const leafFrame = frames.at(-1);
|
|
66
|
+
if (leafFrame === undefined) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const parent = frames.slice(0, -1).reduce((node, frame) => {
|
|
70
|
+
const existing = Object.hasOwn(node, frame) ? node[frame] : undefined;
|
|
71
|
+
if (typeof existing === 'object' && existing !== null && !Array.isArray(existing)) {
|
|
72
|
+
return existing;
|
|
73
|
+
}
|
|
74
|
+
const child = {};
|
|
75
|
+
defineOwn(node, frame, child);
|
|
76
|
+
return child;
|
|
77
|
+
}, tree);
|
|
78
|
+
defineOwn(parent, leafFrame, result);
|
|
229
79
|
});
|
|
230
80
|
return tree;
|
|
231
81
|
}
|
|
@@ -237,25 +87,13 @@ _ResultsLog_results = new WeakMap(), _ResultsLog_instances = new WeakSet(), _Res
|
|
|
237
87
|
}
|
|
238
88
|
return resultRankings[current] < resultRankings[incoming];
|
|
239
89
|
};
|
|
90
|
+
/** Writes an own, enumerable property, even for keys such as `__proto__`. */
|
|
91
|
+
const defineOwn = (node, key, value) => {
|
|
92
|
+
Object.defineProperty(node, key, { value, enumerable: true, writable: true, configurable: true });
|
|
93
|
+
};
|
|
240
94
|
/**
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
* This mapping defines the severity hierarchy used by the ResultsLog to determine
|
|
244
|
-
* which results should take precedence when multiple results are captured for the
|
|
245
|
-
* same path. Higher numbers indicate higher severity/priority.
|
|
246
|
-
*
|
|
247
|
-
* The ranking system ensures that critical issues (errors) are never masked by
|
|
248
|
-
* less important results (success), while still allowing for proper escalation
|
|
249
|
-
* when more severe conditions are encountered.
|
|
250
|
-
*
|
|
251
|
-
* @example Ranking hierarchy (high to low priority)
|
|
252
|
-
* ```
|
|
253
|
-
* error (50) - Critical failures that prevent generation
|
|
254
|
-
* warning (40) - Issues that allow generation but need attention
|
|
255
|
-
* success (30) - Normal successful completion
|
|
256
|
-
* skipped (20) - Operations that were intentionally bypassed
|
|
257
|
-
* notSupported (10) - Features not yet implemented
|
|
258
|
-
* ```
|
|
95
|
+
* Severity of each result type. A higher number replaces a lower one
|
|
96
|
+
* captured at the same trail.
|
|
259
97
|
*/
|
|
260
98
|
const resultRankings = {
|
|
261
99
|
error: 50,
|