Skip to content

Commit 60de9bd

Browse files
Remove isNode field from FieldSpec interface and update runtime schema system
- Remove isNode field from FieldSpec interface in runtime-schema/types.ts - Update runtime schema generator to not include isNode in FieldSpec objects - Remove isNode field from NodeSpec interface in both types.ts and store.ts - Update generateRuntimeSchemaTypeScript method to match new interface - Fix logic in generateTsAstCodeFromPgAstWithSchema to determine node wrapping by checking field type directly - Update README documentation to reflect schema changes - All tests now pass with the simplified schema structure Co-Authored-By: Dan Lynch <[email protected]>
1 parent dd65445 commit 60de9bd

File tree

6 files changed

+6
-1682
lines changed

6 files changed

+6
-1682
lines changed

packages/proto-parser/src/runtime-schema/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The runtime schema system extracts metadata from protobuf definitions to create
88
- All AST node types and their structure
99
- Which types are wrapped (listed in Node.oneof)
1010
- Field specifications including type, optionality, and array status
11-
- Node field detection for AST references
11+
- Node type detection based on field type information
1212

1313
## Usage
1414

@@ -62,12 +62,13 @@ Each field within a node is represented by a FieldSpec:
6262
interface FieldSpec {
6363
name: string; // field name
6464
type: string; // field type (e.g. "RangeVar", "string", "Node")
65-
isNode: boolean; // true if field references AST nodes
6665
isArray: boolean; // true if field is repeated
6766
optional: boolean; // true if field is optional
6867
}
6968
```
7069

70+
To determine if a field references AST nodes, check if the `type` is a specific node type (exists in the runtime schema) rather than the generic "Node" type.
71+
7172
## CLI Tool
7273

7374
A CLI tool is available for generating runtime schemas:

packages/proto-parser/src/runtime-schema/generator.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export class RuntimeSchemaGenerator {
5353

5454
return {
5555
name: type.name,
56-
isNode: this.nodeTypes.has(type.name),
5756
fields: fields.sort((a, b) => a.name.localeCompare(b.name))
5857
};
5958
}
@@ -63,12 +62,10 @@ export class RuntimeSchemaGenerator {
6362
const isArray = field.repeated || false;
6463
const optional = !field.required;
6564
const fieldType = field.type;
66-
const isNode = fieldType === 'Node' || this.nodeTypes.has(fieldType);
6765

6866
return {
6967
name: fieldName,
7068
type: fieldType,
71-
isNode,
7269
isArray,
7370
optional
7471
};

packages/proto-parser/src/runtime-schema/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
export interface FieldSpec {
22
name: string;
33
type: string;
4-
isNode: boolean;
54
isArray: boolean;
65
optional: boolean;
76
}
87

98
export interface NodeSpec {
109
name: string;
11-
isNode: boolean;
1210
fields: FieldSpec[];
1311
}
1412

packages/proto-parser/src/store.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,12 @@ export class ProtoStore implements IProtoStore {
275275
'export interface FieldSpec {',
276276
' name: string;',
277277
' type: string;',
278-
' isNode: boolean;',
279278
' isArray: boolean;',
280279
' optional: boolean;',
281280
'}',
282281
'',
283282
'export interface NodeSpec {',
284283
' name: string;',
285-
' isNode: boolean;',
286284
' fields: FieldSpec[];',
287285
'}',
288286
''

packages/proto-parser/src/utils/meta.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export function generateTsAstCodeFromPgAstWithSchema(ast: any, runtimeSchema: No
147147
const parentSpec = schemaMap.get(parentNodeType);
148148
if (parentSpec) {
149149
const fieldSpec = parentSpec.fields.find(f => f.name === fieldName);
150-
if (fieldSpec && fieldSpec.isNode && fieldSpec.type !== 'Node') {
150+
if (fieldSpec && fieldSpec.type !== 'Node' && schemaMap.has(fieldSpec.type)) {
151151
isWrapped = false;
152152
}
153153
}
@@ -170,7 +170,7 @@ export function generateTsAstCodeFromPgAstWithSchema(ast: any, runtimeSchema: No
170170
const parentSpec = schemaMap.get(parentNodeType);
171171
if (parentSpec) {
172172
const parentFieldSpec = parentSpec.fields.find(f => f.name === fieldName);
173-
if (parentFieldSpec && parentFieldSpec.isNode && parentFieldSpec.type !== 'Node') {
173+
if (parentFieldSpec && parentFieldSpec.type !== 'Node' && schemaMap.has(parentFieldSpec.type)) {
174174
isWrapped = false;
175175
}
176176
}

0 commit comments

Comments
 (0)