@tscircuit/props 0.0.679 → 0.0.680

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.
@@ -258,7 +258,11 @@ export interface CommonComponentProps<PinLabel extends string = string>
258
258
  * Whether to show this component's CAD model as translucent in the 3D viewer.
259
259
  */
260
260
  showAsTranslucentModel?: boolean
261
+ /** Alias for manufacturerPartNumber. No default; use resolveManufacturerPartNumber to resolve aliases. */
262
+ mpn?: string
263
+ /** Alias for manufacturerPartNumber. Retained for existing circuits. */
261
264
  mfn?: string
265
+ /** Manufacturer's part number. Aliases must agree when specified together. */
262
266
  manufacturerPartNumber?: string
263
267
  /**
264
268
  * This component will be drawn as part of this section e.g. "Power"
@@ -314,6 +318,7 @@ export const commonComponentProps = commonLayoutProps
314
318
  "Whether to show this component's CAD model as translucent in the 3D viewer.",
315
319
  ),
316
320
  pinAttributes: z.record(z.string(), pinAttributeMap).optional(),
321
+ mpn: z.string().describe("Manufacturer Part Number").optional(),
317
322
  mfn: z.string().describe("Manufacturer Part Number").optional(),
318
323
  manufacturerPartNumber: z.string().optional(),
319
324
  })
@@ -0,0 +1,23 @@
1
+ import type { CommonComponentProps } from "./layout"
2
+
3
+ /**
4
+ * Schemas retain the author's optional aliases so their Zod objects remain
5
+ * composable. Consumers resolve them to a canonical manufacturer part number
6
+ * with this helper. There is no default: empty/whitespace-only values are absent.
7
+ * Equal aliases are accepted; conflicting nonempty aliases throw. Existing
8
+ * manufacturerPartNumber and mfn inputs remain supported without migration.
9
+ */
10
+ export const resolveManufacturerPartNumber = (
11
+ props: Pick<CommonComponentProps, "manufacturerPartNumber" | "mpn" | "mfn">,
12
+ ): string | undefined => {
13
+ const partNumbers = [props.manufacturerPartNumber, props.mpn, props.mfn]
14
+ .map((partNumber) => partNumber?.trim())
15
+ .filter((partNumber): partNumber is string => Boolean(partNumber))
16
+
17
+ if (new Set(partNumbers).size > 1) {
18
+ throw new Error(
19
+ "Conflicting manufacturerPartNumber, mpn, and mfn: specify the same manufacturer part number for all aliases",
20
+ )
21
+ }
22
+ return partNumbers[0]
23
+ }
@@ -31,7 +31,6 @@ export interface CrystalProps<PinLabel extends string = string>
31
31
  /** Maximum allowed PCB trace length between the crystal and its connected component */
32
32
  maxTraceLength?: number | string
33
33
  manufacturerPartNumber?: string
34
- mpn?: string
35
34
  pinVariant?: PinVariant
36
35
  schOrientation?: SchematicOrientation
37
36
  connections?: Connections<CrystalPinLabels>
@@ -42,7 +41,6 @@ export const crystalProps = commonComponentProps.extend({
42
41
  loadCapacitance: capacitance,
43
42
  maxTraceLength: distance.optional(),
44
43
  manufacturerPartNumber: z.string().optional(),
45
- mpn: z.string().optional(),
46
44
  pinVariant: z.enum(["two_pin", "four_pin"]).optional(),
47
45
  schOrientation: schematicOrientation.optional(),
48
46
  connections: createConnectionsProp(crystalPins).optional(),
@@ -7,6 +7,8 @@ import { subcircuitGroupProps, type SubcircuitGroupProps } from "./group"
7
7
 
8
8
  type MountedBoardChipProps = Pick<
9
9
  ChipPropsSU,
10
+ | "mpn"
11
+ | "mfn"
10
12
  | "manufacturerPartNumber"
11
13
  | "pinLabels"
12
14
  | "showPinAliases"
@@ -26,6 +28,8 @@ export interface MountedBoardProps
26
28
  }
27
29
 
28
30
  export const mountedboardProps = subcircuitGroupProps.extend({
31
+ mpn: chipProps.shape.mpn,
32
+ mfn: chipProps.shape.mfn,
29
33
  manufacturerPartNumber: chipProps.shape.manufacturerPartNumber,
30
34
  pinLabels: chipProps.shape.pinLabels,
31
35
  showPinAliases: chipProps.shape.showPinAliases,
package/lib/index.ts CHANGED
@@ -4,6 +4,7 @@ export * from "./assembly"
4
4
  export * from "./enclosure"
5
5
  export * from "./common/portHints"
6
6
  export * from "./common/layout"
7
+ export * from "./common/resolveManufacturerPartNumber"
7
8
  export * from "./common/pinAttributeMap"
8
9
  export * from "./common/point3"
9
10
  export * from "./common/pcbPath"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.679",
3
+ "version": "0.0.680",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",