@tscircuit/props 0.0.693 → 0.0.695

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>
@@ -0,0 +1,24 @@
1
+ import type { SupplierName } from "./layout"
2
+
3
+ export type PartAvailabilityPlatformFetch = (
4
+ input: Parameters<typeof fetch>[0],
5
+ init?: Parameters<typeof fetch>[1],
6
+ ) => ReturnType<typeof fetch>
7
+
8
+ export interface FetchPartAvailabilityParams {
9
+ supplierName: SupplierName
10
+ supplierPartNumber: string
11
+ platformFetch?: PartAvailabilityPlatformFetch
12
+ signal?: AbortSignal
13
+ }
14
+
15
+ export interface PartAvailability {
16
+ /** Available unit count; null means availability could not be confirmed. */
17
+ stock: number | null
18
+ /** Unit price at the supplier's lowest quantity tier; null means unknown. */
19
+ price: number | null
20
+ /** ISO 4217 currency code, such as USD; null when the price is unknown. */
21
+ currency: string | null
22
+ /** ISO timestamp of this lookup, rather than a guarantee of stock freshness. */
23
+ checkedAt?: string
24
+ }
@@ -34,6 +34,10 @@ import {
34
34
  import { url } from "lib/common/url"
35
35
  import type { Connections } from "lib/utility-types/connections-and-selectors"
36
36
  import type { ImplicitBreakoutPointSolverFn } from "lib/common/implicitBreakoutPointSolver"
37
+ import type {
38
+ FetchPartAvailabilityParams,
39
+ PartAvailability,
40
+ } from "lib/common/part-availability"
37
41
 
38
42
  export const layoutConfig = z.object({
39
43
  layoutMode: z
@@ -297,6 +301,10 @@ export interface BaseGroupProps extends CommonLayoutProps, LayoutConfig {
297
301
  }
298
302
 
299
303
  export type PartsEngine = {
304
+ /** Optional stock and price lookup. Return undefined for unsupported suppliers. */
305
+ fetchPartAvailability?: (
306
+ params: FetchPartAvailabilityParams,
307
+ ) => Promise<PartAvailability | undefined> | PartAvailability | undefined
300
308
  findPart: (params: {
301
309
  sourceComponent: AnySourceComponent
302
310
  footprinterString?: string
package/lib/index.ts CHANGED
@@ -53,6 +53,7 @@ export * from "./components/resonator"
53
53
  export * from "./components/stampboard"
54
54
  export * from "./components/capacitor"
55
55
  export * from "./components/group"
56
+ export * from "./common/part-availability"
56
57
  export * from "./components/net"
57
58
  export * from "./components/fiducial"
58
59
  export * from "./components/constrainedlayout"
@@ -69,6 +69,13 @@ type EsModuleImportResult = {
69
69
  export interface PlatformConfig {
70
70
  partsEngine?: PartsEngine
71
71
 
72
+ /**
73
+ * Check JLCPCB supplier stock through jlcsearch during rendering and warn when
74
+ * availability cannot be confirmed. Omitted or false performs no checks.
75
+ * Enabling this adds network requests and non-deterministic diagnostics.
76
+ */
77
+ checkAvailability?: boolean
78
+
72
79
  /** Optional fabricator-specific DRC provider. No checks run when omitted. */
73
80
  fabricatorEngine?: FabricatorEngine
74
81
 
@@ -275,6 +282,12 @@ export const fabricatorEngine = z.custom<FabricatorEngine>(
275
282
 
276
283
  export const platformConfig = z.object({
277
284
  partsEngine: partsEngine.optional(),
285
+ checkAvailability: z
286
+ .boolean()
287
+ .describe(
288
+ "Opt in to networked JLCPCB availability checks during rendering. Disabled by default; enabling adds non-deterministic diagnostics.",
289
+ )
290
+ .optional(),
278
291
  fabricatorEngine: fabricatorEngine.optional(),
279
292
  autorouter: autorouterProp.optional(),
280
293
  autorouterMap: z.record(z.string(), autorouterDefinition).optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.693",
3
+ "version": "0.0.695",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",