@tscircuit/props 0.0.714 → 0.0.715
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/dist/index.d.ts +121 -2
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/lib/assembly/cable.ts +45 -7
- package/package.json +1 -1
package/lib/assembly/cable.ts
CHANGED
|
@@ -14,15 +14,53 @@ export interface AssemblyCableProps {
|
|
|
14
14
|
standard?: AssemblyCableStandard
|
|
15
15
|
/** Explicit cable model specification. Omit to infer the cable from its endpoints. */
|
|
16
16
|
model?: string
|
|
17
|
+
waypoints?: { x: number; y: number; z: number }[]
|
|
18
|
+
/** Reference endpoint for waypoint offsets. Required when waypoints is defined. */
|
|
19
|
+
waypointAnchor?: "start" | "end"
|
|
20
|
+
/** Board orientation for waypoint axes. Required when waypoints is defined. */
|
|
21
|
+
waypointAxisOrientation?: "board_at_start" | "board_at_end"
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
export const assemblyCableProps = z
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
export const assemblyCableProps = z
|
|
25
|
+
.object({
|
|
26
|
+
name: z.string().trim().min(1),
|
|
27
|
+
from: z.string().trim().min(1),
|
|
28
|
+
to: z.string().trim().min(1),
|
|
29
|
+
standard: z.literal("usb_c").optional(),
|
|
30
|
+
model: z.string().trim().min(1).optional(),
|
|
31
|
+
waypoints: z
|
|
32
|
+
.array(
|
|
33
|
+
z.object({
|
|
34
|
+
x: z.number().finite(),
|
|
35
|
+
y: z.number().finite(),
|
|
36
|
+
z: z.number().finite(),
|
|
37
|
+
}),
|
|
38
|
+
)
|
|
39
|
+
.optional(),
|
|
40
|
+
waypointAnchor: z.enum(["start", "end"]).optional(),
|
|
41
|
+
waypointAxisOrientation: z
|
|
42
|
+
.enum(["board_at_start", "board_at_end"])
|
|
43
|
+
.optional(),
|
|
44
|
+
})
|
|
45
|
+
.superRefine((cable, context) => {
|
|
46
|
+
if (cable.waypoints === undefined) return
|
|
47
|
+
|
|
48
|
+
if (cable.waypointAnchor === undefined) {
|
|
49
|
+
context.addIssue({
|
|
50
|
+
code: z.ZodIssueCode.custom,
|
|
51
|
+
path: ["waypointAnchor"],
|
|
52
|
+
message: "waypointAnchor is required when waypoints is defined",
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
if (cable.waypointAxisOrientation === undefined) {
|
|
56
|
+
context.addIssue({
|
|
57
|
+
code: z.ZodIssueCode.custom,
|
|
58
|
+
path: ["waypointAxisOrientation"],
|
|
59
|
+
message:
|
|
60
|
+
"waypointAxisOrientation is required when waypoints is defined",
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
})
|
|
26
64
|
|
|
27
65
|
export type AssemblyCablePropsInput = z.input<typeof assemblyCableProps>
|
|
28
66
|
|