bridgelist 1.0.6 → 1.0.7
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/README.md +13 -2
- package/dist/analyzers/ast-analyzer.d.ts +1 -5
- package/dist/analyzers/ast-analyzer.js +10 -251
- package/dist/analyzers/ast-analyzer.js.map +1 -1
- package/dist/analyzers/method-analyzer.d.ts +27 -0
- package/dist/analyzers/method-analyzer.js +185 -0
- package/dist/analyzers/method-analyzer.js.map +1 -0
- package/dist/analyzers/property-access-analyzer.d.ts +23 -0
- package/dist/analyzers/property-access-analyzer.js +123 -0
- package/dist/analyzers/property-access-analyzer.js.map +1 -0
- package/dist/generators/html-generator.js +2 -3
- package/dist/generators/html-generator.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,18 @@ pnpm add bridgelist
|
|
|
33
33
|
``` typescript
|
|
34
34
|
import { GenerateMappingDocumentation, generateDocumentation } from 'bridgelist';
|
|
35
35
|
```
|
|
36
|
-
|
|
36
|
+
2. Extend tsconfig.json settings
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"compilerOptions": {
|
|
41
|
+
...
|
|
42
|
+
"experimentalDecorators": true,
|
|
43
|
+
...
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
3. Decorate your mapping methods:
|
|
37
48
|
``` typescript
|
|
38
49
|
class SimpleMapper {
|
|
39
50
|
@GenerateMappingDocumentation({
|
|
@@ -51,7 +62,7 @@ class SimpleMapper {
|
|
|
51
62
|
}
|
|
52
63
|
}
|
|
53
64
|
```
|
|
54
|
-
|
|
65
|
+
4. Generate the documentation:
|
|
55
66
|
``` typescript
|
|
56
67
|
// Scans the project and creates HTML documentation
|
|
57
68
|
generateDocumentation('./docs/api-mappings.html');
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
interface MappingRelation {
|
|
1
|
+
export interface MappingRelation {
|
|
2
2
|
sourceField: string;
|
|
3
3
|
targetField: string;
|
|
4
4
|
transformation?: string;
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
7
|
-
* analyzes a TypeScript method and extracts mapping relations
|
|
8
|
-
*/
|
|
9
6
|
export declare function analyzeMethod(filePath: string, className: string, methodName: string): MappingRelation[];
|
|
10
|
-
export {};
|
|
@@ -40,12 +40,18 @@ exports.analyzeMethod = analyzeMethod;
|
|
|
40
40
|
const typescript_1 = __importDefault(require("typescript"));
|
|
41
41
|
const fs = __importStar(require("fs"));
|
|
42
42
|
const path = __importStar(require("path"));
|
|
43
|
-
|
|
44
|
-
* analyzes a TypeScript method and extracts mapping relations
|
|
45
|
-
*/
|
|
43
|
+
const method_analyzer_1 = require("./method-analyzer");
|
|
46
44
|
function analyzeMethod(filePath, className, methodName) {
|
|
47
45
|
const sourceCode = fs.readFileSync(filePath, 'utf-8');
|
|
48
46
|
const sourceFile = typescript_1.default.createSourceFile(path.basename(filePath), sourceCode, typescript_1.default.ScriptTarget.Latest, true);
|
|
47
|
+
const methodNode = findMethodInAST(sourceFile, className, methodName);
|
|
48
|
+
if (methodNode) {
|
|
49
|
+
const analyzer = new method_analyzer_1.MethodAnalyzer(methodNode);
|
|
50
|
+
return analyzer.extractMappings();
|
|
51
|
+
}
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
function findMethodInAST(sourceFile, className, methodName) {
|
|
49
55
|
function findMethod(node) {
|
|
50
56
|
if (typescript_1.default.isMethodDeclaration(node) &&
|
|
51
57
|
node.name.getText() === methodName &&
|
|
@@ -63,253 +69,6 @@ function analyzeMethod(filePath, className, methodName) {
|
|
|
63
69
|
});
|
|
64
70
|
return result;
|
|
65
71
|
}
|
|
66
|
-
|
|
67
|
-
// Initialize results array
|
|
68
|
-
const results = [];
|
|
69
|
-
// Store all variable declarations with their initializers
|
|
70
|
-
const variableDeclarations = new Map();
|
|
71
|
-
// Identify all parameters of the method
|
|
72
|
-
const parameterNames = new Set();
|
|
73
|
-
if (methodNode.parameters) {
|
|
74
|
-
methodNode.parameters.forEach(param => {
|
|
75
|
-
if (param.name && typescript_1.default.isIdentifier(param.name)) {
|
|
76
|
-
parameterNames.add(param.name.getText());
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
// Keep track of decorator nodes to exclude them from analysis
|
|
81
|
-
const decoratorNodes = new Set();
|
|
82
|
-
if (methodNode.modifiers) {
|
|
83
|
-
methodNode.modifiers.forEach(modifier => {
|
|
84
|
-
if (typescript_1.default.isDecorator(modifier)) {
|
|
85
|
-
decoratorNodes.add(modifier);
|
|
86
|
-
// Also add the decorator's children to the exclusion set
|
|
87
|
-
function addAllChildren(node) {
|
|
88
|
-
decoratorNodes.add(node);
|
|
89
|
-
typescript_1.default.forEachChild(node, addAllChildren);
|
|
90
|
-
}
|
|
91
|
-
typescript_1.default.forEachChild(modifier, addAllChildren);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
// Check if a node is part of a decorator
|
|
96
|
-
function isPartOfDecorator(node) {
|
|
97
|
-
return decoratorNodes.has(node);
|
|
98
|
-
}
|
|
99
|
-
// First pass: collect all variable declarations
|
|
100
|
-
function collectVariables(node) {
|
|
101
|
-
// Skip decorator nodes
|
|
102
|
-
if (isPartOfDecorator(node)) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
// Handle variable declarations
|
|
106
|
-
if (typescript_1.default.isVariableDeclaration(node) && typescript_1.default.isIdentifier(node.name) && node.initializer) {
|
|
107
|
-
variableDeclarations.set(node.name.getText(), node.initializer);
|
|
108
|
-
}
|
|
109
|
-
typescript_1.default.forEachChild(node, collectVariables);
|
|
110
|
-
}
|
|
111
|
-
// Second pass: analyze object property assignments and mapping relations
|
|
112
|
-
function analyzePropertyAssignments(node) {
|
|
113
|
-
// Skip decorator nodes
|
|
114
|
-
if (isPartOfDecorator(node)) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
// Handle object literal properties
|
|
118
|
-
if (typescript_1.default.isPropertyAssignment(node) && node.parent && typescript_1.default.isObjectLiteralExpression(node.parent)) {
|
|
119
|
-
const targetField = node.name.getText();
|
|
120
|
-
const initializer = node.initializer;
|
|
121
|
-
// Find the variable that this object belongs to
|
|
122
|
-
let containerVar = findContainingVariable(node.parent);
|
|
123
|
-
// Process different types of initializers
|
|
124
|
-
if (typescript_1.default.isElementAccessExpression(initializer)) {
|
|
125
|
-
// Handle element access (e.g., obj[key])
|
|
126
|
-
processElementAccess(initializer, targetField, containerVar);
|
|
127
|
-
}
|
|
128
|
-
else if (typescript_1.default.isPropertyAccessExpression(initializer)) {
|
|
129
|
-
// Handle property access (e.g., obj.prop)
|
|
130
|
-
results.push({
|
|
131
|
-
targetField: containerVar ? `${containerVar}.${targetField}` : targetField,
|
|
132
|
-
sourceField: initializer.getText()
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
else if (typescript_1.default.isCallExpression(initializer)) {
|
|
136
|
-
// Handle function calls
|
|
137
|
-
const sourceFields = findPropertyAccesses(initializer);
|
|
138
|
-
results.push({
|
|
139
|
-
targetField: containerVar ? `${containerVar}.${targetField}` : targetField,
|
|
140
|
-
sourceField: sourceFields.length > 0 ? sourceFields.join(', ') : initializer.getText(),
|
|
141
|
-
transformation: initializer.expression.getText()
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
else if (typescript_1.default.isObjectLiteralExpression(initializer)) {
|
|
145
|
-
// For nested objects, we'll handle them recursively
|
|
146
|
-
// Child properties will be analyzed in subsequent recursive calls
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
// Handle other expressions or literals
|
|
150
|
-
const sourceFields = findPropertyAccesses(initializer);
|
|
151
|
-
if (sourceFields.length > 0) {
|
|
152
|
-
results.push({
|
|
153
|
-
targetField: containerVar ? `${containerVar}.${targetField}` : targetField,
|
|
154
|
-
sourceField: sourceFields.join(', '),
|
|
155
|
-
transformation: "Expression"
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
// Constant values
|
|
160
|
-
results.push({
|
|
161
|
-
targetField: containerVar ? `${containerVar}.${targetField}` : targetField,
|
|
162
|
-
sourceField: "Constant value",
|
|
163
|
-
transformation: initializer.getText()
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
typescript_1.default.forEachChild(node, analyzePropertyAssignments);
|
|
169
|
-
}
|
|
170
|
-
// Helper to find the variable an object belongs to
|
|
171
|
-
function findContainingVariable(objectLiteral) {
|
|
172
|
-
let result;
|
|
173
|
-
variableDeclarations.forEach((value, key) => {
|
|
174
|
-
if (value === objectLiteral) {
|
|
175
|
-
result = key;
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
return result;
|
|
179
|
-
}
|
|
180
|
-
// Helper to process element access expressions
|
|
181
|
-
function processElementAccess(expr, targetField, containerVar) {
|
|
182
|
-
const objExpr = expr.expression;
|
|
183
|
-
if (typescript_1.default.isPropertyAccessExpression(objExpr) &&
|
|
184
|
-
objExpr.expression &&
|
|
185
|
-
typescript_1.default.isIdentifier(objExpr.expression) &&
|
|
186
|
-
parameterNames.has(objExpr.expression.getText())) {
|
|
187
|
-
// Handle dynamic property access with string concatenation
|
|
188
|
-
if (typescript_1.default.isBinaryExpression(expr.argumentExpression) &&
|
|
189
|
-
expr.argumentExpression.operatorToken.kind === typescript_1.default.SyntaxKind.PlusToken &&
|
|
190
|
-
typescript_1.default.isPropertyAccessExpression(expr.argumentExpression.left) &&
|
|
191
|
-
typescript_1.default.isStringLiteral(expr.argumentExpression.right)) {
|
|
192
|
-
const prefix = expr.argumentExpression.left.getText();
|
|
193
|
-
const suffix = expr.argumentExpression.right.text;
|
|
194
|
-
results.push({
|
|
195
|
-
targetField: containerVar ? `${containerVar}.${targetField}` : targetField,
|
|
196
|
-
sourceField: `Dynamic access: ${objExpr.getText()}[${prefix} + '${suffix}']`,
|
|
197
|
-
transformation: "Dynamic property mapping"
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
// Handle direct string literal access
|
|
201
|
-
else if (typescript_1.default.isStringLiteral(expr.argumentExpression)) {
|
|
202
|
-
results.push({
|
|
203
|
-
targetField: containerVar ? `${containerVar}.${targetField}` : targetField,
|
|
204
|
-
sourceField: `${objExpr.getText()}['${expr.argumentExpression.text}']`
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
// Handle other dynamic access
|
|
208
|
-
else {
|
|
209
|
-
results.push({
|
|
210
|
-
targetField: containerVar ? `${containerVar}.${targetField}` : targetField,
|
|
211
|
-
sourceField: `Dynamic access: ${expr.getText()}`,
|
|
212
|
-
transformation: "Dynamic property mapping"
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
// Find all property accesses in an expression
|
|
218
|
-
function findPropertyAccesses(node) {
|
|
219
|
-
const sourceFields = new Set();
|
|
220
|
-
const visitedNodes = new Set();
|
|
221
|
-
// Track most specific property paths
|
|
222
|
-
const allPropertyPaths = new Set();
|
|
223
|
-
const partialPropertyPaths = new Set();
|
|
224
|
-
function visit(n) {
|
|
225
|
-
// Avoid duplicate processing
|
|
226
|
-
if (visitedNodes.has(n)) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
visitedNodes.add(n);
|
|
230
|
-
// Skip decorator nodes
|
|
231
|
-
if (isPartOfDecorator(n)) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
// Handle nested PropertyAccessExpression
|
|
235
|
-
if (typescript_1.default.isPropertyAccessExpression(n)) {
|
|
236
|
-
// For nested property accesses, we want the full chain
|
|
237
|
-
// e.g., hubspotContact.properties.fieldName
|
|
238
|
-
let current = n;
|
|
239
|
-
let isFromParam = false;
|
|
240
|
-
// Traverse to the base of the expression
|
|
241
|
-
while (typescript_1.default.isPropertyAccessExpression(current.expression)) {
|
|
242
|
-
// Add each partial path to the set of partial paths
|
|
243
|
-
partialPropertyPaths.add(current.expression.getText());
|
|
244
|
-
current = current.expression;
|
|
245
|
-
}
|
|
246
|
-
// Check if the base is a parameter
|
|
247
|
-
if (typescript_1.default.isIdentifier(current.expression) &&
|
|
248
|
-
parameterNames.has(current.expression.getText())) {
|
|
249
|
-
isFromParam = true;
|
|
250
|
-
}
|
|
251
|
-
// If this is a property access based on a method parameter, add it
|
|
252
|
-
if (isFromParam) {
|
|
253
|
-
allPropertyPaths.add(n.getText());
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
// Handle ElementAccessExpression (e.g., obj['property'] or obj[variable])
|
|
257
|
-
else if (typescript_1.default.isElementAccessExpression(n) &&
|
|
258
|
-
n.expression &&
|
|
259
|
-
typescript_1.default.isPropertyAccessExpression(n.expression)) {
|
|
260
|
-
let current = n.expression;
|
|
261
|
-
let isFromParam = false;
|
|
262
|
-
// Traverse to the base of the expression and track partial paths
|
|
263
|
-
while (typescript_1.default.isPropertyAccessExpression(current.expression)) {
|
|
264
|
-
partialPropertyPaths.add(current.expression.getText());
|
|
265
|
-
current = current.expression;
|
|
266
|
-
}
|
|
267
|
-
// Check if the base is a parameter
|
|
268
|
-
if (typescript_1.default.isIdentifier(current.expression) &&
|
|
269
|
-
parameterNames.has(current.expression.getText())) {
|
|
270
|
-
isFromParam = true;
|
|
271
|
-
}
|
|
272
|
-
// If this is an element access based on a method parameter
|
|
273
|
-
if (isFromParam) {
|
|
274
|
-
if (typescript_1.default.isStringLiteral(n.argumentExpression)) {
|
|
275
|
-
allPropertyPaths.add(`${n.expression.getText()}['${n.argumentExpression.text}']`);
|
|
276
|
-
}
|
|
277
|
-
else if (typescript_1.default.isBinaryExpression(n.argumentExpression) &&
|
|
278
|
-
n.argumentExpression.operatorToken.kind === typescript_1.default.SyntaxKind.PlusToken &&
|
|
279
|
-
typescript_1.default.isPropertyAccessExpression(n.argumentExpression.left) &&
|
|
280
|
-
typescript_1.default.isStringLiteral(n.argumentExpression.right)) {
|
|
281
|
-
const prefix = n.argumentExpression.left.getText();
|
|
282
|
-
const suffix = n.argumentExpression.right.text;
|
|
283
|
-
allPropertyPaths.add(`${n.expression.getText()}[${prefix} + '${suffix}']`);
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
allPropertyPaths.add(n.getText());
|
|
287
|
-
}
|
|
288
|
-
// Add the base of the element access as a partial path
|
|
289
|
-
partialPropertyPaths.add(n.expression.getText());
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
typescript_1.default.forEachChild(n, visit);
|
|
293
|
-
}
|
|
294
|
-
visit(node);
|
|
295
|
-
// Only add property paths that are not partial paths
|
|
296
|
-
allPropertyPaths.forEach(path => {
|
|
297
|
-
if (!partialPropertyPaths.has(path)) {
|
|
298
|
-
sourceFields.add(path);
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
return Array.from(sourceFields);
|
|
302
|
-
}
|
|
303
|
-
// Run our analysis passes
|
|
304
|
-
collectVariables(methodNode);
|
|
305
|
-
analyzePropertyAssignments(methodNode);
|
|
306
|
-
return results;
|
|
307
|
-
}
|
|
308
|
-
// find method in AST and extract mappings
|
|
309
|
-
const methodNode = findMethod(sourceFile);
|
|
310
|
-
if (methodNode) {
|
|
311
|
-
return extractMappings(methodNode);
|
|
312
|
-
}
|
|
313
|
-
return [];
|
|
72
|
+
return findMethod(sourceFile);
|
|
314
73
|
}
|
|
315
74
|
//# sourceMappingURL=ast-analyzer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-analyzer.js","sourceRoot":"","sources":["../../src/analyzers/ast-analyzer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ast-analyzer.js","sourceRoot":"","sources":["../../src/analyzers/ast-analyzer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,sCAgBC;AA5BD,4DAA4B;AAC5B,uCAAyB;AACzB,2CAA6B;AAC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CAAC;IAED,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { MappingRelation } from './ast-analyzer';
|
|
3
|
+
export declare class MethodAnalyzer {
|
|
4
|
+
private readonly methodNode;
|
|
5
|
+
private results;
|
|
6
|
+
private variableDeclarations;
|
|
7
|
+
private parameterNames;
|
|
8
|
+
private decoratorNodes;
|
|
9
|
+
constructor(methodNode: ts.MethodDeclaration);
|
|
10
|
+
extractMappings(): MappingRelation[];
|
|
11
|
+
private initializeParameters;
|
|
12
|
+
private initializeDecorators;
|
|
13
|
+
private addAllChildrenToDecoratorSet;
|
|
14
|
+
private isPartOfDecorator;
|
|
15
|
+
private collectVariables;
|
|
16
|
+
private analyzePropertyAssignments;
|
|
17
|
+
private processPropertyAssignment;
|
|
18
|
+
private processPropertyAccess;
|
|
19
|
+
private processCallExpression;
|
|
20
|
+
private processOtherExpression;
|
|
21
|
+
private findContainingVariable;
|
|
22
|
+
private processElementAccess;
|
|
23
|
+
private processDynamicConcatenation;
|
|
24
|
+
private processStringLiteralAccess;
|
|
25
|
+
private processOtherDynamicAccess;
|
|
26
|
+
private findPropertyAccesses;
|
|
27
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MethodAnalyzer = void 0;
|
|
7
|
+
const property_access_analyzer_1 = require("./property-access-analyzer");
|
|
8
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
9
|
+
class MethodAnalyzer {
|
|
10
|
+
constructor(methodNode) {
|
|
11
|
+
this.results = [];
|
|
12
|
+
this.variableDeclarations = new Map();
|
|
13
|
+
this.parameterNames = new Set();
|
|
14
|
+
this.decoratorNodes = new Set();
|
|
15
|
+
this.methodNode = methodNode;
|
|
16
|
+
this.initializeParameters();
|
|
17
|
+
this.initializeDecorators();
|
|
18
|
+
}
|
|
19
|
+
extractMappings() {
|
|
20
|
+
this.collectVariables(this.methodNode);
|
|
21
|
+
this.analyzePropertyAssignments(this.methodNode);
|
|
22
|
+
return this.results;
|
|
23
|
+
}
|
|
24
|
+
initializeParameters() {
|
|
25
|
+
if (this.methodNode.parameters) {
|
|
26
|
+
this.methodNode.parameters.forEach(param => {
|
|
27
|
+
if (param.name && typescript_1.default.isIdentifier(param.name)) {
|
|
28
|
+
this.parameterNames.add(param.name.getText());
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
initializeDecorators() {
|
|
34
|
+
if (this.methodNode.modifiers) {
|
|
35
|
+
this.methodNode.modifiers.forEach(modifier => {
|
|
36
|
+
if (typescript_1.default.isDecorator(modifier)) {
|
|
37
|
+
this.decoratorNodes.add(modifier);
|
|
38
|
+
this.addAllChildrenToDecoratorSet(modifier);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
addAllChildrenToDecoratorSet(node) {
|
|
44
|
+
this.decoratorNodes.add(node);
|
|
45
|
+
typescript_1.default.forEachChild(node, child => this.addAllChildrenToDecoratorSet(child));
|
|
46
|
+
}
|
|
47
|
+
isPartOfDecorator(node) {
|
|
48
|
+
return this.decoratorNodes.has(node);
|
|
49
|
+
}
|
|
50
|
+
collectVariables(node) {
|
|
51
|
+
if (this.isPartOfDecorator(node)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (typescript_1.default.isVariableDeclaration(node) && typescript_1.default.isIdentifier(node.name) && node.initializer) {
|
|
55
|
+
this.variableDeclarations.set(node.name.getText(), node.initializer);
|
|
56
|
+
}
|
|
57
|
+
typescript_1.default.forEachChild(node, child => this.collectVariables(child));
|
|
58
|
+
}
|
|
59
|
+
// PropertyAssignment = ObjectProperty in AST
|
|
60
|
+
analyzePropertyAssignments(node) {
|
|
61
|
+
if (this.isPartOfDecorator(node)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
// ObjectLiteralExpression = ObjectExpression in AST
|
|
65
|
+
if (typescript_1.default.isPropertyAssignment(node) && node.parent && typescript_1.default.isObjectLiteralExpression(node.parent)) {
|
|
66
|
+
this.processPropertyAssignment(node);
|
|
67
|
+
}
|
|
68
|
+
typescript_1.default.forEachChild(node, child => this.analyzePropertyAssignments(child));
|
|
69
|
+
}
|
|
70
|
+
processPropertyAssignment(node) {
|
|
71
|
+
const targetField = node.name.getText();
|
|
72
|
+
const initializer = node.initializer;
|
|
73
|
+
const containerVar = this.findContainingVariable(node.parent);
|
|
74
|
+
if (typescript_1.default.isElementAccessExpression(initializer)) {
|
|
75
|
+
this.processElementAccess(initializer, targetField, containerVar);
|
|
76
|
+
}
|
|
77
|
+
else if (typescript_1.default.isPropertyAccessExpression(initializer)) {
|
|
78
|
+
this.processPropertyAccess(initializer, targetField, containerVar);
|
|
79
|
+
}
|
|
80
|
+
else if (typescript_1.default.isCallExpression(initializer)) {
|
|
81
|
+
this.processCallExpression(initializer, targetField, containerVar);
|
|
82
|
+
}
|
|
83
|
+
else if (typescript_1.default.isObjectLiteralExpression(initializer)) {
|
|
84
|
+
// For nested objects, we'll handle them recursively
|
|
85
|
+
// Child properties will be analyzed in subsequent recursive calls
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this.processOtherExpression(initializer, targetField, containerVar);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
processPropertyAccess(initializer, targetField, containerVar) {
|
|
92
|
+
this.results.push({
|
|
93
|
+
targetField: containerVar ? `${containerVar}.${targetField}` : targetField,
|
|
94
|
+
sourceField: initializer.getText()
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
processCallExpression(initializer, targetField, containerVar) {
|
|
98
|
+
const sourceFields = this.findPropertyAccesses(initializer);
|
|
99
|
+
this.results.push({
|
|
100
|
+
targetField: containerVar ? `${containerVar}.${targetField}` : targetField,
|
|
101
|
+
sourceField: sourceFields.length > 0 ? sourceFields.join(', ') : initializer.getText(),
|
|
102
|
+
transformation: initializer.expression.getText()
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
processOtherExpression(initializer, targetField, containerVar) {
|
|
106
|
+
const sourceFields = this.findPropertyAccesses(initializer);
|
|
107
|
+
if (sourceFields.length > 0) {
|
|
108
|
+
this.results.push({
|
|
109
|
+
targetField: containerVar ? `${containerVar}.${targetField}` : targetField,
|
|
110
|
+
sourceField: sourceFields.join(', '),
|
|
111
|
+
transformation: "Expression"
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// Constant values
|
|
116
|
+
this.results.push({
|
|
117
|
+
targetField: containerVar ? `${containerVar}.${targetField}` : targetField,
|
|
118
|
+
sourceField: "Constant value",
|
|
119
|
+
transformation: initializer.getText()
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
findContainingVariable(objectLiteral) {
|
|
124
|
+
let result;
|
|
125
|
+
this.variableDeclarations.forEach((value, key) => {
|
|
126
|
+
if (value === objectLiteral) {
|
|
127
|
+
result = key;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
processElementAccess(expr, targetField, containerVar) {
|
|
133
|
+
const objExpr = expr.expression;
|
|
134
|
+
if (typescript_1.default.isPropertyAccessExpression(objExpr) &&
|
|
135
|
+
objExpr.expression &&
|
|
136
|
+
typescript_1.default.isIdentifier(objExpr.expression) &&
|
|
137
|
+
this.parameterNames.has(objExpr.expression.getText())) {
|
|
138
|
+
// Handle dynamic property access with string concatenation
|
|
139
|
+
if (typescript_1.default.isBinaryExpression(expr.argumentExpression) &&
|
|
140
|
+
expr.argumentExpression.operatorToken.kind === typescript_1.default.SyntaxKind.PlusToken &&
|
|
141
|
+
typescript_1.default.isPropertyAccessExpression(expr.argumentExpression.left) &&
|
|
142
|
+
typescript_1.default.isStringLiteral(expr.argumentExpression.right)) {
|
|
143
|
+
this.processDynamicConcatenation(expr, objExpr, targetField, containerVar);
|
|
144
|
+
}
|
|
145
|
+
// Handle direct string literal access
|
|
146
|
+
else if (typescript_1.default.isStringLiteral(expr.argumentExpression)) {
|
|
147
|
+
this.processStringLiteralAccess(expr, objExpr, targetField, containerVar);
|
|
148
|
+
}
|
|
149
|
+
// Handle other dynamic access
|
|
150
|
+
else {
|
|
151
|
+
this.processOtherDynamicAccess(expr, targetField, containerVar);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
processDynamicConcatenation(expr, objExpr, targetField, containerVar) {
|
|
156
|
+
const binaryExpr = expr.argumentExpression;
|
|
157
|
+
const prefix = binaryExpr.left.getText();
|
|
158
|
+
const suffix = binaryExpr.right.text;
|
|
159
|
+
this.results.push({
|
|
160
|
+
targetField: containerVar ? `${containerVar}.${targetField}` : targetField,
|
|
161
|
+
sourceField: `Dynamic access: ${objExpr.getText()}[${prefix} + '${suffix}']`,
|
|
162
|
+
transformation: "Dynamic property mapping"
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
processStringLiteralAccess(expr, objExpr, targetField, containerVar) {
|
|
166
|
+
const stringLiteral = expr.argumentExpression;
|
|
167
|
+
this.results.push({
|
|
168
|
+
targetField: containerVar ? `${containerVar}.${targetField}` : targetField,
|
|
169
|
+
sourceField: `${objExpr.getText()}['${stringLiteral.text}']`
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
processOtherDynamicAccess(expr, targetField, containerVar) {
|
|
173
|
+
this.results.push({
|
|
174
|
+
targetField: containerVar ? `${containerVar}.${targetField}` : targetField,
|
|
175
|
+
sourceField: `Dynamic access: ${expr.getText()}`,
|
|
176
|
+
transformation: "Dynamic property mapping"
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
findPropertyAccesses(node) {
|
|
180
|
+
const analyzer = new property_access_analyzer_1.PropertyAccessAnalyzer(this.parameterNames, this.decoratorNodes);
|
|
181
|
+
return analyzer.findPropertyAccesses(node);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.MethodAnalyzer = MethodAnalyzer;
|
|
185
|
+
//# sourceMappingURL=method-analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"method-analyzer.js","sourceRoot":"","sources":["../../src/analyzers/method-analyzer.ts"],"names":[],"mappings":";;;;;;AAAA,yEAAoE;AACpE,4DAA4B;AAG5B,MAAa,cAAc;IAOvB,YAAY,UAAgC;QALpC,YAAO,GAAsB,EAAE,CAAC;QAChC,yBAAoB,GAAG,IAAI,GAAG,EAAmB,CAAC;QAClD,mBAAc,GAAG,IAAI,GAAG,EAAU,CAAC;QACnC,mBAAc,GAAG,IAAI,GAAG,EAAW,CAAC;QAGxC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC5B,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAChC,CAAC;IAEM,eAAe;QAClB,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACvC,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAEO,oBAAoB;QACxB,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;YAC7B,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACvC,IAAI,KAAK,CAAC,IAAI,IAAI,oBAAE,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC5C,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;gBAClD,C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AW,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW;YAC1E,WAAW,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,KAAK,aAAa,CAAC,IAAI,IAAI;SAC/D,CAAC,CAAC;IACP,CAAC;IAEO,yBAAyB,CAAC,IAAgC,EAAE,WAAmB,EAAE,YAAqB;QAC1G,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YACd,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW;YAC1E,WAAW,EAAE,mBAAmB,IAAI,CAAC,OAAO,EAAE,EAAE;YAChD,cAAc,EAAE,0BAA0B;SAC7C,CAAC,CAAC;IACP,CAAC;IAEO,oBAAoB,CAAC,IAAa;QACtC,MAAM,QAAQ,GAAG,IAAI,iDAAsB,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACtF,OAAO,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;CACJ;AApND,wCAoNC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
/**
|
|
3
|
+
* Analyzes property accesses in TypeScript expressions
|
|
4
|
+
*/
|
|
5
|
+
export declare class PropertyAccessAnalyzer {
|
|
6
|
+
private sourceFields;
|
|
7
|
+
private visitedNodes;
|
|
8
|
+
private allPropertyPaths;
|
|
9
|
+
private partialPropertyPaths;
|
|
10
|
+
private parameterNames;
|
|
11
|
+
private decoratorNodes;
|
|
12
|
+
constructor(parameterNames: Set<string>, decoratorNodes: Set<ts.Node>);
|
|
13
|
+
findPropertyAccesses(node: ts.Node): string[];
|
|
14
|
+
private visit;
|
|
15
|
+
private isPartOfDecorator;
|
|
16
|
+
private isRelevantElementAccessExpression;
|
|
17
|
+
private processPropertyAccessExpression;
|
|
18
|
+
private processElementAccessExpression;
|
|
19
|
+
private processArgumentExpression;
|
|
20
|
+
private isConcatenationExpression;
|
|
21
|
+
private processStringLiteralArgument;
|
|
22
|
+
private processConcatenationArgument;
|
|
23
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PropertyAccessAnalyzer = void 0;
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
+
/**
|
|
9
|
+
* Analyzes property accesses in TypeScript expressions
|
|
10
|
+
*/
|
|
11
|
+
class PropertyAccessAnalyzer {
|
|
12
|
+
constructor(parameterNames, decoratorNodes) {
|
|
13
|
+
this.sourceFields = new Set();
|
|
14
|
+
this.visitedNodes = new Set();
|
|
15
|
+
this.allPropertyPaths = new Set();
|
|
16
|
+
this.partialPropertyPaths = new Set();
|
|
17
|
+
this.parameterNames = parameterNames;
|
|
18
|
+
this.decoratorNodes = decoratorNodes;
|
|
19
|
+
}
|
|
20
|
+
findPropertyAccesses(node) {
|
|
21
|
+
this.visit(node);
|
|
22
|
+
// Only add property paths that are not partial paths
|
|
23
|
+
this.allPropertyPaths.forEach(path => {
|
|
24
|
+
if (!this.partialPropertyPaths.has(path)) {
|
|
25
|
+
this.sourceFields.add(path);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return Array.from(this.sourceFields);
|
|
29
|
+
}
|
|
30
|
+
visit(node) {
|
|
31
|
+
// Avoid duplicate processing
|
|
32
|
+
if (this.visitedNodes.has(node)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
this.visitedNodes.add(node);
|
|
36
|
+
if (this.isPartOfDecorator(node)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (typescript_1.default.isPropertyAccessExpression(node)) {
|
|
40
|
+
this.processPropertyAccessExpression(node);
|
|
41
|
+
}
|
|
42
|
+
else if (this.isRelevantElementAccessExpression(node)) {
|
|
43
|
+
this.processElementAccessExpression(node);
|
|
44
|
+
}
|
|
45
|
+
typescript_1.default.forEachChild(node, child => this.visit(child));
|
|
46
|
+
}
|
|
47
|
+
isPartOfDecorator(node) {
|
|
48
|
+
return this.decoratorNodes.has(node);
|
|
49
|
+
}
|
|
50
|
+
isRelevantElementAccessExpression(node) {
|
|
51
|
+
return typescript_1.default.isElementAccessExpression(node) &&
|
|
52
|
+
node.expression &&
|
|
53
|
+
typescript_1.default.isPropertyAccessExpression(node.expression);
|
|
54
|
+
}
|
|
55
|
+
processPropertyAccessExpression(node) {
|
|
56
|
+
let current = node;
|
|
57
|
+
let isFromParam = false;
|
|
58
|
+
// Traverse to the base of the expression
|
|
59
|
+
while (typescript_1.default.isPropertyAccessExpression(current.expression)) {
|
|
60
|
+
// Add each partial path to the set of partial paths
|
|
61
|
+
this.partialPropertyPaths.add(current.expression.getText());
|
|
62
|
+
current = current.expression;
|
|
63
|
+
}
|
|
64
|
+
// Check if the base is a parameter
|
|
65
|
+
if (typescript_1.default.isIdentifier(current.expression) &&
|
|
66
|
+
this.parameterNames.has(current.expression.getText())) {
|
|
67
|
+
isFromParam = true;
|
|
68
|
+
}
|
|
69
|
+
// If this is a property access based on a method parameter, add it
|
|
70
|
+
if (isFromParam) {
|
|
71
|
+
this.allPropertyPaths.add(node.getText());
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
processElementAccessExpression(node) {
|
|
75
|
+
let current = node.expression;
|
|
76
|
+
let isFromParam = false;
|
|
77
|
+
// Traverse to the base of the expression and track partial paths
|
|
78
|
+
while (typescript_1.default.isPropertyAccessExpression(current.expression)) {
|
|
79
|
+
this.partialPropertyPaths.add(current.expression.getText());
|
|
80
|
+
current = current.expression;
|
|
81
|
+
}
|
|
82
|
+
// Check if the base is a parameter
|
|
83
|
+
if (typescript_1.default.isIdentifier(current.expression) &&
|
|
84
|
+
this.parameterNames.has(current.expression.getText())) {
|
|
85
|
+
isFromParam = true;
|
|
86
|
+
}
|
|
87
|
+
// If this is an element access based on a method parameter
|
|
88
|
+
if (isFromParam) {
|
|
89
|
+
this.processArgumentExpression(node);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
processArgumentExpression(node) {
|
|
93
|
+
if (typescript_1.default.isStringLiteral(node.argumentExpression)) {
|
|
94
|
+
this.processStringLiteralArgument(node);
|
|
95
|
+
}
|
|
96
|
+
else if (this.isConcatenationExpression(node.argumentExpression)) {
|
|
97
|
+
this.processConcatenationArgument(node);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
this.allPropertyPaths.add(node.getText());
|
|
101
|
+
}
|
|
102
|
+
// Add the base of the element access as a partial path
|
|
103
|
+
this.partialPropertyPaths.add(node.expression.getText());
|
|
104
|
+
}
|
|
105
|
+
isConcatenationExpression(expr) {
|
|
106
|
+
return typescript_1.default.isBinaryExpression(expr) &&
|
|
107
|
+
expr.operatorToken.kind === typescript_1.default.SyntaxKind.PlusToken &&
|
|
108
|
+
typescript_1.default.isPropertyAccessExpression(expr.left) &&
|
|
109
|
+
typescript_1.default.isStringLiteral(expr.right);
|
|
110
|
+
}
|
|
111
|
+
processStringLiteralArgument(node) {
|
|
112
|
+
const stringLiteral = node.argumentExpression;
|
|
113
|
+
this.allPropertyPaths.add(`${node.expression.getText()}['${stringLiteral.text}']`);
|
|
114
|
+
}
|
|
115
|
+
processConcatenationArgument(node) {
|
|
116
|
+
const binaryExpr = node.argumentExpression;
|
|
117
|
+
const prefix = binaryExpr.left.getText();
|
|
118
|
+
const suffix = binaryExpr.right.text;
|
|
119
|
+
this.allPropertyPaths.add(`${node.expression.getText()}[${prefix} + '${suffix}']`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.PropertyAccessAnalyzer = PropertyAccessAnalyzer;
|
|
123
|
+
//# sourceMappingURL=property-access-analyzer.js.map
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C,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7D,CAAC;IAEO,yBAAyB,CAAC,IAAmB;QACjD,OAAO,oBAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC;YAC9B,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,oBAAE,CAAC,UAAU,CAAC,SAAS;YACnD,oBAAE,CAAC,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC;YACxC,oBAAE,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IAEO,4BAA4B,CAAC,IAAgC;QACjE,MAAM,aAAa,GAAG,IAAI,CAAC,kBAAsC,CAAC;QAClE,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,aAAa,CAAC,IAAI,IAAI,CAAC,CAAC;IACvF,CAAC;IAEO,4BAA4B,CAAC,IAAgC;QACjE,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAyC,CAAC;QAClE,MAAM,MAAM,GAAI,UAAU,CAAC,IAAoC,CAAC,OAAO,EAAE,CAAC;QAC1E,MAAM,MAAM,GAAI,UAAU,CAAC,KAA0B,CAAC,IAAI,CAAC;QAC3D,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,MAAM,OAAO,MAAM,IAAI,CAAC,CAAC;IACvF,CAAC;CACJ;AAnID,wDAmIC"}
|
|
@@ -216,13 +216,12 @@ function generateDocumentation(outputPath) {
|
|
|
216
216
|
`;
|
|
217
217
|
});
|
|
218
218
|
html += `</table>
|
|
219
|
-
|
|
220
|
-
</div>`;
|
|
219
|
+
</div>`;
|
|
221
220
|
}
|
|
222
221
|
html += `
|
|
222
|
+
</div>
|
|
223
223
|
<script>
|
|
224
224
|
const collapseButtons = document.querySelectorAll('.show-hide-mapping');
|
|
225
|
-
const mappingTables = document.querySelectorAll('.mapping-table');
|
|
226
225
|
const search = document.getElementById('searchInput');
|
|
227
226
|
const mappingContainers = document.querySelectorAll('.mapping-container');
|
|
228
227
|
const tableRows = document.querySelectorAll('tr');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-generator.js","sourceRoot":"","sources":["../../src/generators/html-generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,
|
|
1
|
+
{"version":3,"file":"html-generator.js","sourceRoot":"","sources":["../../src/generators/html-generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,sDAsPC;AA5PD,uCAAyB;AACzB,2CAA6B;AAC7B,4DAAwD;AACxD,8DAAqD;AACrD,sDAAwC;AAExC,SAAgB,qBAAqB,CAAC,UAAkB;IACpD,IAAI,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgIZ,CAAC;IACA,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAClC,MAAM,cAAc,GAAG,IAAA,6BAAW,EAAC,WAAW,CAAC,CAAC;IAEhD,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;QACzC,MAAM,gBAAgB,GAAG,IAAA,4BAAa,EAClC,aAAa,CAAC,QAAQ,EACtB,aAAa,CAAC,SAAS,EACvB,aAAa,CAAC,UAAU,CAC3B,CAAC;QAEF,IAAI,IAAI;;;;;yDAKyC,aAAa,CAAC,SAAS;;;2DAGrB,aAAa,CAAC,UAAU;;;;;OAK5E,aAAa,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE;;;;;;;;;iCASb,aAAa,CAAC,OAAO,CAAC,YAAY,wBAAwB,aAAa,CAAC,OAAO,CAAC,YAAY;;;;YAIjH,aAAa,C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