@huaqiu/hardware-artifacts 0.7.13 → 0.7.14
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/lib/index.d.mts +53 -10
- package/lib/index.mjs +80 -8
- package/lib/routes.d.mts +14 -3
- package/lib/routes.mjs +205 -10
- package/lib/service-CtVn7z8b.d.mts +568 -0
- package/lib/service-Yrc2C_eo.mjs +2005 -0
- package/lib/service.d.mts +2 -226
- package/lib/service.mjs +1 -837
- package/package.json +3 -2
- package/src/index.ts +117 -8
- package/src/order.ts +778 -0
- package/src/routes.ts +221 -10
- package/src/service.ts +692 -49
package/lib/service.d.mts
CHANGED
|
@@ -1,226 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type ArtifactKind = 'schematic' | 'pcb' | 'pcb-3d' | 'bom' | 'mechanical-3d';
|
|
4
|
-
/** Native handoff is KiCad-only in this POC; SolidCraft stays agent context. */
|
|
5
|
-
type NativeApplication = 'kicad';
|
|
6
|
-
interface HardwareArtifact {
|
|
7
|
-
readonly id: string;
|
|
8
|
-
readonly kind: ArtifactKind;
|
|
9
|
-
readonly path: string;
|
|
10
|
-
readonly projectPath?: string;
|
|
11
|
-
/** BOM keeps its schematic; PCB 3D keeps its board; sheets keep their root. */
|
|
12
|
-
readonly sourcePath?: string;
|
|
13
|
-
readonly title: string;
|
|
14
|
-
readonly format: string;
|
|
15
|
-
/** Content hash of the saved source, filled when the source is read. */
|
|
16
|
-
readonly revision?: string;
|
|
17
|
-
}
|
|
18
|
-
interface HardwareProject {
|
|
19
|
-
readonly path: string;
|
|
20
|
-
readonly name: string;
|
|
21
|
-
/** Root schematic: the authoritative project entry point. */
|
|
22
|
-
readonly rootSheet?: HardwareArtifact;
|
|
23
|
-
readonly schematic?: HardwareArtifact;
|
|
24
|
-
/** Semantic views; both keep the identity of their source artifact. */
|
|
25
|
-
readonly bom?: HardwareArtifact;
|
|
26
|
-
readonly pcb3d?: HardwareArtifact;
|
|
27
|
-
readonly sheets: readonly HardwareArtifact[];
|
|
28
|
-
/** Deterministic default board, only when ownership is unambiguous. */
|
|
29
|
-
readonly defaultBoard?: string;
|
|
30
|
-
readonly boards: readonly HardwareArtifact[];
|
|
31
|
-
readonly mechanical: readonly HardwareArtifact[];
|
|
32
|
-
readonly selectionRequired: boolean;
|
|
33
|
-
}
|
|
34
|
-
interface DiscoveryResult {
|
|
35
|
-
readonly cwd: string;
|
|
36
|
-
readonly manifestPath?: string;
|
|
37
|
-
readonly projects: readonly HardwareProject[];
|
|
38
|
-
readonly selected?: HardwareProject;
|
|
39
|
-
readonly issue?: {
|
|
40
|
-
readonly code: string;
|
|
41
|
-
readonly message: string;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
interface InstallationInfo {
|
|
45
|
-
readonly configured: boolean;
|
|
46
|
-
readonly root?: string;
|
|
47
|
-
readonly cli?: string;
|
|
48
|
-
readonly projectManager?: string;
|
|
49
|
-
readonly pcbEditor?: string;
|
|
50
|
-
readonly schematicEditor?: string;
|
|
51
|
-
readonly executable?: string;
|
|
52
|
-
readonly version?: string;
|
|
53
|
-
readonly error?: string;
|
|
54
|
-
}
|
|
55
|
-
interface Installations {
|
|
56
|
-
readonly kicad: InstallationInfo;
|
|
57
|
-
readonly solidcraft: InstallationInfo;
|
|
58
|
-
}
|
|
59
|
-
interface OpenArtifactRequest {
|
|
60
|
-
readonly application: NativeApplication;
|
|
61
|
-
readonly artifactPath: string;
|
|
62
|
-
readonly kind: ArtifactKind;
|
|
63
|
-
readonly projectPath?: string;
|
|
64
|
-
}
|
|
65
|
-
interface OpenArtifactResult {
|
|
66
|
-
readonly launched: true;
|
|
67
|
-
readonly command: string;
|
|
68
|
-
readonly args: readonly string[];
|
|
69
|
-
readonly cwd: string;
|
|
70
|
-
readonly pid?: number;
|
|
71
|
-
}
|
|
72
|
-
interface SourceRequest {
|
|
73
|
-
readonly artifactPath: string;
|
|
74
|
-
readonly expectedRevision?: string;
|
|
75
|
-
/** Workspace roots the caller is currently authorized to read. */
|
|
76
|
-
readonly roots?: readonly string[];
|
|
77
|
-
}
|
|
78
|
-
interface SourceResult {
|
|
79
|
-
readonly path: string;
|
|
80
|
-
readonly kind: 'schematic' | 'pcb';
|
|
81
|
-
readonly revision: string;
|
|
82
|
-
readonly bytes: number;
|
|
83
|
-
readonly mtimeMs: number;
|
|
84
|
-
readonly text: string;
|
|
85
|
-
}
|
|
86
|
-
interface GlbRequest {
|
|
87
|
-
readonly artifactPath: string;
|
|
88
|
-
readonly roots?: readonly string[];
|
|
89
|
-
readonly signal?: AbortSignal;
|
|
90
|
-
}
|
|
91
|
-
interface GlbResult {
|
|
92
|
-
readonly path: string;
|
|
93
|
-
readonly revision: string;
|
|
94
|
-
readonly bytes: number;
|
|
95
|
-
readonly generatedAt: string;
|
|
96
|
-
readonly cached: boolean;
|
|
97
|
-
readonly file: string;
|
|
98
|
-
}
|
|
99
|
-
/** One grouped BOM line, as KiCad's own BOM export groups it. */
|
|
100
|
-
interface BomRow {
|
|
101
|
-
readonly references: readonly string[];
|
|
102
|
-
readonly quantity: number;
|
|
103
|
-
readonly value: string;
|
|
104
|
-
readonly footprint: string;
|
|
105
|
-
readonly dnp: boolean;
|
|
106
|
-
readonly fields: Readonly<Record<string, string>>;
|
|
107
|
-
}
|
|
108
|
-
interface BomResult {
|
|
109
|
-
readonly path: string;
|
|
110
|
-
readonly revision: string;
|
|
111
|
-
readonly generatedAt: string;
|
|
112
|
-
readonly cached: boolean;
|
|
113
|
-
readonly rows: readonly BomRow[];
|
|
114
|
-
readonly source: 'kicad-cli-bom';
|
|
115
|
-
}
|
|
116
|
-
interface HardwareArtifactsOptions {
|
|
117
|
-
readonly kicadRoot?: string;
|
|
118
|
-
readonly solidcraftRoot?: string;
|
|
119
|
-
readonly probeVersion?: (executable: string) => string | undefined;
|
|
120
|
-
readonly spawnProcess?: (command: string, args: readonly string[], options: {
|
|
121
|
-
cwd: string;
|
|
122
|
-
detached: boolean;
|
|
123
|
-
stdio: 'ignore';
|
|
124
|
-
windowsHide: boolean;
|
|
125
|
-
shell: false;
|
|
126
|
-
}) => Pick<ChildProcess, 'pid'>;
|
|
127
|
-
/** Runs one short-lived CLI command and returns its exit facts. */
|
|
128
|
-
readonly runCommand?: (command: string, args: readonly string[], options: {
|
|
129
|
-
cwd: string;
|
|
130
|
-
timeoutMs: number;
|
|
131
|
-
signal?: AbortSignal;
|
|
132
|
-
}) => Promise<{
|
|
133
|
-
exitCode: number | null;
|
|
134
|
-
stdout: string;
|
|
135
|
-
stderr: string;
|
|
136
|
-
timedOut: boolean;
|
|
137
|
-
}>;
|
|
138
|
-
/** Cache directory for derived outputs; defaults to a temp subdirectory. */
|
|
139
|
-
readonly cacheRoot?: string;
|
|
140
|
-
readonly glbTimeoutMs?: number;
|
|
141
|
-
/** Source text limit; protects the host from pathological files. */
|
|
142
|
-
readonly maxSourceBytes?: number;
|
|
143
|
-
}
|
|
144
|
-
/** Small, immutable host capability implementation. */
|
|
145
|
-
declare class HardwareArtifactService {
|
|
146
|
-
private readonly config;
|
|
147
|
-
private readonly options;
|
|
148
|
-
private readonly cacheRoot;
|
|
149
|
-
private readonly glbTimeoutMs;
|
|
150
|
-
private readonly maxSourceBytes;
|
|
151
|
-
private lastDiscovery?;
|
|
152
|
-
/** Completed GLB exports keyed by `sourcePath:revision`. */
|
|
153
|
-
private readonly glbCache;
|
|
154
|
-
/** In-flight GLB exports keyed by the same key, so concurrent callers share one run. */
|
|
155
|
-
private readonly glbPending;
|
|
156
|
-
/** BOM projections keyed by `sourcePath:revision`. */
|
|
157
|
-
private readonly bomCache;
|
|
158
|
-
constructor(config?: HardwareArtifactsOptions);
|
|
159
|
-
/** Resolve configured installations from validated absolute paths only. */
|
|
160
|
-
installations(): Installations;
|
|
161
|
-
/** Paths passed to agent child processes. Never assign these globally. */
|
|
162
|
-
childEnvironment(): Record<string, string>;
|
|
163
|
-
/** Compact agent context: validated paths only, no project inventory dump. */
|
|
164
|
-
environmentText(current?: DiscoveryResult): string;
|
|
165
|
-
/**
|
|
166
|
-
* Deterministic discovery. An explicit project or manifest wins; otherwise
|
|
167
|
-
* exactly one `.kicad_pro` may be selected automatically. Ambiguity is
|
|
168
|
-
* returned as a selection requirement, never resolved by taking the first.
|
|
169
|
-
*/
|
|
170
|
-
discover(cwdInput: string, explicitProject?: string): DiscoveryResult;
|
|
171
|
-
/** The most recent discovery, used to authorize source reads. */
|
|
172
|
-
discovery(): DiscoveryResult | undefined;
|
|
173
|
-
private projectFrom;
|
|
174
|
-
/** Validate and launch a native application without a shell. */
|
|
175
|
-
open(request: OpenArtifactRequest): OpenArtifactResult;
|
|
176
|
-
/** Workspace roots a read may target: explicit request, last discovery, config. */
|
|
177
|
-
private authorizedRoots;
|
|
178
|
-
/**
|
|
179
|
-
* Authorize one artifact path: canonical, realpath-checked, inside a
|
|
180
|
-
* workspace root, and of an expected type. A browser request cannot turn
|
|
181
|
-
* this into an arbitrary filesystem read, even from loopback.
|
|
182
|
-
*/
|
|
183
|
-
private authorize;
|
|
184
|
-
/** Saved source text plus a content-addressed revision. */
|
|
185
|
-
readSource(request: SourceRequest): Promise<SourceResult>;
|
|
186
|
-
private sourceRevision;
|
|
187
|
-
/** Cache directory for one board's derived outputs. */
|
|
188
|
-
private glbDirectory;
|
|
189
|
-
/**
|
|
190
|
-
* Generate (or reuse) the GLB for one board.
|
|
191
|
-
*
|
|
192
|
-
* - cache key includes the source content hash, so same-size/same-mtime edits invalidate
|
|
193
|
-
* - one in-flight export is shared by concurrent callers for the same revision
|
|
194
|
-
* - output is written to a temp file and renamed only after it validates
|
|
195
|
-
* - a timeout or abort leaves no partial file behind
|
|
196
|
-
*/
|
|
197
|
-
exportGlb(request: GlbRequest): Promise<GlbResult>;
|
|
198
|
-
/**
|
|
199
|
-
* Grouped BOM for one saved root schematic.
|
|
200
|
-
*
|
|
201
|
-
* Reuses KiCad's own BOM extraction (`kicad-cli sch export bom`), the same
|
|
202
|
-
* authoritative source `analyze_kicad_module` consumes, rather than building a
|
|
203
|
-
* second component analyser. Grouping key is every non-reference column, so
|
|
204
|
-
* different MPNs never merge and DNP stays explicit.
|
|
205
|
-
*/
|
|
206
|
-
exportBom(request: {
|
|
207
|
-
readonly artifactPath: string;
|
|
208
|
-
readonly roots?: readonly string[];
|
|
209
|
-
readonly signal?: AbortSignal;
|
|
210
|
-
}): Promise<BomResult>;
|
|
211
|
-
/** Serve a generated GLB file, re-validating the cache entry first. */ glbFile(boardPath: string, revision: string): string;
|
|
212
|
-
/** Drop cached derived outputs for one board (or all of them). */
|
|
213
|
-
clearCache(boardPath?: string): void;
|
|
214
|
-
}
|
|
215
|
-
/** RFC4180-style CSV reader: quoted fields, doubled quotes, CRLF rows. */
|
|
216
|
-
declare function parseCsv(text: string): string[][];
|
|
217
|
-
/**
|
|
218
|
-
* Group KiCad's per-reference BOM rows.
|
|
219
|
-
*
|
|
220
|
-
* Identity is every column except the reference and quantity columns, so a
|
|
221
|
-
* different MPN or a DNP flag always produces a separate line; ordering follows
|
|
222
|
-
* the first reference seen, which keeps the table stable between reads.
|
|
223
|
-
*/
|
|
224
|
-
declare function groupBomRows(table: readonly string[][]): BomRow[];
|
|
225
|
-
//#endregion
|
|
226
|
-
export { ArtifactKind, BomResult, BomRow, DiscoveryResult, GlbRequest, GlbResult, HardwareArtifact, HardwareArtifactService, HardwareArtifactsOptions, HardwareProject, InstallationInfo, Installations, NativeApplication, OpenArtifactRequest, OpenArtifactResult, SourceRequest, SourceResult, groupBomRows, parseCsv };
|
|
1
|
+
import { C as groupBomRows, S as SourceResult, _ as OrderConfigInfo, a as FabricationResult, b as PlaceOrderResult, c as HardwareArtifact, d as HardwareProject, f as InstallationInfo, g as OpenArtifactResult, h as OpenArtifactRequest, i as DiscoveryResult, l as HardwareArtifactService, m as NativeApplication, n as BomResult, o as GlbRequest, p as Installations, r as BomRow, s as GlbResult, t as ArtifactKind, u as HardwareArtifactsOptions, v as OrderPackageSummary, w as parseCsv, x as SourceRequest, y as PlaceOrderRequest } from "./service-CtVn7z8b.mjs";
|
|
2
|
+
export { ArtifactKind, BomResult, BomRow, DiscoveryResult, FabricationResult, GlbRequest, GlbResult, HardwareArtifact, HardwareArtifactService, HardwareArtifactsOptions, HardwareProject, InstallationInfo, Installations, NativeApplication, OpenArtifactRequest, OpenArtifactResult, OrderConfigInfo, OrderPackageSummary, PlaceOrderRequest, PlaceOrderResult, SourceRequest, SourceResult, groupBomRows, parseCsv };
|