diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 00000000..82e0d999 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,45 @@ +# bump 1777865687 +# bump 1777865774 +# bump 1777867257 +# bump 1777910529 +# bump 1777953658 +# bump 1777996857 +# bump 1778040060 +# bump 1778083265 +# bump 1778126461 +# bump 1778169652 +# bump 1778212851 +# bump 1778256046 +# bump 1778299243 +# bump 1778342443 +# bump 1778385644 +# bump 1778428843 +# bump 1778472045 +# bump 1778515251 +# bump 1778558430 +# bump 1778601633 +# bump 1778644829 +# bump 1778688032 +# bump 1778731231 +# bump 1778774432 +# bump 1778817631 +# bump 1778860833 +# bump 1778904030 +# bump 1778947229 +# bump 1778990432 +# bump 1779033629 +# bump 1779076829 +# bump 1779120034 +# bump 1779163231 +# bump 1779206432 +# bump 1779249632 +# bump 1779292833 +# bump 1779336030 +# bump 1779379233 +# bump 1779422433 +# bump 1779465630 +# bump 1779508828 +# bump 1779552031 +# bump 1779595230 +# bump 1779638430 +# bump 1779681629 diff --git a/src/pcb/pcb_hole.ts b/src/pcb/pcb_hole.ts index 6dfae99b..fc357f5a 100644 --- a/src/pcb/pcb_hole.ts +++ b/src/pcb/pcb_hole.ts @@ -84,13 +84,19 @@ export interface PcbHoleRect { } expectTypesMatch(true) -const pcb_hole_circle_or_square = z.object({ +export const pcb_hole_circle_or_square = z.object({ type: z.literal("pcb_hole"), pcb_hole_id: getZodPrefixedIdWithDefault("pcb_hole"), pcb_group_id: z.string().optional(), subcircuit_id: z.string().optional(), pcb_component_id: z.string().optional(), - hole_shape: z.enum(["circle", "square"]), + hole_shape: z + .enum(["circle", "square", "round"]) + .default("circle") + .transform((shape) => { + if (shape === "round") return "circle" as const + return shape as "circle" | "square" + }), hole_diameter: z.number(), x: distance, y: distance, diff --git a/tests/pcb_hole_pill.test.ts b/tests/pcb_hole_pill.test.ts index 9fadbd52..2d2a810a 100644 --- a/tests/pcb_hole_pill.test.ts +++ b/tests/pcb_hole_pill.test.ts @@ -1,6 +1,7 @@ import { expect, test } from "bun:test" import { pcb_hole, + pcb_hole_circle_or_square, type PcbHolePill, type PcbHoleRotatedPill, } from "../src/pcb/pcb_hole" @@ -42,3 +43,36 @@ test("parse rotated pill-shaped non-plated hole", () => { expect(hole.y).toBe(10) expect(hole.ccw_rotation).toBe(45) }) + +test("pcb_hole_circle_or_square accepts 'circle' shape", () => { + const hole = pcb_hole_circle_or_square.parse({ + type: "pcb_hole", + hole_shape: "circle", + hole_diameter: 1, + x: 0, + y: 0, + }) + expect(hole.hole_shape).toBe("circle") +}) + +test("pcb_hole_circle_or_square accepts 'square' shape", () => { + const hole = pcb_hole_circle_or_square.parse({ + type: "pcb_hole", + hole_shape: "square", + hole_diameter: 1, + x: 0, + y: 0, + }) + expect(hole.hole_shape).toBe("square") +}) + +test("pcb_hole_circle_or_square transforms 'round' to 'circle'", () => { + const hole = pcb_hole_circle_or_square.parse({ + type: "pcb_hole", + hole_shape: "round", + hole_diameter: 1, + x: 0, + y: 0, + }) + expect(hole.hole_shape).toBe("circle") +})