circuit-json 0.0.268 → 0.0.270

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/dist/index.mjs CHANGED
@@ -80,6 +80,12 @@ var unitMappings = {
80
80
  ms: {
81
81
  baseUnit: "ms",
82
82
  variants: {
83
+ fs: 1e-12,
84
+ ps: 1e-9,
85
+ ns: 1e-6,
86
+ us: 1e-3,
87
+ \u00B5s: 1e-3,
88
+ ms: 1,
83
89
  s: 1e3
84
90
  }
85
91
  },
@@ -148,8 +154,8 @@ var si_prefix_multiplier = {
148
154
  pico: 1e-12,
149
155
  p: 1e-12
150
156
  };
151
- var parseAndConvertSiUnit = (v) => {
152
- if (typeof v === "undefined")
157
+ function parseAndConvertSiUnit(v) {
158
+ if (v === void 0 || v === null)
153
159
  return { parsedUnit: null, unitOfValue: null, value: null };
154
160
  if (typeof v === "string" && v.match(/^-?[\d\.]+$/))
155
161
  return {
@@ -161,12 +167,17 @@ var parseAndConvertSiUnit = (v) => {
161
167
  return { value: v, parsedUnit: null, unitOfValue: null };
162
168
  if (typeof v === "object" && "x" in v && "y" in v) {
163
169
  const { parsedUnit, unitOfValue } = parseAndConvertSiUnit(v.x);
170
+ const xResult = parseAndConvertSiUnit(v.x);
171
+ const yResult = parseAndConvertSiUnit(v.y);
172
+ if (xResult.value === null || yResult.value === null) {
173
+ return { parsedUnit: null, unitOfValue: null, value: null };
174
+ }
164
175
  return {
165
176
  parsedUnit,
166
177
  unitOfValue,
167
178
  value: {
168
- x: parseAndConvertSiUnit(v.x).value,
169
- y: parseAndConvertSiUnit(v.y).value
179
+ x: xResult.value,
180
+ y: yResult.value
170
181
  }
171
182
  };
172
183
  }
@@ -191,7 +202,7 @@ var parseAndConvertSiUnit = (v) => {
191
202
  unitOfValue: baseUnit,
192
203
  value: conversionFactor * Number.parseFloat(numberPart)
193
204
  };
194
- };
205
+ }
195
206
 
196
207
  // src/units/index.ts
197
208
  import { z } from "zod";
@@ -205,7 +216,10 @@ var length = z.string().or(z.number()).transform((v) => parseAndConvertSiUnit(v)
205
216
  var frequency = z.string().or(z.number()).transform((v) => parseAndConvertSiUnit(v).value);
206
217
  var distance = length;
207
218
  var current = z.string().or(z.number()).transform((v) => parseAndConvertSiUnit(v).value);
208
- var time = z.string().or(z.number()).transform((v) => parseAndConvertSiUnit(v).value);
219
+ var duration_ms = z.string().or(z.number()).transform((v) => parseAndConvertSiUnit(v).value);
220
+ var time = duration_ms;
221
+ var ms = duration_ms;
222
+ var timestamp = z.string().datetime();
209
223
  var rotation = z.string().or(z.number()).transform((arg) => {
210
224
  if (typeof arg === "number") return arg;
211
225
  if (arg.endsWith("deg")) {
@@ -520,7 +534,7 @@ var source_project_metadata = z29.object({
520
534
  name: z29.string().optional(),
521
535
  software_used_string: z29.string().optional(),
522
536
  project_url: z29.string().optional(),
523
- created_at: z29.string().datetime().optional()
537
+ created_at: timestamp.optional()
524
538
  });
525
539
  expectTypesMatch(true);
526
540
 
@@ -2242,36 +2256,54 @@ var pcb_component_outside_board_error = z105.object({
2242
2256
  );
2243
2257
  expectTypesMatch(true);
2244
2258
 
2245
- // src/cad/cad_component.ts
2259
+ // src/pcb/pcb_via_clearance_error.ts
2246
2260
  import { z as z106 } from "zod";
2247
- var cad_component = z106.object({
2248
- type: z106.literal("cad_component"),
2249
- cad_component_id: z106.string(),
2250
- pcb_component_id: z106.string(),
2251
- source_component_id: z106.string(),
2261
+ var pcb_via_clearance_error = z106.object({
2262
+ type: z106.literal("pcb_via_clearance_error"),
2263
+ pcb_error_id: getZodPrefixedIdWithDefault("pcb_error"),
2264
+ error_type: z106.literal("pcb_via_clearance_error").default("pcb_via_clearance_error"),
2265
+ message: z106.string(),
2266
+ pcb_via_ids: z106.array(z106.string()).min(2),
2267
+ minimum_clearance: distance.optional(),
2268
+ actual_clearance: distance.optional(),
2269
+ pcb_center: z106.object({
2270
+ x: z106.number().optional(),
2271
+ y: z106.number().optional()
2272
+ }).optional(),
2273
+ subcircuit_id: z106.string().optional()
2274
+ }).describe("Error emitted when vias are closer than the allowed clearance");
2275
+ expectTypesMatch(true);
2276
+
2277
+ // src/cad/cad_component.ts
2278
+ import { z as z107 } from "zod";
2279
+ var cad_component = z107.object({
2280
+ type: z107.literal("cad_component"),
2281
+ cad_component_id: z107.string(),
2282
+ pcb_component_id: z107.string(),
2283
+ source_component_id: z107.string(),
2252
2284
  position: point3,
2253
2285
  rotation: point3.optional(),
2254
2286
  size: point3.optional(),
2255
2287
  layer: layer_ref.optional(),
2256
- subcircuit_id: z106.string().optional(),
2288
+ subcircuit_id: z107.string().optional(),
2257
2289
  // These are all ways to generate/load the 3d model
2258
- footprinter_string: z106.string().optional(),
2259
- model_obj_url: z106.string().optional(),
2260
- model_stl_url: z106.string().optional(),
2261
- model_3mf_url: z106.string().optional(),
2262
- model_gltf_url: z106.string().optional(),
2263
- model_glb_url: z106.string().optional(),
2264
- model_step_url: z106.string().optional(),
2265
- model_wrl_url: z106.string().optional(),
2266
- model_unit_to_mm_scale_factor: z106.number().optional(),
2267
- model_jscad: z106.any().optional()
2290
+ footprinter_string: z107.string().optional(),
2291
+ model_obj_url: z107.string().optional(),
2292
+ model_stl_url: z107.string().optional(),
2293
+ model_3mf_url: z107.string().optional(),
2294
+ model_gltf_url: z107.string().optional(),
2295
+ model_glb_url: z107.string().optional(),
2296
+ model_step_url: z107.string().optional(),
2297
+ model_wrl_url: z107.string().optional(),
2298
+ model_unit_to_mm_scale_factor: z107.number().optional(),
2299
+ model_jscad: z107.any().optional()
2268
2300
  }).describe("Defines a component on the PCB");
2269
2301
  expectTypesMatch(true);
2270
2302
 
2271
2303
  // src/simulation/simulation_voltage_source.ts
2272
- import { z as z107 } from "zod";
2273
- var wave_shape = z107.enum(["sinewave", "square", "triangle", "sawtooth"]);
2274
- var percentage = z107.union([z107.string(), z107.number()]).transform((val) => {
2304
+ import { z as z108 } from "zod";
2305
+ var wave_shape = z108.enum(["sinewave", "square", "triangle", "sawtooth"]);
2306
+ var percentage = z108.union([z108.string(), z108.number()]).transform((val) => {
2275
2307
  if (typeof val === "string") {
2276
2308
  if (val.endsWith("%")) {
2277
2309
  return parseFloat(val.slice(0, -1)) / 100;
@@ -2280,30 +2312,30 @@ var percentage = z107.union([z107.string(), z107.number()]).transform((val) => {
2280
2312
  }
2281
2313
  return val;
2282
2314
  }).pipe(
2283
- z107.number().min(0, "Duty cycle must be non-negative").max(1, "Duty cycle cannot be greater than 100%")
2315
+ z108.number().min(0, "Duty cycle must be non-negative").max(1, "Duty cycle cannot be greater than 100%")
2284
2316
  );
2285
- var simulation_dc_voltage_source = z107.object({
2286
- type: z107.literal("simulation_voltage_source"),
2317
+ var simulation_dc_voltage_source = z108.object({
2318
+ type: z108.literal("simulation_voltage_source"),
2287
2319
  simulation_voltage_source_id: getZodPrefixedIdWithDefault(
2288
2320
  "simulation_voltage_source"
2289
2321
  ),
2290
- is_dc_source: z107.literal(true).optional().default(true),
2291
- positive_source_port_id: z107.string().optional(),
2292
- negative_source_port_id: z107.string().optional(),
2293
- positive_source_net_id: z107.string().optional(),
2294
- negative_source_net_id: z107.string().optional(),
2322
+ is_dc_source: z108.literal(true).optional().default(true),
2323
+ positive_source_port_id: z108.string().optional(),
2324
+ negative_source_port_id: z108.string().optional(),
2325
+ positive_source_net_id: z108.string().optional(),
2326
+ negative_source_net_id: z108.string().optional(),
2295
2327
  voltage
2296
2328
  }).describe("Defines a DC voltage source for simulation");
2297
- var simulation_ac_voltage_source = z107.object({
2298
- type: z107.literal("simulation_voltage_source"),
2329
+ var simulation_ac_voltage_source = z108.object({
2330
+ type: z108.literal("simulation_voltage_source"),
2299
2331
  simulation_voltage_source_id: getZodPrefixedIdWithDefault(
2300
2332
  "simulation_voltage_source"
2301
2333
  ),
2302
- is_dc_source: z107.literal(false),
2303
- terminal1_source_port_id: z107.string().optional(),
2304
- terminal2_source_port_id: z107.string().optional(),
2305
- terminal1_source_net_id: z107.string().optional(),
2306
- terminal2_source_net_id: z107.string().optional(),
2334
+ is_dc_source: z108.literal(false),
2335
+ terminal1_source_port_id: z108.string().optional(),
2336
+ terminal2_source_port_id: z108.string().optional(),
2337
+ terminal1_source_net_id: z108.string().optional(),
2338
+ terminal2_source_net_id: z108.string().optional(),
2307
2339
  voltage: voltage.optional(),
2308
2340
  frequency: frequency.optional(),
2309
2341
  peak_to_peak_voltage: voltage.optional(),
@@ -2311,63 +2343,63 @@ var simulation_ac_voltage_source = z107.object({
2311
2343
  phase: rotation.optional(),
2312
2344
  duty_cycle: percentage.optional()
2313
2345
  }).describe("Defines an AC voltage source for simulation");
2314
- var simulation_voltage_source = z107.union([simulation_dc_voltage_source, simulation_ac_voltage_source]).describe("Defines a voltage source for simulation");
2346
+ var simulation_voltage_source = z108.union([simulation_dc_voltage_source, simulation_ac_voltage_source]).describe("Defines a voltage source for simulation");
2315
2347
  expectTypesMatch(true);
2316
2348
  expectTypesMatch(true);
2317
2349
  expectTypesMatch(true);
2318
2350
 
2319
2351
  // src/simulation/simulation_experiment.ts
2320
- import { z as z108 } from "zod";
2321
- var experiment_type = z108.union([
2322
- z108.literal("spice_dc_sweep"),
2323
- z108.literal("spice_dc_operating_point"),
2324
- z108.literal("spice_transient_analysis"),
2325
- z108.literal("spice_ac_analysis")
2352
+ import { z as z109 } from "zod";
2353
+ var experiment_type = z109.union([
2354
+ z109.literal("spice_dc_sweep"),
2355
+ z109.literal("spice_dc_operating_point"),
2356
+ z109.literal("spice_transient_analysis"),
2357
+ z109.literal("spice_ac_analysis")
2326
2358
  ]);
2327
- var simulation_experiment = z108.object({
2328
- type: z108.literal("simulation_experiment"),
2359
+ var simulation_experiment = z109.object({
2360
+ type: z109.literal("simulation_experiment"),
2329
2361
  simulation_experiment_id: getZodPrefixedIdWithDefault(
2330
2362
  "simulation_experiment"
2331
2363
  ),
2332
- name: z108.string(),
2364
+ name: z109.string(),
2333
2365
  experiment_type
2334
2366
  }).describe("Defines a simulation experiment configuration");
2335
2367
  expectTypesMatch(true);
2336
2368
 
2337
2369
  // src/simulation/simulation_transient_voltage_graph.ts
2338
- import { z as z109 } from "zod";
2339
- var simulation_transient_voltage_graph = z109.object({
2340
- type: z109.literal("simulation_transient_voltage_graph"),
2370
+ import { z as z110 } from "zod";
2371
+ var simulation_transient_voltage_graph = z110.object({
2372
+ type: z110.literal("simulation_transient_voltage_graph"),
2341
2373
  simulation_transient_voltage_graph_id: getZodPrefixedIdWithDefault(
2342
2374
  "simulation_transient_voltage_graph"
2343
2375
  ),
2344
- simulation_experiment_id: z109.string(),
2345
- timestamps_ms: z109.array(z109.number()).optional(),
2346
- voltage_levels: z109.array(z109.number()),
2347
- schematic_voltage_probe_id: z109.string().optional(),
2348
- subcircuit_connecivity_map_key: z109.string().optional(),
2349
- time_per_step: z109.number(),
2350
- start_time_ms: z109.number(),
2351
- end_time_ms: z109.number(),
2352
- name: z109.string().optional()
2376
+ simulation_experiment_id: z110.string(),
2377
+ timestamps_ms: z110.array(z110.number()).optional(),
2378
+ voltage_levels: z110.array(z110.number()),
2379
+ schematic_voltage_probe_id: z110.string().optional(),
2380
+ subcircuit_connectivity_map_key: z110.string().optional(),
2381
+ time_per_step: duration_ms,
2382
+ start_time_ms: ms,
2383
+ end_time_ms: ms,
2384
+ name: z110.string().optional()
2353
2385
  }).describe("Stores voltage measurements over time for a simulation");
2354
2386
  expectTypesMatch(true);
2355
2387
 
2356
2388
  // src/simulation/simulation_switch.ts
2357
- import { z as z110 } from "zod";
2358
- var simulation_switch = z110.object({
2359
- type: z110.literal("simulation_switch"),
2389
+ import { z as z111 } from "zod";
2390
+ var simulation_switch = z111.object({
2391
+ type: z111.literal("simulation_switch"),
2360
2392
  simulation_switch_id: getZodPrefixedIdWithDefault("simulation_switch"),
2361
- closes_at: time.optional(),
2362
- opens_at: time.optional(),
2363
- starts_closed: z110.boolean().optional(),
2393
+ closes_at: ms.optional(),
2394
+ opens_at: ms.optional(),
2395
+ starts_closed: z111.boolean().optional(),
2364
2396
  switching_frequency: frequency.optional()
2365
2397
  }).describe("Defines a switch for simulation timing control");
2366
2398
  expectTypesMatch(true);
2367
2399
 
2368
2400
  // src/any_circuit_element.ts
2369
- import { z as z111 } from "zod";
2370
- var any_circuit_element = z111.union([
2401
+ import { z as z112 } from "zod";
2402
+ var any_circuit_element = z112.union([
2371
2403
  source_trace,
2372
2404
  source_port,
2373
2405
  any_source_component,
@@ -2424,6 +2456,7 @@ var any_circuit_element = z111.union([
2424
2456
  pcb_placement_error,
2425
2457
  pcb_port_not_matched_error,
2426
2458
  pcb_port_not_connected_error,
2459
+ pcb_via_clearance_error,
2427
2460
  pcb_fabrication_note_path,
2428
2461
  pcb_fabrication_note_text,
2429
2462
  pcb_autorouting_error,
@@ -2474,6 +2507,7 @@ export {
2474
2507
  circuit_json_footprint_load_error,
2475
2508
  current,
2476
2509
  distance,
2510
+ duration_ms,
2477
2511
  experiment_type,
2478
2512
  external_footprint_load_error,
2479
2513
  frequency,
@@ -2482,6 +2516,7 @@ export {
2482
2516
  layer_ref,
2483
2517
  layer_string,
2484
2518
  length,
2519
+ ms,
2485
2520
  ninePointAnchor,
2486
2521
  pcb_autorouting_error,
2487
2522
  pcb_board,
@@ -2535,6 +2570,7 @@ export {
2535
2570
  pcb_trace_route_point_via,
2536
2571
  pcb_trace_route_point_wire,
2537
2572
  pcb_via,
2573
+ pcb_via_clearance_error,
2538
2574
  point,
2539
2575
  point3,
2540
2576
  point_with_bulge,
@@ -2612,6 +2648,7 @@ export {
2612
2648
  source_trace_not_connected_error,
2613
2649
  supplier_name,
2614
2650
  time,
2651
+ timestamp,
2615
2652
  visible_layer,
2616
2653
  voltage,
2617
2654
  wave_shape