@tscircuit/props 0.0.693 → 0.0.694
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.
- package/README.md +7 -0
- package/dist/index.d.ts +27 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/lib/common/part-availability.ts +24 -0
- package/lib/components/group.ts +8 -0
- package/lib/index.ts +1 -0
- package/lib/platformConfig.ts +13 -0
- package/package.json +1 -1
|
@@ -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
|
+
}
|
package/lib/components/group.ts
CHANGED
|
@@ -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"
|
package/lib/platformConfig.ts
CHANGED
|
@@ -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(),
|