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,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Magic Proxy Detection for Factory Integration
|
|
3
|
+
*
|
|
4
|
+
* This module provides enhanced detection capabilities for KubernetesRef objects
|
|
5
|
+
* that originate from TypeKro's magic proxy system (SchemaProxy and ResourcesProxy).
|
|
6
|
+
*/
|
|
7
|
+
import type { KubernetesRef } from '../types/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Information about a detected KubernetesRef from magic proxy
|
|
10
|
+
*/
|
|
11
|
+
export interface MagicProxyRefInfo {
|
|
12
|
+
/** The KubernetesRef object */
|
|
13
|
+
ref: KubernetesRef<any>;
|
|
14
|
+
/** Path where the reference was found */
|
|
15
|
+
path: string;
|
|
16
|
+
/** Source of the reference (schema or resource) */
|
|
17
|
+
source: 'schema' | 'resource' | 'unknown';
|
|
18
|
+
/** Resource ID if from resource proxy */
|
|
19
|
+
resourceId?: string;
|
|
20
|
+
/** Field path within the resource/schema */
|
|
21
|
+
fieldPath: string;
|
|
22
|
+
/** Whether this is a nested reference */
|
|
23
|
+
isNested: boolean;
|
|
24
|
+
/** Depth of nesting */
|
|
25
|
+
nestingDepth: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Result of magic proxy detection
|
|
29
|
+
*/
|
|
30
|
+
export interface MagicProxyDetectionResult {
|
|
31
|
+
/** Whether any KubernetesRef objects were found */
|
|
32
|
+
hasKubernetesRefs: boolean;
|
|
33
|
+
/** List of detected references */
|
|
34
|
+
references: MagicProxyRefInfo[];
|
|
35
|
+
/** Statistics about the detection */
|
|
36
|
+
stats: {
|
|
37
|
+
totalReferences: number;
|
|
38
|
+
schemaReferences: number;
|
|
39
|
+
resourceReferences: number;
|
|
40
|
+
nestedReferences: number;
|
|
41
|
+
maxNestingDepth: number;
|
|
42
|
+
};
|
|
43
|
+
/** Performance metrics */
|
|
44
|
+
metrics: {
|
|
45
|
+
detectionTimeMs: number;
|
|
46
|
+
objectsScanned: number;
|
|
47
|
+
propertiesScanned: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Configuration for magic proxy detection
|
|
52
|
+
*/
|
|
53
|
+
export interface MagicProxyDetectionConfig {
|
|
54
|
+
/** Maximum depth to scan for nested references */
|
|
55
|
+
maxDepth?: number;
|
|
56
|
+
/** Whether to include detailed path information */
|
|
57
|
+
includeDetailedPaths?: boolean;
|
|
58
|
+
/** Whether to analyze reference sources */
|
|
59
|
+
analyzeReferenceSources?: boolean;
|
|
60
|
+
/** Whether to track performance metrics */
|
|
61
|
+
trackMetrics?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Magic Proxy Detector
|
|
65
|
+
*
|
|
66
|
+
* Provides sophisticated detection of KubernetesRef objects that originate
|
|
67
|
+
* from TypeKro's magic proxy system, with detailed analysis of their sources
|
|
68
|
+
* and usage patterns.
|
|
69
|
+
*/
|
|
70
|
+
export declare class MagicProxyDetector {
|
|
71
|
+
/**
|
|
72
|
+
* Detect KubernetesRef objects in a value with detailed analysis
|
|
73
|
+
*
|
|
74
|
+
* @param value - Value to analyze
|
|
75
|
+
* @param config - Detection configuration
|
|
76
|
+
* @param basePath - Base path for reference tracking
|
|
77
|
+
* @returns Detection result
|
|
78
|
+
*/
|
|
79
|
+
detectKubernetesRefs(value: any, config?: MagicProxyDetectionConfig, basePath?: string): MagicProxyDetectionResult;
|
|
80
|
+
/**
|
|
81
|
+
* Check if a value contains any KubernetesRef objects (fast check)
|
|
82
|
+
*
|
|
83
|
+
* @param value - Value to check
|
|
84
|
+
* @param maxDepth - Maximum depth to check
|
|
85
|
+
* @returns Whether KubernetesRef objects were found
|
|
86
|
+
*/
|
|
87
|
+
containsKubernetesRefs(value: any, maxDepth?: number): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Extract all KubernetesRef objects from a value
|
|
90
|
+
*
|
|
91
|
+
* @param value - Value to extract from
|
|
92
|
+
* @param maxDepth - Maximum depth to extract
|
|
93
|
+
* @returns Array of KubernetesRef objects
|
|
94
|
+
*/
|
|
95
|
+
extractKubernetesRefs(value: any, maxDepth?: number): KubernetesRef<any>[];
|
|
96
|
+
/**
|
|
97
|
+
* Analyze the source of a KubernetesRef object
|
|
98
|
+
*
|
|
99
|
+
* @param ref - KubernetesRef to analyze
|
|
100
|
+
* @returns Source analysis
|
|
101
|
+
*/
|
|
102
|
+
analyzeReferenceSource(ref: KubernetesRef<any>): {
|
|
103
|
+
source: 'schema' | 'resource' | 'unknown';
|
|
104
|
+
isSchemaRef: boolean;
|
|
105
|
+
isResourceRef: boolean;
|
|
106
|
+
resourceId?: string;
|
|
107
|
+
fieldPath: string;
|
|
108
|
+
};
|
|
109
|
+
private scanValue;
|
|
110
|
+
private fastScanForRefs;
|
|
111
|
+
private extractRefs;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Global magic proxy detector instance
|
|
115
|
+
*/
|
|
116
|
+
export declare const magicProxyDetector: MagicProxyDetector;
|
|
117
|
+
/**
|
|
118
|
+
* Utility function to detect KubernetesRef objects in a value
|
|
119
|
+
*
|
|
120
|
+
* @param value - Value to analyze
|
|
121
|
+
* @param config - Detection configuration
|
|
122
|
+
* @returns Detection result
|
|
123
|
+
*/
|
|
124
|
+
export declare function detectMagicProxyRefs(value: any, config?: MagicProxyDetectionConfig): MagicProxyDetectionResult;
|
|
125
|
+
/**
|
|
126
|
+
* Utility function to check if a value contains KubernetesRef objects
|
|
127
|
+
*
|
|
128
|
+
* @param value - Value to check
|
|
129
|
+
* @param maxDepth - Maximum depth to check
|
|
130
|
+
* @returns Whether KubernetesRef objects were found
|
|
131
|
+
*/
|
|
132
|
+
export declare function containsMagicProxyRefs(value: any, maxDepth?: number): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Utility function to extract all KubernetesRef objects from a value
|
|
135
|
+
*
|
|
136
|
+
* @param value - Value to extract from
|
|
137
|
+
* @param maxDepth - Maximum depth to extract
|
|
138
|
+
* @returns Array of KubernetesRef objects
|
|
139
|
+
*/
|
|
140
|
+
export declare function extractMagicProxyRefs(value: any, maxDepth?: number): KubernetesRef<any>[];
|
|
141
|
+
/**
|
|
142
|
+
* Utility function to analyze the source of a KubernetesRef object
|
|
143
|
+
*
|
|
144
|
+
* @param ref - KubernetesRef to analyze
|
|
145
|
+
* @returns Source analysis
|
|
146
|
+
*/
|
|
147
|
+
export declare function analyzeMagicProxyRefSource(ref: KubernetesRef<any>): {
|
|
148
|
+
source: "schema" | "resource" | "unknown";
|
|
149
|
+
isSchemaRef: boolean;
|
|
150
|
+
isResourceRef: boolean;
|
|
151
|
+
resourceId?: string;
|
|
152
|
+
fieldPath: string;
|
|
153
|
+
};
|
|
154
|
+
//# sourceMappingURL=magic-proxy-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"magic-proxy-detector.d.ts","sourceRoot":"","sources":["../../../src/core/expressions/magic-proxy-detector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAG,MAAM,mBAAmB,CAAC;AAKxD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,+BAA+B;IAC/B,GAAG,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IACxB,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,MAAM,EAAE,QAAQ,GAAG,UAAU,GAA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,EAAE,GAAG,EAAE,QAAQ,SAAK,GAAG,aAAa,CAAC,GAAG,CAAC,EAAE;IAMtE;;;;;OAKG;IACH,sBAAsB,CAAC,GAAG,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG;QAC/C,MAAM,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;QAC1C,WAAW,EAAE,OAAO,CAAC;QACrB,aAAa,EAAE,OAAO,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;KACnB;IA6CD,OAAO,CAAC,SAAS;IAyDjB,OAAO,CAAC,eAAe;IAoBvB,OAAO,CAAC,WAAW;CAkBpB;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,oBAA2B,CAAC;AAE3D;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,GAAG,EACV,MAAM,CAAC,EAAE,yBAAyB,GACjC,yBAAyB,CAE3B;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAE7E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,EAAE,CAEzF;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,aAAa,CAAC,GAAG,CAAC;YAlMtD,QAAQ,GAAG,UAAU,GAAG,SAAS;iBAC5B,OAAO;mBACL,OAAO;iBACT,MAAM;eACR,MAAM;EAgMpB"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Magic Proxy Detection for Factory Integration
|
|
3
|
+
*
|
|
4
|
+
* This module provides enhanced detection capabilities for KubernetesRef objects
|
|
5
|
+
* that originate from TypeKro's magic proxy system (SchemaProxy and ResourcesProxy).
|
|
6
|
+
*/
|
|
7
|
+
import { getComponentLogger } from '../logging/index.js';
|
|
8
|
+
import { isKubernetesRef } from '../../utils/type-guards.js';
|
|
9
|
+
const logger = getComponentLogger('magic-proxy-detector');
|
|
10
|
+
/**
|
|
11
|
+
* Magic Proxy Detector
|
|
12
|
+
*
|
|
13
|
+
* Provides sophisticated detection of KubernetesRef objects that originate
|
|
14
|
+
* from TypeKro's magic proxy system, with detailed analysis of their sources
|
|
15
|
+
* and usage patterns.
|
|
16
|
+
*/
|
|
17
|
+
export class MagicProxyDetector {
|
|
18
|
+
/**
|
|
19
|
+
* Detect KubernetesRef objects in a value with detailed analysis
|
|
20
|
+
*
|
|
21
|
+
* @param value - Value to analyze
|
|
22
|
+
* @param config - Detection configuration
|
|
23
|
+
* @param basePath - Base path for reference tracking
|
|
24
|
+
* @returns Detection result
|
|
25
|
+
*/
|
|
26
|
+
detectKubernetesRefs(value, config = {}, basePath = '') {
|
|
27
|
+
const startTime = performance.now();
|
|
28
|
+
const result = {
|
|
29
|
+
hasKubernetesRefs: false,
|
|
30
|
+
references: [],
|
|
31
|
+
stats: {
|
|
32
|
+
totalReferences: 0,
|
|
33
|
+
schemaReferences: 0,
|
|
34
|
+
resourceReferences: 0,
|
|
35
|
+
nestedReferences: 0,
|
|
36
|
+
maxNestingDepth: 0
|
|
37
|
+
},
|
|
38
|
+
metrics: {
|
|
39
|
+
detectionTimeMs: 0,
|
|
40
|
+
objectsScanned: 0,
|
|
41
|
+
propertiesScanned: 0
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
this.scanValue(value, result, config, basePath, 0);
|
|
45
|
+
result.hasKubernetesRefs = result.references.length > 0;
|
|
46
|
+
result.stats.totalReferences = result.references.length;
|
|
47
|
+
result.stats.schemaReferences = result.references.filter(r => r.source === 'schema').length;
|
|
48
|
+
result.stats.resourceReferences = result.references.filter(r => r.source === 'resource').length;
|
|
49
|
+
result.stats.nestedReferences = result.references.filter(r => r.isNested).length;
|
|
50
|
+
result.stats.maxNestingDepth = Math.max(...result.references.map(r => r.nestingDepth), 0);
|
|
51
|
+
result.metrics.detectionTimeMs = performance.now() - startTime;
|
|
52
|
+
if (config.trackMetrics !== false) {
|
|
53
|
+
logger.debug('Magic proxy detection completed', {
|
|
54
|
+
hasKubernetesRefs: result.hasKubernetesRefs,
|
|
55
|
+
totalReferences: result.stats.totalReferences,
|
|
56
|
+
detectionTimeMs: result.metrics.detectionTimeMs
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Check if a value contains any KubernetesRef objects (fast check)
|
|
63
|
+
*
|
|
64
|
+
* @param value - Value to check
|
|
65
|
+
* @param maxDepth - Maximum depth to check
|
|
66
|
+
* @returns Whether KubernetesRef objects were found
|
|
67
|
+
*/
|
|
68
|
+
containsKubernetesRefs(value, maxDepth = 10) {
|
|
69
|
+
return this.fastScanForRefs(value, 0, maxDepth);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Extract all KubernetesRef objects from a value
|
|
73
|
+
*
|
|
74
|
+
* @param value - Value to extract from
|
|
75
|
+
* @param maxDepth - Maximum depth to extract
|
|
76
|
+
* @returns Array of KubernetesRef objects
|
|
77
|
+
*/
|
|
78
|
+
extractKubernetesRefs(value, maxDepth = 10) {
|
|
79
|
+
const refs = [];
|
|
80
|
+
this.extractRefs(value, refs, 0, maxDepth);
|
|
81
|
+
return refs;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Analyze the source of a KubernetesRef object
|
|
85
|
+
*
|
|
86
|
+
* @param ref - KubernetesRef to analyze
|
|
87
|
+
* @returns Source analysis
|
|
88
|
+
*/
|
|
89
|
+
analyzeReferenceSource(ref) {
|
|
90
|
+
const resourceId = ref.resourceId;
|
|
91
|
+
const fieldPath = ref.fieldPath || '';
|
|
92
|
+
// Handle malformed refs gracefully
|
|
93
|
+
if (!resourceId || typeof resourceId !== 'string') {
|
|
94
|
+
return {
|
|
95
|
+
source: 'unknown',
|
|
96
|
+
isSchemaRef: false,
|
|
97
|
+
isResourceRef: false,
|
|
98
|
+
fieldPath
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// Detect schema references (typically have __schema__ as resourceId)
|
|
102
|
+
const isSchemaRef = resourceId === '__schema__' || resourceId.startsWith('schema.');
|
|
103
|
+
// Detect resource references (have actual resource IDs)
|
|
104
|
+
const isResourceRef = !isSchemaRef && !!resourceId && resourceId !== '__schema__';
|
|
105
|
+
const source = isSchemaRef ? 'schema' :
|
|
106
|
+
isResourceRef ? 'resource' :
|
|
107
|
+
'unknown';
|
|
108
|
+
const result = {
|
|
109
|
+
source,
|
|
110
|
+
isSchemaRef,
|
|
111
|
+
isResourceRef,
|
|
112
|
+
fieldPath
|
|
113
|
+
};
|
|
114
|
+
if (isResourceRef && resourceId) {
|
|
115
|
+
result.resourceId = resourceId;
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
scanValue(value, result, config, currentPath, depth) {
|
|
120
|
+
const maxDepth = config.maxDepth || 10;
|
|
121
|
+
if (depth >= maxDepth) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
result.metrics.objectsScanned++;
|
|
125
|
+
// Check if this value is a KubernetesRef
|
|
126
|
+
if (isKubernetesRef(value)) {
|
|
127
|
+
const sourceAnalysis = config.analyzeReferenceSources !== false
|
|
128
|
+
? this.analyzeReferenceSource(value)
|
|
129
|
+
: { source: 'unknown', isSchemaRef: false, isResourceRef: false, fieldPath: value.fieldPath };
|
|
130
|
+
const refInfo = {
|
|
131
|
+
ref: value,
|
|
132
|
+
path: currentPath,
|
|
133
|
+
source: sourceAnalysis.source,
|
|
134
|
+
...(sourceAnalysis.resourceId && { resourceId: sourceAnalysis.resourceId }),
|
|
135
|
+
fieldPath: sourceAnalysis.fieldPath,
|
|
136
|
+
isNested: depth > 1, // Only consider nested if depth > 1 (not just at object level)
|
|
137
|
+
nestingDepth: depth
|
|
138
|
+
};
|
|
139
|
+
result.references.push(refInfo);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
// Recursively scan objects and arrays
|
|
143
|
+
if (value && typeof value === 'object') {
|
|
144
|
+
if (Array.isArray(value)) {
|
|
145
|
+
value.forEach((item, index) => {
|
|
146
|
+
result.metrics.propertiesScanned++;
|
|
147
|
+
const itemPath = config.includeDetailedPaths !== false
|
|
148
|
+
? `${currentPath}[${index}]`
|
|
149
|
+
: currentPath;
|
|
150
|
+
this.scanValue(item, result, config, itemPath, depth + 1);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
for (const [key, val] of Object.entries(value)) {
|
|
155
|
+
result.metrics.propertiesScanned++;
|
|
156
|
+
const propPath = config.includeDetailedPaths !== false
|
|
157
|
+
? currentPath ? `${currentPath}.${key}` : key
|
|
158
|
+
: currentPath;
|
|
159
|
+
this.scanValue(val, result, config, propPath, depth + 1);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
fastScanForRefs(value, depth, maxDepth) {
|
|
165
|
+
if (depth >= maxDepth) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
if (isKubernetesRef(value)) {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
if (value && typeof value === 'object') {
|
|
172
|
+
if (Array.isArray(value)) {
|
|
173
|
+
return value.some(item => this.fastScanForRefs(item, depth + 1, maxDepth));
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
return Object.values(value).some(val => this.fastScanForRefs(val, depth + 1, maxDepth));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
extractRefs(value, refs, depth, maxDepth) {
|
|
182
|
+
if (depth >= maxDepth) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (isKubernetesRef(value)) {
|
|
186
|
+
refs.push(value);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (value && typeof value === 'object') {
|
|
190
|
+
if (Array.isArray(value)) {
|
|
191
|
+
value.forEach(item => this.extractRefs(item, refs, depth + 1, maxDepth));
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
Object.values(value).forEach(val => this.extractRefs(val, refs, depth + 1, maxDepth));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Global magic proxy detector instance
|
|
201
|
+
*/
|
|
202
|
+
export const magicProxyDetector = new MagicProxyDetector();
|
|
203
|
+
/**
|
|
204
|
+
* Utility function to detect KubernetesRef objects in a value
|
|
205
|
+
*
|
|
206
|
+
* @param value - Value to analyze
|
|
207
|
+
* @param config - Detection configuration
|
|
208
|
+
* @returns Detection result
|
|
209
|
+
*/
|
|
210
|
+
export function detectMagicProxyRefs(value, config) {
|
|
211
|
+
return magicProxyDetector.detectKubernetesRefs(value, config);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Utility function to check if a value contains KubernetesRef objects
|
|
215
|
+
*
|
|
216
|
+
* @param value - Value to check
|
|
217
|
+
* @param maxDepth - Maximum depth to check
|
|
218
|
+
* @returns Whether KubernetesRef objects were found
|
|
219
|
+
*/
|
|
220
|
+
export function containsMagicProxyRefs(value, maxDepth) {
|
|
221
|
+
return magicProxyDetector.containsKubernetesRefs(value, maxDepth);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Utility function to extract all KubernetesRef objects from a value
|
|
225
|
+
*
|
|
226
|
+
* @param value - Value to extract from
|
|
227
|
+
* @param maxDepth - Maximum depth to extract
|
|
228
|
+
* @returns Array of KubernetesRef objects
|
|
229
|
+
*/
|
|
230
|
+
export function extractMagicProxyRefs(value, maxDepth) {
|
|
231
|
+
return magicProxyDetector.extractKubernetesRefs(value, maxDepth);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Utility function to analyze the source of a KubernetesRef object
|
|
235
|
+
*
|
|
236
|
+
* @param ref - KubernetesRef to analyze
|
|
237
|
+
* @returns Source analysis
|
|
238
|
+
*/
|
|
239
|
+
export function analyzeMagicProxyRefSource(ref) {
|
|
240
|
+
return magicProxyDetector.analyzeReferenceSource(ref);
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=magic-proxy-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"magic-proxy-detector.js","sourceRoot":"","sources":["../../../src/core/expressions/magic-proxy-detector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,MAAM,MAAM,GAAG,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;AA4D1D;;;;;;GAMG;AACH,MAAM,OAAO,kBAAkB;IAC7B;;;;;;;OAOG;IACH,oBAAoB,CAClB,KAAU,EACV,SAAoC,EAAE,EACtC,QAAQ,GAAG,EAAE;QAEb,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAEpC,MAAM,MAAM,GAA8B;YACxC,iBAAiB,EAAE,KAAK;YACxB,UAAU,EAAE,EAAE;YACd,KAAK,EAAE;gBACL,eAAe,EAAE,CAAC;gBAClB,gBAAgB,EAAE,CAAC;gBACnB,kBAAkB,EAAE,CAAC;gBACrB,gBAAgB,EAAE,CAAC;gBACnB,eAAe,EAAE,CAAC;aACnB;YACD,OAAO,EAAE;gBACP,eAAe,EAAE,CAAC;gBAClB,cAAc,EAAE,CAAC;gBACjB,iBAAiB,EAAE,CAAC;aACrB;SACF,CAAC;QAEF,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QAEnD,MAAM,CAAC,iBAAiB,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,C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B,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAU,EAAE,QAAiB;IAClE,OAAO,kBAAkB,CAAC,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACpE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAU,EAAE,QAAiB;IACjE,OAAO,kBAAkB,CAAC,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACnE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,GAAuB;IAChE,OAAO,kBAAkB,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration Helpers for Converting CEL to JavaScript with Magic Proxy Support
|
|
3
|
+
*
|
|
4
|
+
* This module provides utilities to help developers migrate from manual CEL expressions
|
|
5
|
+
* to natural JavaScript expressions that work with TypeKro's magic proxy system.
|
|
6
|
+
*
|
|
7
|
+
* The helpers analyze existing CEL expressions and suggest equivalent JavaScript
|
|
8
|
+
* expressions that will be automatically converted back to CEL by the analyzer.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Migration suggestion for converting CEL to JavaScript
|
|
12
|
+
*/
|
|
13
|
+
export interface MigrationSuggestion {
|
|
14
|
+
/** Original CEL expression */
|
|
15
|
+
originalCel: string;
|
|
16
|
+
/** Suggested JavaScript equivalent */
|
|
17
|
+
suggestedJavaScript: string;
|
|
18
|
+
/** Confidence level of the suggestion (0-1) */
|
|
19
|
+
confidence: number;
|
|
20
|
+
/** Migration category */
|
|
21
|
+
category: MigrationCategory;
|
|
22
|
+
/** Additional notes or warnings */
|
|
23
|
+
notes: string[];
|
|
24
|
+
/** Whether the migration is safe (no behavior change expected) */
|
|
25
|
+
isSafe: boolean;
|
|
26
|
+
/** Example usage in status builder context */
|
|
27
|
+
exampleUsage?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Migration category
|
|
31
|
+
*/
|
|
32
|
+
export type MigrationCategory = 'simple-comparison' | 'template-string' | 'conditional-expression' | 'resource-reference' | 'schema-reference' | 'complex-expression' | 'unsupported';
|
|
33
|
+
/**
|
|
34
|
+
* Migration analysis result
|
|
35
|
+
*/
|
|
36
|
+
export interface MigrationAnalysisResult {
|
|
37
|
+
/** All migration suggestions */
|
|
38
|
+
suggestions: MigrationSuggestion[];
|
|
39
|
+
/** Suggestions by category */
|
|
40
|
+
suggestionsByCategory: Map<MigrationCategory, MigrationSuggestion[]>;
|
|
41
|
+
/** Overall migration feasibility */
|
|
42
|
+
migrationFeasibility: {
|
|
43
|
+
totalExpressions: number;
|
|
44
|
+
migratableExpressions: number;
|
|
45
|
+
safeMigrations: number;
|
|
46
|
+
unsupportedExpressions: number;
|
|
47
|
+
overallConfidence: number;
|
|
48
|
+
};
|
|
49
|
+
/** Migration summary */
|
|
50
|
+
summary: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* CEL to JavaScript Migration Helper
|
|
54
|
+
*
|
|
55
|
+
* Analyzes existing CEL expressions and provides suggestions for converting
|
|
56
|
+
* them to equivalent JavaScript expressions that work with magic proxy.
|
|
57
|
+
*/
|
|
58
|
+
export declare class CelToJavaScriptMigrationHelper {
|
|
59
|
+
private logger;
|
|
60
|
+
/**
|
|
61
|
+
* Analyze status mappings and provide migration suggestions
|
|
62
|
+
*/
|
|
63
|
+
analyzeMigrationOpportunities(statusMappings: Record<string, any>): MigrationAnalysisResult;
|
|
64
|
+
/**
|
|
65
|
+
* Recursively analyze object for CEL expressions that can be migrated
|
|
66
|
+
*/
|
|
67
|
+
private analyzeObjectForMigration;
|
|
68
|
+
/**
|
|
69
|
+
* Analyze a single CEL expression and provide migration suggestion
|
|
70
|
+
*/
|
|
71
|
+
private analyzeCelExpression;
|
|
72
|
+
/**
|
|
73
|
+
* Try to migrate simple comparison expressions
|
|
74
|
+
*/
|
|
75
|
+
private trySimpleComparison;
|
|
76
|
+
/**
|
|
77
|
+
* Try to migrate template string expressions
|
|
78
|
+
*/
|
|
79
|
+
private tryTemplateString;
|
|
80
|
+
/**
|
|
81
|
+
* Try to migrate conditional expressions
|
|
82
|
+
*/
|
|
83
|
+
private tryConditionalExpression;
|
|
84
|
+
/**
|
|
85
|
+
* Try to migrate resource reference expressions
|
|
86
|
+
*/
|
|
87
|
+
private tryResourceReference;
|
|
88
|
+
/**
|
|
89
|
+
* Try to migrate schema reference expressions
|
|
90
|
+
*/
|
|
91
|
+
private trySchemaReference;
|
|
92
|
+
/**
|
|
93
|
+
* Try to migrate complex expressions
|
|
94
|
+
*/
|
|
95
|
+
private tryComplexExpression;
|
|
96
|
+
/**
|
|
97
|
+
* Convert CEL resource reference to JavaScript equivalent
|
|
98
|
+
*/
|
|
99
|
+
private convertCelReferenceToJavaScript;
|
|
100
|
+
/**
|
|
101
|
+
* Convert CEL expression part to JavaScript equivalent
|
|
102
|
+
*/
|
|
103
|
+
private convertCelExpressionToJavaScript;
|
|
104
|
+
/**
|
|
105
|
+
* Convert CEL value to JavaScript equivalent
|
|
106
|
+
*/
|
|
107
|
+
private convertCelValueToJavaScript;
|
|
108
|
+
/**
|
|
109
|
+
* Generate migration summary
|
|
110
|
+
*/
|
|
111
|
+
private generateMigrationSummary;
|
|
112
|
+
/**
|
|
113
|
+
* Generate migration guide for a specific status builder
|
|
114
|
+
*/
|
|
115
|
+
generateMigrationGuide(statusMappings: Record<string, any>, options?: {
|
|
116
|
+
includeExamples?: boolean;
|
|
117
|
+
includeWarnings?: boolean;
|
|
118
|
+
format?: 'markdown' | 'text';
|
|
119
|
+
}): string;
|
|
120
|
+
/**
|
|
121
|
+
* Get human-readable category title
|
|
122
|
+
*/
|
|
123
|
+
private getCategoryTitle;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Convenience function to analyze migration opportunities
|
|
127
|
+
*/
|
|
128
|
+
export declare function analyzeCelMigrationOpportunities(statusMappings: Record<string, any>): MigrationAnalysisResult;
|
|
129
|
+
/**
|
|
130
|
+
* Convenience function to generate migration guide
|
|
131
|
+
*/
|
|
132
|
+
export declare function generateCelMigrationGuide(statusMappings: Record<string, any>, options?: Parameters<CelToJavaScriptMigrationHelper['generateMigrationGuide']>[1]): string;
|
|
133
|
+
//# sourceMappingURL=migration-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-helpers.d.ts","sourceRoot":"","sources":["../../../src/core/expressions/migration-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,8BAA8B;IAC9B,WAAW,EAAE,MAAM,CAAC;IAEpB,sCAAsC;IACtC,mBAAmB,EAAE,MAAM,CAAC;IAE5B,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC;IAEnB,yBAAyB;IACzB,QAAQ,EAAE,iBAAiB,CAAC;IAE5B,mCAAmC;IACnC,KAAK,EAAE,MAAM,EAAE,CAAC;IAEhB,kEAAkE;IAClE,MAAM,EAAE,OAAO,CAAC;IAEhB,8CAA8C;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,mBAAmB,GACnB,iBAAiB,GACjB,wBAAwB,GACxB,oBAAoB,GACpB,kBAAkB,GAClB,oBAAoB,GACpB,aAAa,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,gCAAgC;IAChC,WAAW,EAAE,mBAAmB,EAAE,CAAC;IAEnC,8BAA8B;IAC9B,qBAAqB,EAAE,GAAG,CAAC,iBAAiB,EAAE,mBAAmB,EAAE,CAAC,CAAC;IAErE,oCAAoC;IACpC,oBAAoB,EAAE;QACpB,gBAAgB,EAAE,MAAM,CAAC;QACzB,qBAAqB,EAAE,MAAM,CAAC;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