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.
Files changed (213) hide show
  1. package/README.md +4 -3
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/core/composition/imperative.d.ts.map +1 -1
  4. package/dist/core/composition/imperative.js +15 -2
  5. package/dist/core/composition/imperative.js.map +1 -1
  6. package/dist/core/composition/typekro-runtime/typekro-runtime.d.ts.map +1 -1
  7. package/dist/core/composition/typekro-runtime/typekro-runtime.js +24 -25
  8. package/dist/core/composition/typekro-runtime/typekro-runtime.js.map +1 -1
  9. package/dist/core/dependencies/type-guards.d.ts.map +1 -1
  10. package/dist/core/dependencies/type-guards.js +7 -2
  11. package/dist/core/dependencies/type-guards.js.map +1 -1
  12. package/dist/core/deployment/engine.d.ts +13 -1
  13. package/dist/core/deployment/engine.d.ts.map +1 -1
  14. package/dist/core/deployment/engine.js +48 -3
  15. package/dist/core/deployment/engine.js.map +1 -1
  16. package/dist/core/errors.d.ts +85 -0
  17. package/dist/core/errors.d.ts.map +1 -1
  18. package/dist/core/errors.js +135 -0
  19. package/dist/core/errors.js.map +1 -1
  20. package/dist/core/evaluation/cel-optimizer.d.ts.map +1 -1
  21. package/dist/core/evaluation/cel-optimizer.js +7 -13
  22. package/dist/core/evaluation/cel-optimizer.js.map +1 -1
  23. package/dist/core/expressions/analyzer.d.ts +584 -0
  24. package/dist/core/expressions/analyzer.d.ts.map +1 -0
  25. package/dist/core/expressions/analyzer.js +2956 -0
  26. package/dist/core/expressions/analyzer.js.map +1 -0
  27. package/dist/core/expressions/cache.d.ts +136 -0
  28. package/dist/core/expressions/cache.d.ts.map +1 -0
  29. package/dist/core/expressions/cache.js +347 -0
  30. package/dist/core/expressions/cache.js.map +1 -0
  31. package/dist/core/expressions/cel-conversion-engine.d.ts +126 -0
  32. package/dist/core/expressions/cel-conversion-engine.d.ts.map +1 -0
  33. package/dist/core/expressions/cel-conversion-engine.js +293 -0
  34. package/dist/core/expressions/cel-conversion-engine.js.map +1 -0
  35. package/dist/core/expressions/compile-time-validation.d.ts +270 -0
  36. package/dist/core/expressions/compile-time-validation.d.ts.map +1 -0
  37. package/dist/core/expressions/compile-time-validation.js +506 -0
  38. package/dist/core/expressions/compile-time-validation.js.map +1 -0
  39. package/dist/core/expressions/composition-integration.d.ts +315 -0
  40. package/dist/core/expressions/composition-integration.d.ts.map +1 -0
  41. package/dist/core/expressions/composition-integration.js +936 -0
  42. package/dist/core/expressions/composition-integration.js.map +1 -0
  43. package/dist/core/expressions/conditional-expression-processor.d.ts +154 -0
  44. package/dist/core/expressions/conditional-expression-processor.d.ts.map +1 -0
  45. package/dist/core/expressions/conditional-expression-processor.js +479 -0
  46. package/dist/core/expressions/conditional-expression-processor.js.map +1 -0
  47. package/dist/core/expressions/conditional-integration.d.ts +133 -0
  48. package/dist/core/expressions/conditional-integration.d.ts.map +1 -0
  49. package/dist/core/expressions/conditional-integration.js +293 -0
  50. package/dist/core/expressions/conditional-integration.js.map +1 -0
  51. package/dist/core/expressions/conditional-validation.d.ts +181 -0
  52. package/dist/core/expressions/conditional-validation.d.ts.map +1 -0
  53. package/dist/core/expressions/conditional-validation.js +460 -0
  54. package/dist/core/expressions/conditional-validation.js.map +1 -0
  55. package/dist/core/expressions/context-aware-generator.d.ts +127 -0
  56. package/dist/core/expressions/context-aware-generator.d.ts.map +1 -0
  57. package/dist/core/expressions/context-aware-generator.js +500 -0
  58. package/dist/core/expressions/context-aware-generator.js.map +1 -0
  59. package/dist/core/expressions/context-detector.d.ts +148 -0
  60. package/dist/core/expressions/context-detector.d.ts.map +1 -0
  61. package/dist/core/expressions/context-detector.js +546 -0
  62. package/dist/core/expressions/context-detector.js.map +1 -0
  63. package/dist/core/expressions/context-switcher.d.ts +185 -0
  64. package/dist/core/expressions/context-switcher.d.ts.map +1 -0
  65. package/dist/core/expressions/context-switcher.js +515 -0
  66. package/dist/core/expressions/context-switcher.js.map +1 -0
  67. package/dist/core/expressions/context-validator.d.ts +176 -0
  68. package/dist/core/expressions/context-validator.d.ts.map +1 -0
  69. package/dist/core/expressions/context-validator.js +452 -0
  70. package/dist/core/expressions/context-validator.js.map +1 -0
  71. package/dist/core/expressions/custom-context-manager.d.ts +194 -0
  72. package/dist/core/expressions/custom-context-manager.d.ts.map +1 -0
  73. package/dist/core/expressions/custom-context-manager.js +390 -0
  74. package/dist/core/expressions/custom-context-manager.js.map +1 -0
  75. package/dist/core/expressions/expression-proxy.d.ts +80 -0
  76. package/dist/core/expressions/expression-proxy.d.ts.map +1 -0
  77. package/dist/core/expressions/expression-proxy.js +227 -0
  78. package/dist/core/expressions/expression-proxy.js.map +1 -0
  79. package/dist/core/expressions/factory-integration.d.ts +132 -0
  80. package/dist/core/expressions/factory-integration.d.ts.map +1 -0
  81. package/dist/core/expressions/factory-integration.js +327 -0
  82. package/dist/core/expressions/factory-integration.js.map +1 -0
  83. package/dist/core/expressions/factory-pattern-handler.d.ts +88 -0
  84. package/dist/core/expressions/factory-pattern-handler.d.ts.map +1 -0
  85. package/dist/core/expressions/factory-pattern-handler.js +336 -0
  86. package/dist/core/expressions/factory-pattern-handler.js.map +1 -0
  87. package/dist/core/expressions/field-hydration-processor.d.ts +188 -0
  88. package/dist/core/expressions/field-hydration-processor.d.ts.map +1 -0
  89. package/dist/core/expressions/field-hydration-processor.js +562 -0
  90. package/dist/core/expressions/field-hydration-processor.js.map +1 -0
  91. package/dist/core/expressions/imperative-analyzer.d.ts +21 -0
  92. package/dist/core/expressions/imperative-analyzer.d.ts.map +1 -0
  93. package/dist/core/expressions/imperative-analyzer.js +457 -0
  94. package/dist/core/expressions/imperative-analyzer.js.map +1 -0
  95. package/dist/core/expressions/index.d.ts +54 -0
  96. package/dist/core/expressions/index.d.ts.map +1 -0
  97. package/dist/core/expressions/index.js +50 -0
  98. package/dist/core/expressions/index.js.map +1 -0
  99. package/dist/core/expressions/lazy-analysis.d.ts +1128 -0
  100. package/dist/core/expressions/lazy-analysis.d.ts.map +1 -0
  101. package/dist/core/expressions/lazy-analysis.js +2443 -0
  102. package/dist/core/expressions/lazy-analysis.js.map +1 -0
  103. package/dist/core/expressions/magic-assignable-analyzer.d.ts +123 -0
  104. package/dist/core/expressions/magic-assignable-analyzer.d.ts.map +1 -0
  105. package/dist/core/expressions/magic-assignable-analyzer.js +352 -0
  106. package/dist/core/expressions/magic-assignable-analyzer.js.map +1 -0
  107. package/dist/core/expressions/magic-proxy-analyzer.d.ts +206 -0
  108. package/dist/core/expressions/magic-proxy-analyzer.d.ts.map +1 -0
  109. package/dist/core/expressions/magic-proxy-analyzer.js +639 -0
  110. package/dist/core/expressions/magic-proxy-analyzer.js.map +1 -0
  111. package/dist/core/expressions/magic-proxy-detector.d.ts +154 -0
  112. package/dist/core/expressions/magic-proxy-detector.d.ts.map +1 -0
  113. package/dist/core/expressions/magic-proxy-detector.js +242 -0
  114. package/dist/core/expressions/magic-proxy-detector.js.map +1 -0
  115. package/dist/core/expressions/migration-helpers.d.ts +133 -0
  116. package/dist/core/expressions/migration-helpers.d.ts.map +1 -0
  117. package/dist/core/expressions/migration-helpers.js +443 -0
  118. package/dist/core/expressions/migration-helpers.js.map +1 -0
  119. package/dist/core/expressions/optionality-handler.d.ts +503 -0
  120. package/dist/core/expressions/optionality-handler.d.ts.map +1 -0
  121. package/dist/core/expressions/optionality-handler.js +1306 -0
  122. package/dist/core/expressions/optionality-handler.js.map +1 -0
  123. package/dist/core/expressions/readiness-integration.d.ts +119 -0
  124. package/dist/core/expressions/readiness-integration.d.ts.map +1 -0
  125. package/dist/core/expressions/readiness-integration.js +386 -0
  126. package/dist/core/expressions/readiness-integration.js.map +1 -0
  127. package/dist/core/expressions/resource-analyzer.d.ts +486 -0
  128. package/dist/core/expressions/resource-analyzer.d.ts.map +1 -0
  129. package/dist/core/expressions/resource-analyzer.js +1086 -0
  130. package/dist/core/expressions/resource-analyzer.js.map +1 -0
  131. package/dist/core/expressions/resource-validation.d.ts +187 -0
  132. package/dist/core/expressions/resource-validation.d.ts.map +1 -0
  133. package/dist/core/expressions/resource-validation.js +552 -0
  134. package/dist/core/expressions/resource-validation.js.map +1 -0
  135. package/dist/core/expressions/runtime-error-mapper.d.ts +138 -0
  136. package/dist/core/expressions/runtime-error-mapper.d.ts.map +1 -0
  137. package/dist/core/expressions/runtime-error-mapper.js +412 -0
  138. package/dist/core/expressions/runtime-error-mapper.js.map +1 -0
  139. package/dist/core/expressions/source-map.d.ts +168 -0
  140. package/dist/core/expressions/source-map.d.ts.map +1 -0
  141. package/dist/core/expressions/source-map.js +350 -0
  142. package/dist/core/expressions/source-map.js.map +1 -0
  143. package/dist/core/expressions/status-builder-analyzer.d.ts +353 -0
  144. package/dist/core/expressions/status-builder-analyzer.d.ts.map +1 -0
  145. package/dist/core/expressions/status-builder-analyzer.js +1311 -0
  146. package/dist/core/expressions/status-builder-analyzer.js.map +1 -0
  147. package/dist/core/expressions/type-inference.d.ts +184 -0
  148. package/dist/core/expressions/type-inference.d.ts.map +1 -0
  149. package/dist/core/expressions/type-inference.js +838 -0
  150. package/dist/core/expressions/type-inference.js.map +1 -0
  151. package/dist/core/expressions/type-safety.d.ts +203 -0
  152. package/dist/core/expressions/type-safety.d.ts.map +1 -0
  153. package/dist/core/expressions/type-safety.js +442 -0
  154. package/dist/core/expressions/type-safety.js.map +1 -0
  155. package/dist/core/expressions/types.d.ts +282 -0
  156. package/dist/core/expressions/types.d.ts.map +1 -0
  157. package/dist/core/expressions/types.js +8 -0
  158. package/dist/core/expressions/types.js.map +1 -0
  159. package/dist/core/kubernetes/client-provider.js +2 -2
  160. package/dist/core/kubernetes/client-provider.js.map +1 -1
  161. package/dist/core/references/cel.d.ts +13 -1
  162. package/dist/core/references/cel.d.ts.map +1 -1
  163. package/dist/core/references/cel.js +50 -0
  164. package/dist/core/references/cel.js.map +1 -1
  165. package/dist/core/references/schema-proxy.d.ts.map +1 -1
  166. package/dist/core/references/schema-proxy.js +13 -8
  167. package/dist/core/references/schema-proxy.js.map +1 -1
  168. package/dist/core/serialization/core.d.ts.map +1 -1
  169. package/dist/core/serialization/core.js +573 -9
  170. package/dist/core/serialization/core.js.map +1 -1
  171. package/dist/core/types/deployment.d.ts +7 -0
  172. package/dist/core/types/deployment.d.ts.map +1 -1
  173. package/dist/core/types/deployment.js +7 -0
  174. package/dist/core/types/deployment.js.map +1 -1
  175. package/dist/core/types/index.d.ts +1 -0
  176. package/dist/core/types/index.d.ts.map +1 -1
  177. package/dist/core/types/index.js.map +1 -1
  178. package/dist/core/validation/cel-validator.d.ts.map +1 -1
  179. package/dist/core/validation/cel-validator.js +4 -8
  180. package/dist/core/validation/cel-validator.js.map +1 -1
  181. package/dist/core.d.ts +1 -1
  182. package/dist/core.d.ts.map +1 -1
  183. package/dist/core.js +1 -1
  184. package/dist/core.js.map +1 -1
  185. package/dist/factories/helm/helm-release.d.ts.map +1 -1
  186. package/dist/factories/helm/helm-release.js +0 -5
  187. package/dist/factories/helm/helm-release.js.map +1 -1
  188. package/dist/factories/helm/types.d.ts +1 -1
  189. package/dist/factories/helm/types.d.ts.map +1 -1
  190. package/dist/factories/index.js +1 -0
  191. package/dist/factories/index.js.map +1 -1
  192. package/dist/factories/shared.d.ts.map +1 -1
  193. package/dist/factories/shared.js +21 -1
  194. package/dist/factories/shared.js.map +1 -1
  195. package/dist/factories/simple/index.d.ts +2 -2
  196. package/dist/factories/simple/index.d.ts.map +1 -1
  197. package/dist/factories/simple/workloads/deployment.d.ts +3 -3
  198. package/dist/factories/simple/workloads/deployment.d.ts.map +1 -1
  199. package/dist/factories/simple/workloads/deployment.js +37 -11
  200. package/dist/factories/simple/workloads/deployment.js.map +1 -1
  201. package/dist/index.d.ts +1 -1
  202. package/dist/index.d.ts.map +1 -1
  203. package/dist/index.js +1 -1
  204. package/dist/index.js.map +1 -1
  205. package/dist/utils/index.d.ts +1 -1
  206. package/dist/utils/index.d.ts.map +1 -1
  207. package/dist/utils/index.js +1 -1
  208. package/dist/utils/index.js.map +1 -1
  209. package/dist/utils/type-guards.d.ts +6 -0
  210. package/dist/utils/type-guards.d.ts.map +1 -1
  211. package/dist/utils/type-guards.js +25 -2
  212. package/dist/utils/type-guards.js.map +1 -1
  213. package/package.json +6 -1
