@tscircuit/props 0.0.685 → 0.0.687

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.
@@ -0,0 +1,26 @@
1
+ import { expectTypesMatch } from "lib/typecheck"
2
+ import { z } from "zod"
3
+
4
+ export type AssemblyCableStandard = "usb_c"
5
+
6
+ export interface AssemblyCableProps {
7
+ /** Stable assembly identity for the cable. */
8
+ name: string
9
+ /** Start connector selector or named assembly reference, e.g. MOTOR.wireside. */
10
+ from: string
11
+ /** End connector selector or named assembly reference. */
12
+ to: string
13
+ /** Optional USB-C-to-USB-C preset. Omit to infer the cable from its endpoints. */
14
+ standard?: AssemblyCableStandard
15
+ }
16
+
17
+ export const assemblyCableProps = z.object({
18
+ name: z.string().trim().min(1),
19
+ from: z.string().trim().min(1),
20
+ to: z.string().trim().min(1),
21
+ standard: z.literal("usb_c").optional(),
22
+ })
23
+
24
+ export type AssemblyCablePropsInput = z.input<typeof assemblyCableProps>
25
+
26
+ expectTypesMatch<AssemblyCableProps, AssemblyCablePropsInput>(true)
@@ -1,4 +1,5 @@
1
1
  import { assemblyCadAssemblyProps } from "./cadassembly"
2
+ import { assemblyCableProps } from "./cable"
2
3
  import { assemblyDeviceProps } from "./device"
3
4
  import { assemblyPrintedPartProps } from "./printedpart"
4
5
  import { assemblyMotorProps } from "./motor"
@@ -6,6 +7,7 @@ import { assemblyScreenProps } from "./screen"
6
7
  import { assemblySubassemblyProps } from "./subassembly"
7
8
 
8
9
  export * from "./board-mounting"
10
+ export * from "./cable"
9
11
  export * from "./device"
10
12
  export * from "./motor"
11
13
  export * from "./printedpart"
@@ -14,6 +16,7 @@ export * from "./subassembly"
14
16
  export * from "./cadassembly"
15
17
 
16
18
  export const assemblyProps = {
19
+ cable: assemblyCableProps,
17
20
  device: assemblyDeviceProps,
18
21
  motor: assemblyMotorProps,
19
22
  printedpart: assemblyPrintedPartProps,
@@ -2,6 +2,7 @@ import {
2
2
  type CadModelAxisDirection,
3
3
  cadModelAxisDirection,
4
4
  } from "lib/common/cadModel"
5
+ import { distance, type Distance } from "lib/common/distance"
5
6
  import { expectTypesMatch } from "lib/typecheck"
6
7
  import { z } from "zod"
7
8
 
@@ -25,6 +26,18 @@ export interface AssemblyMotorProps {
25
26
  shaftFacingDirection?: CadModelAxisDirection
26
27
  /** e.g. "jst-ph-6". */
27
28
  wireConnection?: "none" | "stubs" | "jst-ph-6"
29
+ /** Assembly mounting target, e.g. "FRAME.xMotor"; paired with mountFace.
30
+ * Face mating determines orientation, so shaftFacingDirection must be omitted.
31
+ */
32
+ mountedTo?: string
33
+ /** This motor's mating face, e.g. "frontface" or "backface".
34
+ * Outward normals oppose and in-plane X directions align with the target.
35
+ */
36
+ mountFace?: string
37
+ /** Nonnegative surface clearance in mm or a unit string; defaults to zero.
38
+ * Requires mountedTo. Positive values separate the mating faces.
39
+ */
40
+ mountGap?: Distance
28
41
  }
29
42
 
30
43
  export const assemblyMotorProps = z
@@ -35,10 +48,41 @@ export const assemblyMotorProps = z
35
48
  displayName: z.string().optional(),
36
49
  standard: z.enum(["nema8", "nema17", "nema23"]).optional(),
37
50
  model: z.string().trim().min(1).optional(),
38
- shaftFacingDirection: cadModelAxisDirection.default("z+"),
51
+ shaftFacingDirection: cadModelAxisDirection.optional(),
39
52
  wireConnection: z.enum(["none", "stubs", "jst-ph-6"]).optional(),
53
+ mountedTo: z
54
+ .string()
55
+ .trim()
56
+ .regex(/^.+\.[^.]+$/, "Expected part.face")
57
+ .optional(),
58
+ mountFace: z.string().trim().min(1).optional(),
59
+ mountGap: distance.pipe(z.number().nonnegative().finite()).optional(),
40
60
  })
41
61
  .superRefine((motor, context) => {
62
+ if ((motor.mountedTo === undefined) !== (motor.mountFace === undefined)) {
63
+ context.addIssue({
64
+ code: z.ZodIssueCode.custom,
65
+ message: "Provide mountedTo and mountFace together",
66
+ path: ["mountFace"],
67
+ })
68
+ }
69
+ if (motor.mountGap !== undefined && motor.mountedTo === undefined) {
70
+ context.addIssue({
71
+ code: z.ZodIssueCode.custom,
72
+ message: "mountGap requires mountedTo",
73
+ path: ["mountGap"],
74
+ })
75
+ }
76
+ if (
77
+ motor.mountedTo !== undefined &&
78
+ motor.shaftFacingDirection !== undefined
79
+ ) {
80
+ context.addIssue({
81
+ code: z.ZodIssueCode.custom,
82
+ message: "Mounted motors derive shaft direction from the mating faces",
83
+ path: ["shaftFacingDirection"],
84
+ })
85
+ }
42
86
  if (motor.model !== undefined && motor.wireConnection !== undefined) {
43
87
  context.addIssue({
44
88
  code: z.ZodIssueCode.custom,
@@ -62,6 +106,14 @@ export const assemblyMotorProps = z
62
106
  })
63
107
  }
64
108
  })
109
+ .transform((motor) =>
110
+ motor.mountedTo === undefined
111
+ ? {
112
+ ...motor,
113
+ shaftFacingDirection: motor.shaftFacingDirection ?? ("z+" as const),
114
+ }
115
+ : motor,
116
+ )
65
117
 
66
118
  export type AssemblyMotorPropsInput = z.input<typeof assemblyMotorProps>
67
119
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.685",
3
+ "version": "0.0.687",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",