tscircuit / checks

Validity checks for tscircuit soup JSON
2 stars 2 forks source link

Replace ids in error messages from @tscircuit/checks with selectors #9

Closed seveibar closed 4 months ago

seveibar commented 4 months ago

You can test the output of e.g. checkEachPcbTraceNonOverlapping (which returns an array of errors) to make sure the messages have selectors.

You'll likely need a function to derive a selector given a component. I think this probably exists somewhere in builder but it should be a general-purpose function inside of tscircuit/soup-util

image

You'll need to understand the soup specification to do this issue. Here's a summary of most soup elements:

```json [ { "type": "source_component", "ftype": "Excepteur proident ut", "source_component_id": "source_component_1", "name": "E1", "manufacturer_part_number": "irure Lorem nostrud cillum velit", "supplier_part_numbers": { "pariaturb13": [ "ut in est", "sit Ut est fugiat nisi", "dolor", "exercitation aliquip Lorem" ], "dolor9fb": ["adipisicing aliquip ut"] } }, { "type": "source_group", "source_group_id": "source_group_1", "name": "G1" }, { "type": "source_component", "ftype": "led", "source_component_id": "source_component_1", "name": "L1", "manufacturer_part_number": "amet incididunt id consectetur", "supplier_part_numbers": { "qui_3e": [ "nulla eiusmod deserunt adipisicing", "fugiat", "incididunt", "esse nostrud", "dolore consequat ex" ], "dolor203": ["ipsum"], "voluptate_793": ["ad", "anim aute"] } }, { "type": "source_net", "source_net_id": "source_net_1", "name": "N1", "member_source_group_ids": ["ea dolore", "ad do"], "is_ground": true }, { "type": "source_port", "port_hints": ["1", "left"], "name": "P1", "source_port_id": "source_port_1", "source_component_id": "source_component_1" }, { "type": "source_component", "ftype": "simple_bug", "source_component_id": "source_component_1", "name": "B1", "manufacturer_part_number": "ex nostrud exercitation voluptate", "supplier_part_numbers": { "ea__": ["in aute adipisicing", "commodo dolore Duis", "ex velit cillum"] } }, { "type": "source_component", "ftype": "simple_capacitor", "source_component_id": "source_component_1", "name": "C1", "capacitance": "1uF" }, { "type": "source_component", "ftype": "simple_diode", "source_component_id": "source_component_1", "name": "D1" }, { "type": "source_component", "ftype": "simple_ground", "source_component_id": "source_component_1", "name": "G1", "supplier_part_numbers": { "commodoab": [ "eu nulla esse in aliqua", "labore consequat ea Lorem", "quis" ] } }, { "type": "source_component", "ftype": "simple_power_source", "source_component_id": "source_component_1", "name": "P1", "manufacturer_part_number": "ut et anim irure ut", "supplier_part_numbers": { "aute07": ["voluptate ipsum culpa", "eu"] }, "voltage": "5V" }, { "type": "source_component", "ftype": "simple_resistor", "source_component_id": "source_component_1", "name": "R1", "manufacturer_part_number": "qui labore laborum", "supplier_part_numbers": { "ullamco_b_5": ["pariatur minim dolor do", "ipsum"] }, "resistance": "1k" }, { "type": "source_trace", "source_trace_id": "source_trace_1", "connected_source_port_ids": ["enim"], "connected_source_net_ids": [ "esse nostrud labore qui", "dolor consequat", "ullamco ad sed minim" ] }, { "type": "schematic_box", "schematic_component_id": "schematic_component_1", "width": "5mm", "height": "5mm", "x": "3mm", "y": "1mm" }, { "type": "schematic_component", "rotation": "90deg", "size": { "width": "5mm", "height": "5mm" }, "center": { "x": "3mm", "y": "1mm" }, "source_component_id": "source_component_1", "schematic_component_id": "schematic_component_1", "box_width": "sed velit", "port_labels": { "1": "VCC", "2": "GND", "3": "OUT" } }, { "schematic_error_id": "schematic_error_1", "type": "schematic_error", "error_type": "schematic_port_not_found", "message": "dolore Excepteur occaecat ut ad" }, { "type": "schematic_line", "schematic_component_id": "schematic_component_1", "x1": "1mm", "x2": "2mm", "y1": "1mm", "y2": "2mm" }, { "type": "schematic_net_label", "source_net_id": "source_net_1", "center": { "x": "3mm", "y": "1mm" }, "anchor_side": "bottom", "text": "Hello, World!" }, { "type": "schematic_path", "schematic_component_id": "schematic_component_1", "fill_color": "red", "is_filled": true, "points": [ { "x": "3mm", "y": "1mm" }, { "x": "3mm", "y": "1mm" }, { "x": "3mm", "y": "1mm" }, { "x": "3mm", "y": "1mm" }, { "x": "3mm", "y": "1mm" } ] }, { "type": "schematic_port", "schematic_port_id": "schematic_port_1", "source_port_id": "source_port_1", "center": { "x": "3mm", "y": "1mm" } }, { "type": "schematic_text", "schematic_component_id": "schematic_component_1", "schematic_text_id": "schematic_text_1", "text": "Hello, World!", "position": { "x": "3mm", "y": "1mm" }, "rotation": "90deg", "anchor": "bottom" }, { "type": "schematic_trace", "schematic_trace_id": "schematic_trace_1", "source_trace_id": "source_trace_1", "edges": [ { "from": { "x": "3mm", "y": "1mm" }, "to": { "x": "3mm", "y": "1mm" }, "from_schematic_port_id": "from_schematic_port_1", "to_schematic_port_id": "to_schematic_port_1" }, { "from": { "x": "3mm", "y": "1mm" }, "to": { "x": "3mm", "y": "1mm" } }, { "from": { "x": "3mm", "y": "1mm" }, "to": { "x": "3mm", "y": "1mm" } } ] }, { "type": "pcb_board", "width": "5mm", "height": "5mm", "center": { "x": "3mm", "y": "1mm" } }, { "type": "pcb_component", "pcb_component_id": "pcb_component_1", "source_component_id": "source_component_1", "center": { "x": "3mm", "y": "1mm" }, "layer": "top", "rotation": "90deg", "width": "5mm", "height": "5mm" }, { "type": "pcb_fabrication_note_path", "fabrication_note_path_id": "fabrication_note_path_1", "pcb_component_id": "pcb_component_1", "layer": "top", "route": [ { "x": "3mm", "y": "1mm" }, { "x": "3mm", "y": "1mm" }, { "x": "3mm", "y": "1mm" }, { "x": "3mm", "y": "1mm" } ], "stroke_width": "0.1mm" }, { "type": "pcb_fabrication_note_text", "font": "tscircuit2024", "font_size": "1mm", "pcb_component_id": "pcb_component_1", "text": "Hello, World!", "layer": "top", "anchor_position": { "x": "3mm", "y": "1mm" }, "anchor_alignment": "bottom_left" }, { "pcb_error_id": "pcb_error_1", "type": "pcb_error", "error_type": "pcb_placement_error", "message": "est quis dolore enim" }, { "type": "pcb_port", "pcb_port_id": "pcb_port_1", "source_port_id": "source_port_1", "pcb_component_id": "pcb_component_1", "x": "3mm", "y": "1mm", "layers": ["top", "bottom"] }, { "pcb_error_id": "pcb_error_1", "type": "pcb_error", "error_type": "pcb_port_not_matched_error", "message": "minim eiusmod", "pcb_component_ids": ["pcb_component_1"] }, { "type": "pcb_silkscreen_circle", "pcb_silkscreen_circle_id": "pcb_silkscreen_circle_1", "pcb_component_id": "pcb_component_1", "center": { "x": "3mm", "y": "1mm" }, "radius": "5mm", "layer": "top" }, { "type": "pcb_silkscreen_line", "pcb_silkscreen_line_id": "pcb_silkscreen_line_1", "pcb_component_id": "pcb_component_1", "stroke_width": "0.1mm", "x1": "1mm", "y1": "1mm", "x2": "2mm", "y2": "2mm", "layer": "top" }, { "type": "pcb_silkscreen_oval", "pcb_silkscreen_oval_id": "pcb_silkscreen_oval_1", "pcb_component_id": "pcb_component_1", "center": { "x": "3mm", "y": "1mm" }, "radius_x": 41495762.561106086, "radius_y": -97567070.17981991, "layer": "top" }, { "type": "pcb_silkscreen_path", "pcb_silkscreen_path_id": "pcb_silkscreen_path_1", "pcb_component_id": "pcb_component_1", "layer": "top", "route": [ { "x": "3mm", "y": "1mm" }, { "x": "3mm", "y": "1mm" } ], "stroke_width": "0.1mm" }, { "type": "pcb_silkscreen_rect", "pcb_silkscreen_rect_id": "pcb_silkscreen_rect_1", "pcb_component_id": "pcb_component_1", "center": { "x": "3mm", "y": "1mm" }, "width": "5mm", "height": "5mm", "layer": "top" }, { "type": "pcb_silkscreen_text", "font": "tscircuit2024", "font_size": "1mm", "pcb_component_id": "pcb_component_1", "text": "Hello, World!", "layer": "top", "anchor_position": { "x": "3mm", "y": "1mm" }, "anchor_alignment": "bottom_right" }, { "type": "pcb_text", "text": "Hello, World!", "x": "3mm", "y": "1mm", "align": "bottom-left", "width": "5mm", "height": "5mm", "lines": 1 }, { "type": "pcb_trace", "source_trace_id": "source_trace_1", "pcb_component_id": "pcb_component_1", "pcb_trace_id": "pcb_trace_1", "route": [ { "route_type": "via", "x": "3mm", "y": "1mm", "from_layer": "top", "to_layer": "bottom" } ] } ```
tscircuitbot commented 4 months ago

Aider has created a pull request to address this issue: undefined

Please review the changes and provide feedback.