typekro 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/.tsbuildinfo +1 -1
- package/dist/core/composition/imperative.d.ts.map +1 -1
- package/dist/core/composition/imperative.js +15 -2
- package/dist/core/composition/imperative.js.map +1 -1
- package/dist/core/composition/typekro-runtime/typekro-runtime.d.ts.map +1 -1
- package/dist/core/composition/typekro-runtime/typekro-runtime.js +24 -25
- package/dist/core/composition/typekro-runtime/typekro-runtime.js.map +1 -1
- package/dist/core/dependencies/type-guards.d.ts.map +1 -1
- package/dist/core/dependencies/type-guards.js +7 -2
- package/dist/core/dependencies/type-guards.js.map +1 -1
- package/dist/core/deployment/engine.d.ts +13 -1
- package/dist/core/deployment/engine.d.ts.map +1 -1
- package/dist/core/deployment/engine.js +48 -3
- package/dist/core/deployment/engine.js.map +1 -1
- package/dist/core/errors.d.ts +85 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +135 -0
- package/dist/core/errors.js.map +1 -1
- package/dist/core/evaluation/cel-optimizer.d.ts.map +1 -1
- package/dist/core/evaluation/cel-optimizer.js +7 -13
- package/dist/core/evaluation/cel-optimizer.js.map +1 -1
- package/dist/core/expressions/analyzer.d.ts +584 -0
- package/dist/core/expressions/analyzer.d.ts.map +1 -0
- package/dist/core/expressions/analyzer.js +2956 -0
- package/dist/core/expressions/analyzer.js.map +1 -0
- package/dist/core/expressions/cache.d.ts +136 -0
- package/dist/core/expressions/cache.d.ts.map +1 -0
- package/dist/core/expressions/cache.js +347 -0
- package/dist/core/expressions/cache.js.map +1 -0
- package/dist/core/expressions/cel-conversion-engine.d.ts +126 -0
- package/dist/core/expressions/cel-conversion-engine.d.ts.map +1 -0
- package/dist/core/expressions/cel-conversion-engine.js +293 -0
- package/dist/core/expressions/cel-conversion-engine.js.map +1 -0
- package/dist/core/expressions/compile-time-validation.d.ts +270 -0
- package/dist/core/expressions/compile-time-validation.d.ts.map +1 -0
- package/dist/core/expressions/compile-time-validation.js +506 -0
- package/dist/core/expressions/compile-time-validation.js.map +1 -0
- package/dist/core/expressions/composition-integration.d.ts +315 -0
- package/dist/core/expressions/composition-integration.d.ts.map +1 -0
- package/dist/core/expressions/composition-integration.js +936 -0
- package/dist/core/expressions/composition-integration.js.map +1 -0
- package/dist/core/expressions/conditional-expression-processor.d.ts +154 -0
- package/dist/core/expressions/conditional-expression-processor.d.ts.map +1 -0
- package/dist/core/expressions/conditional-expression-processor.js +479 -0
- package/dist/core/expressions/conditional-expression-processor.js.map +1 -0
- package/dist/core/expressions/conditional-integration.d.ts +133 -0
- package/dist/core/expressions/conditional-integration.d.ts.map +1 -0
- package/dist/core/expressions/conditional-integration.js +293 -0
- package/dist/core/expressions/conditional-integration.js.map +1 -0
- package/dist/core/expressions/conditional-validation.d.ts +181 -0
- package/dist/core/expressions/conditional-validation.d.ts.map +1 -0
- package/dist/core/expressions/conditional-validation.js +460 -0
- package/dist/core/expressions/conditional-validation.js.map +1 -0
- package/dist/core/expressions/context-aware-generator.d.ts +127 -0
- package/dist/core/expressions/context-aware-generator.d.ts.map +1 -0
- package/dist/core/expressions/context-aware-generator.js +500 -0
- package/dist/core/expressions/context-aware-generator.js.map +1 -0
- package/dist/core/expressions/context-detector.d.ts +148 -0
- package/dist/core/expressions/context-detector.d.ts.map +1 -0
- package/dist/core/expressions/context-detector.js +546 -0
- package/dist/core/expressions/context-detector.js.map +1 -0
- package/dist/core/expressions/context-switcher.d.ts +185 -0
- package/dist/core/expressions/context-switcher.d.ts.map +1 -0
- package/dist/core/expressions/context-switcher.js +515 -0
- package/dist/core/expressions/context-switcher.js.map +1 -0
- package/dist/core/expressions/context-validator.d.ts +176 -0
- package/dist/core/expressions/context-validator.d.ts.map +1 -0
- package/dist/core/expressions/context-validator.js +452 -0
- package/dist/core/expressions/context-validator.js.map +1 -0
- package/dist/core/expressions/custom-context-manager.d.ts +194 -0
- package/dist/core/expressions/custom-context-manager.d.ts.map +1 -0
- package/dist/core/expressions/custom-context-manager.js +390 -0
- package/dist/core/expressions/custom-context-manager.js.map +1 -0
- package/dist/core/expressions/expression-proxy.d.ts +80 -0
- package/dist/core/expressions/expression-proxy.d.ts.map +1 -0
- package/dist/core/expressions/expression-proxy.js +227 -0
- package/dist/core/expressions/expression-proxy.js.map +1 -0
- package/dist/core/expressions/factory-integration.d.ts +132 -0
- package/dist/core/expressions/factory-integration.d.ts.map +1 -0
- package/dist/core/expressions/factory-integration.js +327 -0
- package/dist/core/expressions/factory-integration.js.map +1 -0
- package/dist/core/expressions/factory-pattern-handler.d.ts +88 -0
- package/dist/core/expressions/factory-pattern-handler.d.ts.map +1 -0
- package/dist/core/expressions/factory-pattern-handler.js +336 -0
- package/dist/core/expressions/factory-pattern-handler.js.map +1 -0
- package/dist/core/expressions/field-hydration-processor.d.ts +188 -0
- package/dist/core/expressions/field-hydration-processor.d.ts.map +1 -0
- package/dist/core/expressions/field-hydration-processor.js +562 -0
- package/dist/core/expressions/field-hydration-processor.js.map +1 -0
- package/dist/core/expressions/imperative-analyzer.d.ts +21 -0
- package/dist/core/expressions/imperative-analyzer.d.ts.map +1 -0
- package/dist/core/expressions/imperative-analyzer.js +457 -0
- package/dist/core/expressions/imperative-analyzer.js.map +1 -0
- package/dist/core/expressions/index.d.ts +54 -0
- package/dist/core/expressions/index.d.ts.map +1 -0
- package/dist/core/expressions/index.js +50 -0
- package/dist/core/expressions/index.js.map +1 -0
- package/dist/core/expressions/lazy-analysis.d.ts +1128 -0
- package/dist/core/expressions/lazy-analysis.d.ts.map +1 -0
- package/dist/core/expressions/lazy-analysis.js +2443 -0
- package/dist/core/expressions/lazy-analysis.js.map +1 -0
- package/dist/core/expressions/magic-assignable-analyzer.d.ts +123 -0
- package/dist/core/expressions/magic-assignable-analyzer.d.ts.map +1 -0
- package/dist/core/expressions/magic-assignable-analyzer.js +352 -0
- package/dist/core/expressions/magic-assignable-analyzer.js.map +1 -0
- package/dist/core/expressions/magic-proxy-analyzer.d.ts +206 -0
- package/dist/core/expressions/magic-proxy-analyzer.d.ts.map +1 -0
- package/dist/core/expressions/magic-proxy-analyzer.js +639 -0
- package/dist/core/expressions/magic-proxy-analyzer.js.map +1 -0
- package/dist/core/expressions/magic-proxy-detector.d.ts +154 -0
- package/dist/core/expressions/magic-proxy-detector.d.ts.map +1 -0
- package/dist/core/expressions/magic-proxy-detector.js +242 -0
- package/dist/core/expressions/magic-proxy-detector.js.map +1 -0
- package/dist/core/expressions/migration-helpers.d.ts +133 -0
- package/dist/core/expressions/migration-helpers.d.ts.map +1 -0
- package/dist/core/expressions/migration-helpers.js +443 -0
- package/dist/core/expressions/migration-helpers.js.map +1 -0
- package/dist/core/expressions/optionality-handler.d.ts +503 -0
- package/dist/core/expressions/optionality-handler.d.ts.map +1 -0
- package/dist/core/expressions/optionality-handler.js +1306 -0
- package/dist/core/expressions/optionality-handler.js.map +1 -0
- package/dist/core/expressions/readiness-integration.d.ts +119 -0
- package/dist/core/expressions/readiness-integration.d.ts.map +1 -0
- package/dist/core/expressions/readiness-integration.js +386 -0
- package/dist/core/expressions/readiness-integration.js.map +1 -0
- package/dist/core/expressions/resource-analyzer.d.ts +486 -0
- package/dist/core/expressions/resource-analyzer.d.ts.map +1 -0
- package/dist/core/expressions/resource-analyzer.js +1086 -0
- package/dist/core/expressions/resource-analyzer.js.map +1 -0
- package/dist/core/expressions/resource-validation.d.ts +187 -0
- package/dist/core/expressions/resource-validation.d.ts.map +1 -0
- package/dist/core/expressions/resource-validation.js +552 -0
- package/dist/core/expressions/resource-validation.js.map +1 -0
- package/dist/core/expressions/runtime-error-mapper.d.ts +138 -0
- package/dist/core/expressions/runtime-error-mapper.d.ts.map +1 -0
- package/dist/core/expressions/runtime-error-mapper.js +412 -0
- package/dist/core/expressions/runtime-error-mapper.js.map +1 -0
- package/dist/core/expressions/source-map.d.ts +168 -0
- package/dist/core/expressions/source-map.d.ts.map +1 -0
- package/dist/core/expressions/source-map.js +350 -0
- package/dist/core/expressions/source-map.js.map +1 -0
- package/dist/core/expressions/status-builder-analyzer.d.ts +353 -0
- package/dist/core/expressions/status-builder-analyzer.d.ts.map +1 -0
- package/dist/core/expressions/status-builder-analyzer.js +1311 -0
- package/dist/core/expressions/status-builder-analyzer.js.map +1 -0
- package/dist/core/expressions/type-inference.d.ts +184 -0
- package/dist/core/expressions/type-inference.d.ts.map +1 -0
- package/dist/core/expressions/type-inference.js +838 -0
- package/dist/core/expressions/type-inference.js.map +1 -0
- package/dist/core/expressions/type-safety.d.ts +203 -0
- package/dist/core/expressions/type-safety.d.ts.map +1 -0
- package/dist/core/expressions/type-safety.js +442 -0
- package/dist/core/expressions/type-safety.js.map +1 -0
- package/dist/core/expressions/types.d.ts +282 -0
- package/dist/core/expressions/types.d.ts.map +1 -0
- package/dist/core/expressions/types.js +8 -0
- package/dist/core/expressions/types.js.map +1 -0
- package/dist/core/kubernetes/client-provider.js +2 -2
- package/dist/core/kubernetes/client-provider.js.map +1 -1
- package/dist/core/references/cel.d.ts +13 -1
- package/dist/core/references/cel.d.ts.map +1 -1
- package/dist/core/references/cel.js +50 -0
- package/dist/core/references/cel.js.map +1 -1
- package/dist/core/references/schema-proxy.d.ts.map +1 -1
- package/dist/core/references/schema-proxy.js +13 -8
- package/dist/core/references/schema-proxy.js.map +1 -1
- package/dist/core/serialization/core.d.ts.map +1 -1
- package/dist/core/serialization/core.js +573 -9
- package/dist/core/serialization/core.js.map +1 -1
- package/dist/core/types/deployment.d.ts +7 -0
- package/dist/core/types/deployment.d.ts.map +1 -1
- package/dist/core/types/deployment.js +7 -0
- package/dist/core/types/deployment.js.map +1 -1
- package/dist/core/types/index.d.ts +1 -0
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/core/types/index.js.map +1 -1
- package/dist/core/validation/cel-validator.d.ts.map +1 -1
- package/dist/core/validation/cel-validator.js +4 -8
- package/dist/core/validation/cel-validator.js.map +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/factories/helm/helm-release.d.ts.map +1 -1
- package/dist/factories/helm/helm-release.js +0 -5
- package/dist/factories/helm/helm-release.js.map +1 -1
- package/dist/factories/helm/types.d.ts +1 -1
- package/dist/factories/helm/types.d.ts.map +1 -1
- package/dist/factories/index.js +1 -0
- package/dist/factories/index.js.map +1 -1
- package/dist/factories/shared.d.ts.map +1 -1
- package/dist/factories/shared.js +21 -1
- package/dist/factories/shared.js.map +1 -1
- package/dist/factories/simple/index.d.ts +2 -2
- package/dist/factories/simple/index.d.ts.map +1 -1
- package/dist/factories/simple/workloads/deployment.d.ts +3 -3
- package/dist/factories/simple/workloads/deployment.d.ts.map +1 -1
- package/dist/factories/simple/workloads/deployment.js +37 -11
- package/dist/factories/simple/workloads/deployment.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/type-guards.d.ts +6 -0
- package/dist/utils/type-guards.d.ts.map +1 -1
- package/dist/utils/type-guards.js +25 -2
- package/dist/utils/type-guards.js.map +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,1128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy Analysis Support for JavaScript to CEL Expression Conversion
|
|
3
|
+
*
|
|
4
|
+
* This module provides lazy evaluation capabilities for expressions containing
|
|
5
|
+
* KubernetesRef objects, optimizing performance by deferring analysis until
|
|
6
|
+
* the results are actually needed.
|
|
7
|
+
*/
|
|
8
|
+
import type { KubernetesRef, CelExpression } from '../types/common.js';
|
|
9
|
+
import type { AnalysisContext, CelConversionResult } from './analyzer.js';
|
|
10
|
+
import { JavaScriptToCelAnalyzer } from './analyzer.js';
|
|
11
|
+
import { ConversionError } from '../errors.js';
|
|
12
|
+
/**
|
|
13
|
+
* Lazy wrapper for expressions that may contain KubernetesRef objects
|
|
14
|
+
* Defers analysis until the CEL expression is actually needed
|
|
15
|
+
*/
|
|
16
|
+
export declare class LazyAnalyzedExpression {
|
|
17
|
+
private readonly _expression;
|
|
18
|
+
private readonly _context;
|
|
19
|
+
private _analyzed;
|
|
20
|
+
private _result;
|
|
21
|
+
private _error;
|
|
22
|
+
private readonly _analyzer;
|
|
23
|
+
constructor(_expression: any, _context: AnalysisContext, analyzer?: JavaScriptToCelAnalyzer);
|
|
24
|
+
/**
|
|
25
|
+
* Get the original expression without triggering analysis
|
|
26
|
+
*/
|
|
27
|
+
get originalExpression(): any;
|
|
28
|
+
/**
|
|
29
|
+
* Get the analysis context
|
|
30
|
+
*/
|
|
31
|
+
get context(): AnalysisContext;
|
|
32
|
+
/**
|
|
33
|
+
* Check if the expression has been analyzed yet
|
|
34
|
+
*/
|
|
35
|
+
get isAnalyzed(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Check if the expression requires conversion (contains KubernetesRef objects)
|
|
38
|
+
* This is a fast check that doesn't trigger full analysis
|
|
39
|
+
*/
|
|
40
|
+
get requiresConversion(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Check if the expression is static (no KubernetesRef objects)
|
|
43
|
+
* This is a fast check that doesn't trigger analysis
|
|
44
|
+
*/
|
|
45
|
+
get isStatic(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Get the analysis result, triggering analysis if not already done
|
|
48
|
+
*/
|
|
49
|
+
get result(): CelConversionResult;
|
|
50
|
+
/**
|
|
51
|
+
* Get the CEL expression, triggering analysis if needed
|
|
52
|
+
*/
|
|
53
|
+
get celExpression(): CelExpression | null;
|
|
54
|
+
/**
|
|
55
|
+
* Get the dependencies, triggering analysis if needed
|
|
56
|
+
*/
|
|
57
|
+
get dependencies(): KubernetesRef<any>[];
|
|
58
|
+
/**
|
|
59
|
+
* Get conversion errors, triggering analysis if needed
|
|
60
|
+
*/
|
|
61
|
+
get errors(): ConversionError[];
|
|
62
|
+
/**
|
|
63
|
+
* Check if the analysis was successful, triggering analysis if needed
|
|
64
|
+
*/
|
|
65
|
+
get isValid(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Force analysis to occur immediately
|
|
68
|
+
*/
|
|
69
|
+
analyze(): CelConversionResult;
|
|
70
|
+
/**
|
|
71
|
+
* Try to get the result without throwing errors
|
|
72
|
+
*/
|
|
73
|
+
tryGetResult(): {
|
|
74
|
+
success: boolean;
|
|
75
|
+
result?: CelConversionResult;
|
|
76
|
+
error?: Error;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Create a new lazy expression with a different context
|
|
80
|
+
*/
|
|
81
|
+
withContext(newContext: AnalysisContext): LazyAnalyzedExpression;
|
|
82
|
+
/**
|
|
83
|
+
* Create a new lazy expression with a different analyzer
|
|
84
|
+
*/
|
|
85
|
+
withAnalyzer(analyzer: JavaScriptToCelAnalyzer): LazyAnalyzedExpression;
|
|
86
|
+
/**
|
|
87
|
+
* Perform the actual analysis
|
|
88
|
+
*/
|
|
89
|
+
private _performAnalysis;
|
|
90
|
+
/**
|
|
91
|
+
* Reset the analysis state (for testing or re-analysis)
|
|
92
|
+
*/
|
|
93
|
+
reset(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Get a string representation for debugging
|
|
96
|
+
*/
|
|
97
|
+
toString(): string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Collection of lazy analyzed expressions for batch processing
|
|
101
|
+
*/
|
|
102
|
+
export declare class LazyExpressionCollection {
|
|
103
|
+
private readonly _expressions;
|
|
104
|
+
private readonly _analyzer;
|
|
105
|
+
constructor(analyzer?: JavaScriptToCelAnalyzer);
|
|
106
|
+
/**
|
|
107
|
+
* Add an expression to the collection
|
|
108
|
+
*/
|
|
109
|
+
add(key: string, expression: any, context: AnalysisContext): LazyAnalyzedExpression;
|
|
110
|
+
/**
|
|
111
|
+
* Get a lazy expression by key
|
|
112
|
+
*/
|
|
113
|
+
get(key: string): LazyAnalyzedExpression | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Check if an expression exists
|
|
116
|
+
*/
|
|
117
|
+
has(key: string): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Remove an expression
|
|
120
|
+
*/
|
|
121
|
+
remove(key: string): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Get all expression keys
|
|
124
|
+
*/
|
|
125
|
+
keys(): string[];
|
|
126
|
+
/**
|
|
127
|
+
* Get all lazy expressions
|
|
128
|
+
*/
|
|
129
|
+
values(): LazyAnalyzedExpression[];
|
|
130
|
+
/**
|
|
131
|
+
* Get all entries
|
|
132
|
+
*/
|
|
133
|
+
entries(): [string, LazyAnalyzedExpression][];
|
|
134
|
+
/**
|
|
135
|
+
* Get the number of expressions
|
|
136
|
+
*/
|
|
137
|
+
get size(): number;
|
|
138
|
+
/**
|
|
139
|
+
* Check how many expressions require conversion
|
|
140
|
+
*/
|
|
141
|
+
get requiresConversionCount(): number;
|
|
142
|
+
/**
|
|
143
|
+
* Check how many expressions are static
|
|
144
|
+
*/
|
|
145
|
+
get staticCount(): number;
|
|
146
|
+
/**
|
|
147
|
+
* Check how many expressions have been analyzed
|
|
148
|
+
*/
|
|
149
|
+
get analyzedCount(): number;
|
|
150
|
+
/**
|
|
151
|
+
* Analyze all expressions that require conversion
|
|
152
|
+
*/
|
|
153
|
+
analyzeAll(): Map<string, CelConversionResult>;
|
|
154
|
+
/**
|
|
155
|
+
* Analyze expressions in parallel (for independent expressions)
|
|
156
|
+
*/
|
|
157
|
+
analyzeAllParallel(): Promise<Map<string, CelConversionResult>>;
|
|
158
|
+
/**
|
|
159
|
+
* Get statistics about the collection
|
|
160
|
+
*/
|
|
161
|
+
getStats(): LazyCollectionStats;
|
|
162
|
+
/**
|
|
163
|
+
* Clear all expressions
|
|
164
|
+
*/
|
|
165
|
+
clear(): void;
|
|
166
|
+
/**
|
|
167
|
+
* Reset analysis state for all expressions
|
|
168
|
+
*/
|
|
169
|
+
resetAll(): void;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Statistics about a lazy expression collection
|
|
173
|
+
*/
|
|
174
|
+
export interface LazyCollectionStats {
|
|
175
|
+
/** Total number of expressions */
|
|
176
|
+
total: number;
|
|
177
|
+
/** Number of expressions that require conversion */
|
|
178
|
+
requiresConversion: number;
|
|
179
|
+
/** Number of static expressions (no conversion needed) */
|
|
180
|
+
static: number;
|
|
181
|
+
/** Number of expressions that have been analyzed */
|
|
182
|
+
analyzed: number;
|
|
183
|
+
/** Number of expressions pending analysis */
|
|
184
|
+
pending: number;
|
|
185
|
+
/** Ratio of expressions requiring conversion (0-1) */
|
|
186
|
+
conversionRatio: number;
|
|
187
|
+
/** Analysis progress for expressions requiring conversion (0-1) */
|
|
188
|
+
analysisProgress: number;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Factory function to create lazy analyzed expressions
|
|
192
|
+
*/
|
|
193
|
+
export declare function createLazyExpression(expression: any, context: AnalysisContext, analyzer?: JavaScriptToCelAnalyzer): LazyAnalyzedExpression;
|
|
194
|
+
/**
|
|
195
|
+
* Factory function to create lazy expression collections
|
|
196
|
+
*/
|
|
197
|
+
export declare function createLazyCollection(analyzer?: JavaScriptToCelAnalyzer): LazyExpressionCollection;
|
|
198
|
+
/**
|
|
199
|
+
* On-demand expression analyzer that performs KubernetesRef detection and analysis
|
|
200
|
+
* only when results are actually needed
|
|
201
|
+
*/
|
|
202
|
+
export declare class OnDemandExpressionAnalyzer {
|
|
203
|
+
private readonly _analyzer;
|
|
204
|
+
private readonly _cache;
|
|
205
|
+
private _cacheHits;
|
|
206
|
+
private _cacheMisses;
|
|
207
|
+
constructor(analyzer?: JavaScriptToCelAnalyzer);
|
|
208
|
+
/**
|
|
209
|
+
* Create a lazy expression that will be analyzed on-demand
|
|
210
|
+
*/
|
|
211
|
+
createLazyExpression(expression: any, context: AnalysisContext, cacheKey?: string): LazyAnalyzedExpression;
|
|
212
|
+
/**
|
|
213
|
+
* Analyze an expression immediately if it contains KubernetesRef objects,
|
|
214
|
+
* otherwise return it as-is
|
|
215
|
+
*/
|
|
216
|
+
analyzeIfNeeded(expression: any, context: AnalysisContext): {
|
|
217
|
+
needsConversion: boolean;
|
|
218
|
+
result: any;
|
|
219
|
+
lazy?: LazyAnalyzedExpression;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Batch analyze multiple expressions, only processing those that need conversion
|
|
223
|
+
*/
|
|
224
|
+
batchAnalyze(expressions: Array<{
|
|
225
|
+
key: string;
|
|
226
|
+
expression: any;
|
|
227
|
+
context: AnalysisContext;
|
|
228
|
+
}>): Map<string, {
|
|
229
|
+
needsConversion: boolean;
|
|
230
|
+
result: any;
|
|
231
|
+
lazy?: LazyAnalyzedExpression;
|
|
232
|
+
}>;
|
|
233
|
+
/**
|
|
234
|
+
* Get cache statistics
|
|
235
|
+
*/
|
|
236
|
+
getCacheStats(): {
|
|
237
|
+
hits: number;
|
|
238
|
+
misses: number;
|
|
239
|
+
size: number;
|
|
240
|
+
hitRatio: number;
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Clear the cache
|
|
244
|
+
*/
|
|
245
|
+
clearCache(): void;
|
|
246
|
+
/**
|
|
247
|
+
* Generate a cache key for an expression and context
|
|
248
|
+
*/
|
|
249
|
+
private _generateCacheKey;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Expression tree analyzer for complex nested expressions with KubernetesRef objects
|
|
253
|
+
*/
|
|
254
|
+
export declare class ExpressionTreeAnalyzer {
|
|
255
|
+
private readonly _onDemandAnalyzer;
|
|
256
|
+
constructor(analyzer?: JavaScriptToCelAnalyzer);
|
|
257
|
+
/**
|
|
258
|
+
* Analyze a complex expression tree, creating lazy expressions for branches
|
|
259
|
+
* that contain KubernetesRef objects
|
|
260
|
+
*/
|
|
261
|
+
analyzeTree(expressionTree: any, context: AnalysisContext, path?: string[]): ExpressionTreeResult;
|
|
262
|
+
/**
|
|
263
|
+
* Get all lazy expressions from a tree result
|
|
264
|
+
*/
|
|
265
|
+
getAllLazyExpressions(treeResult: ExpressionTreeResult): LazyAnalyzedExpression[];
|
|
266
|
+
/**
|
|
267
|
+
* Get statistics about the expression tree
|
|
268
|
+
*/
|
|
269
|
+
getTreeStats(treeResult: ExpressionTreeResult): ExpressionTreeStats;
|
|
270
|
+
/**
|
|
271
|
+
* Check if a value is a primitive type
|
|
272
|
+
*/
|
|
273
|
+
private _isPrimitive;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Result of analyzing an expression tree
|
|
277
|
+
*/
|
|
278
|
+
export interface ExpressionTreeResult {
|
|
279
|
+
/** Path to this node in the tree */
|
|
280
|
+
path: string[];
|
|
281
|
+
/** Whether this node or its children need conversion */
|
|
282
|
+
needsConversion: boolean;
|
|
283
|
+
/** Static value if no conversion is needed */
|
|
284
|
+
staticValue: any;
|
|
285
|
+
/** Lazy expression if conversion is needed */
|
|
286
|
+
lazyExpression: LazyAnalyzedExpression | null;
|
|
287
|
+
/** Child nodes */
|
|
288
|
+
children: Map<string, ExpressionTreeResult>;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Statistics about an expression tree
|
|
292
|
+
*/
|
|
293
|
+
export interface ExpressionTreeStats {
|
|
294
|
+
/** Total number of nodes in the tree */
|
|
295
|
+
totalNodes: number;
|
|
296
|
+
/** Number of nodes that need lazy analysis */
|
|
297
|
+
lazyNodes: number;
|
|
298
|
+
/** Number of static nodes */
|
|
299
|
+
staticNodes: number;
|
|
300
|
+
/** Maximum depth of the tree */
|
|
301
|
+
maxDepth: number;
|
|
302
|
+
/** Ratio of lazy nodes to total nodes */
|
|
303
|
+
lazyRatio: number;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Global on-demand analyzer instance
|
|
307
|
+
*/
|
|
308
|
+
export declare const globalOnDemandAnalyzer: OnDemandExpressionAnalyzer;
|
|
309
|
+
/**
|
|
310
|
+
* Lazy loading manager for complex expression trees with magic proxy integration
|
|
311
|
+
*/
|
|
312
|
+
export declare class LazyExpressionTreeLoader {
|
|
313
|
+
private readonly _treeAnalyzer;
|
|
314
|
+
private readonly _loadedTrees;
|
|
315
|
+
private readonly _loadingPromises;
|
|
316
|
+
private _loadCount;
|
|
317
|
+
constructor(analyzer?: JavaScriptToCelAnalyzer);
|
|
318
|
+
/**
|
|
319
|
+
* Load an expression tree lazily, returning immediately with a promise
|
|
320
|
+
*/
|
|
321
|
+
loadTree(expressionTree: any, context: AnalysisContext, treeId?: string): Promise<ExpressionTreeResult>;
|
|
322
|
+
/**
|
|
323
|
+
* Load multiple trees in parallel
|
|
324
|
+
*/
|
|
325
|
+
loadTrees(trees: Array<{
|
|
326
|
+
tree: any;
|
|
327
|
+
context: AnalysisContext;
|
|
328
|
+
id?: string;
|
|
329
|
+
}>): Promise<Map<string, ExpressionTreeResult>>;
|
|
330
|
+
/**
|
|
331
|
+
* Get a tree if it's already loaded, otherwise return null
|
|
332
|
+
*/
|
|
333
|
+
getLoadedTree(treeId: string): ExpressionTreeResult | null;
|
|
334
|
+
/**
|
|
335
|
+
* Check if a tree is currently being loaded
|
|
336
|
+
*/
|
|
337
|
+
isLoading(treeId: string): boolean;
|
|
338
|
+
/**
|
|
339
|
+
* Check if a tree is loaded
|
|
340
|
+
*/
|
|
341
|
+
isLoaded(treeId: string): boolean;
|
|
342
|
+
/**
|
|
343
|
+
* Preload trees that are likely to be needed soon
|
|
344
|
+
*/
|
|
345
|
+
preloadTrees(trees: Array<{
|
|
346
|
+
tree: any;
|
|
347
|
+
context: AnalysisContext;
|
|
348
|
+
id?: string;
|
|
349
|
+
priority?: number;
|
|
350
|
+
}>): Promise<void>;
|
|
351
|
+
/**
|
|
352
|
+
* Get loading statistics
|
|
353
|
+
*/
|
|
354
|
+
getStats(): LazyTreeLoaderStats;
|
|
355
|
+
/**
|
|
356
|
+
* Clear loaded trees to free memory
|
|
357
|
+
*/
|
|
358
|
+
clearCache(): void;
|
|
359
|
+
/**
|
|
360
|
+
* Perform the actual tree loading
|
|
361
|
+
*/
|
|
362
|
+
private _performTreeLoad;
|
|
363
|
+
/**
|
|
364
|
+
* Generate a unique ID for a tree
|
|
365
|
+
*/
|
|
366
|
+
private _generateTreeId;
|
|
367
|
+
/**
|
|
368
|
+
* Estimate memory usage of loaded trees
|
|
369
|
+
*/
|
|
370
|
+
private _estimateMemoryUsage;
|
|
371
|
+
/**
|
|
372
|
+
* Estimate the size of a tree result
|
|
373
|
+
*/
|
|
374
|
+
private _estimateTreeSize;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Magic proxy integration for lazy expression loading
|
|
378
|
+
*/
|
|
379
|
+
export declare class MagicProxyLazyIntegration {
|
|
380
|
+
private readonly _treeLoader;
|
|
381
|
+
private readonly _proxyCache;
|
|
382
|
+
constructor(analyzer?: JavaScriptToCelAnalyzer);
|
|
383
|
+
/**
|
|
384
|
+
* Create a lazy proxy for a complex object that may contain KubernetesRef objects
|
|
385
|
+
*/
|
|
386
|
+
createLazyProxy<T extends object>(target: T, context: AnalysisContext, options?: LazyProxyOptions): T;
|
|
387
|
+
/**
|
|
388
|
+
* Load expression trees for all KubernetesRef-containing values in an object
|
|
389
|
+
*/
|
|
390
|
+
preloadObjectTrees(obj: any, context: AnalysisContext, maxDepth?: number): Promise<void>;
|
|
391
|
+
/**
|
|
392
|
+
* Get statistics about the magic proxy integration
|
|
393
|
+
*/
|
|
394
|
+
getStats(): MagicProxyIntegrationStats;
|
|
395
|
+
/**
|
|
396
|
+
* Clear all caches
|
|
397
|
+
*/
|
|
398
|
+
clearCaches(): void;
|
|
399
|
+
/**
|
|
400
|
+
* Create a lazy value wrapper
|
|
401
|
+
*/
|
|
402
|
+
private _createLazyValue;
|
|
403
|
+
/**
|
|
404
|
+
* Check if a value is simple (not an object or array)
|
|
405
|
+
*/
|
|
406
|
+
private _isSimpleValue;
|
|
407
|
+
/**
|
|
408
|
+
* Generate a unique ID for a proxy
|
|
409
|
+
*/
|
|
410
|
+
private _generateProxyId;
|
|
411
|
+
/**
|
|
412
|
+
* Invalidate cache entries related to a proxy
|
|
413
|
+
*/
|
|
414
|
+
private _invalidateCache;
|
|
415
|
+
/**
|
|
416
|
+
* Collect trees from an object recursively
|
|
417
|
+
*/
|
|
418
|
+
private _collectTreesFromObject;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Options for creating lazy proxies
|
|
422
|
+
*/
|
|
423
|
+
export interface LazyProxyOptions {
|
|
424
|
+
/** Unique identifier for the proxy */
|
|
425
|
+
id?: string;
|
|
426
|
+
/** Maximum depth to traverse for preloading */
|
|
427
|
+
maxDepth?: number;
|
|
428
|
+
/** Whether to preload trees immediately */
|
|
429
|
+
preload?: boolean;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Statistics about lazy tree loading
|
|
433
|
+
*/
|
|
434
|
+
export interface LazyTreeLoaderStats {
|
|
435
|
+
/** Number of loaded trees */
|
|
436
|
+
loadedTrees: number;
|
|
437
|
+
/** Number of trees currently loading */
|
|
438
|
+
loadingTrees: number;
|
|
439
|
+
/** Total number of load operations */
|
|
440
|
+
totalLoads: number;
|
|
441
|
+
/** Estimated memory usage in bytes */
|
|
442
|
+
memoryUsage: number;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Statistics about magic proxy integration
|
|
446
|
+
*/
|
|
447
|
+
export interface MagicProxyIntegrationStats {
|
|
448
|
+
/** Number of cached proxies */
|
|
449
|
+
cachedProxies: number;
|
|
450
|
+
/** Tree loader statistics */
|
|
451
|
+
treeLoaderStats: LazyTreeLoaderStats;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Global lazy tree loader instance
|
|
455
|
+
*/
|
|
456
|
+
export declare const globalLazyTreeLoader: LazyExpressionTreeLoader;
|
|
457
|
+
/**
|
|
458
|
+
* Memory-optimized expression manager for large sets of KubernetesRef-containing expressions
|
|
459
|
+
*/
|
|
460
|
+
export declare class MemoryOptimizedExpressionManager {
|
|
461
|
+
private readonly _expressions;
|
|
462
|
+
private readonly _expressionSizes;
|
|
463
|
+
private readonly _accessTimes;
|
|
464
|
+
private readonly _analyzer;
|
|
465
|
+
private _totalMemoryUsage;
|
|
466
|
+
private _maxMemoryUsage;
|
|
467
|
+
private _cleanupThreshold;
|
|
468
|
+
private _lastCleanup;
|
|
469
|
+
constructor(analyzer?: JavaScriptToCelAnalyzer, options?: MemoryOptimizationOptions);
|
|
470
|
+
/**
|
|
471
|
+
* Create or retrieve a lazy expression with memory management
|
|
472
|
+
*/
|
|
473
|
+
getOrCreateExpression(key: string, expression: any, context: AnalysisContext): LazyAnalyzedExpression;
|
|
474
|
+
/**
|
|
475
|
+
* Batch create expressions with memory optimization
|
|
476
|
+
*/
|
|
477
|
+
batchCreateExpressions(expressions: Array<{
|
|
478
|
+
key: string;
|
|
479
|
+
expression: any;
|
|
480
|
+
context: AnalysisContext;
|
|
481
|
+
}>): Map<string, LazyAnalyzedExpression>;
|
|
482
|
+
/**
|
|
483
|
+
* Get memory usage statistics
|
|
484
|
+
*/
|
|
485
|
+
getMemoryStats(): MemoryStats;
|
|
486
|
+
/**
|
|
487
|
+
* Force cleanup of unused expressions
|
|
488
|
+
*/
|
|
489
|
+
forceCleanup(): MemoryCleanupResult;
|
|
490
|
+
/**
|
|
491
|
+
* Set memory limits
|
|
492
|
+
*/
|
|
493
|
+
setMemoryLimits(maxMemoryUsage: number, cleanupThreshold: number): void;
|
|
494
|
+
/**
|
|
495
|
+
* Clear all expressions
|
|
496
|
+
*/
|
|
497
|
+
clear(): void;
|
|
498
|
+
/**
|
|
499
|
+
* Get expressions that are likely to be garbage collected soon
|
|
500
|
+
*/
|
|
501
|
+
getExpiringExpressions(): string[];
|
|
502
|
+
/**
|
|
503
|
+
* Estimate the memory size of an expression
|
|
504
|
+
*/
|
|
505
|
+
private _estimateExpressionSize;
|
|
506
|
+
/**
|
|
507
|
+
* Check if cleanup is needed
|
|
508
|
+
*/
|
|
509
|
+
private _shouldCleanup;
|
|
510
|
+
/**
|
|
511
|
+
* Perform memory cleanup
|
|
512
|
+
*/
|
|
513
|
+
private _performCleanup;
|
|
514
|
+
/**
|
|
515
|
+
* Clean up dead weak references
|
|
516
|
+
*/
|
|
517
|
+
private _cleanupDeadReferences;
|
|
518
|
+
/**
|
|
519
|
+
* Clean up least recently used expressions
|
|
520
|
+
*/
|
|
521
|
+
private _cleanupLRU;
|
|
522
|
+
/**
|
|
523
|
+
* Clean up a single expression
|
|
524
|
+
*/
|
|
525
|
+
private _cleanupExpression;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Advanced parallel expression analyzer for independent expressions with KubernetesRef objects
|
|
529
|
+
*/
|
|
530
|
+
export declare class ParallelExpressionAnalyzer {
|
|
531
|
+
private readonly _analyzer;
|
|
532
|
+
private readonly _maxConcurrency;
|
|
533
|
+
private readonly _detector;
|
|
534
|
+
private _activeAnalyses;
|
|
535
|
+
private _totalAnalyses;
|
|
536
|
+
private _completedAnalyses;
|
|
537
|
+
private _failedAnalyses;
|
|
538
|
+
constructor(analyzer?: JavaScriptToCelAnalyzer, maxConcurrency?: number, detector?: OptimizedKubernetesRefDetector);
|
|
539
|
+
/**
|
|
540
|
+
* Analyze multiple expressions in parallel with advanced scheduling
|
|
541
|
+
*/
|
|
542
|
+
analyzeParallel(expressions: Array<{
|
|
543
|
+
key: string;
|
|
544
|
+
expression: any;
|
|
545
|
+
context: AnalysisContext;
|
|
546
|
+
}>): Promise<Map<string, CelConversionResult>>;
|
|
547
|
+
/**
|
|
548
|
+
* Analyze expressions with priority-based scheduling and dependency resolution
|
|
549
|
+
*/
|
|
550
|
+
analyzePrioritized(expressions: Array<{
|
|
551
|
+
key: string;
|
|
552
|
+
expression: any;
|
|
553
|
+
context: AnalysisContext;
|
|
554
|
+
priority: number;
|
|
555
|
+
dependencies?: string[];
|
|
556
|
+
}>): Promise<Map<string, CelConversionResult>>;
|
|
557
|
+
/**
|
|
558
|
+
* Analyze expressions with adaptive concurrency based on system load
|
|
559
|
+
*/
|
|
560
|
+
analyzeAdaptive(expressions: Array<{
|
|
561
|
+
key: string;
|
|
562
|
+
expression: any;
|
|
563
|
+
context: AnalysisContext;
|
|
564
|
+
}>, options?: AdaptiveAnalysisOptions): Promise<Map<string, CelConversionResult>>;
|
|
565
|
+
/**
|
|
566
|
+
* Stream analysis results as they complete
|
|
567
|
+
*/
|
|
568
|
+
analyzeStream(expressions: Array<{
|
|
569
|
+
key: string;
|
|
570
|
+
expression: any;
|
|
571
|
+
context: AnalysisContext;
|
|
572
|
+
}>): AsyncGenerator<{
|
|
573
|
+
key: string;
|
|
574
|
+
result: CelConversionResult;
|
|
575
|
+
progress: number;
|
|
576
|
+
}>;
|
|
577
|
+
/**
|
|
578
|
+
* Get comprehensive analysis statistics
|
|
579
|
+
*/
|
|
580
|
+
getStats(): AdvancedParallelAnalysisStats;
|
|
581
|
+
/**
|
|
582
|
+
* Create work queue with complexity analysis
|
|
583
|
+
*/
|
|
584
|
+
private _createWorkQueue;
|
|
585
|
+
/**
|
|
586
|
+
* Process work queue in parallel
|
|
587
|
+
*/
|
|
588
|
+
private _processWorkQueue;
|
|
589
|
+
/**
|
|
590
|
+
* Process a batch of work items
|
|
591
|
+
*/
|
|
592
|
+
private _processBatch;
|
|
593
|
+
/**
|
|
594
|
+
* Build dependency graph for expressions
|
|
595
|
+
*/
|
|
596
|
+
private _buildDependencyGraph;
|
|
597
|
+
/**
|
|
598
|
+
* Topological sort for dependency resolution
|
|
599
|
+
*/
|
|
600
|
+
private _topologicalSort;
|
|
601
|
+
/**
|
|
602
|
+
* Group expressions by priority
|
|
603
|
+
*/
|
|
604
|
+
private _groupByPriority;
|
|
605
|
+
/**
|
|
606
|
+
* Calculate expression complexity
|
|
607
|
+
*/
|
|
608
|
+
private _calculateComplexity;
|
|
609
|
+
/**
|
|
610
|
+
* Create batches for parallel processing
|
|
611
|
+
*/
|
|
612
|
+
private _createBatches;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Options for adaptive analysis
|
|
616
|
+
*/
|
|
617
|
+
export interface AdaptiveAnalysisOptions {
|
|
618
|
+
/** Initial concurrency level */
|
|
619
|
+
initialConcurrency?: number;
|
|
620
|
+
/** Maximum concurrency level */
|
|
621
|
+
maxConcurrency?: number;
|
|
622
|
+
/** Minimum concurrency level */
|
|
623
|
+
minConcurrency?: number;
|
|
624
|
+
/** Interval for adaptation in milliseconds */
|
|
625
|
+
adaptationInterval?: number;
|
|
626
|
+
/** Performance threshold in milliseconds */
|
|
627
|
+
performanceThreshold?: number;
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Advanced parallel analysis statistics
|
|
631
|
+
*/
|
|
632
|
+
export interface AdvancedParallelAnalysisStats extends ParallelAnalysisStats {
|
|
633
|
+
/** Total number of analyses started */
|
|
634
|
+
totalAnalyses: number;
|
|
635
|
+
/** Number of completed analyses */
|
|
636
|
+
completedAnalyses: number;
|
|
637
|
+
/** Number of failed analyses */
|
|
638
|
+
failedAnalyses: number;
|
|
639
|
+
/** Success rate (0-1) */
|
|
640
|
+
successRate: number;
|
|
641
|
+
/** Detector cache statistics */
|
|
642
|
+
detectorStats: {
|
|
643
|
+
hits: number;
|
|
644
|
+
misses: number;
|
|
645
|
+
hitRatio: number;
|
|
646
|
+
size: number;
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Memory optimization options
|
|
651
|
+
*/
|
|
652
|
+
export interface MemoryOptimizationOptions {
|
|
653
|
+
/** Maximum memory usage in bytes */
|
|
654
|
+
maxMemoryUsage?: number;
|
|
655
|
+
/** Cleanup threshold (0-1) */
|
|
656
|
+
cleanupThreshold?: number;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Memory usage statistics
|
|
660
|
+
*/
|
|
661
|
+
export interface MemoryStats {
|
|
662
|
+
/** Total number of expressions */
|
|
663
|
+
totalExpressions: number;
|
|
664
|
+
/** Total memory usage in bytes */
|
|
665
|
+
totalMemoryUsage: number;
|
|
666
|
+
/** Maximum allowed memory usage */
|
|
667
|
+
maxMemoryUsage: number;
|
|
668
|
+
/** Memory utilization ratio (0-1) */
|
|
669
|
+
memoryUtilization: number;
|
|
670
|
+
/** Average expression size in bytes */
|
|
671
|
+
averageExpressionSize: number;
|
|
672
|
+
/** Timestamp of last cleanup */
|
|
673
|
+
lastCleanup: number;
|
|
674
|
+
/** Whether cleanup is needed */
|
|
675
|
+
needsCleanup: boolean;
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Memory cleanup result
|
|
679
|
+
*/
|
|
680
|
+
export interface MemoryCleanupResult {
|
|
681
|
+
/** Cleanup duration in milliseconds */
|
|
682
|
+
duration: number;
|
|
683
|
+
/** Initial memory usage */
|
|
684
|
+
initialMemoryUsage: number;
|
|
685
|
+
/** Final memory usage */
|
|
686
|
+
finalMemoryUsage: number;
|
|
687
|
+
/** Amount of memory freed */
|
|
688
|
+
freedMemory: number;
|
|
689
|
+
/** Initial expression count */
|
|
690
|
+
initialExpressionCount: number;
|
|
691
|
+
/** Final expression count */
|
|
692
|
+
finalExpressionCount: number;
|
|
693
|
+
/** Number of expressions cleaned */
|
|
694
|
+
cleanedExpressions: number;
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Parallel analysis statistics
|
|
698
|
+
*/
|
|
699
|
+
export interface ParallelAnalysisStats {
|
|
700
|
+
/** Maximum concurrency level */
|
|
701
|
+
maxConcurrency: number;
|
|
702
|
+
/** Currently active analyses */
|
|
703
|
+
activeAnalyses: number;
|
|
704
|
+
/** Utilization ratio (0-1) */
|
|
705
|
+
utilizationRatio: number;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Global memory-optimized expression manager
|
|
709
|
+
*/
|
|
710
|
+
export declare const globalMemoryOptimizedManager: MemoryOptimizedExpressionManager;
|
|
711
|
+
/**
|
|
712
|
+
* Performance profiler for expression analysis with KubernetesRef detection
|
|
713
|
+
*/
|
|
714
|
+
export declare class ExpressionAnalysisProfiler {
|
|
715
|
+
private readonly _profiles;
|
|
716
|
+
private readonly _analyzer;
|
|
717
|
+
private _enabled;
|
|
718
|
+
constructor(analyzer?: JavaScriptToCelAnalyzer);
|
|
719
|
+
/**
|
|
720
|
+
* Enable or disable profiling
|
|
721
|
+
*/
|
|
722
|
+
setEnabled(enabled: boolean): void;
|
|
723
|
+
/**
|
|
724
|
+
* Profile expression analysis performance
|
|
725
|
+
*/
|
|
726
|
+
profileExpression(expression: any, context: AnalysisContext, profileId?: string): {
|
|
727
|
+
result: CelConversionResult;
|
|
728
|
+
profile: PerformanceProfile;
|
|
729
|
+
};
|
|
730
|
+
/**
|
|
731
|
+
* Profile multiple expressions in batch
|
|
732
|
+
*/
|
|
733
|
+
profileBatch(expressions: Array<{
|
|
734
|
+
expression: any;
|
|
735
|
+
context: AnalysisContext;
|
|
736
|
+
id?: string;
|
|
737
|
+
}>): Map<string, {
|
|
738
|
+
result: CelConversionResult;
|
|
739
|
+
profile: PerformanceProfile;
|
|
740
|
+
}>;
|
|
741
|
+
/**
|
|
742
|
+
* Get performance statistics
|
|
743
|
+
*/
|
|
744
|
+
getStats(): PerformanceStats;
|
|
745
|
+
/**
|
|
746
|
+
* Get profiles that exceed performance thresholds
|
|
747
|
+
*/
|
|
748
|
+
getSlowProfiles(durationThreshold?: number): PerformanceProfile[];
|
|
749
|
+
/**
|
|
750
|
+
* Get profiles with high KubernetesRef detection overhead
|
|
751
|
+
*/
|
|
752
|
+
getHighOverheadProfiles(overheadThreshold?: number): PerformanceProfile[];
|
|
753
|
+
/**
|
|
754
|
+
* Clear all profiles
|
|
755
|
+
*/
|
|
756
|
+
clearProfiles(): void;
|
|
757
|
+
/**
|
|
758
|
+
* Export profiles for analysis
|
|
759
|
+
*/
|
|
760
|
+
exportProfiles(): PerformanceProfile[];
|
|
761
|
+
/**
|
|
762
|
+
* Generate a profile ID
|
|
763
|
+
*/
|
|
764
|
+
private _generateProfileId;
|
|
765
|
+
/**
|
|
766
|
+
* Calculate expression complexity score
|
|
767
|
+
*/
|
|
768
|
+
private _calculateComplexity;
|
|
769
|
+
/**
|
|
770
|
+
* Estimate memory usage
|
|
771
|
+
*/
|
|
772
|
+
private _estimateMemoryUsage;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Performance profile for an expression analysis
|
|
776
|
+
*/
|
|
777
|
+
export interface PerformanceProfile {
|
|
778
|
+
/** Unique profile ID */
|
|
779
|
+
id: string;
|
|
780
|
+
/** Original expression */
|
|
781
|
+
expression: string;
|
|
782
|
+
/** Start time (performance.now()) */
|
|
783
|
+
startTime: number;
|
|
784
|
+
/** End time (performance.now()) */
|
|
785
|
+
endTime: number;
|
|
786
|
+
/** Total duration in milliseconds */
|
|
787
|
+
duration: number;
|
|
788
|
+
/** Time spent on KubernetesRef detection */
|
|
789
|
+
kubernetesRefDetectionTime: number;
|
|
790
|
+
/** Time spent on AST parsing */
|
|
791
|
+
astParsingTime: number;
|
|
792
|
+
/** Time spent on CEL generation */
|
|
793
|
+
celGenerationTime: number;
|
|
794
|
+
/** Estimated memory usage in bytes */
|
|
795
|
+
memoryUsage: number;
|
|
796
|
+
/** Number of KubernetesRef objects found */
|
|
797
|
+
kubernetesRefCount: number;
|
|
798
|
+
/** Expression complexity score */
|
|
799
|
+
expressionComplexity: number;
|
|
800
|
+
/** Whether this was a cache hit */
|
|
801
|
+
cacheHit: boolean;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Performance statistics
|
|
805
|
+
*/
|
|
806
|
+
export interface PerformanceStats {
|
|
807
|
+
/** Total number of profiles */
|
|
808
|
+
totalProfiles: number;
|
|
809
|
+
/** Average analysis duration */
|
|
810
|
+
averageDuration: number;
|
|
811
|
+
/** Average KubernetesRef detection time */
|
|
812
|
+
averageKubernetesRefDetectionTime: number;
|
|
813
|
+
/** Average CEL generation time */
|
|
814
|
+
averageCelGenerationTime: number;
|
|
815
|
+
/** Average memory usage */
|
|
816
|
+
averageMemoryUsage: number;
|
|
817
|
+
/** Average KubernetesRef count */
|
|
818
|
+
averageKubernetesRefCount: number;
|
|
819
|
+
/** Average complexity score */
|
|
820
|
+
averageComplexity: number;
|
|
821
|
+
/** Slowest expression profile */
|
|
822
|
+
slowestExpression: PerformanceProfile | null;
|
|
823
|
+
/** Fastest expression profile */
|
|
824
|
+
fastestExpression: PerformanceProfile | null;
|
|
825
|
+
/** Most complex expression profile */
|
|
826
|
+
mostComplexExpression: PerformanceProfile | null;
|
|
827
|
+
/** Cache hit ratio (0-1) */
|
|
828
|
+
cacheHitRatio: number;
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Optimized KubernetesRef detector with caching and fast paths
|
|
832
|
+
*/
|
|
833
|
+
export declare class OptimizedKubernetesRefDetector {
|
|
834
|
+
private readonly _cache;
|
|
835
|
+
private readonly _refCache;
|
|
836
|
+
private _cacheHits;
|
|
837
|
+
private _cacheMisses;
|
|
838
|
+
private _maxCacheSize;
|
|
839
|
+
/**
|
|
840
|
+
* Fast detection of KubernetesRef objects with caching
|
|
841
|
+
*/
|
|
842
|
+
containsKubernetesRefs(value: unknown, useCache?: boolean): boolean;
|
|
843
|
+
/**
|
|
844
|
+
* Extract KubernetesRef objects with optimized traversal
|
|
845
|
+
*/
|
|
846
|
+
extractKubernetesRefs(value: unknown, useCache?: boolean): KubernetesRef<any>[];
|
|
847
|
+
/**
|
|
848
|
+
* Optimized traversal that stops early when possible
|
|
849
|
+
*/
|
|
850
|
+
traverseOptimized(value: unknown, callback: (value: unknown, path: string[]) => boolean | undefined, path?: string[], maxDepth?: number): boolean;
|
|
851
|
+
/**
|
|
852
|
+
* Get cache statistics
|
|
853
|
+
*/
|
|
854
|
+
getCacheStats(): {
|
|
855
|
+
hits: number;
|
|
856
|
+
misses: number;
|
|
857
|
+
hitRatio: number;
|
|
858
|
+
size: number;
|
|
859
|
+
};
|
|
860
|
+
/**
|
|
861
|
+
* Clear caches
|
|
862
|
+
*/
|
|
863
|
+
clearCache(): void;
|
|
864
|
+
/**
|
|
865
|
+
* Set maximum cache size
|
|
866
|
+
*/
|
|
867
|
+
setMaxCacheSize(size: number): void;
|
|
868
|
+
/**
|
|
869
|
+
* Uncached KubernetesRef detection with optimizations
|
|
870
|
+
*/
|
|
871
|
+
private _containsKubernetesRefsUncached;
|
|
872
|
+
/**
|
|
873
|
+
* Uncached KubernetesRef extraction with optimizations
|
|
874
|
+
*/
|
|
875
|
+
private _extractKubernetesRefsUncached;
|
|
876
|
+
/**
|
|
877
|
+
* Generate cache key for a value
|
|
878
|
+
*/
|
|
879
|
+
private _generateCacheKey;
|
|
880
|
+
/**
|
|
881
|
+
* Simple hash function for cache keys
|
|
882
|
+
*/
|
|
883
|
+
private _simpleHash;
|
|
884
|
+
/**
|
|
885
|
+
* Fast primitive check
|
|
886
|
+
*/
|
|
887
|
+
private _isPrimitive;
|
|
888
|
+
/**
|
|
889
|
+
* Fast KubernetesRef check
|
|
890
|
+
*/
|
|
891
|
+
isKubernetesRef(value: unknown): boolean;
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Optimized expression traverser for complex nested structures
|
|
895
|
+
*/
|
|
896
|
+
export declare class OptimizedExpressionTraverser {
|
|
897
|
+
private readonly _detector;
|
|
898
|
+
private readonly _visitedObjects;
|
|
899
|
+
constructor(detector?: OptimizedKubernetesRefDetector);
|
|
900
|
+
/**
|
|
901
|
+
* Traverse expression tree with cycle detection and optimization
|
|
902
|
+
*/
|
|
903
|
+
traverse(expression: any, visitor: (value: any, path: string[], context: TraversalContext) => TraversalAction, options?: TraversalOptions): TraversalResult;
|
|
904
|
+
/**
|
|
905
|
+
* Find all KubernetesRef objects efficiently
|
|
906
|
+
*/
|
|
907
|
+
findAllKubernetesRefs(expression: any, maxDepth?: number): KubernetesRef<any>[];
|
|
908
|
+
/**
|
|
909
|
+
* Check if expression contains KubernetesRefs efficiently
|
|
910
|
+
*/
|
|
911
|
+
hasKubernetesRefs(expression: any, maxDepth?: number): boolean;
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Traversal action returned by visitor functions
|
|
915
|
+
*/
|
|
916
|
+
export declare enum TraversalAction {
|
|
917
|
+
/** Continue normal traversal */
|
|
918
|
+
CONTINUE = "continue",
|
|
919
|
+
/** Skip this subtree */
|
|
920
|
+
SKIP = "skip",
|
|
921
|
+
/** Stop entire traversal */
|
|
922
|
+
STOP = "stop"
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Context provided to traversal visitors
|
|
926
|
+
*/
|
|
927
|
+
export interface TraversalContext {
|
|
928
|
+
/** Current depth in the tree */
|
|
929
|
+
depth: number;
|
|
930
|
+
/** Whether the current value is a KubernetesRef */
|
|
931
|
+
isKubernetesRef: boolean;
|
|
932
|
+
/** Whether the current value contains KubernetesRefs */
|
|
933
|
+
hasKubernetesRefs: boolean;
|
|
934
|
+
/** Path to the current value */
|
|
935
|
+
path: string[];
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Options for expression traversal
|
|
939
|
+
*/
|
|
940
|
+
export interface TraversalOptions {
|
|
941
|
+
/** Maximum depth to traverse */
|
|
942
|
+
maxDepth?: number;
|
|
943
|
+
/** Whether to detect and skip cycles */
|
|
944
|
+
detectCycles?: boolean;
|
|
945
|
+
/** Whether to skip duplicate objects */
|
|
946
|
+
skipDuplicates?: boolean;
|
|
947
|
+
/** Whether to enable early termination */
|
|
948
|
+
earlyTermination?: boolean;
|
|
949
|
+
}
|
|
950
|
+
/**
|
|
951
|
+
* Result of expression traversal
|
|
952
|
+
*/
|
|
953
|
+
export interface TraversalResult {
|
|
954
|
+
/** Number of nodes visited */
|
|
955
|
+
visited: number;
|
|
956
|
+
/** Number of nodes skipped */
|
|
957
|
+
skipped: number;
|
|
958
|
+
/** KubernetesRef objects found */
|
|
959
|
+
kubernetesRefs: KubernetesRef<any>[];
|
|
960
|
+
/** Whether maximum depth was reached */
|
|
961
|
+
maxDepthReached: boolean;
|
|
962
|
+
/** Number of cycles detected */
|
|
963
|
+
cyclesDetected: number;
|
|
964
|
+
/** Number of duplicates skipped */
|
|
965
|
+
duplicatesSkipped: number;
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Global optimized KubernetesRef detector
|
|
969
|
+
*/
|
|
970
|
+
export declare const globalOptimizedDetector: OptimizedKubernetesRefDetector;
|
|
971
|
+
/**
|
|
972
|
+
* Expression complexity analyzer with warnings for magic proxy usage
|
|
973
|
+
*/
|
|
974
|
+
export declare class ExpressionComplexityAnalyzer {
|
|
975
|
+
private readonly _detector;
|
|
976
|
+
private readonly _traverser;
|
|
977
|
+
private readonly _thresholds;
|
|
978
|
+
constructor(detector?: OptimizedKubernetesRefDetector, traverser?: OptimizedExpressionTraverser, thresholds?: Partial<ComplexityThresholds>);
|
|
979
|
+
/**
|
|
980
|
+
* Analyze expression complexity and generate warnings
|
|
981
|
+
*/
|
|
982
|
+
analyzeComplexity(expression: any): ComplexityAnalysisResult;
|
|
983
|
+
/**
|
|
984
|
+
* Batch analyze multiple expressions
|
|
985
|
+
*/
|
|
986
|
+
batchAnalyzeComplexity(expressions: Array<{
|
|
987
|
+
key: string;
|
|
988
|
+
expression: any;
|
|
989
|
+
}>): Map<string, ComplexityAnalysisResult>;
|
|
990
|
+
/**
|
|
991
|
+
* Get complexity statistics for a set of expressions
|
|
992
|
+
*/
|
|
993
|
+
getComplexityStats(expressions: Array<{
|
|
994
|
+
key: string;
|
|
995
|
+
expression: any;
|
|
996
|
+
}>): ComplexityStats;
|
|
997
|
+
/**
|
|
998
|
+
* Calculate syntactic complexity (based on syntax patterns)
|
|
999
|
+
*/
|
|
1000
|
+
private _calculateSyntacticComplexity;
|
|
1001
|
+
/**
|
|
1002
|
+
* Calculate structural complexity (based on nesting and object structure)
|
|
1003
|
+
*/
|
|
1004
|
+
private _calculateStructuralComplexity;
|
|
1005
|
+
/**
|
|
1006
|
+
* Calculate magic proxy complexity (based on KubernetesRef usage)
|
|
1007
|
+
*/
|
|
1008
|
+
private _calculateMagicProxyComplexity;
|
|
1009
|
+
/**
|
|
1010
|
+
* Calculate cyclomatic complexity (based on control flow)
|
|
1011
|
+
*/
|
|
1012
|
+
private _calculateCyclomaticComplexity;
|
|
1013
|
+
/**
|
|
1014
|
+
* Determine complexity level
|
|
1015
|
+
*/
|
|
1016
|
+
private _determineComplexityLevel;
|
|
1017
|
+
/**
|
|
1018
|
+
* Generate warnings based on complexity analysis
|
|
1019
|
+
*/
|
|
1020
|
+
private _generateWarnings;
|
|
1021
|
+
/**
|
|
1022
|
+
* Generate recommendations for reducing complexity
|
|
1023
|
+
*/
|
|
1024
|
+
private _generateRecommendations;
|
|
1025
|
+
/**
|
|
1026
|
+
* Estimate conversion time based on complexity
|
|
1027
|
+
*/
|
|
1028
|
+
private _estimateConversionTime;
|
|
1029
|
+
/**
|
|
1030
|
+
* Estimate memory impact
|
|
1031
|
+
*/
|
|
1032
|
+
private _estimateMemoryImpact;
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Complexity thresholds for different levels
|
|
1036
|
+
*/
|
|
1037
|
+
export interface ComplexityThresholds {
|
|
1038
|
+
low: number;
|
|
1039
|
+
medium: number;
|
|
1040
|
+
high: number;
|
|
1041
|
+
extreme: number;
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Complexity level
|
|
1045
|
+
*/
|
|
1046
|
+
export type ComplexityLevel = 'low' | 'medium' | 'high' | 'extreme';
|
|
1047
|
+
/**
|
|
1048
|
+
* Memory impact level
|
|
1049
|
+
*/
|
|
1050
|
+
export type MemoryImpact = 'low' | 'medium' | 'high' | 'extreme';
|
|
1051
|
+
/**
|
|
1052
|
+
* Complexity metrics
|
|
1053
|
+
*/
|
|
1054
|
+
export interface ComplexityMetrics {
|
|
1055
|
+
syntacticComplexity: number;
|
|
1056
|
+
structuralComplexity: number;
|
|
1057
|
+
magicProxyComplexity: number;
|
|
1058
|
+
cyclomaticComplexity: number;
|
|
1059
|
+
overallComplexity: number;
|
|
1060
|
+
level: ComplexityLevel;
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Complexity warning
|
|
1064
|
+
*/
|
|
1065
|
+
export interface ComplexityWarning {
|
|
1066
|
+
type: string;
|
|
1067
|
+
severity: 'info' | 'warning' | 'error';
|
|
1068
|
+
message: string;
|
|
1069
|
+
metric: string;
|
|
1070
|
+
value: number;
|
|
1071
|
+
threshold: number;
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Result of complexity analysis
|
|
1075
|
+
*/
|
|
1076
|
+
export interface ComplexityAnalysisResult extends ComplexityMetrics {
|
|
1077
|
+
expression: string;
|
|
1078
|
+
warnings: ComplexityWarning[];
|
|
1079
|
+
recommendations: string[];
|
|
1080
|
+
analysisTime: number;
|
|
1081
|
+
kubernetesRefCount: number;
|
|
1082
|
+
estimatedConversionTime: number;
|
|
1083
|
+
memoryImpact: MemoryImpact;
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Complexity statistics for a set of expressions
|
|
1087
|
+
*/
|
|
1088
|
+
export interface ComplexityStats {
|
|
1089
|
+
totalExpressions: number;
|
|
1090
|
+
averageComplexity: number;
|
|
1091
|
+
maxComplexity: number;
|
|
1092
|
+
minComplexity: number;
|
|
1093
|
+
complexityDistribution: Record<ComplexityLevel, number>;
|
|
1094
|
+
totalWarnings: number;
|
|
1095
|
+
averageWarnings: number;
|
|
1096
|
+
mostComplexExpression: ComplexityAnalysisResult | null;
|
|
1097
|
+
totalKubernetesRefs: number;
|
|
1098
|
+
averageKubernetesRefs: number;
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Global expression complexity analyzer
|
|
1102
|
+
*/
|
|
1103
|
+
export declare const globalComplexityAnalyzer: ExpressionComplexityAnalyzer;
|
|
1104
|
+
/**
|
|
1105
|
+
* Global optimized expression traverser
|
|
1106
|
+
*/
|
|
1107
|
+
export declare const globalOptimizedTraverser: OptimizedExpressionTraverser;
|
|
1108
|
+
/**
|
|
1109
|
+
* Global expression analysis profiler
|
|
1110
|
+
*/
|
|
1111
|
+
export declare const globalExpressionProfiler: ExpressionAnalysisProfiler;
|
|
1112
|
+
/**
|
|
1113
|
+
* Global parallel expression analyzer
|
|
1114
|
+
*/
|
|
1115
|
+
export declare const globalParallelAnalyzer: ParallelExpressionAnalyzer;
|
|
1116
|
+
/**
|
|
1117
|
+
* Global magic proxy integration instance
|
|
1118
|
+
*/
|
|
1119
|
+
export declare const globalMagicProxyIntegration: MagicProxyLazyIntegration;
|
|
1120
|
+
/**
|
|
1121
|
+
* Global expression tree analyzer instance
|
|
1122
|
+
*/
|
|
1123
|
+
export declare const globalTreeAnalyzer: ExpressionTreeAnalyzer;
|
|
1124
|
+
/**
|
|
1125
|
+
* Utility to check if a value should be wrapped in a lazy expression
|
|
1126
|
+
*/
|
|
1127
|
+
export declare function shouldUseLazyAnalysis(expression: any): boolean;
|
|
1128
|
+
//# sourceMappingURL=lazy-analysis.d.ts.map
|