@tscircuit/props 0.0.694 → 0.0.696

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.
@@ -12,6 +12,8 @@ export interface AssemblyCableProps {
12
12
  to: string
13
13
  /** Optional USB-C-to-USB-C preset. Omit to infer the cable from its endpoints. */
14
14
  standard?: AssemblyCableStandard
15
+ /** Explicit cable model specification. Omit to infer the cable from its endpoints. */
16
+ model?: string
15
17
  }
16
18
 
17
19
  export const assemblyCableProps = z.object({
@@ -19,6 +21,7 @@ export const assemblyCableProps = z.object({
19
21
  from: z.string().trim().min(1),
20
22
  to: z.string().trim().min(1),
21
23
  standard: z.literal("usb_c").optional(),
24
+ model: z.string().trim().min(1).optional(),
22
25
  })
23
26
 
24
27
  export type AssemblyCablePropsInput = z.input<typeof assemblyCableProps>
@@ -1,6 +1,7 @@
1
1
  import { assemblyCadAssemblyProps } from "./cadassembly"
2
2
  import { assemblyCableProps } from "./cable"
3
3
  import { assemblyDeviceProps } from "./device"
4
+ import { assemblyPartProps } from "./part"
4
5
  import { assemblyPrintedPartProps } from "./printedpart"
5
6
  import { assemblyMotorProps } from "./motor"
6
7
  import { assemblyScreenProps } from "./screen"
@@ -10,6 +11,7 @@ export * from "./board-mounting"
10
11
  export * from "./cable"
11
12
  export * from "./device"
12
13
  export * from "./motor"
14
+ export * from "./part"
13
15
  export * from "./printedpart"
14
16
  export * from "./screen"
15
17
  export * from "./subassembly"
@@ -19,6 +21,7 @@ export const assemblyProps = {
19
21
  cable: assemblyCableProps,
20
22
  device: assemblyDeviceProps,
21
23
  motor: assemblyMotorProps,
24
+ part: assemblyPartProps,
22
25
  printedpart: assemblyPrintedPartProps,
23
26
  screen: assemblyScreenProps,
24
27
  subassembly: assemblySubassemblyProps,
@@ -0,0 +1,43 @@
1
+ import { type CadModelProp, cadModelProp } from "lib/common/cadModel"
2
+ import { url } from "lib/common/url"
3
+ import { expectTypesMatch } from "lib/typecheck"
4
+ import { z } from "zod"
5
+
6
+ /** A generic component of an assembly, with optional CAD geometry. */
7
+ export interface AssemblyPartProps {
8
+ /** Stable identity used by assembly selectors. */
9
+ name: string
10
+ /** Human-facing alternate to the stable name. */
11
+ displayName?: string
12
+ /** Modelprinter/footprinter string, trimmed; mutually exclusive with modelUrl and cadModel. */
13
+ model?: string
14
+ /** Imported CAD model URL; mutually exclusive with model and cadModel. */
15
+ modelUrl?: string
16
+ /** Existing component CAD model formats; mutually exclusive with model and modelUrl. */
17
+ cadModel?: CadModelProp
18
+ }
19
+
20
+ export const assemblyPartProps = z
21
+ .object({
22
+ name: z.string().trim().min(1),
23
+ displayName: z.string().optional(),
24
+ model: z.string().trim().min(1).optional(),
25
+ modelUrl: url
26
+ .refine((value) => value.trim().length > 0, "modelUrl cannot be empty")
27
+ .optional(),
28
+ cadModel: cadModelProp.optional(),
29
+ })
30
+ .refine(
31
+ (part) =>
32
+ [part.model, part.modelUrl, part.cadModel].filter(
33
+ (value) => value !== undefined,
34
+ ).length <= 1,
35
+ {
36
+ message: "Provide only one of model, modelUrl, or cadModel",
37
+ path: ["model"],
38
+ },
39
+ )
40
+
41
+ export type AssemblyPartPropsInput = z.input<typeof assemblyPartProps>
42
+
43
+ expectTypesMatch<AssemblyPartProps, AssemblyPartPropsInput>(true)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.694",
3
+ "version": "0.0.696",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",