@@ -0,0 +1,293 @@
1
+ /**
2
+ * CEL Conversion Engine for Factory Integration
3
+ *
4
+ * This module provides automatic conversion of JavaScript expressions containing
5
+ * KubernetesRef objects to appropriate CEL expressions for different deployment
6
+ * strategies.
7
+ */
8
+ import { getComponentLogger } from '../logging/index.js';
9
+ import { isKubernetesRef } from '../../utils/type-guards.js';
10
+ import { CEL_EXPRESSION_BRAND } from '../constants/brands.js';
11
+ import { MagicProxyDetector } from './magic-proxy-detector.js';
12
+ import { getCurrentCompositionContext } from '../../factories/shared.js';
13
+ const logger = getComponentLogger('cel-conversion-engine');
14
+ /**
15
+ * CEL Conversion Engine
16
+ *
17
+ * Automatically converts JavaScript expressions containing KubernetesRef objects
18
+ * to appropriate CEL expressions based on the factory type and usage context.
19
+ */
20
+ export class CelConversionEngine {
21
+ magicProxyDetector;
22
+ constructor() {
23
+ this.magicProxyDetector = new MagicProxyDetector();
24
+ }
25
+ /**
26
+ * Convert a value containing KubernetesRef objects to appropriate format
27
+ *
28
+ * @param value - Value to convert
29
+ * @param context - Factory context
30
+ * @param config - Conversion configuration
31
+ * @returns Conversion result
32
+ */
33
+ convertValue(value, context, config = {}) {
34
+ const startTime = performance.now();
35
+ logger.debug('Starting CEL conversion', {
36
+ factoryType: context.factoryType,
37
+ factoryName: context.factoryName,
38
+ valueType: typeof value
39
+ });
40
+ const result = {
41
+ converted: value,
42
+ wasConverted: false,
43
+ original: value,
44
+ strategy: 'static',
45
+ metrics: {
46
+ conversionTimeMs: 0,
47
+ referencesConverted: 0,
48
+ expressionsGenerated: 0
49
+ },
50
+ warnings: [],
51
+ debugInfo: {
52
+ detectedReferences: [],
53
+ conversionSteps: []
54
+ }
55
+ };
56
+ // Detect KubernetesRef objects in the value
57
+ const detection = this.magicProxyDetector.detectKubernetesRefs(value, {
58
+ maxDepth: config.maxDepth || 10,
59
+ includeDetailedPaths: true,
60
+ analyzeReferenceSources: true,
61
+ trackMetrics: true
62
+ });
63
+ if (config.includeDebugInfo) {
64
+ result.debugInfo.detectedReferences = detection.references;
65
+ result.debugInfo?.conversionSteps.push(`Detected ${detection.references.length} KubernetesRef objects`);
66
+ }
67
+ // If no KubernetesRef objects found, return as-is
68
+ if (!detection.hasKubernetesRefs) {
69
+ result.strategy = 'static';
70
+ result.metrics.conversionTimeMs = performance.now() - startTime;
71
+ return result;
72
+ }
73
+ // Convert based on factory type and value structure
74
+ const converted = this.performConversion(value, detection, context, config, result);
75
+ result.converted = converted;
76
+ result.wasConverted = true;
77
+ result.metrics.referencesConverted = detection.references.length;
78
+ result.metrics.conversionTimeMs = performance.now() - startTime;
79
+ logger.debug('CEL conversion completed', {
80
+ wasConverted: result.wasConverted,
81
+ strategy: result.strategy,
82
+ referencesConverted: result.metrics.referencesConverted,
83
+ conversionTimeMs: result.metrics.conversionTimeMs
84
+ });
85
+ return result;
86
+ }
87
+ /**
88
+ * Convert a simple KubernetesRef to CEL expression
89
+ *
90
+ * @param ref - KubernetesRef to convert
91
+ * @param context - Factory context
92
+ * @returns CEL expression
93
+ */
94
+ convertKubernetesRefToCel(ref, context) {
95
+ const celExpression = this.generateCelFromRef(ref, context);
96
+ return {
97
+ [CEL_EXPRESSION_BRAND]: true,
98
+ expression: celExpression,
99
+ type: 'unknown' // Type will be inferred during serialization
100
+ };
101
+ }
102
+ /**
103
+ * Check if a value needs CEL conversion
104
+ *
105
+ * @param value - Value to check
106
+ * @param maxDepth - Maximum depth to check
107
+ * @returns Whether conversion is needed
108
+ */
109
+ needsConversion(value, maxDepth = 10) {
110
+ return this.magicProxyDetector.containsKubernetesRefs(value, maxDepth);
111
+ }
112
+ performConversion(value, detection, context, config, result) {
113
+ // Handle direct KubernetesRef objects
114
+ if (isKubernetesRef(value)) {
115
+ result.strategy = 'direct';
116
+ // Check if this is an external reference
117
+ if (this.isExternalReference(value)) {
118
+ if (config.includeDebugInfo) {
119
+ result.debugInfo?.conversionSteps.push('Skipping conversion for external reference');
120
+ }
121
+ // External references should not be converted to CEL expressions
122
+ // They will be handled by the serialization layer
123
+ return value;
124
+ }
125
+ if (config.includeDebugInfo) {
126
+ result.debugInfo?.conversionSteps.push('Converting direct KubernetesRef to CEL expression');
127
+ }
128
+ if (context.factoryType === 'kro') {
129
+ // For Kro factories, convert to CEL expression
130
+ const celExpr = this.convertKubernetesRefToCel(value, context);
131
+ result.metrics.expressionsGenerated = 1;
132
+ return celExpr;
133
+ }
134
+ else {
135
+ // For direct factories, preserve the reference
136
+ return value;
137
+ }
138
+ }
139
+ // Handle template literals with KubernetesRef objects
140
+ if (this.isTemplateLiteralWithRefs(value, detection)) {
141
+ result.strategy = 'template-literal';
142
+ if (config.includeDebugInfo) {
143
+ result.debugInfo?.conversionSteps.push('Converting template literal with KubernetesRef objects');
144
+ }
145
+ return this.convertTemplateLiteral(value, detection, context, result);
146
+ }
147
+ // Handle objects and arrays recursively
148
+ if (value && typeof value === 'object') {
149
+ result.strategy = 'cel-expression';
150
+ if (config.includeDebugInfo) {
151
+ result.debugInfo?.conversionSteps.push('Converting object/array with nested KubernetesRef objects');
152
+ }
153
+ return this.convertObjectWithRefs(value, detection, context, config, result);
154
+ }
155
+ // Fallback: return as-is
156
+ return value;
157
+ }
158
+ /**
159
+ * Check if a KubernetesRef comes from an external reference
160
+ * External references are not registered in the current composition context
161
+ */
162
+ isExternalReference(ref) {
163
+ const resourceId = ref.resourceId;
164
+ // Schema references are never external
165
+ if (resourceId === '__schema__') {
166
+ return false;
167
+ }
168
+ // Check if the resource exists in the current composition context
169
+ const context = getCurrentCompositionContext();
170
+ if (!context) {
171
+ // If no composition context, we can't determine if it's external
172
+ // In this case, proceed with normal CEL conversion
173
+ return false;
174
+ }
175
+ // If the resource is not registered in the current context, it's external
176
+ return !(resourceId in context.resources);
177
+ }
178
+ generateCelFromRef(ref, _context) {
179
+ const resourceId = ref.resourceId;
180
+ const fieldPath = ref.fieldPath;
181
+ // Handle schema references
182
+ if (resourceId === '__schema__') {
183
+ return `schema.${fieldPath}`;
184
+ }
185
+ // Handle resource references - don't include 'resources.' prefix
186
+ // The final YAML serialization will wrap this with ${} to create ${resourceId.fieldPath}
187
+ return `${resourceId}.${fieldPath}`;
188
+ }
189
+ isTemplateLiteralWithRefs(value, detection) {
190
+ // This is a simplified check - in a real implementation, we'd need to parse
191
+ // the template literal structure to detect embedded KubernetesRef objects
192
+ return typeof value === 'string' && detection.hasKubernetesRefs;
193
+ }
194
+ convertTemplateLiteral(value, _detection, _context, result) {
195
+ // For now, return as-is since template literal parsing is complex
196
+ // In a full implementation, this would parse the template and convert
197
+ // embedded KubernetesRef objects to CEL expressions
198
+ result.warnings.push('Template literal conversion not fully implemented');
199
+ return value;
200
+ }
201
+ convertObjectWithRefs(value, _detection, context, config, result) {
202
+ if (Array.isArray(value)) {
203
+ return value.map((item, _index) => {
204
+ if (isKubernetesRef(item)) {
205
+ // Check if this is an external reference
206
+ if (this.isExternalReference(item)) {
207
+ // External references should not be converted
208
+ return item;
209
+ }
210
+ result.metrics.expressionsGenerated++;
211
+ return context.factoryType === 'kro'
212
+ ? this.convertKubernetesRefToCel(item, context)
213
+ : item;
214
+ }
215
+ // Recursively convert nested items
216
+ if (this.magicProxyDetector.containsKubernetesRefs(item)) {
217
+ const nestedResult = this.convertValue(item, context, config);
218
+ if (nestedResult.wasConverted) {
219
+ result.metrics.expressionsGenerated += nestedResult.metrics.expressionsGenerated;
220
+ }
221
+ return nestedResult.converted;
222
+ }
223
+ return item;
224
+ });
225
+ }
226
+ if (value && typeof value === 'object' && value.constructor === Object) {
227
+ const converted = {};
228
+ for (const [key, val] of Object.entries(value)) {
229
+ if (isKubernetesRef(val)) {
230
+ // Check if this is an external reference
231
+ if (this.isExternalReference(val)) {
232
+ // External references should not be converted
233
+ converted[key] = val;
234
+ }
235
+ else {
236
+ result.metrics.expressionsGenerated++;
237
+ converted[key] = context.factoryType === 'kro'
238
+ ? this.convertKubernetesRefToCel(val, context)
239
+ : val;
240
+ }
241
+ }
242
+ else if (this.magicProxyDetector.containsKubernetesRefs(val)) {
243
+ const nestedResult = this.convertValue(val, context, config);
244
+ if (nestedResult.wasConverted) {
245
+ result.metrics.expressionsGenerated += nestedResult.metrics.expressionsGenerated;
246
+ }
247
+ converted[key] = nestedResult.converted;
248
+ }
249
+ else {
250
+ converted[key] = val;
251
+ }
252
+ }
253
+ return converted;
254
+ }
255
+ return value;
256
+ }
257
+ }
258
+ /**
259
+ * Global CEL conversion engine instance
260
+ */
261
+ export const celConversionEngine = new CelConversionEngine();
262
+ /**
263
+ * Utility function to convert a value with KubernetesRef objects
264
+ *
265
+ * @param value - Value to convert
266
+ * @param context - Factory context
267
+ * @param config - Conversion configuration
268
+ * @returns Conversion result
269
+ */
270
+ export function convertToCel(value, context, config) {
271
+ return celConversionEngine.convertValue(value, context, config);
272
+ }
273
+ /**
274
+ * Utility function to convert a KubernetesRef to CEL expression
275
+ *
276
+ * @param ref - KubernetesRef to convert
277
+ * @param context - Factory context
278
+ * @returns CEL expression
279
+ */
280
+ export function kubernetesRefToCel(ref, context) {
281
+ return celConversionEngine.convertKubernetesRefToCel(ref, context);
282
+ }
283
+ /**
284
+ * Utility function to check if a value needs CEL conversion
285
+ *
286
+ * @param value - Value to check
287
+ * @param maxDepth - Maximum depth to check
288
+ * @returns Whether conversion is needed
289
+ */
290
+ export function needsCelConversion(value, maxDepth) {
291
+ return celConversionEngine.needsConversion(value, maxDepth);
292
+ }
293
+ //# sourceMappingURL=cel-conversion-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cel-conversion-engine.js","sourceRoot":"","sources":["../../../src/core/expressions/cel-conversion-engine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA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AC;oBACV,CAAC;gBACH,CAAC;qBAAM,IAAI,IAAI,CAAC,kBAAkB,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC/D,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;oBAC7D,IAAI,YAAY,CAAC,YAAY,EAAE,CAAC;wBAC9B,MAAM,CAAC,OAAO,CAAC,oBAAoB,IAAI,YAAY,CAAC,OAAO,CAAC,oBAAoB,CAAC;oBACnF,CAAC;oBACD,SAAS,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC;gBAC1C,CAAC;qBAAM,CAAC;oBACN,SAAS,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;gBACvB,CAAC;YACH,CAAC;YAED,OAAO,SAAc,CAAC;QACxB,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAQ,EACR,OAAiC,EACjC,MAA4B;IAE5B,OAAO,mBAAmB,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAChC,GAAqB,EACrB,OAAiC;IAEjC,OAAO,mBAAmB,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAU,EAAE,QAAiB;IAC9D,OAAO,mBAAmB,CAAC,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,270 @@
1
+ /**
2
+ * Compile-Time Type Checking for Expression Compatibility
3
+ *
4
+ * This module provides compile-time type checking capabilities for JavaScript
5
+ * expressions that will be converted to CEL. It integrates with TypeScript's
6
+ * type system to validate expressions before runtime conversion.
7
+ */
8
+ import type { KubernetesRef } from '../types/common.js';
9
+ import type { Enhanced } from '../types/kubernetes.js';
10
+ import type { SchemaProxy } from '../types/serialization.js';
11
+ import type { TypeInfo } from './type-safety.js';
12
+ /**
13
+ * Compile-time validation result
14
+ */
15
+ export interface CompileTimeValidationResult {
16
+ /** Whether the expression passes compile-time validation */
17
+ valid: boolean;
18
+ /** Compile-time type information */
19
+ compileTimeType?: CompileTimeTypeInfo;
20
+ /** Runtime type information (inferred) */
21
+ runtimeType?: TypeInfo;
22
+ /** Type compatibility issues */
23
+ compatibilityIssues: TypeCompatibilityIssue[];
24
+ /** Compile-time errors */
25
+ errors: CompileTimeError[];
26
+ /** Compile-time warnings */
27
+ warnings: CompileTimeWarning[];
28
+ /** Suggestions for fixing issues */
29
+ suggestions: string[];
30
+ /** Metadata about the validation */
31
+ metadata: CompileTimeValidationMetadata;
32
+ }
33
+ /**
34
+ * Compile-time type information
35
+ */
36
+ export interface CompileTimeTypeInfo {
37
+ /** TypeScript type name */
38
+ typeName: string;
39
+ /** Whether the type is a union type */
40
+ isUnion: boolean;
41
+ /** Union type members if applicable */
42
+ unionMembers?: string[];
43
+ /** Whether the type is generic */
44
+ isGeneric: boolean;
45
+ /** Generic type parameters */
46
+ genericParams?: string[];
47
+ /** Whether the type is optional */
48
+ optional: boolean;
49
+ /** Whether the type can be null */
50
+ nullable: boolean;
51
+ /** Whether the type can be undefined */
52
+ undefinable: boolean;
53
+ /** Type constraints */
54
+ constraints?: TypeConstraint[];
55
+ /** Source location of the type */
56
+ sourceLocation?: {
57
+ file: string;
58
+ line: number;
59
+ column: number;
60
+ };
61
+ }
62
+ /**
63
+ * Type compatibility issue
64
+ */
65
+ export interface TypeCompatibilityIssue {
66
+ /** Type of compatibility issue */
67
+ type: CompatibilityIssueType;
68
+ /** Description of the issue */
69
+ description: string;
70
+ /** Expected type */
71
+ expectedType: CompileTimeTypeInfo;
72
+ /** Actual type */
73
+ actualType: CompileTimeTypeInfo;
74
+ /** Severity of the issue */
75
+ severity: 'error' | 'warning' | 'info';
76
+ /** Location where the issue occurs */
77
+ location?: {
78
+ line: number;
79
+ column: number;
80
+ };
81
+ /** Suggested fix */
82
+ suggestedFix?: string;
83
+ }
84
+ /**
85
+ * Compile-time error
86
+ */
87
+ export declare class CompileTimeError extends Error {
88
+ readonly errorType: CompileTimeErrorType;
89
+ readonly expression: string;
90
+ readonly location?: {
91
+ line: number;
92
+ column: number;
93
+ } | undefined;
94
+ constructor(message: string, errorType: CompileTimeErrorType, expression: string, location?: {
95
+ line: number;
96
+ column: number;
97
+ } | undefined);
98
+ static forTypeIncompatibility(expression: string, expectedType: string, actualType: string, location?: {
99
+ line: number;
100
+ column: number;
101
+ }): CompileTimeError;
102
+ static forUnsupportedSyntax(expression: string, syntaxFeature: string, location?: {
103
+ line: number;
104
+ column: number;
105
+ }): CompileTimeError;
106
+ static forGenericConstraintViolation(expression: string, constraint: string, actualType: string, location?: {
107
+ line: number;
108
+ column: number;
109
+ }): CompileTimeError;
110
+ }
111
+ /**
112
+ * Compile-time warning
113
+ */
114
+ export declare class CompileTimeWarning {
115
+ readonly message: string;
116
+ readonly warningType: CompileTimeWarningType;
117
+ readonly expression: string;
118
+ readonly location?: {
119
+ line: number;
120
+ column: number;
121
+ } | undefined;
122
+ constructor(message: string, warningType: CompileTimeWarningType, expression: string, location?: {
123
+ line: number;
124
+ column: number;
125
+ } | undefined);
126
+ static forPotentialRuntimeError(expression: string, reason: string, location?: {
127
+ line: number;
128
+ column: number;
129
+ }): CompileTimeWarning;
130
+ static forPerformanceImpact(expression: string, impact: string, location?: {
131
+ line: number;
132
+ column: number;
133
+ }): CompileTimeWarning;
134
+ static forDeprecatedFeature(expression: string, feature: string, replacement?: string, location?: {
135
+ line: number;
136
+ column: number;
137
+ }): CompileTimeWarning;
138
+ }
139
+ /**
140
+ * Validation metadata
141
+ */
142
+ export interface CompileTimeValidationMetadata {
143
+ /** TypeScript version used for validation */
144
+ typescriptVersion?: string;
145
+ /** Compilation target */
146
+ target?: string;
147
+ /** Whether strict mode is enabled */
148
+ strictMode: boolean;
149
+ /** Whether null checks are enabled */
150
+ strictNullChecks: boolean;
151
+ /** Time taken for validation (ms) */
152
+ validationTime: number;
153
+ /** Number of type checks performed */
154
+ typeChecksPerformed: number;
155
+ /** Complexity score of the expression */
156
+ complexityScore: number;
157
+ }
158
+ /**
159
+ * Type constraint
160
+ */
161
+ export interface TypeConstraint {
162
+ /** Type of constraint */
163
+ type: 'extends' | 'keyof' | 'typeof' | 'conditional';
164
+ /** Constraint expression */
165
+ expression: string;
166
+ /** Whether the constraint is satisfied */
167
+ satisfied: boolean;
168
+ }
169
+ /**
170
+ * Enum types
171
+ */
172
+ export type CompatibilityIssueType = 'TYPE_MISMATCH' | 'NULLABILITY_MISMATCH' | 'OPTIONALITY_MISMATCH' | 'GENERIC_PARAMETER_MISMATCH' | 'UNION_TYPE_INCOMPATIBILITY' | 'CONSTRAINT_VIOLATION';
173
+ export type CompileTimeErrorType = 'TYPE_INCOMPATIBILITY' | 'UNSUPPORTED_SYNTAX' | 'GENERIC_CONSTRAINT_VIOLATION' | 'CIRCULAR_TYPE_REFERENCE' | 'MISSING_TYPE_INFORMATION';
174
+ export type CompileTimeWarningType = 'POTENTIAL_RUNTIME_ERROR' | 'PERFORMANCE_IMPACT' | 'DEPRECATED_FEATURE' | 'TYPE_ASSERTION_USED' | 'IMPLICIT_ANY';
175
+ /**
176
+ * Compile-time type checker
177
+ */
178
+ export declare class CompileTimeTypeChecker {
179
+ private typeCache;
180
+ private validationCache;
181
+ /**
182
+ * Validate expression compatibility at compile time
183
+ */
184
+ validateExpressionCompatibility(expression: string, context: CompileTimeValidationContext): CompileTimeValidationResult;
185
+ /**
186
+ * Validate multiple expressions for compatibility
187
+ */
188
+ validateExpressionsCompatibility(expressions: string[], context: CompileTimeValidationContext): CompileTimeValidationResult[];
189
+ /**
190
+ * Validate that a KubernetesRef type is compatible with its usage
191
+ */
192
+ validateKubernetesRefCompatibility(ref: KubernetesRef<any>, usageContext: KubernetesRefUsageContext, validationContext: CompileTimeValidationContext): CompileTimeValidationResult;
193
+ /**
194
+ * Extract compile-time type information from expression
195
+ */
196
+ private extractCompileTimeType;
197
+ /**
198
+ * Infer runtime type from compile-time information
199
+ */
200
+ private inferRuntimeType;
201
+ /**
202
+ * Check compatibility between compile-time and runtime types
203
+ */
204
+ private checkTypeCompatibility;
205
+ /**
206
+ * Validate against expected type
207
+ */
208
+ private validateAgainstExpectedType;
209
+ /**
210
+ * Validate syntax support
211
+ */
212
+ private validateSyntaxSupport;
213
+ /**
214
+ * Validate runtime safety
215
+ */
216
+ private validateRuntimeSafety;
217
+ /**
218
+ * Extract KubernetesRef type information
219
+ */
220
+ private extractKubernetesRefType;
221
+ /**
222
+ * Validate KubernetesRef usage
223
+ */
224
+ private validateKubernetesRefUsage;
225
+ /**
226
+ * Utility methods
227
+ */
228
+ private areTypesCompatible;
229
+ private convertRuntimeToCompileTime;
230
+ private generateSuggestions;
231
+ private calculateComplexityScore;
232
+ private createCacheKey;
233
+ private isBooleanExpression;
234
+ private isNumericExpression;
235
+ /**
236
+ * Clear validation cache
237
+ */
238
+ clearCache(): void;
239
+ }
240
+ /**
241
+ * Compile-time validation context
242
+ */
243
+ export interface CompileTimeValidationContext {
244
+ /** Whether strict mode is enabled */
245
+ strictMode?: boolean;
246
+ /** Whether strict null checks are enabled */
247
+ strictNullChecks?: boolean;
248
+ /** Expected type for the expression */
249
+ expectedType?: CompileTimeTypeInfo;
250
+ /** Available type definitions */
251
+ availableTypes?: Record<string, CompileTimeTypeInfo>;
252
+ /** Whether to skip cache lookup */
253
+ skipCache?: boolean;
254
+ /** TypeScript compiler options */
255
+ compilerOptions?: any;
256
+ }
257
+ /**
258
+ * KubernetesRef usage context
259
+ */
260
+ export interface KubernetesRefUsageContext {
261
+ /** Available resources */
262
+ availableResources: Record<string, Enhanced<any, any>>;
263
+ /** Schema proxy if available */
264
+ schemaProxy?: SchemaProxy<any, any>;
265
+ /** How the KubernetesRef is being used */
266
+ usageType: 'property-access' | 'method-call' | 'comparison' | 'template-literal';
267
+ /** Expected result type of the usage */
268
+ expectedResultType?: CompileTimeTypeInfo;
269
+ }
270
+ //# sourceMappingURL=compile-time-validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-time-validation.d.ts","sourceRoot":"","sources":["../../../src/core/expressions/compile-time-validation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAG,MAAM,kBAAkB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,4DAA4D;IAC5D,KAAK,EAAE,OAAO,CAAC;IAEf,oCAAoC;IACpC,eAAe,CAAC,EAAE,mBAAmB,CAAC;IAEtC,0CAA0C;IAC1C,WAAW,CAAC,EAAE,QAAQ,CAAC;IAEvB,gCAAgC;IAChC,mBAAmB,EAAE,sBAAsB,EAAE,CAAC;IAE9C,0BAA0B;IAC1B,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAE3B,4BAA4B;IAC5B,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAE/B,oCAAoC;IACpC,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB,oCAAoC;IACpC,QAAQ,EAAE,6BAA6B,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IAEjB,uCAAuC;IACvC,OAAO,EAAE,OAAO,CAAC;IAEjB,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB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