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,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Context Manager for Conditional Expressions
|
|
3
|
+
*
|
|
4
|
+
* This module provides functionality to define and manage custom CEL expression
|
|
5
|
+
* contexts that can contain KubernetesRef objects, enabling developers to create
|
|
6
|
+
* their own conditional expression types beyond includeWhen and readyWhen.
|
|
7
|
+
*/
|
|
8
|
+
import { type ConditionalExpressionConfig, type ConditionalExpressionResult } from './conditional-expression-processor.js';
|
|
9
|
+
import type { FactoryExpressionContext } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Configuration for a custom expression context
|
|
12
|
+
*/
|
|
13
|
+
export interface CustomContextConfig {
|
|
14
|
+
/** Name of the custom context */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Description of what this context is used for */
|
|
17
|
+
description?: string;
|
|
18
|
+
/** Expected return type for expressions in this context */
|
|
19
|
+
expectedReturnType?: 'boolean' | 'string' | 'number' | 'object' | 'any';
|
|
20
|
+
/** Whether expressions in this context support async operations */
|
|
21
|
+
supportsAsync?: boolean;
|
|
22
|
+
/** Validation rules for expressions in this context */
|
|
23
|
+
validationRules?: CustomContextValidationRule[];
|
|
24
|
+
/** CEL generation strategy for this context */
|
|
25
|
+
celStrategy?: 'conditional-check' | 'resource-reference' | 'template-interpolation' | 'custom';
|
|
26
|
+
/** Custom CEL template for this context */
|
|
27
|
+
celTemplate?: string;
|
|
28
|
+
/** Whether to enable debug information for this context */
|
|
29
|
+
enableDebugInfo?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Validation rule for custom context expressions
|
|
33
|
+
*/
|
|
34
|
+
export interface CustomContextValidationRule {
|
|
35
|
+
/** Rule identifier */
|
|
36
|
+
id: string;
|
|
37
|
+
/** Rule name */
|
|
38
|
+
name: string;
|
|
39
|
+
/** Rule description */
|
|
40
|
+
description: string;
|
|
41
|
+
/** Validation function */
|
|
42
|
+
validate: (expression: any, context: FactoryExpressionContext) => CustomContextValidationResult;
|
|
43
|
+
/** Severity level */
|
|
44
|
+
severity: 'error' | 'warning' | 'info';
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Result of custom context validation
|
|
48
|
+
*/
|
|
49
|
+
export interface CustomContextValidationResult {
|
|
50
|
+
/** Whether validation passed */
|
|
51
|
+
isValid: boolean;
|
|
52
|
+
/** Validation message */
|
|
53
|
+
message?: string;
|
|
54
|
+
/** Suggestions for fixing validation issues */
|
|
55
|
+
suggestions?: string[];
|
|
56
|
+
/** Additional validation details */
|
|
57
|
+
details?: Record<string, any>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Custom expression context definition
|
|
61
|
+
*/
|
|
62
|
+
export interface CustomExpressionContext {
|
|
63
|
+
/** Context configuration */
|
|
64
|
+
config: CustomContextConfig;
|
|
65
|
+
/** Processor function for expressions in this context */
|
|
66
|
+
processor: (expression: any, context: FactoryExpressionContext, config?: ConditionalExpressionConfig) => ConditionalExpressionResult;
|
|
67
|
+
/** Validator function for expressions in this context */
|
|
68
|
+
validator: (expression: any, context: FactoryExpressionContext) => CustomContextValidationResult[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Result of custom context processing
|
|
72
|
+
*/
|
|
73
|
+
export interface CustomContextProcessingResult {
|
|
74
|
+
/** Name of the context that was used */
|
|
75
|
+
contextName: string;
|
|
76
|
+
/** Processing result */
|
|
77
|
+
result: ConditionalExpressionResult;
|
|
78
|
+
/** Validation results */
|
|
79
|
+
validationResults: CustomContextValidationResult[];
|
|
80
|
+
/** Performance metrics */
|
|
81
|
+
metrics: {
|
|
82
|
+
processingTimeMs: number;
|
|
83
|
+
validationTimeMs: number;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Custom Context Manager
|
|
88
|
+
*
|
|
89
|
+
* Manages custom CEL expression contexts and provides processing capabilities
|
|
90
|
+
* for expressions containing KubernetesRef objects in custom contexts.
|
|
91
|
+
*/
|
|
92
|
+
export declare class CustomContextManager {
|
|
93
|
+
private contexts;
|
|
94
|
+
private processor;
|
|
95
|
+
private contextDetector;
|
|
96
|
+
constructor();
|
|
97
|
+
/**
|
|
98
|
+
* Register a custom expression context
|
|
99
|
+
*
|
|
100
|
+
* @param contextConfig - Configuration for the custom context
|
|
101
|
+
* @returns The registered custom context
|
|
102
|
+
*/
|
|
103
|
+
registerCustomContext(contextConfig: CustomContextConfig): CustomExpressionContext;
|
|
104
|
+
/**
|
|
105
|
+
* Unregister a custom expression context
|
|
106
|
+
*
|
|
107
|
+
* @param contextName - Name of the context to unregister
|
|
108
|
+
* @returns Whether the context was successfully unregistered
|
|
109
|
+
*/
|
|
110
|
+
unregisterCustomContext(contextName: string): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Get a registered custom context
|
|
113
|
+
*
|
|
114
|
+
* @param contextName - Name of the context to retrieve
|
|
115
|
+
* @returns The custom context or undefined if not found
|
|
116
|
+
*/
|
|
117
|
+
getCustomContext(contextName: string): CustomExpressionContext | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* List all registered custom contexts
|
|
120
|
+
*
|
|
121
|
+
* @returns Array of context names
|
|
122
|
+
*/
|
|
123
|
+
listCustomContexts(): string[];
|
|
124
|
+
/**
|
|
125
|
+
* Process an expression in a custom context
|
|
126
|
+
*
|
|
127
|
+
* @param contextName - Name of the custom context
|
|
128
|
+
* @param expression - Expression to process
|
|
129
|
+
* @param factoryContext - Factory context
|
|
130
|
+
* @param config - Processing configuration
|
|
131
|
+
* @returns Processing result
|
|
132
|
+
*/
|
|
133
|
+
processInCustomContext(contextName: string, expression: any, factoryContext: FactoryExpressionContext, config?: ConditionalExpressionConfig): CustomContextProcessingResult;
|
|
134
|
+
/**
|
|
135
|
+
* Auto-detect and process expression in the most appropriate custom context
|
|
136
|
+
*
|
|
137
|
+
* @param expression - Expression to process
|
|
138
|
+
* @param factoryContext - Factory context
|
|
139
|
+
* @param config - Processing configuration
|
|
140
|
+
* @returns Processing result or null if no suitable context found
|
|
141
|
+
*/
|
|
142
|
+
autoProcessInCustomContext(expression: any, factoryContext: FactoryExpressionContext, config?: ConditionalExpressionConfig): CustomContextProcessingResult | null;
|
|
143
|
+
/**
|
|
144
|
+
* Create a custom processor for a context configuration
|
|
145
|
+
*/
|
|
146
|
+
private createCustomProcessor;
|
|
147
|
+
/**
|
|
148
|
+
* Create a custom validator for a context configuration
|
|
149
|
+
*/
|
|
150
|
+
private createCustomValidator;
|
|
151
|
+
/**
|
|
152
|
+
* Validate expression against expected return type
|
|
153
|
+
*/
|
|
154
|
+
private validateExpectedReturnType;
|
|
155
|
+
/**
|
|
156
|
+
* Check if a detection result matches a custom context
|
|
157
|
+
*/
|
|
158
|
+
private isContextMatch;
|
|
159
|
+
/**
|
|
160
|
+
* Register built-in contexts
|
|
161
|
+
*/
|
|
162
|
+
private registerBuiltInContexts;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Global custom context manager instance
|
|
166
|
+
*/
|
|
167
|
+
export declare const customContextManager: CustomContextManager;
|
|
168
|
+
/**
|
|
169
|
+
* Utility function to register a custom context
|
|
170
|
+
*
|
|
171
|
+
* @param contextConfig - Configuration for the custom context
|
|
172
|
+
* @returns The registered custom context
|
|
173
|
+
*/
|
|
174
|
+
export declare function registerCustomContext(contextConfig: CustomContextConfig): CustomExpressionContext;
|
|
175
|
+
/**
|
|
176
|
+
* Utility function to process expression in custom context
|
|
177
|
+
*
|
|
178
|
+
* @param contextName - Name of the custom context
|
|
179
|
+
* @param expression - Expression to process
|
|
180
|
+
* @param factoryContext - Factory context
|
|
181
|
+
* @param config - Processing configuration
|
|
182
|
+
* @returns Processing result
|
|
183
|
+
*/
|
|
184
|
+
export declare function processInCustomContext(contextName: string, expression: any, factoryContext: FactoryExpressionContext, config?: ConditionalExpressionConfig): CustomContextProcessingResult;
|
|
185
|
+
/**
|
|
186
|
+
* Utility function to auto-process expression in custom context
|
|
187
|
+
*
|
|
188
|
+
* @param expression - Expression to process
|
|
189
|
+
* @param factoryContext - Factory context
|
|
190
|
+
* @param config - Processing configuration
|
|
191
|
+
* @returns Processing result or null if no suitable context found
|
|
192
|
+
*/
|
|
193
|
+
export declare function autoProcessInCustomContext(expression: any, factoryContext: FactoryExpressionContext, config?: ConditionalExpressionConfig): CustomContextProcessingResult | null;
|
|
194
|
+
//# sourceMappingURL=custom-context-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-context-manager.d.ts","sourceRoot":"","sources":["../../../src/core/expressions/custom-context-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAEL,KA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,GAAE,2BAAgC,GACvC,6BAA6B;IAuDhC;;;;;;;OAOG;IACH,0BAA0B,CACxB,UAAU,EAAE,GAAG,EACf,cAAc,EAAE,wBAAwB,EACxC,MAAM,GAAE,2BAAgC,GACvC,6BAA6B,GAAG,IAAI;IA+BvC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAY7B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAgC7B;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAiDlC;;OAEG;IACH,OAAO,CAAC,cAAc;IAUtB;;OAEG;IACH,OAAO,CAAC,uBAAuB;CAmFhC;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,sBAA6B,CAAC;AAE/D;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,mBAAmB,GAAG,uBAAuB,CAEjG;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,GAAG,EACf,cAAc,EAAE,wBAAwB,EACxC,MAAM,CAAC,EAAE,2BAA2B,GACnC,6BAA6B,CAE/B;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,GAAG,EACf,cAAc,EAAE,wBAAwB,EACxC,MAAM,CAAC,EAAE,2BAA2B,GACnC,6BAA6B,GAAG,IAAI,CAEtC"}
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Context Manager for Conditional Expressions
|
|
3
|
+
*
|
|
4
|
+
* This module provides functionality to define and manage custom CEL expression
|
|
5
|
+
* contexts that can contain KubernetesRef objects, enabling developers to create
|
|
6
|
+
* their own conditional expression types beyond includeWhen and readyWhen.
|
|
7
|
+
*/
|
|
8
|
+
import { getComponentLogger } from '../logging/index.js';
|
|
9
|
+
import { ConditionalExpressionProcessor } from './conditional-expression-processor.js';
|
|
10
|
+
import { ExpressionContextDetector, } from './context-detector.js';
|
|
11
|
+
const logger = getComponentLogger('custom-context-manager');
|
|
12
|
+
/**
|
|
13
|
+
* Custom Context Manager
|
|
14
|
+
*
|
|
15
|
+
* Manages custom CEL expression contexts and provides processing capabilities
|
|
16
|
+
* for expressions containing KubernetesRef objects in custom contexts.
|
|
17
|
+
*/
|
|
18
|
+
export class CustomContextManager {
|
|
19
|
+
contexts = new Map();
|
|
20
|
+
processor;
|
|
21
|
+
contextDetector;
|
|
22
|
+
constructor() {
|
|
23
|
+
this.processor = new ConditionalExpressionProcessor();
|
|
24
|
+
this.contextDetector = new ExpressionContextDetector();
|
|
25
|
+
// Register built-in contexts
|
|
26
|
+
this.registerBuiltInContexts();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Register a custom expression context
|
|
30
|
+
*
|
|
31
|
+
* @param contextConfig - Configuration for the custom context
|
|
32
|
+
* @returns The registered custom context
|
|
33
|
+
*/
|
|
34
|
+
registerCustomContext(contextConfig) {
|
|
35
|
+
logger.debug('Registering custom expression context', {
|
|
36
|
+
contextName: contextConfig.name,
|
|
37
|
+
expectedReturnType: contextConfig.expectedReturnType
|
|
38
|
+
});
|
|
39
|
+
const customContext = {
|
|
40
|
+
config: contextConfig,
|
|
41
|
+
processor: this.createCustomProcessor(contextConfig),
|
|
42
|
+
validator: this.createCustomValidator(contextConfig)
|
|
43
|
+
};
|
|
44
|
+
this.contexts.set(contextConfig.name, customContext);
|
|
45
|
+
logger.info('Custom expression context registered', {
|
|
46
|
+
contextName: contextConfig.name,
|
|
47
|
+
totalContexts: this.contexts.size
|
|
48
|
+
});
|
|
49
|
+
return customContext;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Unregister a custom expression context
|
|
53
|
+
*
|
|
54
|
+
* @param contextName - Name of the context to unregister
|
|
55
|
+
* @returns Whether the context was successfully unregistered
|
|
56
|
+
*/
|
|
57
|
+
unregisterCustomContext(contextName) {
|
|
58
|
+
const existed = this.contexts.has(contextName);
|
|
59
|
+
this.contexts.delete(contextName);
|
|
60
|
+
if (existed) {
|
|
61
|
+
logger.info('Custom expression context unregistered', {
|
|
62
|
+
contextName,
|
|
63
|
+
remainingContexts: this.contexts.size
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return existed;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get a registered custom context
|
|
70
|
+
*
|
|
71
|
+
* @param contextName - Name of the context to retrieve
|
|
72
|
+
* @returns The custom context or undefined if not found
|
|
73
|
+
*/
|
|
74
|
+
getCustomContext(contextName) {
|
|
75
|
+
return this.contexts.get(contextName);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* List all registered custom contexts
|
|
79
|
+
*
|
|
80
|
+
* @returns Array of context names
|
|
81
|
+
*/
|
|
82
|
+
listCustomContexts() {
|
|
83
|
+
return Array.from(this.contexts.keys());
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Process an expression in a custom context
|
|
87
|
+
*
|
|
88
|
+
* @param contextName - Name of the custom context
|
|
89
|
+
* @param expression - Expression to process
|
|
90
|
+
* @param factoryContext - Factory context
|
|
91
|
+
* @param config - Processing configuration
|
|
92
|
+
* @returns Processing result
|
|
93
|
+
*/
|
|
94
|
+
processInCustomContext(contextName, expression, factoryContext, config = {}) {
|
|
95
|
+
const startTime = performance.now();
|
|
96
|
+
logger.debug('Processing expression in custom context', {
|
|
97
|
+
contextName,
|
|
98
|
+
factoryType: factoryContext.factoryType,
|
|
99
|
+
expressionType: typeof expression
|
|
100
|
+
});
|
|
101
|
+
const customContext = this.contexts.get(contextName);
|
|
102
|
+
if (!customContext) {
|
|
103
|
+
throw new Error(`Custom context '${contextName}' not found`);
|
|
104
|
+
}
|
|
105
|
+
// Validate the expression
|
|
106
|
+
const validationStartTime = performance.now();
|
|
107
|
+
const validationResults = customContext.validator(expression, factoryContext);
|
|
108
|
+
const validationTimeMs = performance.now() - validationStartTime;
|
|
109
|
+
// Check for validation errors
|
|
110
|
+
const hasErrors = validationResults.some(result => !result.isValid &&
|
|
111
|
+
customContext.config.validationRules?.find(rule => rule.severity === 'error'));
|
|
112
|
+
if (hasErrors && config.strictValidation) {
|
|
113
|
+
const errorMessages = validationResults
|
|
114
|
+
.filter(result => !result.isValid)
|
|
115
|
+
.map(result => result.message)
|
|
116
|
+
.join(', ');
|
|
117
|
+
throw new Error(`Validation failed for custom context '${contextName}': ${errorMessages}`);
|
|
118
|
+
}
|
|
119
|
+
// Process the expression
|
|
120
|
+
const result = customContext.processor(expression, factoryContext, config);
|
|
121
|
+
const processingTimeMs = performance.now() - startTime;
|
|
122
|
+
logger.debug('Custom context processing completed', {
|
|
123
|
+
contextName,
|
|
124
|
+
wasProcessed: result.wasProcessed,
|
|
125
|
+
validationResults: validationResults.length,
|
|
126
|
+
processingTimeMs
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
contextName,
|
|
130
|
+
result,
|
|
131
|
+
validationResults,
|
|
132
|
+
metrics: {
|
|
133
|
+
processingTimeMs,
|
|
134
|
+
validationTimeMs
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Auto-detect and process expression in the most appropriate custom context
|
|
140
|
+
*
|
|
141
|
+
* @param expression - Expression to process
|
|
142
|
+
* @param factoryContext - Factory context
|
|
143
|
+
* @param config - Processing configuration
|
|
144
|
+
* @returns Processing result or null if no suitable context found
|
|
145
|
+
*/
|
|
146
|
+
autoProcessInCustomContext(expression, factoryContext, config = {}) {
|
|
147
|
+
logger.debug('Auto-detecting custom context for expression', {
|
|
148
|
+
factoryType: factoryContext.factoryType,
|
|
149
|
+
expressionType: typeof expression
|
|
150
|
+
});
|
|
151
|
+
// Try to detect context using the context detector
|
|
152
|
+
const detectionResult = this.contextDetector.detectContext(expression, {
|
|
153
|
+
factoryType: factoryContext.factoryType,
|
|
154
|
+
...(factoryContext.availableResources && { availableResources: factoryContext.availableResources }),
|
|
155
|
+
...(factoryContext.schemaProxy && { schemaProxy: factoryContext.schemaProxy })
|
|
156
|
+
});
|
|
157
|
+
// Look for a custom context that matches the detected context
|
|
158
|
+
for (const [contextName, customContext] of this.contexts.entries()) {
|
|
159
|
+
if (this.isContextMatch(detectionResult, customContext)) {
|
|
160
|
+
try {
|
|
161
|
+
return this.processInCustomContext(contextName, expression, factoryContext, config);
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
logger.warn('Failed to process in detected custom context', {
|
|
165
|
+
contextName,
|
|
166
|
+
error: error instanceof Error ? error.message : String(error)
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
logger.debug('No suitable custom context found for auto-processing');
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Create a custom processor for a context configuration
|
|
176
|
+
*/
|
|
177
|
+
createCustomProcessor(contextConfig) {
|
|
178
|
+
return (expression, context, config = {}) => {
|
|
179
|
+
// Use the conditional expression processor with custom context
|
|
180
|
+
return this.processor.processCustomConditionalExpression(expression, context, {
|
|
181
|
+
...config,
|
|
182
|
+
includeDebugInfo: config.includeDebugInfo ?? contextConfig.enableDebugInfo ?? false
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Create a custom validator for a context configuration
|
|
188
|
+
*/
|
|
189
|
+
createCustomValidator(contextConfig) {
|
|
190
|
+
return (expression, context) => {
|
|
191
|
+
const results = [];
|
|
192
|
+
// Apply custom validation rules
|
|
193
|
+
if (contextConfig.validationRules) {
|
|
194
|
+
for (const rule of contextConfig.validationRules) {
|
|
195
|
+
try {
|
|
196
|
+
const result = rule.validate(expression, context);
|
|
197
|
+
results.push(result);
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
results.push({
|
|
201
|
+
isValid: false,
|
|
202
|
+
message: `Validation rule '${rule.name}' failed: ${error}`,
|
|
203
|
+
details: { ruleId: rule.id, error: String(error) }
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// Apply default validation based on expected return type
|
|
209
|
+
if (contextConfig.expectedReturnType) {
|
|
210
|
+
const typeValidation = this.validateExpectedReturnType(expression, contextConfig.expectedReturnType);
|
|
211
|
+
results.push(typeValidation);
|
|
212
|
+
}
|
|
213
|
+
return results;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Validate expression against expected return type
|
|
218
|
+
*/
|
|
219
|
+
validateExpectedReturnType(expression, expectedType) {
|
|
220
|
+
// This is a simplified validation - in a real implementation,
|
|
221
|
+
// we would need more sophisticated type analysis
|
|
222
|
+
switch (expectedType) {
|
|
223
|
+
case 'boolean':
|
|
224
|
+
if (typeof expression === 'boolean') {
|
|
225
|
+
return { isValid: true };
|
|
226
|
+
}
|
|
227
|
+
if (typeof expression === 'string' && /[><=!]=?|&&|\|\||true|false/.test(expression)) {
|
|
228
|
+
return { isValid: true };
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
isValid: false,
|
|
232
|
+
message: `Expression should evaluate to boolean, but appears to be ${typeof expression}`,
|
|
233
|
+
suggestions: ['Use comparison operators (>, <, ==, !=)', 'Use logical operators (&&, ||)', 'Use boolean literals (true, false)']
|
|
234
|
+
};
|
|
235
|
+
case 'string':
|
|
236
|
+
if (typeof expression === 'string') {
|
|
237
|
+
return { isValid: true };
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
isValid: false,
|
|
241
|
+
message: `Expression should evaluate to string, but appears to be ${typeof expression}`,
|
|
242
|
+
suggestions: ['Use string literals', 'Use template literals', 'Use string concatenation']
|
|
243
|
+
};
|
|
244
|
+
case 'number':
|
|
245
|
+
if (typeof expression === 'number') {
|
|
246
|
+
return { isValid: true };
|
|
247
|
+
}
|
|
248
|
+
if (typeof expression === 'string' && /^\d+(\.\d+)?$/.test(expression)) {
|
|
249
|
+
return { isValid: true };
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
isValid: false,
|
|
253
|
+
message: `Expression should evaluate to number, but appears to be ${typeof expression}`,
|
|
254
|
+
suggestions: ['Use numeric literals', 'Use arithmetic operations']
|
|
255
|
+
};
|
|
256
|
+
default:
|
|
257
|
+
return { isValid: true }; // Accept any type for 'object' or 'any'
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Check if a detection result matches a custom context
|
|
262
|
+
*/
|
|
263
|
+
isContextMatch(detectionResult, _customContext) {
|
|
264
|
+
// Simple matching based on context name
|
|
265
|
+
// In a more sophisticated implementation, this could use more complex matching logic
|
|
266
|
+
return detectionResult.context === 'conditional' ||
|
|
267
|
+
detectionResult.context === 'unknown';
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Register built-in contexts
|
|
271
|
+
*/
|
|
272
|
+
registerBuiltInContexts() {
|
|
273
|
+
// Register includeWhen context
|
|
274
|
+
this.registerCustomContext({
|
|
275
|
+
name: 'includeWhen',
|
|
276
|
+
description: 'Conditional resource inclusion',
|
|
277
|
+
expectedReturnType: 'boolean',
|
|
278
|
+
supportsAsync: false,
|
|
279
|
+
celStrategy: 'conditional-check',
|
|
280
|
+
validationRules: [
|
|
281
|
+
{
|
|
282
|
+
id: 'boolean-result',
|
|
283
|
+
name: 'Boolean Result',
|
|
284
|
+
description: 'includeWhen expressions should evaluate to boolean',
|
|
285
|
+
severity: 'warning',
|
|
286
|
+
validate: (expression) => {
|
|
287
|
+
if (typeof expression === 'boolean') {
|
|
288
|
+
return { isValid: true };
|
|
289
|
+
}
|
|
290
|
+
if (typeof expression === 'string' && /[><=!]=?|&&|\|\||true|false/.test(expression)) {
|
|
291
|
+
return { isValid: true };
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
isValid: false,
|
|
295
|
+
message: 'includeWhen expressions should evaluate to boolean values',
|
|
296
|
+
suggestions: ['Add comparison operators', 'Use boolean literals']
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
]
|
|
301
|
+
});
|
|
302
|
+
// Register readyWhen context
|
|
303
|
+
this.registerCustomContext({
|
|
304
|
+
name: 'readyWhen',
|
|
305
|
+
description: 'Resource readiness conditions',
|
|
306
|
+
expectedReturnType: 'boolean',
|
|
307
|
+
supportsAsync: false,
|
|
308
|
+
celStrategy: 'conditional-check',
|
|
309
|
+
validationRules: [
|
|
310
|
+
{
|
|
311
|
+
id: 'boolean-result',
|
|
312
|
+
name: 'Boolean Result',
|
|
313
|
+
description: 'readyWhen expressions should evaluate to boolean',
|
|
314
|
+
severity: 'warning',
|
|
315
|
+
validate: (expression) => {
|
|
316
|
+
if (typeof expression === 'boolean') {
|
|
317
|
+
return { isValid: true };
|
|
318
|
+
}
|
|
319
|
+
if (typeof expression === 'string' && /[><=!]=?|&&|\|\||ready|available/.test(expression.toLowerCase())) {
|
|
320
|
+
return { isValid: true };
|
|
321
|
+
}
|
|
322
|
+
return {
|
|
323
|
+
isValid: false,
|
|
324
|
+
message: 'readyWhen expressions should evaluate to boolean values',
|
|
325
|
+
suggestions: ['Add comparison operators', 'Use readiness-related terms']
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
id: 'status-reference',
|
|
331
|
+
name: 'Status Reference',
|
|
332
|
+
description: 'readyWhen expressions should typically reference status fields',
|
|
333
|
+
severity: 'info',
|
|
334
|
+
validate: (expression, _context) => {
|
|
335
|
+
// This is a simplified check - in reality, we'd analyze the expression for status references
|
|
336
|
+
const expressionString = String(expression);
|
|
337
|
+
if (expressionString.includes('status')) {
|
|
338
|
+
return { isValid: true };
|
|
339
|
+
}
|
|
340
|
+
return {
|
|
341
|
+
isValid: false,
|
|
342
|
+
message: 'readyWhen expressions typically reference resource status fields',
|
|
343
|
+
suggestions: ['Reference .status fields', 'Use resource readiness indicators']
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
]
|
|
348
|
+
});
|
|
349
|
+
logger.info('Built-in custom contexts registered', {
|
|
350
|
+
contexts: ['includeWhen', 'readyWhen']
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Global custom context manager instance
|
|
356
|
+
*/
|
|
357
|
+
export const customContextManager = new CustomContextManager();
|
|
358
|
+
/**
|
|
359
|
+
* Utility function to register a custom context
|
|
360
|
+
*
|
|
361
|
+
* @param contextConfig - Configuration for the custom context
|
|
362
|
+
* @returns The registered custom context
|
|
363
|
+
*/
|
|
364
|
+
export function registerCustomContext(contextConfig) {
|
|
365
|
+
return customContextManager.registerCustomContext(contextConfig);
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Utility function to process expression in custom context
|
|
369
|
+
*
|
|
370
|
+
* @param contextName - Name of the custom context
|
|
371
|
+
* @param expression - Expression to process
|
|
372
|
+
* @param factoryContext - Factory context
|
|
373
|
+
* @param config - Processing configuration
|
|
374
|
+
* @returns Processing result
|
|
375
|
+
*/
|
|
376
|
+
export function processInCustomContext(contextName, expression, factoryContext, config) {
|
|
377
|
+
return customContextManager.processInCustomContext(contextName, expression, factoryContext, config);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Utility function to auto-process expression in custom context
|
|
381
|
+
*
|
|
382
|
+
* @param expression - Expression to process
|
|
383
|
+
* @param factoryContext - Factory context
|
|
384
|
+
* @param config - Processing configuration
|
|
385
|
+
* @returns Processing result or null if no suitable context found
|
|
386
|
+
*/
|
|
387
|
+
export function autoProcessInCustomContext(expression, factoryContext, config) {
|
|
388
|
+
return customContextManager.autoProcessInCustomContext(expression, factoryContext, config);
|
|
389
|
+
}
|
|
390
|
+
//# sourceMappingURL=custom-context-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-context-manager.js","sourceRoot":"","sources":["../../../src/core/expressions/custom-context-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBA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