@memberjunction/react-test-harness 2.124.0 → 2.126.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/dist/lib/component-linter.d.ts.map +1 -1
- package/dist/lib/component-linter.js +433 -2
- package/dist/lib/component-linter.js.map +1 -1
- package/dist/lib/constraint-validators/base-constraint-validator.d.ts +259 -0
- package/dist/lib/constraint-validators/base-constraint-validator.d.ts.map +1 -0
- package/dist/lib/constraint-validators/base-constraint-validator.js +304 -0
- package/dist/lib/constraint-validators/base-constraint-validator.js.map +1 -0
- package/dist/lib/constraint-validators/index.d.ts +21 -0
- package/dist/lib/constraint-validators/index.d.ts.map +1 -0
- package/dist/lib/constraint-validators/index.js +37 -0
- package/dist/lib/constraint-validators/index.js.map +1 -0
- package/dist/lib/constraint-validators/required-when-validator.d.ts +43 -0
- package/dist/lib/constraint-validators/required-when-validator.d.ts.map +1 -0
- package/dist/lib/constraint-validators/required-when-validator.js +97 -0
- package/dist/lib/constraint-validators/required-when-validator.js.map +1 -0
- package/dist/lib/constraint-validators/sql-where-clause-validator.d.ts +116 -0
- package/dist/lib/constraint-validators/sql-where-clause-validator.d.ts.map +1 -0
- package/dist/lib/constraint-validators/sql-where-clause-validator.js +381 -0
- package/dist/lib/constraint-validators/sql-where-clause-validator.js.map +1 -0
- package/dist/lib/constraint-validators/subset-of-entity-fields-validator.d.ts +60 -0
- package/dist/lib/constraint-validators/subset-of-entity-fields-validator.d.ts.map +1 -0
- package/dist/lib/constraint-validators/subset-of-entity-fields-validator.js +198 -0
- package/dist/lib/constraint-validators/subset-of-entity-fields-validator.js.map +1 -0
- package/dist/lib/constraint-validators/validation-context.d.ts +326 -0
- package/dist/lib/constraint-validators/validation-context.d.ts.map +1 -0
- package/dist/lib/constraint-validators/validation-context.js +14 -0
- package/dist/lib/constraint-validators/validation-context.js.map +1 -0
- package/dist/lib/prop-value-extractor.d.ts +147 -0
- package/dist/lib/prop-value-extractor.d.ts.map +1 -0
- package/dist/lib/prop-value-extractor.js +499 -0
- package/dist/lib/prop-value-extractor.js.map +1 -0
- package/dist/lib/type-context.d.ts +2 -0
- package/dist/lib/type-context.d.ts.map +1 -1
- package/dist/lib/type-context.js +22 -9
- package/dist/lib/type-context.js.map +1 -1
- package/dist/lib/type-inference-engine.d.ts +20 -0
- package/dist/lib/type-inference-engine.d.ts.map +1 -1
- package/dist/lib/type-inference-engine.js +253 -20
- package/dist/lib/type-inference-engine.js.map +1 -1
- package/package.json +13 -9
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prop Value Extractor Utility
|
|
3
|
+
*
|
|
4
|
+
* Extracts static values from JSX attribute AST nodes for validation purposes.
|
|
5
|
+
* This utility is foundational for constraint validation - it converts AST nodes
|
|
6
|
+
* into analyzable values that constraint validators can work with.
|
|
7
|
+
*
|
|
8
|
+
* Supported Extractions:
|
|
9
|
+
* - Literal values: strings, numbers, booleans, null
|
|
10
|
+
* - Arrays of literals
|
|
11
|
+
* - Object literals (nested)
|
|
12
|
+
* - Identifies dynamic values (identifiers/expressions) that can't be extracted
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const value = PropValueExtractor.extract(jsxAttribute);
|
|
17
|
+
* if (value._type === 'identifier') {
|
|
18
|
+
* // Can't validate statically - skip with warning
|
|
19
|
+
* } else {
|
|
20
|
+
* // Can validate - proceed with constraint checking
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
import * as t from '@babel/types';
|
|
25
|
+
/**
|
|
26
|
+
* Represents a value that couldn't be extracted statically
|
|
27
|
+
*/
|
|
28
|
+
export interface DynamicValue {
|
|
29
|
+
_type: 'identifier' | 'expression';
|
|
30
|
+
name?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Union type for extracted values
|
|
35
|
+
*/
|
|
36
|
+
export type ExtractedValue = string | number | boolean | null | undefined | ExtractedValue[] | {
|
|
37
|
+
[key: string]: ExtractedValue;
|
|
38
|
+
} | DynamicValue;
|
|
39
|
+
/**
|
|
40
|
+
* Utility class for extracting static values from JSX attribute AST nodes
|
|
41
|
+
*/
|
|
42
|
+
export declare class PropValueExtractor {
|
|
43
|
+
/**
|
|
44
|
+
* Extract a value from a JSX attribute
|
|
45
|
+
*
|
|
46
|
+
* @param attr - The JSX attribute node
|
|
47
|
+
* @returns The extracted value, or a DynamicValue object if it can't be extracted statically
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* // Boolean shorthand: <Component show />
|
|
52
|
+
* PropValueExtractor.extract(attr) // => true
|
|
53
|
+
*
|
|
54
|
+
* // String literal: <Component name="test" />
|
|
55
|
+
* PropValueExtractor.extract(attr) // => "test"
|
|
56
|
+
*
|
|
57
|
+
* // Expression: <Component count={42} />
|
|
58
|
+
* PropValueExtractor.extract(attr) // => 42
|
|
59
|
+
*
|
|
60
|
+
* // Array: <Component items={['a', 'b']} />
|
|
61
|
+
* PropValueExtractor.extract(attr) // => ['a', 'b']
|
|
62
|
+
*
|
|
63
|
+
* // Dynamic: <Component name={userName} />
|
|
64
|
+
* PropValueExtractor.extract(attr) // => { _type: 'identifier', name: 'userName' }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
static extract(attr: t.JSXAttribute): ExtractedValue;
|
|
68
|
+
/**
|
|
69
|
+
* Extract a value from an expression node
|
|
70
|
+
*
|
|
71
|
+
* @param expr - The expression node
|
|
72
|
+
* @returns The extracted value
|
|
73
|
+
*/
|
|
74
|
+
private static extractExpression;
|
|
75
|
+
/**
|
|
76
|
+
* Extract template literal if it's static
|
|
77
|
+
*
|
|
78
|
+
* @param node - Template literal node
|
|
79
|
+
* @returns Concatenated string if all expressions are literals, otherwise DynamicValue
|
|
80
|
+
*/
|
|
81
|
+
private static extractTemplateLiteral;
|
|
82
|
+
/**
|
|
83
|
+
* Extract array expression
|
|
84
|
+
*
|
|
85
|
+
* @param node - Array expression node
|
|
86
|
+
* @returns Array of extracted values
|
|
87
|
+
*/
|
|
88
|
+
private static extractArray;
|
|
89
|
+
/**
|
|
90
|
+
* Extract object literal
|
|
91
|
+
*
|
|
92
|
+
* @param node - Object expression node
|
|
93
|
+
* @returns Object with extracted property values
|
|
94
|
+
*/
|
|
95
|
+
private static extractObjectLiteral;
|
|
96
|
+
/**
|
|
97
|
+
* Get property key as string
|
|
98
|
+
*
|
|
99
|
+
* @param key - Property key node
|
|
100
|
+
* @param computed - Whether the property is computed
|
|
101
|
+
* @returns String key or null if can't be extracted
|
|
102
|
+
*/
|
|
103
|
+
private static getPropertyKey;
|
|
104
|
+
/**
|
|
105
|
+
* Extract unary expression if operand is static
|
|
106
|
+
*
|
|
107
|
+
* @param node - Unary expression node
|
|
108
|
+
* @returns Computed value or DynamicValue
|
|
109
|
+
*/
|
|
110
|
+
private static extractUnaryExpression;
|
|
111
|
+
/**
|
|
112
|
+
* Extract binary expression if both operands are static
|
|
113
|
+
*
|
|
114
|
+
* @param node - Binary expression node
|
|
115
|
+
* @returns Computed value or DynamicValue
|
|
116
|
+
*/
|
|
117
|
+
private static extractBinaryExpression;
|
|
118
|
+
/**
|
|
119
|
+
* Extract conditional expression (ternary) if all parts are static
|
|
120
|
+
*
|
|
121
|
+
* @param node - Conditional expression node
|
|
122
|
+
* @returns Value of the taken branch or DynamicValue
|
|
123
|
+
*/
|
|
124
|
+
private static extractConditionalExpression;
|
|
125
|
+
/**
|
|
126
|
+
* Check if a value is a DynamicValue (can't be validated statically)
|
|
127
|
+
*
|
|
128
|
+
* @param value - The extracted value
|
|
129
|
+
* @returns True if the value is dynamic
|
|
130
|
+
*/
|
|
131
|
+
static isDynamicValue(value: ExtractedValue): value is DynamicValue;
|
|
132
|
+
/**
|
|
133
|
+
* Check if an array contains any dynamic values
|
|
134
|
+
*
|
|
135
|
+
* @param arr - The array to check
|
|
136
|
+
* @returns True if any element is dynamic
|
|
137
|
+
*/
|
|
138
|
+
static hasAnyDynamicValue(arr: ExtractedValue[]): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Get a human-readable description of the value
|
|
141
|
+
*
|
|
142
|
+
* @param value - The extracted value
|
|
143
|
+
* @returns Description string
|
|
144
|
+
*/
|
|
145
|
+
static describe(value: ExtractedValue): string;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=prop-value-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prop-value-extractor.d.ts","sourceRoot":"","sources":["../../src/lib/prop-value-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,YAAY,GAAG,YAAY,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,cAAc,EAAE,GAChB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;CAAE,GACjC,YAAY,CAAC;AAEjB;;GAEG;AACH,qBAAa,kBAAkB;IAC7B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,YAAY,GAAG,cAAc;IAkCpD;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA4EhC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAkCrC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IAyB3B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAsCnC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IA2B7B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IA6BrC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IA6EtC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAkB3C;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,KAAK,IAAI,YAAY;IASnE;;;;;OAKG;IACH,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,OAAO;IAWzD;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM;CA0B/C"}
|
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Prop Value Extractor Utility
|
|
4
|
+
*
|
|
5
|
+
* Extracts static values from JSX attribute AST nodes for validation purposes.
|
|
6
|
+
* This utility is foundational for constraint validation - it converts AST nodes
|
|
7
|
+
* into analyzable values that constraint validators can work with.
|
|
8
|
+
*
|
|
9
|
+
* Supported Extractions:
|
|
10
|
+
* - Literal values: strings, numbers, booleans, null
|
|
11
|
+
* - Arrays of literals
|
|
12
|
+
* - Object literals (nested)
|
|
13
|
+
* - Identifies dynamic values (identifiers/expressions) that can't be extracted
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const value = PropValueExtractor.extract(jsxAttribute);
|
|
18
|
+
* if (value._type === 'identifier') {
|
|
19
|
+
* // Can't validate statically - skip with warning
|
|
20
|
+
* } else {
|
|
21
|
+
* // Can validate - proceed with constraint checking
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
28
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
29
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
30
|
+
}
|
|
31
|
+
Object.defineProperty(o, k2, desc);
|
|
32
|
+
}) : (function(o, m, k, k2) {
|
|
33
|
+
if (k2 === undefined) k2 = k;
|
|
34
|
+
o[k2] = m[k];
|
|
35
|
+
}));
|
|
36
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
37
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
38
|
+
}) : function(o, v) {
|
|
39
|
+
o["default"] = v;
|
|
40
|
+
});
|
|
41
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
42
|
+
if (mod && mod.__esModule) return mod;
|
|
43
|
+
var result = {};
|
|
44
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
45
|
+
__setModuleDefault(result, mod);
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.PropValueExtractor = void 0;
|
|
50
|
+
const t = __importStar(require("@babel/types"));
|
|
51
|
+
/**
|
|
52
|
+
* Utility class for extracting static values from JSX attribute AST nodes
|
|
53
|
+
*/
|
|
54
|
+
class PropValueExtractor {
|
|
55
|
+
/**
|
|
56
|
+
* Extract a value from a JSX attribute
|
|
57
|
+
*
|
|
58
|
+
* @param attr - The JSX attribute node
|
|
59
|
+
* @returns The extracted value, or a DynamicValue object if it can't be extracted statically
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* // Boolean shorthand: <Component show />
|
|
64
|
+
* PropValueExtractor.extract(attr) // => true
|
|
65
|
+
*
|
|
66
|
+
* // String literal: <Component name="test" />
|
|
67
|
+
* PropValueExtractor.extract(attr) // => "test"
|
|
68
|
+
*
|
|
69
|
+
* // Expression: <Component count={42} />
|
|
70
|
+
* PropValueExtractor.extract(attr) // => 42
|
|
71
|
+
*
|
|
72
|
+
* // Array: <Component items={['a', 'b']} />
|
|
73
|
+
* PropValueExtractor.extract(attr) // => ['a', 'b']
|
|
74
|
+
*
|
|
75
|
+
* // Dynamic: <Component name={userName} />
|
|
76
|
+
* PropValueExtractor.extract(attr) // => { _type: 'identifier', name: 'userName' }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
static extract(attr) {
|
|
80
|
+
// Boolean shorthand: <Component show />
|
|
81
|
+
if (!attr.value) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
// String literal: <Component name="test" />
|
|
85
|
+
if (t.isStringLiteral(attr.value)) {
|
|
86
|
+
return attr.value.value;
|
|
87
|
+
}
|
|
88
|
+
// Expression container: <Component prop={...} />
|
|
89
|
+
if (t.isJSXExpressionContainer(attr.value)) {
|
|
90
|
+
const expr = attr.value.expression;
|
|
91
|
+
// Handle JSXEmptyExpression (e.g., {/* comment */})
|
|
92
|
+
if (t.isJSXEmptyExpression(expr)) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
return this.extractExpression(expr);
|
|
96
|
+
}
|
|
97
|
+
// JSX element or fragment (rare but possible)
|
|
98
|
+
if (t.isJSXElement(attr.value) || t.isJSXFragment(attr.value)) {
|
|
99
|
+
return {
|
|
100
|
+
_type: 'expression',
|
|
101
|
+
description: 'JSX element as prop value',
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Extract a value from an expression node
|
|
108
|
+
*
|
|
109
|
+
* @param expr - The expression node
|
|
110
|
+
* @returns The extracted value
|
|
111
|
+
*/
|
|
112
|
+
static extractExpression(expr) {
|
|
113
|
+
// Simple literals
|
|
114
|
+
if (t.isStringLiteral(expr))
|
|
115
|
+
return expr.value;
|
|
116
|
+
if (t.isNumericLiteral(expr))
|
|
117
|
+
return expr.value;
|
|
118
|
+
if (t.isBooleanLiteral(expr))
|
|
119
|
+
return expr.value;
|
|
120
|
+
if (t.isNullLiteral(expr))
|
|
121
|
+
return null;
|
|
122
|
+
// Template literals (can be static)
|
|
123
|
+
if (t.isTemplateLiteral(expr)) {
|
|
124
|
+
return this.extractTemplateLiteral(expr);
|
|
125
|
+
}
|
|
126
|
+
// Arrays
|
|
127
|
+
if (t.isArrayExpression(expr)) {
|
|
128
|
+
return this.extractArray(expr);
|
|
129
|
+
}
|
|
130
|
+
// Objects
|
|
131
|
+
if (t.isObjectExpression(expr)) {
|
|
132
|
+
return this.extractObjectLiteral(expr);
|
|
133
|
+
}
|
|
134
|
+
// Unary expressions (e.g., -5, !true)
|
|
135
|
+
if (t.isUnaryExpression(expr)) {
|
|
136
|
+
return this.extractUnaryExpression(expr);
|
|
137
|
+
}
|
|
138
|
+
// Binary expressions (e.g., 1 + 2, 'hello' + 'world')
|
|
139
|
+
if (t.isBinaryExpression(expr)) {
|
|
140
|
+
return this.extractBinaryExpression(expr);
|
|
141
|
+
}
|
|
142
|
+
// Identifiers - can't extract statically
|
|
143
|
+
if (t.isIdentifier(expr)) {
|
|
144
|
+
return {
|
|
145
|
+
_type: 'identifier',
|
|
146
|
+
name: expr.name,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
// Member expressions (e.g., obj.prop)
|
|
150
|
+
if (t.isMemberExpression(expr)) {
|
|
151
|
+
return {
|
|
152
|
+
_type: 'expression',
|
|
153
|
+
description: 'member expression',
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// Call expressions (e.g., func())
|
|
157
|
+
if (t.isCallExpression(expr)) {
|
|
158
|
+
return {
|
|
159
|
+
_type: 'expression',
|
|
160
|
+
description: 'function call',
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
// Arrow functions, function expressions
|
|
164
|
+
if (t.isArrowFunctionExpression(expr) || t.isFunctionExpression(expr)) {
|
|
165
|
+
return {
|
|
166
|
+
_type: 'expression',
|
|
167
|
+
description: 'function',
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
// Conditional expressions (ternary)
|
|
171
|
+
if (t.isConditionalExpression(expr)) {
|
|
172
|
+
return this.extractConditionalExpression(expr);
|
|
173
|
+
}
|
|
174
|
+
// All other expression types
|
|
175
|
+
return {
|
|
176
|
+
_type: 'expression',
|
|
177
|
+
description: expr.type,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Extract template literal if it's static
|
|
182
|
+
*
|
|
183
|
+
* @param node - Template literal node
|
|
184
|
+
* @returns Concatenated string if all expressions are literals, otherwise DynamicValue
|
|
185
|
+
*/
|
|
186
|
+
static extractTemplateLiteral(node) {
|
|
187
|
+
// Check if all expressions are static literals
|
|
188
|
+
const parts = [];
|
|
189
|
+
for (let i = 0; i < node.quasis.length; i++) {
|
|
190
|
+
parts.push(node.quasis[i].value.cooked || node.quasis[i].value.raw);
|
|
191
|
+
if (i < node.expressions.length) {
|
|
192
|
+
const expr = node.expressions[i];
|
|
193
|
+
// Handle TSType nodes (TypeScript types in template literals)
|
|
194
|
+
if (!t.isExpression(expr) && !t.isJSXEmptyExpression(expr)) {
|
|
195
|
+
return {
|
|
196
|
+
_type: 'expression',
|
|
197
|
+
description: 'template literal with type annotation',
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
const value = this.extractExpression(expr);
|
|
201
|
+
// If any expression is dynamic, the whole template is dynamic
|
|
202
|
+
if (this.isDynamicValue(value)) {
|
|
203
|
+
return {
|
|
204
|
+
_type: 'expression',
|
|
205
|
+
description: 'template literal with dynamic expressions',
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
// Convert to string
|
|
209
|
+
parts.push(String(value));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return parts.join('');
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Extract array expression
|
|
216
|
+
*
|
|
217
|
+
* @param node - Array expression node
|
|
218
|
+
* @returns Array of extracted values
|
|
219
|
+
*/
|
|
220
|
+
static extractArray(node) {
|
|
221
|
+
const result = [];
|
|
222
|
+
for (const element of node.elements) {
|
|
223
|
+
if (!element) {
|
|
224
|
+
// Sparse array: [1, , 3]
|
|
225
|
+
result.push(undefined);
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (t.isSpreadElement(element)) {
|
|
229
|
+
// Spread element: [...items] - can't extract statically
|
|
230
|
+
result.push({
|
|
231
|
+
_type: 'expression',
|
|
232
|
+
description: 'spread element',
|
|
233
|
+
});
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
result.push(this.extractExpression(element));
|
|
237
|
+
}
|
|
238
|
+
return result;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Extract object literal
|
|
242
|
+
*
|
|
243
|
+
* @param node - Object expression node
|
|
244
|
+
* @returns Object with extracted property values
|
|
245
|
+
*/
|
|
246
|
+
static extractObjectLiteral(node) {
|
|
247
|
+
const result = {};
|
|
248
|
+
for (const prop of node.properties) {
|
|
249
|
+
// Spread properties: { ...obj }
|
|
250
|
+
if (t.isSpreadElement(prop)) {
|
|
251
|
+
result['...'] = {
|
|
252
|
+
_type: 'expression',
|
|
253
|
+
description: 'spread property',
|
|
254
|
+
};
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
// Object method: { foo() {} }
|
|
258
|
+
if (t.isObjectMethod(prop)) {
|
|
259
|
+
const key = this.getPropertyKey(prop.key, prop.computed);
|
|
260
|
+
if (key) {
|
|
261
|
+
result[key] = {
|
|
262
|
+
_type: 'expression',
|
|
263
|
+
description: 'object method',
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
// Regular property: { foo: 'bar' }
|
|
269
|
+
if (t.isObjectProperty(prop)) {
|
|
270
|
+
const key = this.getPropertyKey(prop.key, prop.computed);
|
|
271
|
+
if (key) {
|
|
272
|
+
result[key] = this.extractExpression(prop.value);
|
|
273
|
+
}
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return result;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Get property key as string
|
|
281
|
+
*
|
|
282
|
+
* @param key - Property key node
|
|
283
|
+
* @param computed - Whether the property is computed
|
|
284
|
+
* @returns String key or null if can't be extracted
|
|
285
|
+
*/
|
|
286
|
+
static getPropertyKey(key, computed) {
|
|
287
|
+
if (t.isIdentifier(key)) {
|
|
288
|
+
return key.name;
|
|
289
|
+
}
|
|
290
|
+
if (t.isStringLiteral(key)) {
|
|
291
|
+
return key.value;
|
|
292
|
+
}
|
|
293
|
+
if (t.isNumericLiteral(key)) {
|
|
294
|
+
return String(key.value);
|
|
295
|
+
}
|
|
296
|
+
if (computed && t.isExpression(key)) {
|
|
297
|
+
// Computed property: { [expr]: value }
|
|
298
|
+
const value = this.extractExpression(key);
|
|
299
|
+
if (!this.isDynamicValue(value)) {
|
|
300
|
+
return String(value);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Extract unary expression if operand is static
|
|
307
|
+
*
|
|
308
|
+
* @param node - Unary expression node
|
|
309
|
+
* @returns Computed value or DynamicValue
|
|
310
|
+
*/
|
|
311
|
+
static extractUnaryExpression(node) {
|
|
312
|
+
const operand = this.extractExpression(node.argument);
|
|
313
|
+
if (this.isDynamicValue(operand)) {
|
|
314
|
+
return operand;
|
|
315
|
+
}
|
|
316
|
+
// Apply unary operator
|
|
317
|
+
switch (node.operator) {
|
|
318
|
+
case '-':
|
|
319
|
+
return typeof operand === 'number' ? -operand : operand;
|
|
320
|
+
case '+':
|
|
321
|
+
return typeof operand === 'number' ? +operand : operand;
|
|
322
|
+
case '!':
|
|
323
|
+
return !operand;
|
|
324
|
+
case '~':
|
|
325
|
+
return typeof operand === 'number' ? ~operand : operand;
|
|
326
|
+
case 'typeof':
|
|
327
|
+
return typeof operand;
|
|
328
|
+
case 'void':
|
|
329
|
+
return undefined;
|
|
330
|
+
default:
|
|
331
|
+
return {
|
|
332
|
+
_type: 'expression',
|
|
333
|
+
description: `unary ${node.operator}`,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Extract binary expression if both operands are static
|
|
339
|
+
*
|
|
340
|
+
* @param node - Binary expression node
|
|
341
|
+
* @returns Computed value or DynamicValue
|
|
342
|
+
*/
|
|
343
|
+
static extractBinaryExpression(node) {
|
|
344
|
+
// Handle PrivateName in left operand (shouldn't happen in normal code but TypeScript allows it)
|
|
345
|
+
if (t.isPrivateName(node.left)) {
|
|
346
|
+
return {
|
|
347
|
+
_type: 'expression',
|
|
348
|
+
description: 'binary expression with private name',
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
const left = this.extractExpression(node.left);
|
|
352
|
+
const right = this.extractExpression(node.right);
|
|
353
|
+
// If either side is dynamic, can't compute
|
|
354
|
+
if (this.isDynamicValue(left) || this.isDynamicValue(right)) {
|
|
355
|
+
return {
|
|
356
|
+
_type: 'expression',
|
|
357
|
+
description: `binary ${node.operator}`,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
// Try to compute the result
|
|
361
|
+
try {
|
|
362
|
+
switch (node.operator) {
|
|
363
|
+
case '+':
|
|
364
|
+
return left + right;
|
|
365
|
+
case '-':
|
|
366
|
+
return left - right;
|
|
367
|
+
case '*':
|
|
368
|
+
return left * right;
|
|
369
|
+
case '/':
|
|
370
|
+
return left / right;
|
|
371
|
+
case '%':
|
|
372
|
+
return left % right;
|
|
373
|
+
case '**':
|
|
374
|
+
return left ** right;
|
|
375
|
+
case '==':
|
|
376
|
+
return left == right;
|
|
377
|
+
case '!=':
|
|
378
|
+
return left != right;
|
|
379
|
+
case '===':
|
|
380
|
+
return left === right;
|
|
381
|
+
case '!==':
|
|
382
|
+
return left !== right;
|
|
383
|
+
case '<':
|
|
384
|
+
return left < right;
|
|
385
|
+
case '<=':
|
|
386
|
+
return left <= right;
|
|
387
|
+
case '>':
|
|
388
|
+
return left > right;
|
|
389
|
+
case '>=':
|
|
390
|
+
return left >= right;
|
|
391
|
+
case '&':
|
|
392
|
+
return left & right;
|
|
393
|
+
case '|':
|
|
394
|
+
return left | right;
|
|
395
|
+
case '^':
|
|
396
|
+
return left ^ right;
|
|
397
|
+
case '<<':
|
|
398
|
+
return left << right;
|
|
399
|
+
case '>>':
|
|
400
|
+
return left >> right;
|
|
401
|
+
case '>>>':
|
|
402
|
+
return left >>> right;
|
|
403
|
+
default:
|
|
404
|
+
return {
|
|
405
|
+
_type: 'expression',
|
|
406
|
+
description: `binary ${node.operator}`,
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
catch {
|
|
411
|
+
// Computation failed (e.g., type error)
|
|
412
|
+
return {
|
|
413
|
+
_type: 'expression',
|
|
414
|
+
description: `binary ${node.operator}`,
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Extract conditional expression (ternary) if all parts are static
|
|
420
|
+
*
|
|
421
|
+
* @param node - Conditional expression node
|
|
422
|
+
* @returns Value of the taken branch or DynamicValue
|
|
423
|
+
*/
|
|
424
|
+
static extractConditionalExpression(node) {
|
|
425
|
+
const test = this.extractExpression(node.test);
|
|
426
|
+
// If test is dynamic, we can't determine which branch is taken
|
|
427
|
+
if (this.isDynamicValue(test)) {
|
|
428
|
+
return {
|
|
429
|
+
_type: 'expression',
|
|
430
|
+
description: 'conditional expression',
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
// Evaluate which branch is taken
|
|
434
|
+
const consequent = this.extractExpression(node.consequent);
|
|
435
|
+
const alternate = this.extractExpression(node.alternate);
|
|
436
|
+
return test ? consequent : alternate;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Check if a value is a DynamicValue (can't be validated statically)
|
|
440
|
+
*
|
|
441
|
+
* @param value - The extracted value
|
|
442
|
+
* @returns True if the value is dynamic
|
|
443
|
+
*/
|
|
444
|
+
static isDynamicValue(value) {
|
|
445
|
+
return (typeof value === 'object' &&
|
|
446
|
+
value !== null &&
|
|
447
|
+
'_type' in value &&
|
|
448
|
+
(value._type === 'identifier' || value._type === 'expression'));
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Check if an array contains any dynamic values
|
|
452
|
+
*
|
|
453
|
+
* @param arr - The array to check
|
|
454
|
+
* @returns True if any element is dynamic
|
|
455
|
+
*/
|
|
456
|
+
static hasAnyDynamicValue(arr) {
|
|
457
|
+
return arr.some((val) => {
|
|
458
|
+
if (this.isDynamicValue(val))
|
|
459
|
+
return true;
|
|
460
|
+
if (Array.isArray(val))
|
|
461
|
+
return this.hasAnyDynamicValue(val);
|
|
462
|
+
if (typeof val === 'object' && val !== null && !('_type' in val)) {
|
|
463
|
+
return Object.values(val).some((v) => this.isDynamicValue(v));
|
|
464
|
+
}
|
|
465
|
+
return false;
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Get a human-readable description of the value
|
|
470
|
+
*
|
|
471
|
+
* @param value - The extracted value
|
|
472
|
+
* @returns Description string
|
|
473
|
+
*/
|
|
474
|
+
static describe(value) {
|
|
475
|
+
if (value === null)
|
|
476
|
+
return 'null';
|
|
477
|
+
if (value === undefined)
|
|
478
|
+
return 'undefined';
|
|
479
|
+
if (this.isDynamicValue(value)) {
|
|
480
|
+
if (value._type === 'identifier' && value.name) {
|
|
481
|
+
return `identifier '${value.name}'`;
|
|
482
|
+
}
|
|
483
|
+
return value.description || 'dynamic expression';
|
|
484
|
+
}
|
|
485
|
+
if (Array.isArray(value)) {
|
|
486
|
+
return `array with ${value.length} element${value.length !== 1 ? 's' : ''}`;
|
|
487
|
+
}
|
|
488
|
+
if (typeof value === 'object') {
|
|
489
|
+
const keys = Object.keys(value);
|
|
490
|
+
return `object with ${keys.length} propert${keys.length !== 1 ? 'ies' : 'y'}: {${keys.slice(0, 3).join(', ')}${keys.length > 3 ? '...' : ''}}`;
|
|
491
|
+
}
|
|
492
|
+
if (typeof value === 'string') {
|
|
493
|
+
return `"${value.length > 50 ? value.substring(0, 50) + '...' : value}"`;
|
|
494
|
+
}
|
|
495
|
+
return String(value);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
exports.PropValueExtractor = PropValueExtractor;
|
|
499
|
+
//# sourceMappingURL=prop-value-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prop-value-extractor.js","sourceRoot":"","sources":["../../src/lib/prop-value-extractor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAkC;AAwBlC;;GAEG;AACH,MAAa,kBAAkB;IAC7B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,MAAM,CAAC,OAAO,CAAC,IAAoB;QACjC,wCAAwC;QACxC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,4CAA4C;QAC5C,IAAI,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QAC1B,CAAC;QAED,iDAAiD;QACjD,IAAI,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;YAEnC,oDAAoD;YACpD,IAAI,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;gBACjC,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC;QAED,8CAA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AAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAChC,OAAO,eAAe,IAAI,CAAC,MAAM,WAAW,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;QACjJ,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;QAC3E,CAAC;QAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;CACF;AAhfD,gDAgfC"}
|
|
@@ -27,6 +27,8 @@ export interface TypeInfo {
|
|
|
27
27
|
nullable?: boolean;
|
|
28
28
|
/** Whether this type came from metadata (vs inferred) */
|
|
29
29
|
fromMetadata?: boolean;
|
|
30
|
+
/** For constant literals, the actual value (e.g., '' for empty string, '2024-01-01' for date literal) */
|
|
31
|
+
literalValue?: string | number | boolean | null;
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
34
|
* Type information for a specific field
|