@grayhaven/nerve 0.1.0
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/LICENSE +202 -0
- package/dist/index.d.ts +1149 -0
- package/dist/index.js +799 -0
- package/package.json +38 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1149 @@
|
|
|
1
|
+
import * as effect_Effect from 'effect/Effect';
|
|
2
|
+
import * as effect_ParseResult from 'effect/ParseResult';
|
|
3
|
+
import * as effect_SchemaAST from 'effect/SchemaAST';
|
|
4
|
+
import { Schema } from 'effect';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Core domain model for Grayhaven Nerve.
|
|
8
|
+
*
|
|
9
|
+
* These are the user-facing design types produced by the DSL builders.
|
|
10
|
+
* The compiler normalizes a `HarnessDesign` into the HIR (see ./hir/schema.ts),
|
|
11
|
+
* which is what renderers, validators, and exporters consume.
|
|
12
|
+
*/
|
|
13
|
+
type Units = "mm" | "in";
|
|
14
|
+
type ConnectorGender = "plug" | "receptacle" | "hermaphroditic";
|
|
15
|
+
/**
|
|
16
|
+
* Component master data for a connector housing (PRD §9.2, §30).
|
|
17
|
+
* Instances reference a part; parts live in libraries such as
|
|
18
|
+
* `@grayhaven/nerve-connectors`.
|
|
19
|
+
*/
|
|
20
|
+
interface ConnectorPart {
|
|
21
|
+
readonly mpn: string;
|
|
22
|
+
readonly manufacturer?: string;
|
|
23
|
+
readonly family?: string;
|
|
24
|
+
readonly description?: string;
|
|
25
|
+
readonly gender?: ConnectorGender;
|
|
26
|
+
readonly pinCount: number;
|
|
27
|
+
readonly pinNumbering?: string;
|
|
28
|
+
readonly cavityLayout?: {
|
|
29
|
+
readonly rows: number;
|
|
30
|
+
readonly columns: number;
|
|
31
|
+
};
|
|
32
|
+
readonly matingMpn?: string;
|
|
33
|
+
readonly compatibleTerminals?: ReadonlyArray<string>;
|
|
34
|
+
readonly compatibleSeals?: ReadonlyArray<string>;
|
|
35
|
+
readonly wireGaugeRange?: {
|
|
36
|
+
readonly min: string;
|
|
37
|
+
readonly max: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** A reference to a specific pin/cavity on a connector instance. */
|
|
41
|
+
interface PinRef {
|
|
42
|
+
readonly kind: "pin-ref";
|
|
43
|
+
readonly connector: string;
|
|
44
|
+
readonly pin: string;
|
|
45
|
+
}
|
|
46
|
+
/** A reference to a splice node. */
|
|
47
|
+
interface SpliceRef {
|
|
48
|
+
readonly kind: "splice-ref";
|
|
49
|
+
readonly splice: string;
|
|
50
|
+
}
|
|
51
|
+
/** Where a wire terminates: a connector pin or a splice. */
|
|
52
|
+
type WireEndpoint = PinRef | SpliceRef;
|
|
53
|
+
/** Map of pin number/name to assigned signal name. */
|
|
54
|
+
type PinAssignments = Readonly<Record<string | number, string>>;
|
|
55
|
+
/** A connector instance placed in a harness, e.g. `connector("J1", part, {...})`. */
|
|
56
|
+
interface ConnectorInstance {
|
|
57
|
+
readonly kind: "connector";
|
|
58
|
+
readonly ref: string;
|
|
59
|
+
readonly part: ConnectorPart;
|
|
60
|
+
readonly pins: Readonly<Record<string, string>>;
|
|
61
|
+
/** Build a `PinRef` for a pin on this connector. */
|
|
62
|
+
pin(pin: string | number): PinRef;
|
|
63
|
+
}
|
|
64
|
+
interface WireProps {
|
|
65
|
+
readonly gauge?: string;
|
|
66
|
+
readonly color?: string;
|
|
67
|
+
readonly stripe?: string;
|
|
68
|
+
readonly length?: number;
|
|
69
|
+
readonly lengthTolerance?: number;
|
|
70
|
+
readonly signal?: string;
|
|
71
|
+
readonly insulation?: string;
|
|
72
|
+
readonly voltageRating?: number;
|
|
73
|
+
readonly temperatureRating?: number;
|
|
74
|
+
readonly currentEstimate?: number;
|
|
75
|
+
readonly twistGroup?: string;
|
|
76
|
+
readonly shieldGroup?: string;
|
|
77
|
+
/** Cable this wire is a conductor of (see `cable()`). */
|
|
78
|
+
readonly cable?: string;
|
|
79
|
+
/** Conductor number/name within the cable. */
|
|
80
|
+
readonly conductor?: string | number;
|
|
81
|
+
readonly notes?: string;
|
|
82
|
+
}
|
|
83
|
+
interface WireDef extends WireProps {
|
|
84
|
+
readonly kind: "wire";
|
|
85
|
+
readonly id: string;
|
|
86
|
+
readonly from: WireEndpoint;
|
|
87
|
+
readonly to: WireEndpoint;
|
|
88
|
+
}
|
|
89
|
+
interface SpliceProps {
|
|
90
|
+
/** crimp, solder-sleeve, ultrasonic-weld, ... */
|
|
91
|
+
readonly type?: string;
|
|
92
|
+
/** Crimp or solder-sleeve part number. */
|
|
93
|
+
readonly part?: string;
|
|
94
|
+
/** Branch the splice sits on. */
|
|
95
|
+
readonly branch?: string;
|
|
96
|
+
/** Distance along the branch from its start, in harness units. */
|
|
97
|
+
readonly location?: number;
|
|
98
|
+
/** Seal / heat-shrink / inspection notes (PRD §9.2). */
|
|
99
|
+
readonly notes?: string;
|
|
100
|
+
}
|
|
101
|
+
interface SpliceDef extends SpliceProps {
|
|
102
|
+
readonly kind: "splice";
|
|
103
|
+
readonly id: string;
|
|
104
|
+
}
|
|
105
|
+
interface CableProps {
|
|
106
|
+
/** Catalog type, e.g. "2x24AWG twisted shielded". */
|
|
107
|
+
readonly type?: string;
|
|
108
|
+
readonly conductors?: number;
|
|
109
|
+
readonly shield?: string;
|
|
110
|
+
readonly jacket?: string;
|
|
111
|
+
readonly outerDiameter?: number;
|
|
112
|
+
readonly notes?: string;
|
|
113
|
+
}
|
|
114
|
+
interface CableDef extends CableProps {
|
|
115
|
+
readonly kind: "cable";
|
|
116
|
+
readonly id: string;
|
|
117
|
+
}
|
|
118
|
+
interface BranchProps {
|
|
119
|
+
readonly path: ReadonlyArray<ConnectorInstance | string>;
|
|
120
|
+
readonly parent?: string;
|
|
121
|
+
readonly sleeve?: string;
|
|
122
|
+
readonly nominalLength?: number;
|
|
123
|
+
readonly breakoutDistance?: number;
|
|
124
|
+
}
|
|
125
|
+
interface BranchDef {
|
|
126
|
+
readonly kind: "branch";
|
|
127
|
+
readonly id: string;
|
|
128
|
+
readonly path: ReadonlyArray<string>;
|
|
129
|
+
readonly parent?: string;
|
|
130
|
+
readonly sleeve?: string;
|
|
131
|
+
readonly nominalLength?: number;
|
|
132
|
+
readonly breakoutDistance?: number;
|
|
133
|
+
}
|
|
134
|
+
interface LabelProps {
|
|
135
|
+
readonly text: string;
|
|
136
|
+
readonly attachTo: ConnectorInstance | string;
|
|
137
|
+
readonly offsetFrom?: ConnectorInstance | string;
|
|
138
|
+
readonly distance?: number;
|
|
139
|
+
readonly material?: string;
|
|
140
|
+
readonly quantity?: number;
|
|
141
|
+
}
|
|
142
|
+
interface LabelDef {
|
|
143
|
+
readonly kind: "label";
|
|
144
|
+
readonly id: string;
|
|
145
|
+
readonly text: string;
|
|
146
|
+
readonly attachTo: string;
|
|
147
|
+
readonly offsetFrom?: string;
|
|
148
|
+
readonly distance?: number;
|
|
149
|
+
readonly material?: string;
|
|
150
|
+
readonly quantity?: number;
|
|
151
|
+
}
|
|
152
|
+
interface HarnessProps {
|
|
153
|
+
readonly revision: string;
|
|
154
|
+
readonly units: Units;
|
|
155
|
+
readonly metadata?: Readonly<Record<string, string>>;
|
|
156
|
+
readonly connectors: ReadonlyArray<ConnectorInstance>;
|
|
157
|
+
readonly wires: ReadonlyArray<WireDef>;
|
|
158
|
+
readonly branches?: ReadonlyArray<BranchDef>;
|
|
159
|
+
readonly labels?: ReadonlyArray<LabelDef>;
|
|
160
|
+
readonly splices?: ReadonlyArray<SpliceDef>;
|
|
161
|
+
readonly cables?: ReadonlyArray<CableDef>;
|
|
162
|
+
}
|
|
163
|
+
/** The root design object returned by `harness(...)` — the unit of compilation. */
|
|
164
|
+
interface HarnessDesign {
|
|
165
|
+
readonly kind: "harness";
|
|
166
|
+
readonly id: string;
|
|
167
|
+
readonly revision: string;
|
|
168
|
+
readonly units: Units;
|
|
169
|
+
readonly metadata: Readonly<Record<string, string>>;
|
|
170
|
+
readonly connectors: ReadonlyArray<ConnectorInstance>;
|
|
171
|
+
readonly wires: ReadonlyArray<WireDef>;
|
|
172
|
+
readonly branches: ReadonlyArray<BranchDef>;
|
|
173
|
+
readonly labels: ReadonlyArray<LabelDef>;
|
|
174
|
+
readonly splices: ReadonlyArray<SpliceDef>;
|
|
175
|
+
readonly cables: ReadonlyArray<CableDef>;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* TypeScript authoring DSL (PRD §9.1).
|
|
180
|
+
*
|
|
181
|
+
* Builders are cheap and permissive: they capture intent as plain data.
|
|
182
|
+
* Correctness lives in the compiler/validator, which reports precise
|
|
183
|
+
* diagnostics instead of throwing mid-definition.
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
/** Place a connector in the harness: `connector("J1", MolexMicroFit["43025-0800"], { pins: {...} })`. */
|
|
187
|
+
declare const connector: (ref: string, part: ConnectorPart, opts: {
|
|
188
|
+
readonly pins: PinAssignments;
|
|
189
|
+
}) => ConnectorInstance;
|
|
190
|
+
/** Anything a wire can terminate on: a pin ref, a splice (def or ref). */
|
|
191
|
+
type EndpointInput = PinRef | SpliceDef | {
|
|
192
|
+
kind: "splice-ref";
|
|
193
|
+
splice: string;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Define a wire between two endpoints:
|
|
197
|
+
* `wire("W1", j1.pin(1), m1.pin(1), { gauge: "18AWG", ... })` or
|
|
198
|
+
* `wire("W5", j1.pin(2), s1, {...})` where `s1` is a splice.
|
|
199
|
+
*/
|
|
200
|
+
declare const wire: (id: string, from: EndpointInput, to: EndpointInput, props?: WireProps) => WireDef;
|
|
201
|
+
/** Define a splice node: `splice("S1", { type: "crimp", branch: "main", location: 120 })`. */
|
|
202
|
+
declare const splice: (id: string, props?: SpliceProps) => SpliceDef;
|
|
203
|
+
/** Define a multi-conductor cable that wires can belong to via `cable`/`conductor` props. */
|
|
204
|
+
declare const cable: (id: string, props?: CableProps) => CableDef;
|
|
205
|
+
/** Define a physical branch through the harness: `branch("main", { path: [j1, m1], ... })`. */
|
|
206
|
+
declare const branch: (id: string, props: BranchProps) => BranchDef;
|
|
207
|
+
/** Define a label: `label("L1", { text: "MOTOR CTRL A", attachTo: "main", ... })`. */
|
|
208
|
+
declare const label: (id: string, props: LabelProps) => LabelDef;
|
|
209
|
+
/** Define a harness — the root design object and default export of a `.harness.ts` file. */
|
|
210
|
+
declare const harness: (id: string, props: HarnessProps) => HarnessDesign;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Diagnostics primitives (PRD §11.2).
|
|
214
|
+
*
|
|
215
|
+
* Every diagnostic carries a stable code so CI gates, docs, and suppression
|
|
216
|
+
* config can rely on it across releases.
|
|
217
|
+
*/
|
|
218
|
+
declare const DiagnosticSeverity: {
|
|
219
|
+
readonly Error: "error";
|
|
220
|
+
readonly Warning: "warning";
|
|
221
|
+
readonly Info: "info";
|
|
222
|
+
};
|
|
223
|
+
type DiagnosticSeverity = (typeof DiagnosticSeverity)[keyof typeof DiagnosticSeverity];
|
|
224
|
+
interface Diagnostic {
|
|
225
|
+
/** Stable code, e.g. `HK-WIRE-001`. */
|
|
226
|
+
readonly code: string;
|
|
227
|
+
readonly severity: DiagnosticSeverity;
|
|
228
|
+
readonly message: string;
|
|
229
|
+
/** Stable HIR object reference, e.g. `wire:W12` or `connector:J1.pin:3`. */
|
|
230
|
+
readonly target?: string | undefined;
|
|
231
|
+
}
|
|
232
|
+
/** Structural diagnostic codes emitted by the core compiler. */
|
|
233
|
+
declare const Codes: {
|
|
234
|
+
readonly DuplicateConnectorRef: "HK-CONN-001";
|
|
235
|
+
readonly UndefinedConnectorRef: "HK-CONN-002";
|
|
236
|
+
readonly UndefinedPinRef: "HK-CONN-003";
|
|
237
|
+
readonly DuplicateWireId: "HK-WIRE-001";
|
|
238
|
+
readonly WireEndpointsIdentical: "HK-WIRE-002";
|
|
239
|
+
readonly DuplicateBranchId: "HK-BRANCH-001";
|
|
240
|
+
readonly BranchUndefinedEndpoint: "HK-BRANCH-002";
|
|
241
|
+
readonly DuplicateLabelId: "HK-LABEL-001";
|
|
242
|
+
readonly LabelUndefinedTarget: "HK-LABEL-002";
|
|
243
|
+
readonly DuplicateSpliceId: "HK-SPLICE-001";
|
|
244
|
+
readonly UndefinedSpliceRef: "HK-SPLICE-002";
|
|
245
|
+
readonly SpliceTooFewWires: "HK-SPLICE-003";
|
|
246
|
+
readonly SpliceUndefinedBranch: "HK-SPLICE-004";
|
|
247
|
+
readonly DuplicateCableId: "HK-CABLE-001";
|
|
248
|
+
readonly UndefinedCableRef: "HK-CABLE-002";
|
|
249
|
+
};
|
|
250
|
+
declare const hasErrors: (diagnostics: ReadonlyArray<Diagnostic>) => boolean;
|
|
251
|
+
|
|
252
|
+
declare const HIR_SCHEMA_VERSION: "0.1.0";
|
|
253
|
+
declare const Hir: Schema.Struct<{
|
|
254
|
+
schemaVersion: Schema.Literal<["0.1.0"]>;
|
|
255
|
+
harness: Schema.Struct<{
|
|
256
|
+
id: typeof Schema.String;
|
|
257
|
+
revision: typeof Schema.String;
|
|
258
|
+
units: Schema.Literal<["mm", "in"]>;
|
|
259
|
+
metadata: Schema.Record$<typeof Schema.String, typeof Schema.String>;
|
|
260
|
+
}>;
|
|
261
|
+
connectors: Schema.Array$<Schema.Struct<{
|
|
262
|
+
ref: typeof Schema.String;
|
|
263
|
+
mpn: typeof Schema.String;
|
|
264
|
+
manufacturer: Schema.optional<typeof Schema.String>;
|
|
265
|
+
family: Schema.optional<typeof Schema.String>;
|
|
266
|
+
description: Schema.optional<typeof Schema.String>;
|
|
267
|
+
gender: Schema.optional<Schema.Literal<["plug", "receptacle", "hermaphroditic"]>>;
|
|
268
|
+
pinCount: typeof Schema.Number;
|
|
269
|
+
wireGaugeRange: Schema.optional<Schema.Struct<{
|
|
270
|
+
min: typeof Schema.String;
|
|
271
|
+
max: typeof Schema.String;
|
|
272
|
+
}>>;
|
|
273
|
+
pins: Schema.Array$<Schema.Struct<{
|
|
274
|
+
pin: typeof Schema.String;
|
|
275
|
+
signal: Schema.optional<typeof Schema.String>;
|
|
276
|
+
}>>;
|
|
277
|
+
}>>;
|
|
278
|
+
wires: Schema.Array$<Schema.Struct<{
|
|
279
|
+
id: typeof Schema.String;
|
|
280
|
+
from: Schema.Union<[Schema.Struct<{
|
|
281
|
+
connector: typeof Schema.String;
|
|
282
|
+
pin: typeof Schema.String;
|
|
283
|
+
}>, Schema.Struct<{
|
|
284
|
+
splice: typeof Schema.String;
|
|
285
|
+
}>]>;
|
|
286
|
+
to: Schema.Union<[Schema.Struct<{
|
|
287
|
+
connector: typeof Schema.String;
|
|
288
|
+
pin: typeof Schema.String;
|
|
289
|
+
}>, Schema.Struct<{
|
|
290
|
+
splice: typeof Schema.String;
|
|
291
|
+
}>]>;
|
|
292
|
+
gauge: Schema.optional<typeof Schema.String>;
|
|
293
|
+
color: Schema.optional<typeof Schema.String>;
|
|
294
|
+
stripe: Schema.optional<typeof Schema.String>;
|
|
295
|
+
length: Schema.optional<typeof Schema.Number>;
|
|
296
|
+
lengthTolerance: Schema.optional<typeof Schema.Number>;
|
|
297
|
+
signal: Schema.optional<typeof Schema.String>;
|
|
298
|
+
insulation: Schema.optional<typeof Schema.String>;
|
|
299
|
+
voltageRating: Schema.optional<typeof Schema.Number>;
|
|
300
|
+
temperatureRating: Schema.optional<typeof Schema.Number>;
|
|
301
|
+
currentEstimate: Schema.optional<typeof Schema.Number>;
|
|
302
|
+
twistGroup: Schema.optional<typeof Schema.String>;
|
|
303
|
+
shieldGroup: Schema.optional<typeof Schema.String>;
|
|
304
|
+
cable: Schema.optional<typeof Schema.String>;
|
|
305
|
+
conductor: Schema.optional<typeof Schema.String>;
|
|
306
|
+
branch: Schema.optional<typeof Schema.String>;
|
|
307
|
+
notes: Schema.optional<typeof Schema.String>;
|
|
308
|
+
}>>;
|
|
309
|
+
cables: Schema.Array$<Schema.Struct<{
|
|
310
|
+
id: typeof Schema.String;
|
|
311
|
+
type: Schema.optional<typeof Schema.String>;
|
|
312
|
+
conductors: Schema.optional<typeof Schema.Number>;
|
|
313
|
+
shield: Schema.optional<typeof Schema.String>;
|
|
314
|
+
jacket: Schema.optional<typeof Schema.String>;
|
|
315
|
+
outerDiameter: Schema.optional<typeof Schema.Number>;
|
|
316
|
+
/** Longest member wire — the cable cut length (computed). */
|
|
317
|
+
cutLength: Schema.optional<typeof Schema.Number>;
|
|
318
|
+
notes: Schema.optional<typeof Schema.String>;
|
|
319
|
+
/** Member wire IDs (computed by the compiler). */
|
|
320
|
+
wires: Schema.Array$<typeof Schema.String>;
|
|
321
|
+
}>>;
|
|
322
|
+
branches: Schema.Array$<Schema.Struct<{
|
|
323
|
+
id: typeof Schema.String;
|
|
324
|
+
path: Schema.Array$<typeof Schema.String>;
|
|
325
|
+
parent: Schema.optional<typeof Schema.String>;
|
|
326
|
+
sleeve: Schema.optional<typeof Schema.String>;
|
|
327
|
+
nominalLength: Schema.optional<typeof Schema.Number>;
|
|
328
|
+
breakoutDistance: Schema.optional<typeof Schema.Number>;
|
|
329
|
+
}>>;
|
|
330
|
+
splices: Schema.Array$<Schema.Struct<{
|
|
331
|
+
id: typeof Schema.String;
|
|
332
|
+
type: Schema.optional<typeof Schema.String>;
|
|
333
|
+
part: Schema.optional<typeof Schema.String>;
|
|
334
|
+
branch: Schema.optional<typeof Schema.String>;
|
|
335
|
+
location: Schema.optional<typeof Schema.Number>;
|
|
336
|
+
notes: Schema.optional<typeof Schema.String>;
|
|
337
|
+
/** Wire IDs attached to this splice (computed by the compiler). */
|
|
338
|
+
wires: Schema.Array$<typeof Schema.String>;
|
|
339
|
+
}>>;
|
|
340
|
+
labels: Schema.Array$<Schema.Struct<{
|
|
341
|
+
id: typeof Schema.String;
|
|
342
|
+
text: typeof Schema.String;
|
|
343
|
+
attachTo: typeof Schema.String;
|
|
344
|
+
offsetFrom: Schema.optional<typeof Schema.String>;
|
|
345
|
+
distance: Schema.optional<typeof Schema.Number>;
|
|
346
|
+
material: Schema.optional<typeof Schema.String>;
|
|
347
|
+
quantity: Schema.optional<typeof Schema.Number>;
|
|
348
|
+
}>>;
|
|
349
|
+
bom: Schema.Array$<Schema.Struct<{
|
|
350
|
+
internalPartId: Schema.optional<typeof Schema.String>;
|
|
351
|
+
mpn: typeof Schema.String;
|
|
352
|
+
manufacturer: Schema.optional<typeof Schema.String>;
|
|
353
|
+
description: Schema.optional<typeof Schema.String>;
|
|
354
|
+
category: Schema.optional<typeof Schema.String>;
|
|
355
|
+
quantity: typeof Schema.Number;
|
|
356
|
+
unitOfMeasure: typeof Schema.String;
|
|
357
|
+
usedBy: Schema.Array$<typeof Schema.String>;
|
|
358
|
+
notes: Schema.optional<typeof Schema.String>;
|
|
359
|
+
}>>;
|
|
360
|
+
diagnostics: Schema.Array$<Schema.Struct<{
|
|
361
|
+
code: typeof Schema.String;
|
|
362
|
+
severity: Schema.Literal<["error", "warning", "info"]>;
|
|
363
|
+
message: typeof Schema.String;
|
|
364
|
+
target: Schema.optional<typeof Schema.String>;
|
|
365
|
+
}>>;
|
|
366
|
+
layoutHints: Schema.Array$<typeof Schema.Unknown>;
|
|
367
|
+
exports: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
|
|
368
|
+
}>;
|
|
369
|
+
type Hir = Schema.Schema.Type<typeof Hir>;
|
|
370
|
+
declare const HirConnector: Schema.Struct<{
|
|
371
|
+
ref: typeof Schema.String;
|
|
372
|
+
mpn: typeof Schema.String;
|
|
373
|
+
manufacturer: Schema.optional<typeof Schema.String>;
|
|
374
|
+
family: Schema.optional<typeof Schema.String>;
|
|
375
|
+
description: Schema.optional<typeof Schema.String>;
|
|
376
|
+
gender: Schema.optional<Schema.Literal<["plug", "receptacle", "hermaphroditic"]>>;
|
|
377
|
+
pinCount: typeof Schema.Number;
|
|
378
|
+
wireGaugeRange: Schema.optional<Schema.Struct<{
|
|
379
|
+
min: typeof Schema.String;
|
|
380
|
+
max: typeof Schema.String;
|
|
381
|
+
}>>;
|
|
382
|
+
pins: Schema.Array$<Schema.Struct<{
|
|
383
|
+
pin: typeof Schema.String;
|
|
384
|
+
signal: Schema.optional<typeof Schema.String>;
|
|
385
|
+
}>>;
|
|
386
|
+
}>;
|
|
387
|
+
type HirConnector = Schema.Schema.Type<typeof HirConnector>;
|
|
388
|
+
declare const HirWire: Schema.Struct<{
|
|
389
|
+
id: typeof Schema.String;
|
|
390
|
+
from: Schema.Union<[Schema.Struct<{
|
|
391
|
+
connector: typeof Schema.String;
|
|
392
|
+
pin: typeof Schema.String;
|
|
393
|
+
}>, Schema.Struct<{
|
|
394
|
+
splice: typeof Schema.String;
|
|
395
|
+
}>]>;
|
|
396
|
+
to: Schema.Union<[Schema.Struct<{
|
|
397
|
+
connector: typeof Schema.String;
|
|
398
|
+
pin: typeof Schema.String;
|
|
399
|
+
}>, Schema.Struct<{
|
|
400
|
+
splice: typeof Schema.String;
|
|
401
|
+
}>]>;
|
|
402
|
+
gauge: Schema.optional<typeof Schema.String>;
|
|
403
|
+
color: Schema.optional<typeof Schema.String>;
|
|
404
|
+
stripe: Schema.optional<typeof Schema.String>;
|
|
405
|
+
length: Schema.optional<typeof Schema.Number>;
|
|
406
|
+
lengthTolerance: Schema.optional<typeof Schema.Number>;
|
|
407
|
+
signal: Schema.optional<typeof Schema.String>;
|
|
408
|
+
insulation: Schema.optional<typeof Schema.String>;
|
|
409
|
+
voltageRating: Schema.optional<typeof Schema.Number>;
|
|
410
|
+
temperatureRating: Schema.optional<typeof Schema.Number>;
|
|
411
|
+
currentEstimate: Schema.optional<typeof Schema.Number>;
|
|
412
|
+
twistGroup: Schema.optional<typeof Schema.String>;
|
|
413
|
+
shieldGroup: Schema.optional<typeof Schema.String>;
|
|
414
|
+
cable: Schema.optional<typeof Schema.String>;
|
|
415
|
+
conductor: Schema.optional<typeof Schema.String>;
|
|
416
|
+
branch: Schema.optional<typeof Schema.String>;
|
|
417
|
+
notes: Schema.optional<typeof Schema.String>;
|
|
418
|
+
}>;
|
|
419
|
+
type HirWire = Schema.Schema.Type<typeof HirWire>;
|
|
420
|
+
declare const HirBranch: Schema.Struct<{
|
|
421
|
+
id: typeof Schema.String;
|
|
422
|
+
path: Schema.Array$<typeof Schema.String>;
|
|
423
|
+
parent: Schema.optional<typeof Schema.String>;
|
|
424
|
+
sleeve: Schema.optional<typeof Schema.String>;
|
|
425
|
+
nominalLength: Schema.optional<typeof Schema.Number>;
|
|
426
|
+
breakoutDistance: Schema.optional<typeof Schema.Number>;
|
|
427
|
+
}>;
|
|
428
|
+
type HirBranch = Schema.Schema.Type<typeof HirBranch>;
|
|
429
|
+
declare const HirLabel: Schema.Struct<{
|
|
430
|
+
id: typeof Schema.String;
|
|
431
|
+
text: typeof Schema.String;
|
|
432
|
+
attachTo: typeof Schema.String;
|
|
433
|
+
offsetFrom: Schema.optional<typeof Schema.String>;
|
|
434
|
+
distance: Schema.optional<typeof Schema.Number>;
|
|
435
|
+
material: Schema.optional<typeof Schema.String>;
|
|
436
|
+
quantity: Schema.optional<typeof Schema.Number>;
|
|
437
|
+
}>;
|
|
438
|
+
type HirLabel = Schema.Schema.Type<typeof HirLabel>;
|
|
439
|
+
declare const HirBomItem: Schema.Struct<{
|
|
440
|
+
internalPartId: Schema.optional<typeof Schema.String>;
|
|
441
|
+
mpn: typeof Schema.String;
|
|
442
|
+
manufacturer: Schema.optional<typeof Schema.String>;
|
|
443
|
+
description: Schema.optional<typeof Schema.String>;
|
|
444
|
+
category: Schema.optional<typeof Schema.String>;
|
|
445
|
+
quantity: typeof Schema.Number;
|
|
446
|
+
unitOfMeasure: typeof Schema.String;
|
|
447
|
+
usedBy: Schema.Array$<typeof Schema.String>;
|
|
448
|
+
notes: Schema.optional<typeof Schema.String>;
|
|
449
|
+
}>;
|
|
450
|
+
type HirBomItem = Schema.Schema.Type<typeof HirBomItem>;
|
|
451
|
+
declare const HirPinRef: Schema.Struct<{
|
|
452
|
+
connector: typeof Schema.String;
|
|
453
|
+
pin: typeof Schema.String;
|
|
454
|
+
}>;
|
|
455
|
+
type HirPinRef = Schema.Schema.Type<typeof HirPinRef>;
|
|
456
|
+
declare const HirSpliceRef: Schema.Struct<{
|
|
457
|
+
splice: typeof Schema.String;
|
|
458
|
+
}>;
|
|
459
|
+
type HirSpliceRef = Schema.Schema.Type<typeof HirSpliceRef>;
|
|
460
|
+
/** A wire endpoint: a connector pin or a splice node. */
|
|
461
|
+
declare const HirEndpoint: Schema.Union<[Schema.Struct<{
|
|
462
|
+
connector: typeof Schema.String;
|
|
463
|
+
pin: typeof Schema.String;
|
|
464
|
+
}>, Schema.Struct<{
|
|
465
|
+
splice: typeof Schema.String;
|
|
466
|
+
}>]>;
|
|
467
|
+
type HirEndpoint = Schema.Schema.Type<typeof HirEndpoint>;
|
|
468
|
+
declare const HirSplice: Schema.Struct<{
|
|
469
|
+
id: typeof Schema.String;
|
|
470
|
+
type: Schema.optional<typeof Schema.String>;
|
|
471
|
+
part: Schema.optional<typeof Schema.String>;
|
|
472
|
+
branch: Schema.optional<typeof Schema.String>;
|
|
473
|
+
location: Schema.optional<typeof Schema.Number>;
|
|
474
|
+
notes: Schema.optional<typeof Schema.String>;
|
|
475
|
+
/** Wire IDs attached to this splice (computed by the compiler). */
|
|
476
|
+
wires: Schema.Array$<typeof Schema.String>;
|
|
477
|
+
}>;
|
|
478
|
+
type HirSplice = Schema.Schema.Type<typeof HirSplice>;
|
|
479
|
+
declare const HirCable: Schema.Struct<{
|
|
480
|
+
id: typeof Schema.String;
|
|
481
|
+
type: Schema.optional<typeof Schema.String>;
|
|
482
|
+
conductors: Schema.optional<typeof Schema.Number>;
|
|
483
|
+
shield: Schema.optional<typeof Schema.String>;
|
|
484
|
+
jacket: Schema.optional<typeof Schema.String>;
|
|
485
|
+
outerDiameter: Schema.optional<typeof Schema.Number>;
|
|
486
|
+
/** Longest member wire — the cable cut length (computed). */
|
|
487
|
+
cutLength: Schema.optional<typeof Schema.Number>;
|
|
488
|
+
notes: Schema.optional<typeof Schema.String>;
|
|
489
|
+
/** Member wire IDs (computed by the compiler). */
|
|
490
|
+
wires: Schema.Array$<typeof Schema.String>;
|
|
491
|
+
}>;
|
|
492
|
+
type HirCable = Schema.Schema.Type<typeof HirCable>;
|
|
493
|
+
/** Narrow an endpoint to a pin ref. */
|
|
494
|
+
declare const isPinEndpoint: (e: HirEndpoint) => e is HirPinRef;
|
|
495
|
+
/** Stable display form: `J1.1` or `S1`. */
|
|
496
|
+
declare const endpointLabel: (e: HirEndpoint) => string;
|
|
497
|
+
/** Decode an untrusted value (e.g. a cached `harness.json`) into HIR. Throws `ParseError`. */
|
|
498
|
+
declare const decodeHir: (u: unknown, overrideOptions?: effect_SchemaAST.ParseOptions) => {
|
|
499
|
+
readonly harness: {
|
|
500
|
+
readonly id: string;
|
|
501
|
+
readonly revision: string;
|
|
502
|
+
readonly units: "mm" | "in";
|
|
503
|
+
readonly metadata: {
|
|
504
|
+
readonly [x: string]: string;
|
|
505
|
+
};
|
|
506
|
+
};
|
|
507
|
+
readonly wires: readonly {
|
|
508
|
+
readonly id: string;
|
|
509
|
+
readonly from: {
|
|
510
|
+
readonly connector: string;
|
|
511
|
+
readonly pin: string;
|
|
512
|
+
} | {
|
|
513
|
+
readonly splice: string;
|
|
514
|
+
};
|
|
515
|
+
readonly to: {
|
|
516
|
+
readonly connector: string;
|
|
517
|
+
readonly pin: string;
|
|
518
|
+
} | {
|
|
519
|
+
readonly splice: string;
|
|
520
|
+
};
|
|
521
|
+
readonly cable?: string | undefined;
|
|
522
|
+
readonly branch?: string | undefined;
|
|
523
|
+
readonly signal?: string | undefined;
|
|
524
|
+
readonly length?: number | undefined;
|
|
525
|
+
readonly gauge?: string | undefined;
|
|
526
|
+
readonly color?: string | undefined;
|
|
527
|
+
readonly stripe?: string | undefined;
|
|
528
|
+
readonly lengthTolerance?: number | undefined;
|
|
529
|
+
readonly insulation?: string | undefined;
|
|
530
|
+
readonly voltageRating?: number | undefined;
|
|
531
|
+
readonly temperatureRating?: number | undefined;
|
|
532
|
+
readonly currentEstimate?: number | undefined;
|
|
533
|
+
readonly twistGroup?: string | undefined;
|
|
534
|
+
readonly shieldGroup?: string | undefined;
|
|
535
|
+
readonly conductor?: string | undefined;
|
|
536
|
+
readonly notes?: string | undefined;
|
|
537
|
+
}[];
|
|
538
|
+
readonly schemaVersion: "0.1.0";
|
|
539
|
+
readonly connectors: readonly {
|
|
540
|
+
readonly ref: string;
|
|
541
|
+
readonly mpn: string;
|
|
542
|
+
readonly manufacturer?: string | undefined;
|
|
543
|
+
readonly family?: string | undefined;
|
|
544
|
+
readonly description?: string | undefined;
|
|
545
|
+
readonly gender?: "plug" | "receptacle" | "hermaphroditic" | undefined;
|
|
546
|
+
readonly pinCount: number;
|
|
547
|
+
readonly wireGaugeRange?: {
|
|
548
|
+
readonly min: string;
|
|
549
|
+
readonly max: string;
|
|
550
|
+
} | undefined;
|
|
551
|
+
readonly pins: readonly {
|
|
552
|
+
readonly pin: string;
|
|
553
|
+
readonly signal?: string | undefined;
|
|
554
|
+
}[];
|
|
555
|
+
}[];
|
|
556
|
+
readonly cables: readonly {
|
|
557
|
+
readonly id: string;
|
|
558
|
+
readonly notes?: string | undefined;
|
|
559
|
+
readonly type?: string | undefined;
|
|
560
|
+
readonly wires: readonly string[];
|
|
561
|
+
readonly conductors?: number | undefined;
|
|
562
|
+
readonly shield?: string | undefined;
|
|
563
|
+
readonly jacket?: string | undefined;
|
|
564
|
+
readonly outerDiameter?: number | undefined;
|
|
565
|
+
readonly cutLength?: number | undefined;
|
|
566
|
+
}[];
|
|
567
|
+
readonly branches: readonly {
|
|
568
|
+
readonly id: string;
|
|
569
|
+
readonly path: readonly string[];
|
|
570
|
+
readonly parent?: string | undefined;
|
|
571
|
+
readonly sleeve?: string | undefined;
|
|
572
|
+
readonly nominalLength?: number | undefined;
|
|
573
|
+
readonly breakoutDistance?: number | undefined;
|
|
574
|
+
}[];
|
|
575
|
+
readonly splices: readonly {
|
|
576
|
+
readonly id: string;
|
|
577
|
+
readonly branch?: string | undefined;
|
|
578
|
+
readonly notes?: string | undefined;
|
|
579
|
+
readonly type?: string | undefined;
|
|
580
|
+
readonly part?: string | undefined;
|
|
581
|
+
readonly location?: number | undefined;
|
|
582
|
+
readonly wires: readonly string[];
|
|
583
|
+
}[];
|
|
584
|
+
readonly labels: readonly {
|
|
585
|
+
readonly id: string;
|
|
586
|
+
readonly attachTo: string;
|
|
587
|
+
readonly offsetFrom?: string | undefined;
|
|
588
|
+
readonly text: string;
|
|
589
|
+
readonly distance?: number | undefined;
|
|
590
|
+
readonly material?: string | undefined;
|
|
591
|
+
readonly quantity?: number | undefined;
|
|
592
|
+
}[];
|
|
593
|
+
readonly bom: readonly {
|
|
594
|
+
readonly quantity: number;
|
|
595
|
+
readonly mpn: string;
|
|
596
|
+
readonly manufacturer?: string | undefined;
|
|
597
|
+
readonly description?: string | undefined;
|
|
598
|
+
readonly notes?: string | undefined;
|
|
599
|
+
readonly internalPartId?: string | undefined;
|
|
600
|
+
readonly category?: string | undefined;
|
|
601
|
+
readonly unitOfMeasure: string;
|
|
602
|
+
readonly usedBy: readonly string[];
|
|
603
|
+
}[];
|
|
604
|
+
readonly diagnostics: readonly {
|
|
605
|
+
readonly code: string;
|
|
606
|
+
readonly severity: "error" | "warning" | "info";
|
|
607
|
+
readonly message: string;
|
|
608
|
+
readonly target?: string | undefined;
|
|
609
|
+
}[];
|
|
610
|
+
readonly layoutHints: readonly unknown[];
|
|
611
|
+
readonly exports: {
|
|
612
|
+
readonly [x: string]: unknown;
|
|
613
|
+
};
|
|
614
|
+
};
|
|
615
|
+
/** Decode as an Effect, for use inside services. */
|
|
616
|
+
declare const decodeHirEffect: (u: unknown, overrideOptions?: effect_SchemaAST.ParseOptions) => effect_Effect.Effect<{
|
|
617
|
+
readonly harness: {
|
|
618
|
+
readonly id: string;
|
|
619
|
+
readonly revision: string;
|
|
620
|
+
readonly units: "mm" | "in";
|
|
621
|
+
readonly metadata: {
|
|
622
|
+
readonly [x: string]: string;
|
|
623
|
+
};
|
|
624
|
+
};
|
|
625
|
+
readonly wires: readonly {
|
|
626
|
+
readonly id: string;
|
|
627
|
+
readonly from: {
|
|
628
|
+
readonly connector: string;
|
|
629
|
+
readonly pin: string;
|
|
630
|
+
} | {
|
|
631
|
+
readonly splice: string;
|
|
632
|
+
};
|
|
633
|
+
readonly to: {
|
|
634
|
+
readonly connector: string;
|
|
635
|
+
readonly pin: string;
|
|
636
|
+
} | {
|
|
637
|
+
readonly splice: string;
|
|
638
|
+
};
|
|
639
|
+
readonly cable?: string | undefined;
|
|
640
|
+
readonly branch?: string | undefined;
|
|
641
|
+
readonly signal?: string | undefined;
|
|
642
|
+
readonly length?: number | undefined;
|
|
643
|
+
readonly gauge?: string | undefined;
|
|
644
|
+
readonly color?: string | undefined;
|
|
645
|
+
readonly stripe?: string | undefined;
|
|
646
|
+
readonly lengthTolerance?: number | undefined;
|
|
647
|
+
readonly insulation?: string | undefined;
|
|
648
|
+
readonly voltageRating?: number | undefined;
|
|
649
|
+
readonly temperatureRating?: number | undefined;
|
|
650
|
+
readonly currentEstimate?: number | undefined;
|
|
651
|
+
readonly twistGroup?: string | undefined;
|
|
652
|
+
readonly shieldGroup?: string | undefined;
|
|
653
|
+
readonly conductor?: string | undefined;
|
|
654
|
+
readonly notes?: string | undefined;
|
|
655
|
+
}[];
|
|
656
|
+
readonly schemaVersion: "0.1.0";
|
|
657
|
+
readonly connectors: readonly {
|
|
658
|
+
readonly ref: string;
|
|
659
|
+
readonly mpn: string;
|
|
660
|
+
readonly manufacturer?: string | undefined;
|
|
661
|
+
readonly family?: string | undefined;
|
|
662
|
+
readonly description?: string | undefined;
|
|
663
|
+
readonly gender?: "plug" | "receptacle" | "hermaphroditic" | undefined;
|
|
664
|
+
readonly pinCount: number;
|
|
665
|
+
readonly wireGaugeRange?: {
|
|
666
|
+
readonly min: string;
|
|
667
|
+
readonly max: string;
|
|
668
|
+
} | undefined;
|
|
669
|
+
readonly pins: readonly {
|
|
670
|
+
readonly pin: string;
|
|
671
|
+
readonly signal?: string | undefined;
|
|
672
|
+
}[];
|
|
673
|
+
}[];
|
|
674
|
+
readonly cables: readonly {
|
|
675
|
+
readonly id: string;
|
|
676
|
+
readonly notes?: string | undefined;
|
|
677
|
+
readonly type?: string | undefined;
|
|
678
|
+
readonly wires: readonly string[];
|
|
679
|
+
readonly conductors?: number | undefined;
|
|
680
|
+
readonly shield?: string | undefined;
|
|
681
|
+
readonly jacket?: string | undefined;
|
|
682
|
+
readonly outerDiameter?: number | undefined;
|
|
683
|
+
readonly cutLength?: number | undefined;
|
|
684
|
+
}[];
|
|
685
|
+
readonly branches: readonly {
|
|
686
|
+
readonly id: string;
|
|
687
|
+
readonly path: readonly string[];
|
|
688
|
+
readonly parent?: string | undefined;
|
|
689
|
+
readonly sleeve?: string | undefined;
|
|
690
|
+
readonly nominalLength?: number | undefined;
|
|
691
|
+
readonly breakoutDistance?: number | undefined;
|
|
692
|
+
}[];
|
|
693
|
+
readonly splices: readonly {
|
|
694
|
+
readonly id: string;
|
|
695
|
+
readonly branch?: string | undefined;
|
|
696
|
+
readonly notes?: string | undefined;
|
|
697
|
+
readonly type?: string | undefined;
|
|
698
|
+
readonly part?: string | undefined;
|
|
699
|
+
readonly location?: number | undefined;
|
|
700
|
+
readonly wires: readonly string[];
|
|
701
|
+
}[];
|
|
702
|
+
readonly labels: readonly {
|
|
703
|
+
readonly id: string;
|
|
704
|
+
readonly attachTo: string;
|
|
705
|
+
readonly offsetFrom?: string | undefined;
|
|
706
|
+
readonly text: string;
|
|
707
|
+
readonly distance?: number | undefined;
|
|
708
|
+
readonly material?: string | undefined;
|
|
709
|
+
readonly quantity?: number | undefined;
|
|
710
|
+
}[];
|
|
711
|
+
readonly bom: readonly {
|
|
712
|
+
readonly quantity: number;
|
|
713
|
+
readonly mpn: string;
|
|
714
|
+
readonly manufacturer?: string | undefined;
|
|
715
|
+
readonly description?: string | undefined;
|
|
716
|
+
readonly notes?: string | undefined;
|
|
717
|
+
readonly internalPartId?: string | undefined;
|
|
718
|
+
readonly category?: string | undefined;
|
|
719
|
+
readonly unitOfMeasure: string;
|
|
720
|
+
readonly usedBy: readonly string[];
|
|
721
|
+
}[];
|
|
722
|
+
readonly diagnostics: readonly {
|
|
723
|
+
readonly code: string;
|
|
724
|
+
readonly severity: "error" | "warning" | "info";
|
|
725
|
+
readonly message: string;
|
|
726
|
+
readonly target?: string | undefined;
|
|
727
|
+
}[];
|
|
728
|
+
readonly layoutHints: readonly unknown[];
|
|
729
|
+
readonly exports: {
|
|
730
|
+
readonly [x: string]: unknown;
|
|
731
|
+
};
|
|
732
|
+
}, effect_ParseResult.ParseError, never>;
|
|
733
|
+
/** Encode HIR back to its JSON-ready form. */
|
|
734
|
+
declare const encodeHir: (a: {
|
|
735
|
+
readonly harness: {
|
|
736
|
+
readonly id: string;
|
|
737
|
+
readonly revision: string;
|
|
738
|
+
readonly units: "mm" | "in";
|
|
739
|
+
readonly metadata: {
|
|
740
|
+
readonly [x: string]: string;
|
|
741
|
+
};
|
|
742
|
+
};
|
|
743
|
+
readonly wires: readonly {
|
|
744
|
+
readonly id: string;
|
|
745
|
+
readonly from: {
|
|
746
|
+
readonly connector: string;
|
|
747
|
+
readonly pin: string;
|
|
748
|
+
} | {
|
|
749
|
+
readonly splice: string;
|
|
750
|
+
};
|
|
751
|
+
readonly to: {
|
|
752
|
+
readonly connector: string;
|
|
753
|
+
readonly pin: string;
|
|
754
|
+
} | {
|
|
755
|
+
readonly splice: string;
|
|
756
|
+
};
|
|
757
|
+
readonly cable?: string | undefined;
|
|
758
|
+
readonly branch?: string | undefined;
|
|
759
|
+
readonly signal?: string | undefined;
|
|
760
|
+
readonly length?: number | undefined;
|
|
761
|
+
readonly gauge?: string | undefined;
|
|
762
|
+
readonly color?: string | undefined;
|
|
763
|
+
readonly stripe?: string | undefined;
|
|
764
|
+
readonly lengthTolerance?: number | undefined;
|
|
765
|
+
readonly insulation?: string | undefined;
|
|
766
|
+
readonly voltageRating?: number | undefined;
|
|
767
|
+
readonly temperatureRating?: number | undefined;
|
|
768
|
+
readonly currentEstimate?: number | undefined;
|
|
769
|
+
readonly twistGroup?: string | undefined;
|
|
770
|
+
readonly shieldGroup?: string | undefined;
|
|
771
|
+
readonly conductor?: string | undefined;
|
|
772
|
+
readonly notes?: string | undefined;
|
|
773
|
+
}[];
|
|
774
|
+
readonly schemaVersion: "0.1.0";
|
|
775
|
+
readonly connectors: readonly {
|
|
776
|
+
readonly ref: string;
|
|
777
|
+
readonly mpn: string;
|
|
778
|
+
readonly manufacturer?: string | undefined;
|
|
779
|
+
readonly family?: string | undefined;
|
|
780
|
+
readonly description?: string | undefined;
|
|
781
|
+
readonly gender?: "plug" | "receptacle" | "hermaphroditic" | undefined;
|
|
782
|
+
readonly pinCount: number;
|
|
783
|
+
readonly wireGaugeRange?: {
|
|
784
|
+
readonly min: string;
|
|
785
|
+
readonly max: string;
|
|
786
|
+
} | undefined;
|
|
787
|
+
readonly pins: readonly {
|
|
788
|
+
readonly pin: string;
|
|
789
|
+
readonly signal?: string | undefined;
|
|
790
|
+
}[];
|
|
791
|
+
}[];
|
|
792
|
+
readonly cables: readonly {
|
|
793
|
+
readonly id: string;
|
|
794
|
+
readonly notes?: string | undefined;
|
|
795
|
+
readonly type?: string | undefined;
|
|
796
|
+
readonly wires: readonly string[];
|
|
797
|
+
readonly conductors?: number | undefined;
|
|
798
|
+
readonly shield?: string | undefined;
|
|
799
|
+
readonly jacket?: string | undefined;
|
|
800
|
+
readonly outerDiameter?: number | undefined;
|
|
801
|
+
readonly cutLength?: number | undefined;
|
|
802
|
+
}[];
|
|
803
|
+
readonly branches: readonly {
|
|
804
|
+
readonly id: string;
|
|
805
|
+
readonly path: readonly string[];
|
|
806
|
+
readonly parent?: string | undefined;
|
|
807
|
+
readonly sleeve?: string | undefined;
|
|
808
|
+
readonly nominalLength?: number | undefined;
|
|
809
|
+
readonly breakoutDistance?: number | undefined;
|
|
810
|
+
}[];
|
|
811
|
+
readonly splices: readonly {
|
|
812
|
+
readonly id: string;
|
|
813
|
+
readonly branch?: string | undefined;
|
|
814
|
+
readonly notes?: string | undefined;
|
|
815
|
+
readonly type?: string | undefined;
|
|
816
|
+
readonly part?: string | undefined;
|
|
817
|
+
readonly location?: number | undefined;
|
|
818
|
+
readonly wires: readonly string[];
|
|
819
|
+
}[];
|
|
820
|
+
readonly labels: readonly {
|
|
821
|
+
readonly id: string;
|
|
822
|
+
readonly attachTo: string;
|
|
823
|
+
readonly offsetFrom?: string | undefined;
|
|
824
|
+
readonly text: string;
|
|
825
|
+
readonly distance?: number | undefined;
|
|
826
|
+
readonly material?: string | undefined;
|
|
827
|
+
readonly quantity?: number | undefined;
|
|
828
|
+
}[];
|
|
829
|
+
readonly bom: readonly {
|
|
830
|
+
readonly quantity: number;
|
|
831
|
+
readonly mpn: string;
|
|
832
|
+
readonly manufacturer?: string | undefined;
|
|
833
|
+
readonly description?: string | undefined;
|
|
834
|
+
readonly notes?: string | undefined;
|
|
835
|
+
readonly internalPartId?: string | undefined;
|
|
836
|
+
readonly category?: string | undefined;
|
|
837
|
+
readonly unitOfMeasure: string;
|
|
838
|
+
readonly usedBy: readonly string[];
|
|
839
|
+
}[];
|
|
840
|
+
readonly diagnostics: readonly {
|
|
841
|
+
readonly code: string;
|
|
842
|
+
readonly severity: "error" | "warning" | "info";
|
|
843
|
+
readonly message: string;
|
|
844
|
+
readonly target?: string | undefined;
|
|
845
|
+
}[];
|
|
846
|
+
readonly layoutHints: readonly unknown[];
|
|
847
|
+
readonly exports: {
|
|
848
|
+
readonly [x: string]: unknown;
|
|
849
|
+
};
|
|
850
|
+
}, overrideOptions?: effect_SchemaAST.ParseOptions) => {
|
|
851
|
+
readonly harness: {
|
|
852
|
+
readonly id: string;
|
|
853
|
+
readonly revision: string;
|
|
854
|
+
readonly units: "mm" | "in";
|
|
855
|
+
readonly metadata: {
|
|
856
|
+
readonly [x: string]: string;
|
|
857
|
+
};
|
|
858
|
+
};
|
|
859
|
+
readonly wires: readonly {
|
|
860
|
+
readonly id: string;
|
|
861
|
+
readonly from: {
|
|
862
|
+
readonly connector: string;
|
|
863
|
+
readonly pin: string;
|
|
864
|
+
} | {
|
|
865
|
+
readonly splice: string;
|
|
866
|
+
};
|
|
867
|
+
readonly to: {
|
|
868
|
+
readonly connector: string;
|
|
869
|
+
readonly pin: string;
|
|
870
|
+
} | {
|
|
871
|
+
readonly splice: string;
|
|
872
|
+
};
|
|
873
|
+
readonly cable?: string | undefined;
|
|
874
|
+
readonly branch?: string | undefined;
|
|
875
|
+
readonly signal?: string | undefined;
|
|
876
|
+
readonly length?: number | undefined;
|
|
877
|
+
readonly gauge?: string | undefined;
|
|
878
|
+
readonly color?: string | undefined;
|
|
879
|
+
readonly stripe?: string | undefined;
|
|
880
|
+
readonly lengthTolerance?: number | undefined;
|
|
881
|
+
readonly insulation?: string | undefined;
|
|
882
|
+
readonly voltageRating?: number | undefined;
|
|
883
|
+
readonly temperatureRating?: number | undefined;
|
|
884
|
+
readonly currentEstimate?: number | undefined;
|
|
885
|
+
readonly twistGroup?: string | undefined;
|
|
886
|
+
readonly shieldGroup?: string | undefined;
|
|
887
|
+
readonly conductor?: string | undefined;
|
|
888
|
+
readonly notes?: string | undefined;
|
|
889
|
+
}[];
|
|
890
|
+
readonly schemaVersion: "0.1.0";
|
|
891
|
+
readonly connectors: readonly {
|
|
892
|
+
readonly ref: string;
|
|
893
|
+
readonly mpn: string;
|
|
894
|
+
readonly pinCount: number;
|
|
895
|
+
readonly pins: readonly {
|
|
896
|
+
readonly pin: string;
|
|
897
|
+
readonly signal?: string | undefined;
|
|
898
|
+
}[];
|
|
899
|
+
readonly manufacturer?: string | undefined;
|
|
900
|
+
readonly family?: string | undefined;
|
|
901
|
+
readonly description?: string | undefined;
|
|
902
|
+
readonly gender?: "plug" | "receptacle" | "hermaphroditic" | undefined;
|
|
903
|
+
readonly wireGaugeRange?: {
|
|
904
|
+
readonly min: string;
|
|
905
|
+
readonly max: string;
|
|
906
|
+
} | undefined;
|
|
907
|
+
}[];
|
|
908
|
+
readonly cables: readonly {
|
|
909
|
+
readonly id: string;
|
|
910
|
+
readonly wires: readonly string[];
|
|
911
|
+
readonly notes?: string | undefined;
|
|
912
|
+
readonly type?: string | undefined;
|
|
913
|
+
readonly conductors?: number | undefined;
|
|
914
|
+
readonly shield?: string | undefined;
|
|
915
|
+
readonly jacket?: string | undefined;
|
|
916
|
+
readonly outerDiameter?: number | undefined;
|
|
917
|
+
readonly cutLength?: number | undefined;
|
|
918
|
+
}[];
|
|
919
|
+
readonly branches: readonly {
|
|
920
|
+
readonly id: string;
|
|
921
|
+
readonly path: readonly string[];
|
|
922
|
+
readonly parent?: string | undefined;
|
|
923
|
+
readonly sleeve?: string | undefined;
|
|
924
|
+
readonly nominalLength?: number | undefined;
|
|
925
|
+
readonly breakoutDistance?: number | undefined;
|
|
926
|
+
}[];
|
|
927
|
+
readonly splices: readonly {
|
|
928
|
+
readonly id: string;
|
|
929
|
+
readonly wires: readonly string[];
|
|
930
|
+
readonly branch?: string | undefined;
|
|
931
|
+
readonly notes?: string | undefined;
|
|
932
|
+
readonly type?: string | undefined;
|
|
933
|
+
readonly part?: string | undefined;
|
|
934
|
+
readonly location?: number | undefined;
|
|
935
|
+
}[];
|
|
936
|
+
readonly labels: readonly {
|
|
937
|
+
readonly id: string;
|
|
938
|
+
readonly attachTo: string;
|
|
939
|
+
readonly text: string;
|
|
940
|
+
readonly offsetFrom?: string | undefined;
|
|
941
|
+
readonly distance?: number | undefined;
|
|
942
|
+
readonly material?: string | undefined;
|
|
943
|
+
readonly quantity?: number | undefined;
|
|
944
|
+
}[];
|
|
945
|
+
readonly bom: readonly {
|
|
946
|
+
readonly quantity: number;
|
|
947
|
+
readonly mpn: string;
|
|
948
|
+
readonly unitOfMeasure: string;
|
|
949
|
+
readonly usedBy: readonly string[];
|
|
950
|
+
readonly manufacturer?: string | undefined;
|
|
951
|
+
readonly description?: string | undefined;
|
|
952
|
+
readonly notes?: string | undefined;
|
|
953
|
+
readonly internalPartId?: string | undefined;
|
|
954
|
+
readonly category?: string | undefined;
|
|
955
|
+
}[];
|
|
956
|
+
readonly diagnostics: readonly {
|
|
957
|
+
readonly code: string;
|
|
958
|
+
readonly severity: "error" | "warning" | "info";
|
|
959
|
+
readonly message: string;
|
|
960
|
+
readonly target?: string | undefined;
|
|
961
|
+
}[];
|
|
962
|
+
readonly layoutHints: readonly unknown[];
|
|
963
|
+
readonly exports: {
|
|
964
|
+
readonly [x: string]: unknown;
|
|
965
|
+
};
|
|
966
|
+
};
|
|
967
|
+
/** Stable object references (PRD §19), e.g. `connector:J1.pin:1`. */
|
|
968
|
+
declare const refs: {
|
|
969
|
+
readonly connector: (ref: string) => string;
|
|
970
|
+
readonly pin: (connector: string, pin: string) => string;
|
|
971
|
+
readonly wire: (id: string) => string;
|
|
972
|
+
readonly branch: (id: string) => string;
|
|
973
|
+
readonly splice: (id: string) => string;
|
|
974
|
+
readonly label: (id: string) => string;
|
|
975
|
+
readonly bom: (mpn: string) => string;
|
|
976
|
+
};
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* Design → HIR normalization (PRD §9.3).
|
|
980
|
+
*
|
|
981
|
+
* `compileDesign` is a pure, deterministic function: given the same
|
|
982
|
+
* `HarnessDesign`, it produces a byte-identical HIR regardless of the order
|
|
983
|
+
* in which connectors, wires, branches, or labels were authored. All
|
|
984
|
+
* collections are canonically sorted and optional fields are omitted (never
|
|
985
|
+
* `undefined`) so serialized output is stable and diffable.
|
|
986
|
+
*
|
|
987
|
+
* Structural integrity checks run here because a broken object graph makes
|
|
988
|
+
* downstream rules meaningless. Domain rules (gauge vs current, twisted
|
|
989
|
+
* pairs, seals, ...) belong to `@grayhaven/nerve-rules`.
|
|
990
|
+
*/
|
|
991
|
+
|
|
992
|
+
interface CompileResult {
|
|
993
|
+
readonly hir: Hir;
|
|
994
|
+
readonly diagnostics: ReadonlyArray<Diagnostic>;
|
|
995
|
+
}
|
|
996
|
+
declare const compileDesign: (design: HarnessDesign) => CompileResult;
|
|
997
|
+
|
|
998
|
+
/**
|
|
999
|
+
* Validation rule primitives (PRD §9.4).
|
|
1000
|
+
*
|
|
1001
|
+
* Rules are plain TypeScript functions that run against HIR — never against
|
|
1002
|
+
* user source. Built-in rules live in `@grayhaven/nerve-rules`; users define
|
|
1003
|
+
* custom rules with `rule()` and package them like any other TypeScript.
|
|
1004
|
+
*/
|
|
1005
|
+
|
|
1006
|
+
interface RuleReport {
|
|
1007
|
+
readonly severity: DiagnosticSeverity;
|
|
1008
|
+
readonly message: string;
|
|
1009
|
+
readonly target?: string;
|
|
1010
|
+
/** Override the rule's stable code for this report. Rarely needed. */
|
|
1011
|
+
readonly code?: string;
|
|
1012
|
+
}
|
|
1013
|
+
interface RuleContext {
|
|
1014
|
+
readonly hir: Hir;
|
|
1015
|
+
report(report: RuleReport): void;
|
|
1016
|
+
}
|
|
1017
|
+
interface Rule {
|
|
1018
|
+
readonly name: string;
|
|
1019
|
+
/** Stable diagnostic code attached to this rule's reports. */
|
|
1020
|
+
readonly code: string;
|
|
1021
|
+
run(ctx: RuleContext): void;
|
|
1022
|
+
}
|
|
1023
|
+
interface RuleOptions {
|
|
1024
|
+
readonly code?: string;
|
|
1025
|
+
}
|
|
1026
|
+
/** Define a validation rule: `rule("require-can-pairs-twisted", (ctx) => {...})`. */
|
|
1027
|
+
declare const rule: (name: string, run: (ctx: RuleContext) => void, options?: RuleOptions) => Rule;
|
|
1028
|
+
/**
|
|
1029
|
+
* Per-rule severity configuration (PRD §10.5 config example):
|
|
1030
|
+
* `{ missingWireColor: "error", missingLabel: "warning", noisyRule: "off" }`.
|
|
1031
|
+
*/
|
|
1032
|
+
type RuleConfig = Readonly<Record<string, DiagnosticSeverity | "off">>;
|
|
1033
|
+
/**
|
|
1034
|
+
* Run rules against HIR, producing canonically ordered diagnostics.
|
|
1035
|
+
* Deterministic: output depends only on (hir, rules, config).
|
|
1036
|
+
*/
|
|
1037
|
+
declare const runRules: (hir: Hir, rules: ReadonlyArray<Rule>, config?: RuleConfig) => ReadonlyArray<Diagnostic>;
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* Project configuration (PRD §10.5).
|
|
1041
|
+
*
|
|
1042
|
+
* Lives in `nerve.config.ts` at the project root:
|
|
1043
|
+
*
|
|
1044
|
+
* ```ts
|
|
1045
|
+
* import { defineConfig } from "@grayhaven/nerve"
|
|
1046
|
+
* export default defineConfig({
|
|
1047
|
+
* units: "mm",
|
|
1048
|
+
* outputDir: "dist",
|
|
1049
|
+
* rules: { missingWireColor: "error", missingWireLength: "warning" },
|
|
1050
|
+
* exports: { csv: true, svg: true }
|
|
1051
|
+
* })
|
|
1052
|
+
* ```
|
|
1053
|
+
*/
|
|
1054
|
+
|
|
1055
|
+
interface NerveConfig {
|
|
1056
|
+
readonly units?: Units;
|
|
1057
|
+
readonly defaultWireTolerance?: number;
|
|
1058
|
+
readonly outputDir?: string;
|
|
1059
|
+
readonly rules?: RuleConfig;
|
|
1060
|
+
readonly exports?: {
|
|
1061
|
+
readonly csv?: boolean;
|
|
1062
|
+
readonly svg?: boolean;
|
|
1063
|
+
readonly pdf?: boolean;
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
declare const defineConfig: (config: NerveConfig) => NerveConfig;
|
|
1067
|
+
|
|
1068
|
+
/**
|
|
1069
|
+
* Harness variants (PRD §8.4).
|
|
1070
|
+
*
|
|
1071
|
+
* A variant derives a new `HarnessDesign` from a base by adding, removing,
|
|
1072
|
+
* and overriding entities. The base is never mutated; shared definitions
|
|
1073
|
+
* stay shared. Lineage is recorded in `metadata.variantOf` so exports and
|
|
1074
|
+
* diffs can trace a variant back to its base. Validation applies to
|
|
1075
|
+
* variants exactly as to any harness — they compile through the same
|
|
1076
|
+
* pipeline.
|
|
1077
|
+
*/
|
|
1078
|
+
|
|
1079
|
+
interface SectionMods<T> {
|
|
1080
|
+
readonly add?: ReadonlyArray<T>;
|
|
1081
|
+
readonly remove?: ReadonlyArray<string>;
|
|
1082
|
+
}
|
|
1083
|
+
interface VariantOptions {
|
|
1084
|
+
readonly id: string;
|
|
1085
|
+
readonly revision?: string;
|
|
1086
|
+
readonly metadata?: Readonly<Record<string, string>>;
|
|
1087
|
+
readonly connectors?: SectionMods<ConnectorInstance>;
|
|
1088
|
+
readonly wires?: SectionMods<WireDef> & {
|
|
1089
|
+
/** Per-wire property overrides, e.g. `{ W1: { length: 800 } }`. */
|
|
1090
|
+
readonly override?: Readonly<Record<string, WireProps>>;
|
|
1091
|
+
};
|
|
1092
|
+
readonly branches?: SectionMods<BranchDef> & {
|
|
1093
|
+
readonly override?: Readonly<Record<string, Partial<Omit<BranchDef, "kind" | "id">>>>;
|
|
1094
|
+
};
|
|
1095
|
+
readonly labels?: SectionMods<LabelDef> & {
|
|
1096
|
+
readonly override?: Readonly<Record<string, Partial<Omit<LabelDef, "kind" | "id">>>>;
|
|
1097
|
+
};
|
|
1098
|
+
readonly splices?: SectionMods<SpliceDef>;
|
|
1099
|
+
readonly cables?: SectionMods<CableDef>;
|
|
1100
|
+
}
|
|
1101
|
+
/** Derive a variant: `variant(base, { id: "...-long", wires: { override: { W1: { length: 800 } } } })`. */
|
|
1102
|
+
declare const variant: (base: HarnessDesign, opts: VariantOptions) => HarnessDesign;
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* Revision diff (PRD §21, DoD #9).
|
|
1106
|
+
*
|
|
1107
|
+
* Pure structural comparison of two HIR documents. Identifies added,
|
|
1108
|
+
* removed, and changed connectors, pinouts, wires, branches, labels, and
|
|
1109
|
+
* BOM rows — the categories §21 requires. Deterministic: output order
|
|
1110
|
+
* follows canonical HIR ordering.
|
|
1111
|
+
*/
|
|
1112
|
+
|
|
1113
|
+
interface FieldChange {
|
|
1114
|
+
readonly field: string;
|
|
1115
|
+
readonly from: string;
|
|
1116
|
+
readonly to: string;
|
|
1117
|
+
}
|
|
1118
|
+
interface EntityChange {
|
|
1119
|
+
readonly id: string;
|
|
1120
|
+
readonly changes: ReadonlyArray<FieldChange>;
|
|
1121
|
+
}
|
|
1122
|
+
interface SectionDiff {
|
|
1123
|
+
readonly added: ReadonlyArray<string>;
|
|
1124
|
+
readonly removed: ReadonlyArray<string>;
|
|
1125
|
+
readonly changed: ReadonlyArray<EntityChange>;
|
|
1126
|
+
}
|
|
1127
|
+
interface PinoutChange {
|
|
1128
|
+
readonly connector: string;
|
|
1129
|
+
readonly pin: string;
|
|
1130
|
+
readonly from: string | undefined;
|
|
1131
|
+
readonly to: string | undefined;
|
|
1132
|
+
}
|
|
1133
|
+
interface HirDiff {
|
|
1134
|
+
readonly harness: ReadonlyArray<FieldChange>;
|
|
1135
|
+
readonly connectors: SectionDiff;
|
|
1136
|
+
readonly pinouts: ReadonlyArray<PinoutChange>;
|
|
1137
|
+
readonly wires: SectionDiff;
|
|
1138
|
+
readonly splices: SectionDiff;
|
|
1139
|
+
readonly cables: SectionDiff;
|
|
1140
|
+
readonly branches: SectionDiff;
|
|
1141
|
+
readonly labels: SectionDiff;
|
|
1142
|
+
readonly bom: SectionDiff;
|
|
1143
|
+
}
|
|
1144
|
+
declare const diffHir: (a: Hir, b: Hir) => HirDiff;
|
|
1145
|
+
declare const isEmptyDiff: (d: HirDiff) => boolean;
|
|
1146
|
+
/** Human-readable diff (git-diff-flavored prefixes). */
|
|
1147
|
+
declare const formatDiff: (d: HirDiff) => string;
|
|
1148
|
+
|
|
1149
|
+
export { type BranchDef, type BranchProps, type CableDef, type CableProps, Codes, type CompileResult, type ConnectorGender, type ConnectorInstance, type ConnectorPart, type Diagnostic, DiagnosticSeverity, type EndpointInput, type EntityChange, type FieldChange, HIR_SCHEMA_VERSION, type HarnessDesign, type HarnessProps, Hir, HirBomItem, HirBranch, HirCable, HirConnector, type HirDiff, HirEndpoint, HirLabel, HirPinRef, HirSplice, HirSpliceRef, HirWire, type LabelDef, type LabelProps, type NerveConfig, type PinAssignments, type PinRef, type PinoutChange, type Rule, type RuleConfig, type RuleContext, type RuleOptions, type RuleReport, type SectionDiff, type SpliceDef, type SpliceProps, type SpliceRef, type Units, type VariantOptions, type WireDef, type WireEndpoint, type WireProps, branch, cable, compileDesign, connector, decodeHir, decodeHirEffect, defineConfig, diffHir, encodeHir, endpointLabel, formatDiff, harness, hasErrors, isEmptyDiff, isPinEndpoint, label, refs, rule, runRules, splice, variant, wire };
|