typekro 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +0 -1
- package/dist/core/deployment/engine.d.ts.map +1 -1
- package/dist/core/deployment/engine.js +0 -1
- 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/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 +343 -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 +1301 -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/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 +4 -0
- package/dist/core/types/deployment.d.ts.map +1 -1
- 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.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/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,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conditional Expression Integration for Factory Functions
|
|
3
|
+
*
|
|
4
|
+
* This module provides integration points for conditional expressions like
|
|
5
|
+
* includeWhen and readyWhen in factory functions, enabling automatic
|
|
6
|
+
* KubernetesRef detection and CEL conversion.
|
|
7
|
+
*/
|
|
8
|
+
import { getComponentLogger } from '../logging/index.js';
|
|
9
|
+
import { ConditionalExpressionProcessor } from './conditional-expression-processor.js';
|
|
10
|
+
import { getCurrentCompositionContext } from '../../factories/shared.js';
|
|
11
|
+
const logger = getComponentLogger('conditional-integration');
|
|
12
|
+
/**
|
|
13
|
+
* Conditional Expression Integrator
|
|
14
|
+
*
|
|
15
|
+
* Integrates conditional expression processing with factory functions
|
|
16
|
+
* and Enhanced resources.
|
|
17
|
+
*/
|
|
18
|
+
export class ConditionalExpressionIntegrator {
|
|
19
|
+
processor;
|
|
20
|
+
constructor() {
|
|
21
|
+
this.processor = new ConditionalExpressionProcessor();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Add conditional expression support to an Enhanced resource
|
|
25
|
+
*
|
|
26
|
+
* @param resource - Enhanced resource to augment
|
|
27
|
+
* @param config - Integration configuration
|
|
28
|
+
* @returns Enhanced resource with conditional expression support
|
|
29
|
+
*/
|
|
30
|
+
addConditionalSupport(resource, config = {}) {
|
|
31
|
+
const enhanced = resource;
|
|
32
|
+
// Add conditional expression properties
|
|
33
|
+
Object.defineProperty(enhanced, 'includeWhen', {
|
|
34
|
+
value: undefined,
|
|
35
|
+
writable: true,
|
|
36
|
+
enumerable: false, // Don't serialize by default
|
|
37
|
+
configurable: true
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(enhanced, 'readyWhen', {
|
|
40
|
+
value: undefined,
|
|
41
|
+
writable: true,
|
|
42
|
+
enumerable: false, // Don't serialize by default
|
|
43
|
+
configurable: true
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(enhanced, 'conditionals', {
|
|
46
|
+
value: {},
|
|
47
|
+
writable: true,
|
|
48
|
+
enumerable: false, // Don't serialize by default
|
|
49
|
+
configurable: true
|
|
50
|
+
});
|
|
51
|
+
// Add fluent builder methods
|
|
52
|
+
Object.defineProperty(enhanced, 'withIncludeWhen', {
|
|
53
|
+
value: (condition) => {
|
|
54
|
+
const context = enhanced.createFactoryContext();
|
|
55
|
+
if (config.autoProcess) {
|
|
56
|
+
const result = this.processor.processIncludeWhenExpression(condition, context, config);
|
|
57
|
+
enhanced.includeWhen = result.expression;
|
|
58
|
+
if (result.validationErrors.length > 0) {
|
|
59
|
+
logger.warn('includeWhen validation warnings', {
|
|
60
|
+
resourceId: enhanced.__resourceId,
|
|
61
|
+
errors: result.validationErrors
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
enhanced.includeWhen = condition;
|
|
67
|
+
}
|
|
68
|
+
return enhanced;
|
|
69
|
+
},
|
|
70
|
+
enumerable: false,
|
|
71
|
+
configurable: true
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(enhanced, 'withReadyWhen', {
|
|
74
|
+
value: (condition) => {
|
|
75
|
+
const context = enhanced.createFactoryContext();
|
|
76
|
+
if (config.autoProcess) {
|
|
77
|
+
const result = this.processor.processReadyWhenExpression(condition, context, config);
|
|
78
|
+
enhanced.readyWhen = result.expression;
|
|
79
|
+
if (result.validationErrors.length > 0) {
|
|
80
|
+
logger.warn('readyWhen validation warnings', {
|
|
81
|
+
resourceId: enhanced.__resourceId,
|
|
82
|
+
errors: result.validationErrors
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
enhanced.readyWhen = condition;
|
|
88
|
+
}
|
|
89
|
+
return enhanced;
|
|
90
|
+
},
|
|
91
|
+
enumerable: false,
|
|
92
|
+
configurable: true
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(enhanced, 'withConditional', {
|
|
95
|
+
value: (name, condition) => {
|
|
96
|
+
const context = enhanced.createFactoryContext();
|
|
97
|
+
if (config.autoProcess) {
|
|
98
|
+
const result = this.processor.processCustomConditionalExpression(condition, context, config);
|
|
99
|
+
if (!enhanced.conditionals) {
|
|
100
|
+
enhanced.conditionals = {};
|
|
101
|
+
}
|
|
102
|
+
enhanced.conditionals[name] = result.expression;
|
|
103
|
+
if (result.validationErrors.length > 0) {
|
|
104
|
+
logger.warn('Custom conditional validation warnings', {
|
|
105
|
+
resourceId: enhanced.__resourceId,
|
|
106
|
+
conditionalName: name,
|
|
107
|
+
errors: result.validationErrors
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
if (!enhanced.conditionals) {
|
|
113
|
+
enhanced.conditionals = {};
|
|
114
|
+
}
|
|
115
|
+
enhanced.conditionals[name] = condition;
|
|
116
|
+
}
|
|
117
|
+
return enhanced;
|
|
118
|
+
},
|
|
119
|
+
enumerable: false,
|
|
120
|
+
configurable: true
|
|
121
|
+
});
|
|
122
|
+
// Add helper method to create factory context
|
|
123
|
+
Object.defineProperty(enhanced, 'createFactoryContext', {
|
|
124
|
+
value: () => {
|
|
125
|
+
const compositionContext = getCurrentCompositionContext();
|
|
126
|
+
return {
|
|
127
|
+
factoryType: 'kro', // Default to Kro, can be overridden
|
|
128
|
+
factoryName: enhanced.kind || 'unknown',
|
|
129
|
+
analysisEnabled: true,
|
|
130
|
+
availableResources: compositionContext?.resources || {},
|
|
131
|
+
schemaProxy: undefined, // Will be set by toResourceGraph if available
|
|
132
|
+
resourceId: enhanced.__resourceId || 'unknown'
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
enumerable: false,
|
|
136
|
+
configurable: true
|
|
137
|
+
});
|
|
138
|
+
return enhanced;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Process all conditional expressions on an Enhanced resource
|
|
142
|
+
*
|
|
143
|
+
* @param resource - Enhanced resource with conditional expressions
|
|
144
|
+
* @param context - Factory context
|
|
145
|
+
* @param config - Integration configuration
|
|
146
|
+
* @returns Processing results
|
|
147
|
+
*/
|
|
148
|
+
processResourceConditionals(resource, context, config = {}) {
|
|
149
|
+
const startTime = performance.now();
|
|
150
|
+
const results = {};
|
|
151
|
+
const warnings = [];
|
|
152
|
+
let hasConditionals = false;
|
|
153
|
+
logger.debug('Processing resource conditional expressions', {
|
|
154
|
+
resourceId: context.resourceId,
|
|
155
|
+
factoryType: context.factoryType
|
|
156
|
+
});
|
|
157
|
+
// Process includeWhen expression
|
|
158
|
+
if (resource.includeWhen !== undefined) {
|
|
159
|
+
hasConditionals = true;
|
|
160
|
+
results.includeWhen = this.processor.processIncludeWhenExpression(resource.includeWhen, context, config);
|
|
161
|
+
if (results.includeWhen.validationErrors.length > 0) {
|
|
162
|
+
warnings.push(...results.includeWhen.validationErrors.map(err => `includeWhen: ${err}`));
|
|
163
|
+
}
|
|
164
|
+
// Update the resource with processed expression
|
|
165
|
+
resource.includeWhen = results.includeWhen.expression;
|
|
166
|
+
}
|
|
167
|
+
// Process readyWhen expression
|
|
168
|
+
if (resource.readyWhen !== undefined) {
|
|
169
|
+
hasConditionals = true;
|
|
170
|
+
results.readyWhen = this.processor.processReadyWhenExpression(resource.readyWhen, context, config);
|
|
171
|
+
if (results.readyWhen.validationErrors.length > 0) {
|
|
172
|
+
warnings.push(...results.readyWhen.validationErrors.map(err => `readyWhen: ${err}`));
|
|
173
|
+
}
|
|
174
|
+
// Update the resource with processed expression
|
|
175
|
+
resource.readyWhen = results.readyWhen.expression;
|
|
176
|
+
}
|
|
177
|
+
// Process custom conditional expressions
|
|
178
|
+
if (resource.conditionals && Object.keys(resource.conditionals).length > 0) {
|
|
179
|
+
hasConditionals = true;
|
|
180
|
+
results.conditionals = {};
|
|
181
|
+
for (const [name, condition] of Object.entries(resource.conditionals)) {
|
|
182
|
+
results.conditionals[name] = this.processor.processCustomConditionalExpression(condition, context, config);
|
|
183
|
+
if (results.conditionals[name].validationErrors.length > 0) {
|
|
184
|
+
warnings.push(...results.conditionals[name].validationErrors.map(err => `${name}: ${err}`));
|
|
185
|
+
}
|
|
186
|
+
// Update the resource with processed expression
|
|
187
|
+
resource.conditionals[name] = results.conditionals[name].expression;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const totalProcessingTimeMs = performance.now() - startTime;
|
|
191
|
+
logger.debug('Resource conditional expressions processing completed', {
|
|
192
|
+
resourceId: context.resourceId,
|
|
193
|
+
hasConditionals,
|
|
194
|
+
totalProcessingTimeMs,
|
|
195
|
+
warningsCount: warnings.length
|
|
196
|
+
});
|
|
197
|
+
return {
|
|
198
|
+
hasConditionals,
|
|
199
|
+
results,
|
|
200
|
+
totalProcessingTimeMs,
|
|
201
|
+
warnings
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Extract conditional expressions from a resource for serialization
|
|
206
|
+
*
|
|
207
|
+
* @param resource - Enhanced resource with conditional expressions
|
|
208
|
+
* @returns Conditional expressions ready for serialization
|
|
209
|
+
*/
|
|
210
|
+
extractConditionalsForSerialization(resource) {
|
|
211
|
+
const conditionals = {};
|
|
212
|
+
if (resource.includeWhen !== undefined) {
|
|
213
|
+
conditionals.includeWhen = resource.includeWhen;
|
|
214
|
+
}
|
|
215
|
+
if (resource.readyWhen !== undefined) {
|
|
216
|
+
conditionals.readyWhen = resource.readyWhen;
|
|
217
|
+
}
|
|
218
|
+
if (resource.conditionals && Object.keys(resource.conditionals).length > 0) {
|
|
219
|
+
Object.assign(conditionals, resource.conditionals);
|
|
220
|
+
}
|
|
221
|
+
return conditionals;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Validate that conditional expressions are appropriate for the factory type
|
|
225
|
+
*
|
|
226
|
+
* @param resource - Enhanced resource with conditional expressions
|
|
227
|
+
* @param factoryType - Target factory type
|
|
228
|
+
* @returns Validation results
|
|
229
|
+
*/
|
|
230
|
+
validateConditionalsForFactory(resource, factoryType) {
|
|
231
|
+
const errors = [];
|
|
232
|
+
const warnings = [];
|
|
233
|
+
// Direct factory limitations
|
|
234
|
+
if (factoryType === 'direct') {
|
|
235
|
+
if (resource.includeWhen !== undefined) {
|
|
236
|
+
warnings.push('includeWhen expressions have limited support in direct factory mode');
|
|
237
|
+
}
|
|
238
|
+
if (resource.readyWhen !== undefined) {
|
|
239
|
+
warnings.push('readyWhen expressions have limited support in direct factory mode');
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
// Kro factory requirements
|
|
243
|
+
if (factoryType === 'kro') {
|
|
244
|
+
// All conditional expressions should be convertible to CEL
|
|
245
|
+
if (resource.includeWhen !== undefined && typeof resource.includeWhen === 'function') {
|
|
246
|
+
errors.push('includeWhen expressions cannot be functions in Kro factory mode');
|
|
247
|
+
}
|
|
248
|
+
if (resource.readyWhen !== undefined && typeof resource.readyWhen === 'function') {
|
|
249
|
+
errors.push('readyWhen expressions cannot be functions in Kro factory mode');
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
isValid: errors.length === 0,
|
|
254
|
+
errors,
|
|
255
|
+
warnings
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Global conditional expression integrator instance
|
|
261
|
+
*/
|
|
262
|
+
export const conditionalExpressionIntegrator = new ConditionalExpressionIntegrator();
|
|
263
|
+
/**
|
|
264
|
+
* Utility function to add conditional support to an Enhanced resource
|
|
265
|
+
*
|
|
266
|
+
* @param resource - Enhanced resource to augment
|
|
267
|
+
* @param config - Integration configuration
|
|
268
|
+
* @returns Enhanced resource with conditional expression support
|
|
269
|
+
*/
|
|
270
|
+
export function withConditionalSupport(resource, config) {
|
|
271
|
+
return conditionalExpressionIntegrator.addConditionalSupport(resource, config);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Utility function to process conditional expressions on a resource
|
|
275
|
+
*
|
|
276
|
+
* @param resource - Enhanced resource with conditional expressions
|
|
277
|
+
* @param context - Factory context
|
|
278
|
+
* @param config - Integration configuration
|
|
279
|
+
* @returns Processing results
|
|
280
|
+
*/
|
|
281
|
+
export function processResourceConditionals(resource, context, config) {
|
|
282
|
+
return conditionalExpressionIntegrator.processResourceConditionals(resource, context, config);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Utility function to extract conditionals for serialization
|
|
286
|
+
*
|
|
287
|
+
* @param resource - Enhanced resource with conditional expressions
|
|
288
|
+
* @returns Conditional expressions ready for serialization
|
|
289
|
+
*/
|
|
290
|
+
export function extractConditionalsForSerialization(resource) {
|
|
291
|
+
return conditionalExpressionIntegrator.extractConditionalsForSerialization(resource);
|
|
292
|
+
}
|
|
293
|
+
//# sourceMappingURL=conditional-integration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditional-integration.js","sourceRoot":"","sources":["../../../src/core/expressions/conditional-integration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EACL,8BAA8B,EAG/B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAEzE,MAAM,MAAM,GAAG,kBAAkB,CAAC,yBAAyB,CAAC,CAAC;AAsD7D;;;;;GAKG;AACH,MAAM,OAAO,+BAA+B;IAClC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G;AACH,MAAM,UAAU,mCAAmC,CACjD,QAAkD;IAElD,OAAO,+BAA+B,CAAC,mCAAmC,CAAC,QAAQ,CAAC,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conditional Expression Validation
|
|
3
|
+
*
|
|
4
|
+
* This module provides comprehensive validation for conditional expressions
|
|
5
|
+
* containing KubernetesRef objects, ensuring they are well-formed and
|
|
6
|
+
* appropriate for their intended contexts.
|
|
7
|
+
*/
|
|
8
|
+
import { type MagicProxyDetectionResult } from './magic-proxy-detector.js';
|
|
9
|
+
import type { FactoryExpressionContext } from './types.js';
|
|
10
|
+
import { type ContextDetectionResult } from './context-detector.js';
|
|
11
|
+
/**
|
|
12
|
+
* Validation severity levels
|
|
13
|
+
*/
|
|
14
|
+
export type ValidationSeverity = 'error' | 'warning' | 'info';
|
|
15
|
+
/**
|
|
16
|
+
* Validation rule configuration
|
|
17
|
+
*/
|
|
18
|
+
export interface ValidationRule {
|
|
19
|
+
/** Unique identifier for the rule */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Human-readable name */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Description of what the rule validates */
|
|
24
|
+
description: string;
|
|
25
|
+
/** Severity level */
|
|
26
|
+
severity: ValidationSeverity;
|
|
27
|
+
/** Contexts where this rule applies */
|
|
28
|
+
applicableContexts: string[];
|
|
29
|
+
/** Whether this rule is enabled by default */
|
|
30
|
+
enabled: boolean;
|
|
31
|
+
/** Validation function */
|
|
32
|
+
validate: (expression: any, context: FactoryExpressionContext, detection: MagicProxyDetectionResult) => ValidationResult;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Result of a single validation rule
|
|
36
|
+
*/
|
|
37
|
+
export interface ValidationResult {
|
|
38
|
+
/** Whether validation passed */
|
|
39
|
+
valid: boolean;
|
|
40
|
+
/** Validation message */
|
|
41
|
+
message?: string;
|
|
42
|
+
/** Suggestions for fixing issues */
|
|
43
|
+
suggestions?: string[];
|
|
44
|
+
/** Additional details */
|
|
45
|
+
details?: Record<string, any>;
|
|
46
|
+
/** Location information if available */
|
|
47
|
+
location?: {
|
|
48
|
+
line?: number;
|
|
49
|
+
column?: number;
|
|
50
|
+
length?: number;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Comprehensive validation result
|
|
55
|
+
*/
|
|
56
|
+
export interface ConditionalValidationResult {
|
|
57
|
+
/** Overall validation status */
|
|
58
|
+
isValid: boolean;
|
|
59
|
+
/** Results from individual rules */
|
|
60
|
+
ruleResults: Map<string, ValidationResult>;
|
|
61
|
+
/** All validation messages grouped by severity */
|
|
62
|
+
messages: {
|
|
63
|
+
errors: string[];
|
|
64
|
+
warnings: string[];
|
|
65
|
+
info: string[];
|
|
66
|
+
};
|
|
67
|
+
/** Context detection result */
|
|
68
|
+
contextResult: ContextDetectionResult;
|
|
69
|
+
/** KubernetesRef detection result */
|
|
70
|
+
detectionResult: MagicProxyDetectionResult;
|
|
71
|
+
/** Performance metrics */
|
|
72
|
+
metrics: {
|
|
73
|
+
validationTimeMs: number;
|
|
74
|
+
rulesEvaluated: number;
|
|
75
|
+
referencesValidated: number;
|
|
76
|
+
};
|
|
77
|
+
/** Summary statistics */
|
|
78
|
+
summary: {
|
|
79
|
+
totalRules: number;
|
|
80
|
+
passedRules: number;
|
|
81
|
+
failedRules: number;
|
|
82
|
+
errorCount: number;
|
|
83
|
+
warningCount: number;
|
|
84
|
+
infoCount: number;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Validation configuration
|
|
89
|
+
*/
|
|
90
|
+
export interface ValidationConfig {
|
|
91
|
+
/** Whether to enable strict validation (fail on warnings) */
|
|
92
|
+
strictMode?: boolean;
|
|
93
|
+
/** Maximum validation time in milliseconds */
|
|
94
|
+
timeoutMs?: number;
|
|
95
|
+
/** Whether to include detailed location information */
|
|
96
|
+
includeLocationInfo?: boolean;
|
|
97
|
+
/** Custom validation rules to add */
|
|
98
|
+
customRules?: ValidationRule[];
|
|
99
|
+
/** Rule IDs to disable */
|
|
100
|
+
disabledRules?: string[];
|
|
101
|
+
/** Whether to validate KubernetesRef objects deeply */
|
|
102
|
+
deepReferenceValidation?: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Conditional Expression Validator
|
|
106
|
+
*
|
|
107
|
+
* Provides comprehensive validation for conditional expressions containing
|
|
108
|
+
* KubernetesRef objects, ensuring they are well-formed and contextually appropriate.
|
|
109
|
+
*/
|
|
110
|
+
export declare class ConditionalExpressionValidator {
|
|
111
|
+
private rules;
|
|
112
|
+
private magicProxyDetector;
|
|
113
|
+
private contextDetector;
|
|
114
|
+
constructor();
|
|
115
|
+
/**
|
|
116
|
+
* Validate a conditional expression
|
|
117
|
+
*
|
|
118
|
+
* @param expression - Expression to validate
|
|
119
|
+
* @param context - Factory context
|
|
120
|
+
* @param config - Validation configuration
|
|
121
|
+
* @returns Comprehensive validation result
|
|
122
|
+
*/
|
|
123
|
+
validateExpression(expression: any, context: FactoryExpressionContext, config?: ValidationConfig): ConditionalValidationResult;
|
|
124
|
+
/**
|
|
125
|
+
* Register a custom validation rule
|
|
126
|
+
*
|
|
127
|
+
* @param rule - Validation rule to register
|
|
128
|
+
*/
|
|
129
|
+
registerRule(rule: ValidationRule): void;
|
|
130
|
+
/**
|
|
131
|
+
* Unregister a validation rule
|
|
132
|
+
*
|
|
133
|
+
* @param ruleId - ID of the rule to unregister
|
|
134
|
+
* @returns Whether the rule was successfully unregistered
|
|
135
|
+
*/
|
|
136
|
+
unregisterRule(ruleId: string): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Get all registered validation rules
|
|
139
|
+
*
|
|
140
|
+
* @returns Array of validation rules
|
|
141
|
+
*/
|
|
142
|
+
getRules(): ValidationRule[];
|
|
143
|
+
/**
|
|
144
|
+
* Get applicable rules for a specific context
|
|
145
|
+
*/
|
|
146
|
+
private getApplicableRules;
|
|
147
|
+
/**
|
|
148
|
+
* Register built-in validation rules
|
|
149
|
+
*/
|
|
150
|
+
private registerBuiltInRules;
|
|
151
|
+
/**
|
|
152
|
+
* Calculate Levenshtein distance between two strings
|
|
153
|
+
*/
|
|
154
|
+
private levenshteinDistance;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Global conditional expression validator instance
|
|
158
|
+
*/
|
|
159
|
+
export declare const conditionalExpressionValidator: ConditionalExpressionValidator;
|
|
160
|
+
/**
|
|
161
|
+
* Utility function to validate a conditional expression
|
|
162
|
+
*
|
|
163
|
+
* @param expression - Expression to validate
|
|
164
|
+
* @param context - Factory context
|
|
165
|
+
* @param config - Validation configuration
|
|
166
|
+
* @returns Validation result
|
|
167
|
+
*/
|
|
168
|
+
export declare function validateConditionalExpression(expression: any, context: FactoryExpressionContext, config?: ValidationConfig): ConditionalValidationResult;
|
|
169
|
+
/**
|
|
170
|
+
* Utility function to register a custom validation rule
|
|
171
|
+
*
|
|
172
|
+
* @param rule - Validation rule to register
|
|
173
|
+
*/
|
|
174
|
+
export declare function registerValidationRule(rule: ValidationRule): void;
|
|
175
|
+
/**
|
|
176
|
+
* Utility function to get all validation rules
|
|
177
|
+
*
|
|
178
|
+
* @returns Array of validation rules
|
|
179
|
+
*/
|
|
180
|
+
export declare function getValidationRules(): ValidationRule[];
|
|
181
|
+
//# sourceMappingURL=conditional-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditional-validation.d.ts","sourceRoot":"","sources":["../../../src/core/expressions/conditional-validation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,uBAAuB,CAAC;AAI/B;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,O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