@tscircuit/props 0.0.717 → 0.0.719

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 { supplierProps, type SupplierProps } from "lib/common/layout"
2
+ import { expectTypesMatch } from "lib/typecheck"
3
+ import { z } from "zod"
4
+
5
+ /** Purchasing metadata shared by physical assembly elements, not CAD primitives. */
6
+ export interface AssemblyBomProps extends SupplierProps {
7
+ /** Alternative HTTP(S) purchase links, independent of supplier part numbers.
8
+ * Omitted and empty arrays are accepted. No SKU-to-URL mapping is inferred.
9
+ */
10
+ purchaseUrls?: string[]
11
+ }
12
+
13
+ export const assemblyBomProps = supplierProps.extend({
14
+ purchaseUrls: z
15
+ .array(
16
+ z
17
+ .string()
18
+ .url()
19
+ .refine((value) => /^https?:\/\//i.test(value), {
20
+ message: "Purchase links must use HTTP or HTTPS",
21
+ }),
22
+ )
23
+ .optional(),
24
+ })
25
+
26
+ expectTypesMatch<AssemblyBomProps, z.input<typeof assemblyBomProps>>(true)
@@ -1,9 +1,10 @@
1
+ import { assemblyBomProps, type AssemblyBomProps } from "./bom"
1
2
  import { expectTypesMatch } from "lib/typecheck"
2
3
  import { z } from "zod"
3
4
 
4
5
  export type AssemblyCableStandard = "usb_c"
5
6
 
