@tscircuit/props 0.0.670 → 0.0.671

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.
@@ -7,16 +7,27 @@ export interface AssemblyDeviceProps {
7
7
  name?: string
8
8
  /** Imported CAD model URL. Mutually exclusive with cadModel where supported. */
9
9
  modelUrl?: string
10
+ /** Modelprinter/footprinter string, trimmed; mutually exclusive with other model sources. */
11
+ model?: string
10
12
  }
11
13
 
12
- export const assemblyDeviceProps = z.object({
13
- name: z.string().optional(),
14
- modelUrl: url
15
- .refine((value) => value.trim().length > 0, {
16
- message: "modelUrl cannot be empty",
17
- })
18
- .optional(),
19
- })
14
+ export const assemblyDeviceProps = z
15
+ .object({
16
+ name: z.string().optional(),
17
+ model: z.string().trim().min(1).optional(),
18
+ modelUrl: url
19
+ .refine((value) => value.trim().length > 0, {
20
+ message: "modelUrl cannot be empty",
21
+ })
22
+ .optional(),
23
+ })
24
+ .refine(
25
+ (device) => device.model === undefined || device.modelUrl === undefined,
26
+ {
27
+ message: "Provide either model or modelUrl, not both",
28
+ path: ["model"],
29
+ },
30
+ )
20
31
 
21
32
  export type AssemblyDevicePropsInput = z.input<typeof assemblyDeviceProps>
22
33
 
@@ -8,6 +8,8 @@ export interface AssemblyScreenProps {
8
8
  name: string
9
9
  /** Imported CAD model URL. Mutually exclusive with cadModel where supported. */
10
10
  modelUrl?: string
11
+ /** Modelprinter/footprinter string, trimmed; mutually exclusive with other model sources. */
12
+ model?: string
11
13
  /** Selector for the connector that the screen attaches to. */
12
14
  connectsTo: string
13
15
  /**
@@ -22,7 +24,7 @@ export interface AssemblyScreenProps {
22
24
  height?: Distance
23
25
  /**
24
26
  * Advanced modelprinter string used to render the screen assembly. Required
25
- * when `width`, `height`, and `modelUrl` are omitted.
27
+ * when `width`, `height`, `model`, and `modelUrl` are omitted.
26
28
  */
27
29
  cadModel?: string
28
30
  }
@@ -40,6 +42,7 @@ const positiveDistance = (fieldName: "width" | "height") =>
40
42
  export const assemblyScreenProps = z
41
43
  .object({
42
44
  name: nonemptyString("name"),
45
+ model: z.string().trim().min(1).optional(),
43
46
  modelUrl: url
44
47
  .refine((value) => value.trim().length > 0, {
45
48
  message: "modelUrl cannot be empty",
@@ -51,6 +54,16 @@ export const assemblyScreenProps = z
51
54
  cadModel: nonemptyString("cadModel").optional(),
52
55
  })
53
56
  .superRefine((screen, context) => {
57
+ if (
58
+ screen.model !== undefined &&
59
+ (screen.modelUrl !== undefined || screen.cadModel !== undefined)
60
+ ) {
61
+ context.addIssue({
62
+ code: z.ZodIssueCode.custom,
63
+ message: "Provide only one of model, modelUrl, or cadModel",
64
+ path: ["model"],
65
+ })
66
+ }
54
67
  if (screen.modelUrl !== undefined && screen.cadModel !== undefined) {
55
68
  context.addIssue({
56
69
  code: z.ZodIssueCode.custom,
@@ -73,11 +86,12 @@ export const assemblyScreenProps = z
73
86
  if (
74
87
  !hasWidth &&
75
88
  screen.cadModel === undefined &&
76
- screen.modelUrl === undefined
89
+ screen.modelUrl === undefined &&
90
+ screen.model === undefined
77
91
  ) {
78
92
  context.addIssue({
79
93
  code: z.ZodIssueCode.custom,
80
- message: "provide width and height, cadModel, or modelUrl",
94
+ message: "provide width and height, model, cadModel, or modelUrl",
81
95
  path: [],
82
96
  })
83
97
  }
@@ -9,6 +9,8 @@ export interface AssemblySubassemblyProps {
9
9
  name: string
10
10
  /** Imported CAD model URL. Mutually exclusive with cadModel where supported. */
11
11
  modelUrl?: string
12
+ /** Modelprinter/footprinter string, trimmed; mutually exclusive with other model sources. */
13
+ model?: string
12
14
  /** Human-facing alternate to the stable name. */
13
15
  displayName?: string
14
16
  /** Optional CAD geometry using the existing component cadModel formats. */
@@ -23,6 +25,7 @@ export const assemblySubassemblyProps = z
23
25
  message: "name cannot be empty",
24
26
  }),
25
27
  displayName: z.string().optional(),
28
+ model: z.string().trim().min(1).optional(),
26
29
  modelUrl: url
27
30
  .refine((value) => value.trim().length > 0, {
28
31
  message: "modelUrl cannot be empty",
@@ -39,6 +42,15 @@ export const assemblySubassemblyProps = z
39
42
  path: ["modelUrl"],
40
43
  },
41
44
  )
45
+ .refine(
46
+ (assembly) =>
47
+ assembly.model === undefined ||
48
+ (assembly.modelUrl === undefined && assembly.cadModel === undefined),
49
+ {
50
+ message: "Provide only one of model, modelUrl, or cadModel",
51
+ path: ["model"],
52
+ },
53
+ )
42
54
 
43
55
  export type AssemblySubassemblyPropsInput = z.input<
44
56
  typeof assemblySubassemblyProps
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.670",
3
+ "version": "0.0.671",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",