driftdetect-core 0.1.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.
Files changed (193) hide show
  1. package/dist/boundaries/boundary-store.d.ts +92 -0
  2. package/dist/boundaries/boundary-store.d.ts.map +1 -0
  3. package/dist/boundaries/boundary-store.js +458 -0
  4. package/dist/boundaries/boundary-store.js.map +1 -0
  5. package/dist/boundaries/index.d.ts +8 -0
  6. package/dist/boundaries/index.d.ts.map +1 -0
  7. package/dist/boundaries/index.js +8 -0
  8. package/dist/boundaries/index.js.map +1 -0
  9. package/dist/boundaries/types.d.ts +237 -0
  10. package/dist/boundaries/types.d.ts.map +1 -0
  11. package/dist/boundaries/types.js +8 -0
  12. package/dist/boundaries/types.js.map +1 -0
  13. package/dist/dna/ai-context.d.ts +10 -0
  14. package/dist/dna/ai-context.d.ts.map +1 -0
  15. package/dist/dna/ai-context.js +46 -0
  16. package/dist/dna/ai-context.js.map +1 -0
  17. package/dist/dna/dna-analyzer.d.ts +34 -0
  18. package/dist/dna/dna-analyzer.d.ts.map +1 -0
  19. package/dist/dna/dna-analyzer.js +110 -0
  20. package/dist/dna/dna-analyzer.js.map +1 -0
  21. package/dist/dna/dna-store.d.ts +13 -0
  22. package/dist/dna/dna-store.d.ts.map +1 -0
  23. package/dist/dna/dna-store.js +43 -0
  24. package/dist/dna/dna-store.js.map +1 -0
  25. package/dist/dna/gene-extractors/animation-approach.d.ts +15 -0
  26. package/dist/dna/gene-extractors/animation-approach.d.ts.map +1 -0
  27. package/dist/dna/gene-extractors/animation-approach.js +97 -0
  28. package/dist/dna/gene-extractors/animation-approach.js.map +1 -0
  29. package/dist/dna/gene-extractors/base-extractor.d.ts +53 -0
  30. package/dist/dna/gene-extractors/base-extractor.d.ts.map +1 -0
  31. package/dist/dna/gene-extractors/base-extractor.js +76 -0
  32. package/dist/dna/gene-extractors/base-extractor.js.map +1 -0
  33. package/dist/dna/gene-extractors/index.d.ts +16 -0
  34. package/dist/dna/gene-extractors/index.d.ts.map +1 -0
  35. package/dist/dna/gene-extractors/index.js +38 -0
  36. package/dist/dna/gene-extractors/index.js.map +1 -0
  37. package/dist/dna/gene-extractors/responsive-approach.d.ts +10 -0
  38. package/dist/dna/gene-extractors/responsive-approach.d.ts.map +1 -0
  39. package/dist/dna/gene-extractors/responsive-approach.js +30 -0
  40. package/dist/dna/gene-extractors/responsive-approach.js.map +1 -0
  41. package/dist/dna/gene-extractors/spacing-philosophy.d.ts +10 -0
  42. package/dist/dna/gene-extractors/spacing-philosophy.d.ts.map +1 -0
  43. package/dist/dna/gene-extractors/spacing-philosophy.js +30 -0
  44. package/dist/dna/gene-extractors/spacing-philosophy.js.map +1 -0
  45. package/dist/dna/gene-extractors/state-styling.d.ts +10 -0
  46. package/dist/dna/gene-extractors/state-styling.d.ts.map +1 -0
  47. package/dist/dna/gene-extractors/state-styling.js +29 -0
  48. package/dist/dna/gene-extractors/state-styling.js.map +1 -0
  49. package/dist/dna/gene-extractors/theming.d.ts +10 -0
  50. package/dist/dna/gene-extractors/theming.d.ts.map +1 -0
  51. package/dist/dna/gene-extractors/theming.js +30 -0
  52. package/dist/dna/gene-extractors/theming.js.map +1 -0
  53. package/dist/dna/gene-extractors/variant-handling.d.ts +13 -0
  54. package/dist/dna/gene-extractors/variant-handling.d.ts.map +1 -0
  55. package/dist/dna/gene-extractors/variant-handling.js +38 -0
  56. package/dist/dna/gene-extractors/variant-handling.js.map +1 -0
  57. package/dist/dna/health-calculator.d.ts +21 -0
  58. package/dist/dna/health-calculator.d.ts.map +1 -0
  59. package/dist/dna/health-calculator.js +113 -0
  60. package/dist/dna/health-calculator.js.map +1 -0
  61. package/dist/dna/index.d.ts +21 -0
  62. package/dist/dna/index.d.ts.map +1 -0
  63. package/dist/dna/index.js +19 -0
  64. package/dist/dna/index.js.map +1 -0
  65. package/dist/dna/mutation-detector.d.ts +10 -0
  66. package/dist/dna/mutation-detector.d.ts.map +1 -0
  67. package/dist/dna/mutation-detector.js +39 -0
  68. package/dist/dna/mutation-detector.js.map +1 -0
  69. package/dist/dna/playbook-generator.d.ts +6 -0
  70. package/dist/dna/playbook-generator.d.ts.map +1 -0
  71. package/dist/dna/playbook-generator.js +53 -0
  72. package/dist/dna/playbook-generator.js.map +1 -0
  73. package/dist/dna/types.d.ts +95 -0
  74. package/dist/dna/types.d.ts.map +1 -0
  75. package/dist/dna/types.js +8 -0
  76. package/dist/dna/types.js.map +1 -0
  77. package/dist/index.d.ts +7 -0
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +10 -0
  80. package/dist/index.js.map +1 -1
  81. package/dist/parsers/parser-manager.d.ts.map +1 -1
  82. package/dist/parsers/parser-manager.js +2 -0
  83. package/dist/parsers/parser-manager.js.map +1 -1
  84. package/dist/parsers/tree-sitter/config.d.ts +82 -0
  85. package/dist/parsers/tree-sitter/config.d.ts.map +1 -0
  86. package/dist/parsers/tree-sitter/config.js +200 -0
  87. package/dist/parsers/tree-sitter/config.js.map +1 -0
  88. package/dist/parsers/tree-sitter/csharp-ast-converter.d.ts +64 -0
  89. package/dist/parsers/tree-sitter/csharp-ast-converter.d.ts.map +1 -0
  90. package/dist/parsers/tree-sitter/csharp-ast-converter.js +271 -0
  91. package/dist/parsers/tree-sitter/csharp-ast-converter.js.map +1 -0
  92. package/dist/parsers/tree-sitter/csharp-loader.d.ts +43 -0
  93. package/dist/parsers/tree-sitter/csharp-loader.d.ts.map +1 -0
  94. package/dist/parsers/tree-sitter/csharp-loader.js +146 -0
  95. package/dist/parsers/tree-sitter/csharp-loader.js.map +1 -0
  96. package/dist/parsers/tree-sitter/index.d.ts +26 -0
  97. package/dist/parsers/tree-sitter/index.d.ts.map +1 -0
  98. package/dist/parsers/tree-sitter/index.js +47 -0
  99. package/dist/parsers/tree-sitter/index.js.map +1 -0
  100. package/dist/parsers/tree-sitter/java/annotation-extractor.d.ts +79 -0
  101. package/dist/parsers/tree-sitter/java/annotation-extractor.d.ts.map +1 -0
  102. package/dist/parsers/tree-sitter/java/annotation-extractor.js +540 -0
  103. package/dist/parsers/tree-sitter/java/annotation-extractor.js.map +1 -0
  104. package/dist/parsers/tree-sitter/java/class-extractor.d.ts +40 -0
  105. package/dist/parsers/tree-sitter/java/class-extractor.d.ts.map +1 -0
  106. package/dist/parsers/tree-sitter/java/class-extractor.js +770 -0
  107. package/dist/parsers/tree-sitter/java/class-extractor.js.map +1 -0
  108. package/dist/parsers/tree-sitter/java/index.d.ts +14 -0
  109. package/dist/parsers/tree-sitter/java/index.d.ts.map +1 -0
  110. package/dist/parsers/tree-sitter/java/index.js +25 -0
  111. package/dist/parsers/tree-sitter/java/index.js.map +1 -0
  112. package/dist/parsers/tree-sitter/java/method-extractor.d.ts +88 -0
  113. package/dist/parsers/tree-sitter/java/method-extractor.d.ts.map +1 -0
  114. package/dist/parsers/tree-sitter/java/method-extractor.js +551 -0
  115. package/dist/parsers/tree-sitter/java/method-extractor.js.map +1 -0
  116. package/dist/parsers/tree-sitter/java/types.d.ts +545 -0
  117. package/dist/parsers/tree-sitter/java/types.d.ts.map +1 -0
  118. package/dist/parsers/tree-sitter/java/types.js +81 -0
  119. package/dist/parsers/tree-sitter/java/types.js.map +1 -0
  120. package/dist/parsers/tree-sitter/loader.d.ts +50 -0
  121. package/dist/parsers/tree-sitter/loader.d.ts.map +1 -0
  122. package/dist/parsers/tree-sitter/loader.js +156 -0
  123. package/dist/parsers/tree-sitter/loader.js.map +1 -0
  124. package/dist/parsers/tree-sitter/pydantic/config-extractor.d.ts +78 -0
  125. package/dist/parsers/tree-sitter/pydantic/config-extractor.d.ts.map +1 -0
  126. package/dist/parsers/tree-sitter/pydantic/config-extractor.js +278 -0
  127. package/dist/parsers/tree-sitter/pydantic/config-extractor.js.map +1 -0
  128. package/dist/parsers/tree-sitter/pydantic/constraint-parser.d.ts +84 -0
  129. package/dist/parsers/tree-sitter/pydantic/constraint-parser.d.ts.map +1 -0
  130. package/dist/parsers/tree-sitter/pydantic/constraint-parser.js +321 -0
  131. package/dist/parsers/tree-sitter/pydantic/constraint-parser.js.map +1 -0
  132. package/dist/parsers/tree-sitter/pydantic/field-extractor.d.ts +74 -0
  133. package/dist/parsers/tree-sitter/pydantic/field-extractor.d.ts.map +1 -0
  134. package/dist/parsers/tree-sitter/pydantic/field-extractor.js +285 -0
  135. package/dist/parsers/tree-sitter/pydantic/field-extractor.js.map +1 -0
  136. package/dist/parsers/tree-sitter/pydantic/index.d.ts +18 -0
  137. package/dist/parsers/tree-sitter/pydantic/index.d.ts.map +1 -0
  138. package/dist/parsers/tree-sitter/pydantic/index.js +23 -0
  139. package/dist/parsers/tree-sitter/pydantic/index.js.map +1 -0
  140. package/dist/parsers/tree-sitter/pydantic/inheritance-resolver.d.ts +70 -0
  141. package/dist/parsers/tree-sitter/pydantic/inheritance-resolver.d.ts.map +1 -0
  142. package/dist/parsers/tree-sitter/pydantic/inheritance-resolver.js +251 -0
  143. package/dist/parsers/tree-sitter/pydantic/inheritance-resolver.js.map +1 -0
  144. package/dist/parsers/tree-sitter/pydantic/pydantic-extractor.d.ts +102 -0
  145. package/dist/parsers/tree-sitter/pydantic/pydantic-extractor.d.ts.map +1 -0
  146. package/dist/parsers/tree-sitter/pydantic/pydantic-extractor.js +399 -0
  147. package/dist/parsers/tree-sitter/pydantic/pydantic-extractor.js.map +1 -0
  148. package/dist/parsers/tree-sitter/pydantic/type-resolver.d.ts +89 -0
  149. package/dist/parsers/tree-sitter/pydantic/type-resolver.d.ts.map +1 -0
  150. package/dist/parsers/tree-sitter/pydantic/type-resolver.js +426 -0
  151. package/dist/parsers/tree-sitter/pydantic/type-resolver.js.map +1 -0
  152. package/dist/parsers/tree-sitter/pydantic/types.d.ts +177 -0
  153. package/dist/parsers/tree-sitter/pydantic/types.d.ts.map +1 -0
  154. package/dist/parsers/tree-sitter/pydantic/types.js +139 -0
  155. package/dist/parsers/tree-sitter/pydantic/types.js.map +1 -0
  156. package/dist/parsers/tree-sitter/pydantic/validator-extractor.d.ts +88 -0
  157. package/dist/parsers/tree-sitter/pydantic/validator-extractor.d.ts.map +1 -0
  158. package/dist/parsers/tree-sitter/pydantic/validator-extractor.js +315 -0
  159. package/dist/parsers/tree-sitter/pydantic/validator-extractor.js.map +1 -0
  160. package/dist/parsers/tree-sitter/python-ast-converter.d.ts +140 -0
  161. package/dist/parsers/tree-sitter/python-ast-converter.d.ts.map +1 -0
  162. package/dist/parsers/tree-sitter/python-ast-converter.js +360 -0
  163. package/dist/parsers/tree-sitter/python-ast-converter.js.map +1 -0
  164. package/dist/parsers/tree-sitter/tree-sitter-csharp-parser.d.ts +465 -0
  165. package/dist/parsers/tree-sitter/tree-sitter-csharp-parser.d.ts.map +1 -0
  166. package/dist/parsers/tree-sitter/tree-sitter-csharp-parser.js +1146 -0
  167. package/dist/parsers/tree-sitter/tree-sitter-csharp-parser.js.map +1 -0
  168. package/dist/parsers/tree-sitter/tree-sitter-python-parser.d.ts +86 -0
  169. package/dist/parsers/tree-sitter/tree-sitter-python-parser.d.ts.map +1 -0
  170. package/dist/parsers/tree-sitter/tree-sitter-python-parser.js +177 -0
  171. package/dist/parsers/tree-sitter/tree-sitter-python-parser.js.map +1 -0
  172. package/dist/parsers/tree-sitter/types.d.ts +399 -0
  173. package/dist/parsers/tree-sitter/types.d.ts.map +1 -0
  174. package/dist/parsers/tree-sitter/types.js +20 -0
  175. package/dist/parsers/tree-sitter/types.js.map +1 -0
  176. package/dist/parsers/types.d.ts +1 -1
  177. package/dist/parsers/types.d.ts.map +1 -1
  178. package/dist/scanner/file-walker.d.ts.map +1 -1
  179. package/dist/scanner/file-walker.js +5 -0
  180. package/dist/scanner/file-walker.js.map +1 -1
  181. package/dist/store/history-store.d.ts +85 -269
  182. package/dist/store/history-store.d.ts.map +1 -1
  183. package/dist/store/history-store.js +272 -624
  184. package/dist/store/history-store.js.map +1 -1
  185. package/dist/types/index.d.ts +1 -0
  186. package/dist/types/index.d.ts.map +1 -1
  187. package/dist/types/index.js +2 -0
  188. package/dist/types/index.js.map +1 -1
  189. package/dist/types/java-type-mapping.d.ts +79 -0
  190. package/dist/types/java-type-mapping.d.ts.map +1 -0
  191. package/dist/types/java-type-mapping.js +290 -0
  192. package/dist/types/java-type-mapping.js.map +1 -0
  193. package/package.json +8 -3
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Tree-sitter Python Parser Configuration
3
+ *
4
+ * Configuration types and defaults for the tree-sitter Python parser.
5
+ * Provides validation and merging utilities.
6
+ *
7
+ * @requirements 3.5 - Unified AST query interface
8
+ */
9
+ /**
10
+ * Configuration options for the Python parser.
11
+ */
12
+ export interface PythonParserConfig {
13
+ /** Use tree-sitter parser if available (default: true) */
14
+ useTreeSitter: boolean;
15
+ /** Extract Pydantic model information (default: true) */
16
+ extractPydanticModels: boolean;
17
+ /** Maximum depth for type resolution to prevent infinite loops (default: 10) */
18
+ maxTypeDepth: number;
19
+ /** Include position information in extracted data (default: true) */
20
+ includePositions: boolean;
21
+ /** Timeout for parsing in milliseconds, 0 = no timeout (default: 5000) */
22
+ parseTimeout: number;
23
+ /** Use incremental parsing when possible (default: true) */
24
+ useIncremental: boolean;
25
+ /** Include comments in the AST (default: true) */
26
+ includeComments: boolean;
27
+ /** Include anonymous nodes in the AST (default: false) */
28
+ includeAnonymous: boolean;
29
+ }
30
+ /**
31
+ * Default configuration for the Python parser.
32
+ */
33
+ export declare const DEFAULT_PYTHON_PARSER_CONFIG: Readonly<PythonParserConfig>;
34
+ /**
35
+ * Validation error for configuration.
36
+ */
37
+ export interface ConfigValidationError {
38
+ /** Field that failed validation */
39
+ field: string;
40
+ /** Error message */
41
+ message: string;
42
+ /** The invalid value */
43
+ value: unknown;
44
+ }
45
+ /**
46
+ * Result of configuration validation.
47
+ */
48
+ export interface ConfigValidationResult {
49
+ /** Whether the configuration is valid */
50
+ valid: boolean;
51
+ /** Validation errors if any */
52
+ errors: ConfigValidationError[];
53
+ /** Validated and normalized configuration */
54
+ config: PythonParserConfig;
55
+ }
56
+ /**
57
+ * Validate a Python parser configuration.
58
+ *
59
+ * @param config - Partial configuration to validate
60
+ * @returns Validation result with normalized config
61
+ */
62
+ export declare function validateConfig(config: Partial<PythonParserConfig>): ConfigValidationResult;
63
+ /**
64
+ * Merge partial configuration with defaults.
65
+ *
66
+ * @param config - Partial configuration
67
+ * @returns Complete configuration with defaults applied
68
+ */
69
+ export declare function mergeConfig(config: Partial<PythonParserConfig>): PythonParserConfig;
70
+ /**
71
+ * Create configuration from environment variables.
72
+ *
73
+ * Environment variables:
74
+ * - DRIFT_PYTHON_USE_TREE_SITTER: 'true' or 'false'
75
+ * - DRIFT_PYTHON_EXTRACT_PYDANTIC: 'true' or 'false'
76
+ * - DRIFT_PYTHON_MAX_TYPE_DEPTH: number
77
+ * - DRIFT_PYTHON_PARSE_TIMEOUT: number (milliseconds)
78
+ *
79
+ * @returns Configuration from environment
80
+ */
81
+ export declare function configFromEnv(): Partial<PythonParserConfig>;
82
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/parsers/tree-sitter/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,aAAa,EAAE,OAAO,CAAC;IAEvB,yDAAyD;IACzD,qBAAqB,EAAE,OAAO,CAAC;IAE/B,gFAAgF;IAChF,YAAY,EAAE,MAAM,CAAC;IAErB,qEAAqE;IACrE,gBAAgB,EAAE,OAAO,CAAC;IAE1B,0EAA0E;IAC1E,YAAY,EAAE,MAAM,CAAC;IAErB,4DAA4D;IAC5D,cAAc,EAAE,OAAO,CAAC;IAExB,kDAAkD;IAClD,eAAe,EAAE,OAAO,CAAC;IAEzB,0DAA0D;IAC1D,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAMD;;GAEG;AACH,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,kBAAkB,CASrE,CAAC;AAMF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,yCAAyC;IACzC,KAAK,EAAE,OAAO,CAAC;IACf,+BAA+B;IAC/B,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChC,6CAA6C;IAC7C,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAClC,sBAAsB,CAuHxB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAClC,kBAAkB,CAKpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC,CA8B3D"}
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Tree-sitter Python Parser Configuration
3
+ *
4
+ * Configuration types and defaults for the tree-sitter Python parser.
5
+ * Provides validation and merging utilities.
6
+ *
7
+ * @requirements 3.5 - Unified AST query interface
8
+ */
9
+ // ============================================
10
+ // Default Configuration
11
+ // ============================================
12
+ /**
13
+ * Default configuration for the Python parser.
14
+ */
15
+ export const DEFAULT_PYTHON_PARSER_CONFIG = {
16
+ useTreeSitter: true,
17
+ extractPydanticModels: true,
18
+ maxTypeDepth: 10,
19
+ includePositions: true,
20
+ parseTimeout: 5000,
21
+ useIncremental: true,
22
+ includeComments: true,
23
+ includeAnonymous: false,
24
+ };
25
+ /**
26
+ * Validate a Python parser configuration.
27
+ *
28
+ * @param config - Partial configuration to validate
29
+ * @returns Validation result with normalized config
30
+ */
31
+ export function validateConfig(config) {
32
+ const errors = [];
33
+ const normalized = { ...DEFAULT_PYTHON_PARSER_CONFIG };
34
+ // Validate useTreeSitter
35
+ if (config.useTreeSitter !== undefined) {
36
+ if (typeof config.useTreeSitter !== 'boolean') {
37
+ errors.push({
38
+ field: 'useTreeSitter',
39
+ message: 'must be a boolean',
40
+ value: config.useTreeSitter,
41
+ });
42
+ }
43
+ else {
44
+ normalized.useTreeSitter = config.useTreeSitter;
45
+ }
46
+ }
47
+ // Validate extractPydanticModels
48
+ if (config.extractPydanticModels !== undefined) {
49
+ if (typeof config.extractPydanticModels !== 'boolean') {
50
+ errors.push({
51
+ field: 'extractPydanticModels',
52
+ message: 'must be a boolean',
53
+ value: config.extractPydanticModels,
54
+ });
55
+ }
56
+ else {
57
+ normalized.extractPydanticModels = config.extractPydanticModels;
58
+ }
59
+ }
60
+ // Validate maxTypeDepth
61
+ if (config.maxTypeDepth !== undefined) {
62
+ if (typeof config.maxTypeDepth !== 'number' || config.maxTypeDepth < 1) {
63
+ errors.push({
64
+ field: 'maxTypeDepth',
65
+ message: 'must be a positive number',
66
+ value: config.maxTypeDepth,
67
+ });
68
+ }
69
+ else if (config.maxTypeDepth > 100) {
70
+ errors.push({
71
+ field: 'maxTypeDepth',
72
+ message: 'must be at most 100',
73
+ value: config.maxTypeDepth,
74
+ });
75
+ }
76
+ else {
77
+ normalized.maxTypeDepth = config.maxTypeDepth;
78
+ }
79
+ }
80
+ // Validate includePositions
81
+ if (config.includePositions !== undefined) {
82
+ if (typeof config.includePositions !== 'boolean') {
83
+ errors.push({
84
+ field: 'includePositions',
85
+ message: 'must be a boolean',
86
+ value: config.includePositions,
87
+ });
88
+ }
89
+ else {
90
+ normalized.includePositions = config.includePositions;
91
+ }
92
+ }
93
+ // Validate parseTimeout
94
+ if (config.parseTimeout !== undefined) {
95
+ if (typeof config.parseTimeout !== 'number' || config.parseTimeout < 0) {
96
+ errors.push({
97
+ field: 'parseTimeout',
98
+ message: 'must be a non-negative number',
99
+ value: config.parseTimeout,
100
+ });
101
+ }
102
+ else {
103
+ normalized.parseTimeout = config.parseTimeout;
104
+ }
105
+ }
106
+ // Validate useIncremental
107
+ if (config.useIncremental !== undefined) {
108
+ if (typeof config.useIncremental !== 'boolean') {
109
+ errors.push({
110
+ field: 'useIncremental',
111
+ message: 'must be a boolean',
112
+ value: config.useIncremental,
113
+ });
114
+ }
115
+ else {
116
+ normalized.useIncremental = config.useIncremental;
117
+ }
118
+ }
119
+ // Validate includeComments
120
+ if (config.includeComments !== undefined) {
121
+ if (typeof config.includeComments !== 'boolean') {
122
+ errors.push({
123
+ field: 'includeComments',
124
+ message: 'must be a boolean',
125
+ value: config.includeComments,
126
+ });
127
+ }
128
+ else {
129
+ normalized.includeComments = config.includeComments;
130
+ }
131
+ }
132
+ // Validate includeAnonymous
133
+ if (config.includeAnonymous !== undefined) {
134
+ if (typeof config.includeAnonymous !== 'boolean') {
135
+ errors.push({
136
+ field: 'includeAnonymous',
137
+ message: 'must be a boolean',
138
+ value: config.includeAnonymous,
139
+ });
140
+ }
141
+ else {
142
+ normalized.includeAnonymous = config.includeAnonymous;
143
+ }
144
+ }
145
+ return {
146
+ valid: errors.length === 0,
147
+ errors,
148
+ config: normalized,
149
+ };
150
+ }
151
+ /**
152
+ * Merge partial configuration with defaults.
153
+ *
154
+ * @param config - Partial configuration
155
+ * @returns Complete configuration with defaults applied
156
+ */
157
+ export function mergeConfig(config) {
158
+ return {
159
+ ...DEFAULT_PYTHON_PARSER_CONFIG,
160
+ ...config,
161
+ };
162
+ }
163
+ /**
164
+ * Create configuration from environment variables.
165
+ *
166
+ * Environment variables:
167
+ * - DRIFT_PYTHON_USE_TREE_SITTER: 'true' or 'false'
168
+ * - DRIFT_PYTHON_EXTRACT_PYDANTIC: 'true' or 'false'
169
+ * - DRIFT_PYTHON_MAX_TYPE_DEPTH: number
170
+ * - DRIFT_PYTHON_PARSE_TIMEOUT: number (milliseconds)
171
+ *
172
+ * @returns Configuration from environment
173
+ */
174
+ export function configFromEnv() {
175
+ const config = {};
176
+ const useTreeSitter = process.env['DRIFT_PYTHON_USE_TREE_SITTER'];
177
+ if (useTreeSitter !== undefined) {
178
+ config.useTreeSitter = useTreeSitter.toLowerCase() === 'true';
179
+ }
180
+ const extractPydantic = process.env['DRIFT_PYTHON_EXTRACT_PYDANTIC'];
181
+ if (extractPydantic !== undefined) {
182
+ config.extractPydanticModels = extractPydantic.toLowerCase() === 'true';
183
+ }
184
+ const maxTypeDepth = process.env['DRIFT_PYTHON_MAX_TYPE_DEPTH'];
185
+ if (maxTypeDepth !== undefined) {
186
+ const parsed = parseInt(maxTypeDepth, 10);
187
+ if (!isNaN(parsed)) {
188
+ config.maxTypeDepth = parsed;
189
+ }
190
+ }
191
+ const parseTimeout = process.env['DRIFT_PYTHON_PARSE_TIMEOUT'];
192
+ if (parseTimeout !== undefined) {
193
+ const parsed = parseInt(parseTimeout, 10);
194
+ if (!isNaN(parsed)) {
195
+ config.parseTimeout = parsed;
196
+ }
197
+ }
198
+ return config;
199
+ }
200
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/parsers/tree-sitter/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmCH,+CAA+C;AAC/C,wBAAwB;AACxB,+CAA+C;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAiC;IACxE,aAAa,EAAE,IAAI;IACnB,qBAAqB,EAAE,IAAI;IAC3B,YAAY,EAAE,EAAE;IAChB,gBAAgB,EAAE,IAAI;IACtB,YAAY,EAAE,IAAI;IAClB,cAAc,EAAE,IAAI;IACpB,eAAe,EAAE,IAAI;IACrB,gBAAgB,EAAE,KAAK;CACxB,CAAC;AA8BF;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAmC;IAEnC,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,MAAM,UAAU,GAAG,EAAE,GAAG,4BAA4B,EAAE,CAAC;IAEvD,yBAAyB;IACzB,IAAI,MAAM,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;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AM,CAAC;IAChE,CAAC;IAED,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IACrE,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,CAAC,qBAAqB,GAAG,eAAe,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;IAC1E,CAAC;IAED,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAChE,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,QAAQ,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACnB,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;IAC/D,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,QAAQ,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACnB,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * C# AST Converter
3
+ *
4
+ * Converts tree-sitter AST nodes to drift's ASTNode format.
5
+ * Preserves position information and handles all C# node types.
6
+ *
7
+ * @requirements 3.5 - Unified AST query interface
8
+ */
9
+ import type { ASTNode, Position } from '../types.js';
10
+ import type { TreeSitterNode, TreeSitterPoint } from './types.js';
11
+ /**
12
+ * Options for AST conversion.
13
+ */
14
+ export interface CSharpConversionOptions {
15
+ /** Whether to include position information */
16
+ includePositions: boolean;
17
+ /** Whether to include anonymous nodes */
18
+ includeAnonymous: boolean;
19
+ /** Maximum depth to convert (0 = unlimited) */
20
+ maxDepth: number;
21
+ }
22
+ /**
23
+ * Default conversion options.
24
+ */
25
+ export declare const DEFAULT_CSHARP_CONVERSION_OPTIONS: CSharpConversionOptions;
26
+ /**
27
+ * Convert a tree-sitter point to drift Position.
28
+ *
29
+ * @param point - Tree-sitter point
30
+ * @returns Drift Position
31
+ */
32
+ export declare function convertCSharpPoint(point: TreeSitterPoint): Position;
33
+ /**
34
+ * Convert a tree-sitter node type to drift node type.
35
+ *
36
+ * @param treeSitterType - Tree-sitter node type
37
+ * @returns Drift node type
38
+ */
39
+ export declare function convertCSharpNodeType(treeSitterType: string): string;
40
+ /**
41
+ * C# AST Converter class.
42
+ *
43
+ * Converts tree-sitter C# AST to drift's unified AST format.
44
+ */
45
+ export declare class CSharpASTConverter {
46
+ private options;
47
+ constructor(options?: Partial<CSharpConversionOptions>);
48
+ /**
49
+ * Convert a tree-sitter node to drift ASTNode.
50
+ *
51
+ * @param node - Tree-sitter node
52
+ * @param depth - Current depth (for maxDepth limiting)
53
+ * @returns Drift ASTNode
54
+ */
55
+ convert(node: TreeSitterNode, depth?: number): ASTNode;
56
+ /**
57
+ * Create a leaf node (no children converted).
58
+ *
59
+ * @param node - Tree-sitter node
60
+ * @returns Drift ASTNode with no children
61
+ */
62
+ private createLeafNode;
63
+ }
64
+ //# sourceMappingURL=csharp-ast-converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csharp-ast-converter.d.ts","sourceRoot":"","sources":["../../../src/parsers/tree-sitter/csharp-ast-converter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA6LlE;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,8CAA8C;IAC9C,gBAAgB,EAAE,OAAO,CAAC;IAC1B,yCAAyC;IACzC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,iCAAiC,EAAE,uBAI/C,CAAC;AAMF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,QAAQ,CAKnE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;;GAIG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,OAAO,CAA0B;gBAE7B,OAAO,GAAE,OAAO,CAAC,uBAAuB,CAAM;IAI1D;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,GAAE,MAAU,GAAG,OAAO;IA6BzD;;;;;OAKG;IACH,OAAO,CAAC,cAAc;CAavB"}
@@ -0,0 +1,271 @@
1
+ /**
2
+ * C# AST Converter
3
+ *
4
+ * Converts tree-sitter AST nodes to drift's ASTNode format.
5
+ * Preserves position information and handles all C# node types.
6
+ *
7
+ * @requirements 3.5 - Unified AST query interface
8
+ */
9
+ // ============================================
10
+ // Node Type Mapping
11
+ // ============================================
12
+ /**
13
+ * Mapping of tree-sitter C# node types to drift node types.
14
+ * This provides semantic normalization across different parsers.
15
+ */
16
+ const NODE_TYPE_MAP = {
17
+ // Compilation unit
18
+ compilation_unit: 'Program',
19
+ // Declarations
20
+ class_declaration: 'ClassDeclaration',
21
+ record_declaration: 'RecordDeclaration',
22
+ struct_declaration: 'StructDeclaration',
23
+ interface_declaration: 'InterfaceDeclaration',
24
+ enum_declaration: 'EnumDeclaration',
25
+ delegate_declaration: 'DelegateDeclaration',
26
+ namespace_declaration: 'NamespaceDeclaration',
27
+ file_scoped_namespace_declaration: 'NamespaceDeclaration',
28
+ // Members
29
+ method_declaration: 'MethodDeclaration',
30
+ constructor_declaration: 'ConstructorDeclaration',
31
+ destructor_declaration: 'DestructorDeclaration',
32
+ property_declaration: 'PropertyDeclaration',
33
+ field_declaration: 'FieldDeclaration',
34
+ event_declaration: 'EventDeclaration',
35
+ indexer_declaration: 'IndexerDeclaration',
36
+ operator_declaration: 'OperatorDeclaration',
37
+ conversion_operator_declaration: 'ConversionOperatorDeclaration',
38
+ // Statements
39
+ block: 'Block',
40
+ local_declaration_statement: 'VariableDeclaration',
41
+ expression_statement: 'ExpressionStatement',
42
+ if_statement: 'IfStatement',
43
+ switch_statement: 'SwitchStatement',
44
+ while_statement: 'WhileStatement',
45
+ do_statement: 'DoStatement',
46
+ for_statement: 'ForStatement',
47
+ foreach_statement: 'ForEachStatement',
48
+ return_statement: 'ReturnStatement',
49
+ throw_statement: 'ThrowStatement',
50
+ try_statement: 'TryStatement',
51
+ using_statement: 'UsingStatement',
52
+ lock_statement: 'LockStatement',
53
+ yield_statement: 'YieldStatement',
54
+ break_statement: 'BreakStatement',
55
+ continue_statement: 'ContinueStatement',
56
+ goto_statement: 'GotoStatement',
57
+ labeled_statement: 'LabeledStatement',
58
+ checked_statement: 'CheckedStatement',
59
+ unchecked_statement: 'UncheckedStatement',
60
+ fixed_statement: 'FixedStatement',
61
+ unsafe_statement: 'UnsafeStatement',
62
+ local_function_statement: 'LocalFunctionStatement',
63
+ // Expressions
64
+ invocation_expression: 'CallExpression',
65
+ member_access_expression: 'MemberExpression',
66
+ element_access_expression: 'IndexExpression',
67
+ object_creation_expression: 'NewExpression',
68
+ array_creation_expression: 'ArrayExpression',
69
+ anonymous_object_creation_expression: 'AnonymousObjectExpression',
70
+ anonymous_method_expression: 'AnonymousMethodExpression',
71
+ lambda_expression: 'ArrowFunctionExpression',
72
+ assignment_expression: 'AssignmentExpression',
73
+ binary_expression: 'BinaryExpression',
74
+ unary_expression: 'UnaryExpression',
75
+ prefix_unary_expression: 'PrefixUnaryExpression',
76
+ postfix_unary_expression: 'PostfixUnaryExpression',
77
+ conditional_expression: 'ConditionalExpression',
78
+ cast_expression: 'CastExpression',
79
+ await_expression: 'AwaitExpression',
80
+ typeof_expression: 'TypeOfExpression',
81
+ sizeof_expression: 'SizeOfExpression',
82
+ nameof_expression: 'NameOfExpression',
83
+ default_expression: 'DefaultExpression',
84
+ checked_expression: 'CheckedExpression',
85
+ unchecked_expression: 'UncheckedExpression',
86
+ is_expression: 'IsExpression',
87
+ as_expression: 'AsExpression',
88
+ is_pattern_expression: 'IsPatternExpression',
89
+ switch_expression: 'SwitchExpression',
90
+ with_expression: 'WithExpression',
91
+ range_expression: 'RangeExpression',
92
+ index_expression: 'IndexExpression',
93
+ throw_expression: 'ThrowExpression',
94
+ ref_expression: 'RefExpression',
95
+ tuple_expression: 'TupleExpression',
96
+ parenthesized_expression: 'ParenthesizedExpression',
97
+ interpolated_string_expression: 'TemplateLiteral',
98
+ query_expression: 'QueryExpression',
99
+ // Literals
100
+ integer_literal: 'NumericLiteral',
101
+ real_literal: 'NumericLiteral',
102
+ character_literal: 'StringLiteral',
103
+ string_literal: 'StringLiteral',
104
+ verbatim_string_literal: 'StringLiteral',
105
+ raw_string_literal: 'StringLiteral',
106
+ boolean_literal: 'BooleanLiteral',
107
+ null_literal: 'NullLiteral',
108
+ // Types
109
+ predefined_type: 'PredefinedType',
110
+ identifier_name: 'Identifier',
111
+ generic_name: 'GenericType',
112
+ qualified_name: 'QualifiedName',
113
+ alias_qualified_name: 'AliasQualifiedName',
114
+ nullable_type: 'NullableType',
115
+ array_type: 'ArrayType',
116
+ tuple_type: 'TupleType',
117
+ pointer_type: 'PointerType',
118
+ function_pointer_type: 'FunctionPointerType',
119
+ ref_type: 'RefType',
120
+ // Attributes
121
+ attribute_list: 'AttributeList',
122
+ attribute: 'Attribute',
123
+ attribute_argument_list: 'AttributeArgumentList',
124
+ attribute_argument: 'AttributeArgument',
125
+ // Parameters
126
+ parameter_list: 'ParameterList',
127
+ parameter: 'Parameter',
128
+ type_parameter_list: 'TypeParameterList',
129
+ type_parameter: 'TypeParameter',
130
+ type_parameter_constraints_clause: 'TypeParameterConstraint',
131
+ // Using directives
132
+ using_directive: 'UsingDirective',
133
+ global_attribute_list: 'GlobalAttributeList',
134
+ extern_alias_directive: 'ExternAliasDirective',
135
+ // Accessors
136
+ accessor_list: 'AccessorList',
137
+ accessor_declaration: 'AccessorDeclaration',
138
+ // Patterns
139
+ declaration_pattern: 'DeclarationPattern',
140
+ constant_pattern: 'ConstantPattern',
141
+ var_pattern: 'VarPattern',
142
+ discard_pattern: 'DiscardPattern',
143
+ recursive_pattern: 'RecursivePattern',
144
+ positional_pattern_clause: 'PositionalPatternClause',
145
+ property_pattern_clause: 'PropertyPatternClause',
146
+ relational_pattern: 'RelationalPattern',
147
+ negation_pattern: 'NegationPattern',
148
+ and_pattern: 'AndPattern',
149
+ or_pattern: 'OrPattern',
150
+ type_pattern: 'TypePattern',
151
+ parenthesized_pattern: 'ParenthesizedPattern',
152
+ list_pattern: 'ListPattern',
153
+ slice_pattern: 'SlicePattern',
154
+ // Comments
155
+ comment: 'Comment',
156
+ // Misc
157
+ argument_list: 'ArgumentList',
158
+ argument: 'Argument',
159
+ base_list: 'BaseList',
160
+ type_argument_list: 'TypeArgumentList',
161
+ initializer_expression: 'InitializerExpression',
162
+ equals_value_clause: 'EqualsValueClause',
163
+ arrow_expression_clause: 'ArrowExpressionClause',
164
+ catch_clause: 'CatchClause',
165
+ finally_clause: 'FinallyClause',
166
+ when_clause: 'WhenClause',
167
+ switch_section: 'SwitchSection',
168
+ case_switch_label: 'CaseSwitchLabel',
169
+ default_switch_label: 'DefaultSwitchLabel',
170
+ case_pattern_switch_label: 'CasePatternSwitchLabel',
171
+ switch_expression_arm: 'SwitchExpressionArm',
172
+ interpolation: 'Interpolation',
173
+ interpolation_alignment_clause: 'InterpolationAlignmentClause',
174
+ interpolation_format_clause: 'InterpolationFormatClause',
175
+ };
176
+ /**
177
+ * Default conversion options.
178
+ */
179
+ export const DEFAULT_CSHARP_CONVERSION_OPTIONS = {
180
+ includePositions: true,
181
+ includeAnonymous: false,
182
+ maxDepth: 0,
183
+ };
184
+ // ============================================
185
+ // Conversion Functions
186
+ // ============================================
187
+ /**
188
+ * Convert a tree-sitter point to drift Position.
189
+ *
190
+ * @param point - Tree-sitter point
191
+ * @returns Drift Position
192
+ */
193
+ export function convertCSharpPoint(point) {
194
+ return {
195
+ row: point.row,
196
+ column: point.column,
197
+ };
198
+ }
199
+ /**
200
+ * Convert a tree-sitter node type to drift node type.
201
+ *
202
+ * @param treeSitterType - Tree-sitter node type
203
+ * @returns Drift node type
204
+ */
205
+ export function convertCSharpNodeType(treeSitterType) {
206
+ return NODE_TYPE_MAP[treeSitterType] ?? treeSitterType;
207
+ }
208
+ /**
209
+ * C# AST Converter class.
210
+ *
211
+ * Converts tree-sitter C# AST to drift's unified AST format.
212
+ */
213
+ export class CSharpASTConverter {
214
+ options;
215
+ constructor(options = {}) {
216
+ this.options = { ...DEFAULT_CSHARP_CONVERSION_OPTIONS, ...options };
217
+ }
218
+ /**
219
+ * Convert a tree-sitter node to drift ASTNode.
220
+ *
221
+ * @param node - Tree-sitter node
222
+ * @param depth - Current depth (for maxDepth limiting)
223
+ * @returns Drift ASTNode
224
+ */
225
+ convert(node, depth = 0) {
226
+ // Check depth limit
227
+ if (this.options.maxDepth > 0 && depth >= this.options.maxDepth) {
228
+ return this.createLeafNode(node);
229
+ }
230
+ // Convert children
231
+ const children = [];
232
+ for (const child of node.children) {
233
+ // Skip anonymous nodes if configured
234
+ if (!this.options.includeAnonymous && !child.isNamed) {
235
+ continue;
236
+ }
237
+ children.push(this.convert(child, depth + 1));
238
+ }
239
+ return {
240
+ type: convertCSharpNodeType(node.type),
241
+ text: node.text,
242
+ startPosition: this.options.includePositions
243
+ ? convertCSharpPoint(node.startPosition)
244
+ : { row: 0, column: 0 },
245
+ endPosition: this.options.includePositions
246
+ ? convertCSharpPoint(node.endPosition)
247
+ : { row: 0, column: 0 },
248
+ children,
249
+ };
250
+ }
251
+ /**
252
+ * Create a leaf node (no children converted).
253
+ *
254
+ * @param node - Tree-sitter node
255
+ * @returns Drift ASTNode with no children
256
+ */
257
+ createLeafNode(node) {
258
+ return {
259
+ type: convertCSharpNodeType(node.type),
260
+ text: node.text,
261
+ startPosition: this.options.includePositions
262
+ ? convertCSharpPoint(node.startPosition)
263
+ : { row: 0, column: 0 },
264
+ endPosition: this.options.includePositions
265
+ ? convertCSharpPoint(node.endPosition)
266
+ : { row: 0, column: 0 },
267
+ children: [],
268
+ };
269
+ }
270
+ }
271
+ //# sourceMappingURL=csharp-ast-converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csharp-ast-converter.js","sourceRoot":"","sources":["../../../src/parsers/tree-sitter/csharp-ast-converter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,+CAA+C;AAC/C,oBAAoB;AACpB,+CAA+C;AAE/C;;;GAGG;AACH,MAAM,aAAa,GAA2B;IAC5C,mBAAmB;IACnB,gBAAgB,EAAE,SAAS;IAE3B,eAAe;IACf,iBAAiB,EAAE,kBAAkB;IACrC,kBAAkB,EAAE,mBAAmB;IACvC,kBAAkB,EAAE,mBAAmB;IACvC,qBAAqB,EAAE,sBAAsB;IAC7C,gBAAgB,EAAE,iBAAiB;IACnC,oBAAoB,EAAE,qBAAqB;IAC3C,qBAAqB,EAAE,sBAAsB;IAC7C,iCAAiC,EAAE,sBAAsB;IAEzD,UAAU;IACV,kBAAkB,EAAE,mBAAmB;IACvC,uBAAuB,EAAE,wBAAwB;IACjD,sBAAsB,EAAE,uBAAuB;IAC/C,oBAAoB,EAAE,qBAAqB;IAC3C,iBAAiB,EAAE,kBAAkB;IACrC,iBAAiB,EAAE,kBAAkB;IACrC,mBAAmB,EAAE,oBAAoB;IACzC,oBAAoB,EAAE,qBAAqB;IAC3C,+BAA+B,EAAE,+BAA+B;IAEhE,aAAa;IACb,KAAK,EAAE,OAAO;IACd,2BAA2B,EAAE,qBAAqB;IAClD,oBAAoB,EAAE,qBAAqB;IAC3C,YAAY,EAAE,aAAa;IAC3B,gBAAgB,EAAE,iBAAi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