6
- export interface AssemblyCableProps {
7
+ export interface AssemblyCableProps extends AssemblyBomProps {
7
8
  /** Stable assembly identity for the cable. */
8
9
  name: string
9
10
  /** Start connector selector or named assembly reference, e.g. MOTOR.wireside. */
@@ -23,6 +24,7 @@ export interface AssemblyCableProps {
23
24
 
24
25
  export const assemblyCableProps = z
25
26
  .object({
27
+ ...assemblyBomProps.shape,
26
28
  name: z.string().trim().min(1),
27
29
  from: z.string().trim().min(1),
28
30
  to: z.string().trim().min(1),
@@ -1,8 +1,9 @@
1
+ import { assemblyBomProps, type AssemblyBomProps } from "./bom"
1
2
  import { url } from "lib/common/url"
2
3
  import { expectTypesMatch } from "lib/typecheck"
3
4
  import { z } from "zod"
4
5
 
5
- export interface AssemblyDeviceProps {
6
+ export interface AssemblyDeviceProps extends AssemblyBomProps {
6
7
  /** Product-level assembly identity. */
7
8
  name?: string
8
9
  /** Imported CAD model URL. Mutually exclusive with cadModel where supported. */
@@ -13,6 +14,7 @@ export interface AssemblyDeviceProps {
13
14
 
14
15
  export const assemblyDeviceProps = z
15
16
  .object({
17
+ ...assemblyBomProps.shape,
16
18
  name: z.string().optional(),
17
19
  model: z.string().trim().min(1).optional(),
18
20
  modelUrl: url
@@ -12,6 +12,7 @@ import { assemblyScreenProps } from "./screen"
12
12
  import { assemblySubassemblyProps } from "./subassembly"
13
13
  import { assemblyExplosionProps } from "./explosion"
14
14
 
15
+ export * from "./bom"
15
16
  export * from "./drawing"
16
17
  export * from "./board-mounting"
17
18
  export * from "./bolt"
@@ -1,3 +1,4 @@
1
+ import { assemblyBomProps, type AssemblyBomProps } from "./bom"
1
2
  import {
2
3
  type CadModelAxisDirection,
3
4
  cadModelAxisDirection,
@@ -12,7 +13,9 @@ import {
12
13
 
13
14
  export type AssemblyMotorStandard = "nema8" | "nema17" | "nema23"
14
15
 
15
- export interface AssemblyMotorProps extends AssemblyFaceMountProps {
16
+ export interface AssemblyMotorProps
17
+ extends AssemblyFaceMountProps,
18
+ AssemblyBomProps {
16
19
  /** Stable assembly identity used by selectors. */
17
20
  name: string
18
21
  /** Human-facing alternate to the stable name. */
@@ -37,6 +40,7 @@ export interface AssemblyMotorProps extends AssemblyFaceMountProps {
37
40
 
38
41
  export const assemblyMotorProps = z
39
42
  .object({
43
+ ...assemblyBomProps.shape,
40
44
  ...assemblyFaceMountShape,
41
45
  name: z.string().refine((value) => value.trim().length > 0, {
42
46
  message: "name cannot be empty",
@@ -1,3 +1,4 @@
1
+ import { assemblyBomProps, type AssemblyBomProps } from "./bom"
1
2
  import { type CadModelProp, cadModelProp } from "lib/common/cadModel"
2
3
  import { url } from "lib/common/url"
3
4
  import { expectTypesMatch } from "lib/typecheck"
@@ -10,7 +11,9 @@ import {
10
11
  } from "./face-mounting"
11
12
 
12
13
  /** A generic component of an assembly, with optional CAD geometry. */
13
- export interface AssemblyPartProps extends AssemblyFaceMountProps {
14
+ export interface AssemblyPartProps
15
+ extends AssemblyFaceMountProps,
16
+ AssemblyBomProps {
14
17
  /** Stable identity used by assembly selectors. */
15
18
  name: string
16
19
  /** Human-facing alternate to the stable name. */
@@ -29,6 +32,7 @@ export interface AssemblyPartProps extends AssemblyFaceMountProps {
29
32
  // Keep model validation separate from ordinary face-mount pairing.
30
33
  export const assemblyPartBaseProps = z
31
34
  .object({
35
+ ...assemblyBomProps.shape,
32
36
  name: z.string().trim().min(1),
33
37
  displayName: z.string().optional(),
34
38
  model: z.string().trim().min(1).optional(),
@@ -1,3 +1,4 @@
1
+ import { assemblyBomProps, type AssemblyBomProps } from "./bom"
1
2
  import { type CadModelProp, cadModelProp } from "lib/common/cadModel"
2
3
  import { url } from "lib/common/url"
3
4
  import { expectTypesMatch } from "lib/typecheck"
@@ -10,7 +11,9 @@ import {
10
11
  } from "./face-mounting"
11
12
 
12
13
  /** Provide exactly one of jscad, model, modelUrl, or cadModel. */
13
- export interface AssemblyPrintedPartProps extends AssemblyFaceMountProps {
14
+ export interface AssemblyPrintedPartProps
15
+ extends AssemblyFaceMountProps,
16
+ AssemblyBomProps {
14
17
  /** Stable identity used by assembly mounting selectors. */
15
18
  name: string
16
19
  displayName?: string
@@ -33,6 +36,7 @@ export interface AssemblyPrintedPartProps extends AssemblyFaceMountProps {
33
36
 
34
37
  export const assemblyPrintedPartProps = z
35
38
  .object({
39
+ ...assemblyBomProps.shape,
36
40
  ...assemblyFaceMountShape,
37
41
  name: z.string().trim().min(1),
38
42
  displayName: z.string().optional(),
@@ -1,9 +1,10 @@
1
+ import { assemblyBomProps, type AssemblyBomProps } from "./bom"
1
2
  import { url } from "lib/common/url"
2
3
  import { type Distance, distance } from "lib/common/distance"
3
4
  import { expectTypesMatch } from "lib/typecheck"
4
5
  import { z } from "zod"
5
6
 
6
- export interface AssemblyScreenProps {
7
+ export interface AssemblyScreenProps extends AssemblyBomProps {
7
8
  /** Stable product-level identity for the screen assembly. */
8
9
  name: string
9
10
  /** Imported CAD model URL. Mutually exclusive with cadModel where supported. */
@@ -41,6 +42,7 @@ const positiveDistance = (fieldName: "width" | "height") =>
41
42
 
42
43
  export const assemblyScreenProps = z
43
44
  .object({
45
+ ...assemblyBomProps.shape,
44
46
  name: nonemptyString("name"),
45
47
  model: z.string().trim().min(1).optional(),
46
48
  modelUrl: url
@@ -1,3 +1,4 @@
1
+ import { assemblyBomProps, type AssemblyBomProps } from "./bom"
1
2
  import { url } from "lib/common/url"
2
3
  import { type CadModelProp, cadModelProp } from "lib/common/cadModel"
3
4
  import { expectTypesMatch } from "lib/typecheck"
@@ -9,7 +10,9 @@ import {
9
10
  type AssemblyFaceMountProps,
10
11
  } from "./face-mounting"
11
12
 
12
- export interface AssemblySubassemblyProps extends AssemblyFaceMountProps {
13
+ export interface AssemblySubassemblyProps
14
+ extends AssemblyFaceMountProps,
15
+ AssemblyBomProps {
13
16
  /** Stable identity used by selectors from other assembly elements. */
14
17
  name: string
15
18
  /** Imported CAD model URL. Mutually exclusive with cadModel where supported. */
@@ -26,6 +29,7 @@ export interface AssemblySubassemblyProps extends AssemblyFaceMountProps {
26
29
 
27
30
  export const assemblySubassemblyProps = z
28
31
  .object({
32
+ ...assemblyBomProps.shape,
29
33
  ...assemblyFaceMountShape,
30
34
  name: z.string().refine((value) => value.trim().length > 0, {
31
35
  message: "name cannot be empty",
@@ -62,19 +62,39 @@ export const kicadProperty = z.object({
62
62
  type InferredKicadProperty = z.input<typeof kicadProperty>
63
63
  expectTypesMatch<KicadProperty, InferredKicadProperty>(true)
64
64
 
65
+ /** Built-in and custom property names share the same validated property shape. */
65
66
  export interface KicadFootprintProperties {
67
+ [propertyName: string]: KicadProperty | undefined
66
68
  Reference?: KicadProperty
67
69
  Value?: KicadProperty
68
70
  Datasheet?: KicadProperty
69
71
  Description?: KicadProperty
70
72
  }
71
73
 
72
- export const kicadFootprintProperties = z.object({
73
- Reference: kicadProperty.optional(),
74
- Value: kicadProperty.optional(),
75
- Datasheet: kicadProperty.optional(),
76
- Description: kicadProperty.optional(),
77
- })
74
+ const kicadFootprintPropertiesSchema = z
75
+ .object({
76
+ Reference: kicadProperty.optional(),
77
+ Value: kicadProperty.optional(),
78
+ Datasheet: kicadProperty.optional(),
79
+ Description: kicadProperty.optional(),
80
+ })
81
+ .catchall(kicadProperty.optional())
82
+
83
+ // Name the schema type so consumers retain the named properties without
84
+ // expanding the catchall throughout generated package declarations.
85
+ interface KicadFootprintPropertiesSchema
86
+ extends z.ZodObject<
87
+ typeof kicadFootprintPropertiesSchema.shape,
88
+ "strip",
89
+ z.ZodOptional<typeof kicadProperty>,
90
+ z.output<typeof kicadFootprintPropertiesSchema>,
91
+ KicadFootprintProperties
92
+ > {}
93
+
94
+ export { type KicadFootprintPropertiesSchema }
95
+
96
+ export const kicadFootprintProperties: KicadFootprintPropertiesSchema =
97
+ kicadFootprintPropertiesSchema
78
98
 
79
99
  type InferredKicadFootprintProperties = z.input<typeof kicadFootprintProperties>
80
100
  expectTypesMatch<KicadFootprintProperties, InferredKicadFootprintProperties>(
@@ -64,7 +64,9 @@ export const kicadSymbolProperty = z.object({
64
64
  type InferredKicadSymbolProperty = z.input<typeof kicadSymbolProperty>
65
65
  expectTypesMatch<KicadSymbolProperty, InferredKicadSymbolProperty>(true)
66
66
 
67
+ /** Built-in and custom property names share the same validated property shape. */
67
68
  export interface KicadSymbolProperties {
69
+ [propertyName: string]: KicadSymbolProperty | undefined
68
70
  Reference?: KicadSymbolProperty
69
71
  Value?: KicadSymbolProperty
70
72
  Footprint?: KicadSymbolProperty
@@ -74,15 +76,33 @@ export interface KicadSymbolProperties {
74
76
  ki_fp_filters?: KicadSymbolProperty
75
77
  }
76
78
 
77
- export const kicadSymbolProperties = z.object({
78
- Reference: kicadSymbolProperty.optional(),
79
- Value: kicadSymbolProperty.optional(),
80
- Footprint: kicadSymbolProperty.optional(),
81
- Datasheet: kicadSymbolProperty.optional(),
82
- Description: kicadSymbolProperty.optional(),
83
- ki_keywords: kicadSymbolProperty.optional(),
84
- ki_fp_filters: kicadSymbolProperty.optional(),
85
- })
79
+ const kicadSymbolPropertiesSchema = z
80
+ .object({
81
+ Reference: kicadSymbolProperty.optional(),
82
+ Value: kicadSymbolProperty.optional(),
83
+ Footprint: kicadSymbolProperty.optional(),
84
+ Datasheet: kicadSymbolProperty.optional(),
85
+ Description: kicadSymbolProperty.optional(),
86
+ ki_keywords: kicadSymbolProperty.optional(),
87
+ ki_fp_filters: kicadSymbolProperty.optional(),
88
+ })
89
+ .catchall(kicadSymbolProperty.optional())
90
+
91
+ // Name the schema type so consumers retain the named properties without
92
+ // expanding the catchall throughout generated package declarations.
93
+ interface KicadSymbolPropertiesSchema
94
+ extends z.ZodObject<
95
+ typeof kicadSymbolPropertiesSchema.shape,
96
+ "strip",
97
+ z.ZodOptional<typeof kicadSymbolProperty>,
98
+ z.output<typeof kicadSymbolPropertiesSchema>,
99
+ KicadSymbolProperties
100
+ > {}
101
+
102
+ export { type KicadSymbolPropertiesSchema }
103
+
104
+ export const kicadSymbolProperties: KicadSymbolPropertiesSchema =
105
+ kicadSymbolPropertiesSchema
86
106
 
87
107
  type InferredKicadSymbolProperties = z.input<typeof kicadSymbolProperties>
88
108
  expectTypesMatch<KicadSymbolProperties, InferredKicadSymbolProperties>(true)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.717",
3
+ "version": "0.0.719",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",