@modular-circuit/perc 0.2.3 → 0.2.5

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.d.mts CHANGED
@@ -169,6 +169,11 @@ declare const INVALID_INPUT: (eda_item_ids: string[], error_message: unknown) =>
169
169
  error_message: unknown;
170
170
  eda_item_ids: string[];
171
171
  };
172
+ declare const INVALID_PORT_ID_REFERENCED_IN_CONNECTION: (eda_item_ids: string[]) => {
173
+ error_code: PP_ERROR;
174
+ error_message: string;
175
+ eda_item_ids: string[];
176
+ };
172
177
 
173
178
  interface REPORT_ITEM {
174
179
  /**
@@ -287,7 +292,7 @@ type ADT_AdjacencyList = Set<string>;
287
292
  type ADT_Graph = Record<string, ADT_AdjacencyList>;
288
293
 
289
294
  interface GRAPH_CONVERTER {
290
- convert_to_graph(design: unknown): true | Error[];
295
+ convert_to_graph(design: unknown): void;
291
296
  get_graph(): ADT_Graph;
292
297
  get_connection_node_map(): ConnectionNodeMap;
293
298
  }
@@ -337,7 +342,8 @@ declare enum PP_ERROR {
337
342
  REQUIRES_CONNECTED_SOURCE_OR_BIDIR = "requires_connected_source_or_bidir",
338
343
  ILLEGAL_CONNECTION = "Illegal_connection",
339
344
  CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT = "connection_count_exceeds_bundle_limit",
340
- INVALID_INPUT = " INVALID_INPUT"
345
+ INVALID_INPUT = "Invalid input",
346
+ INVALID_PORT_ID_REFERENCED_IN_CONNECTION = "Invalid port id referenced in connection"
341
347
  }
342
348
  declare const DEFAULT_PP_ERROR_SEVERITY: Record<PP_ERROR, SEVERITY>;
343
349
 
@@ -449,6 +455,7 @@ declare class IR_GRAPH_CONVERTER implements GRAPH_CONVERTER {
449
455
  private schematics;
450
456
  private bundle_consumed_port_count;
451
457
  private bundles;
458
+ private invalid_port_id;
452
459
  private reporter_context;
453
460
  get_bundle_consumed_port_count(): {
454
461
  bundle_consumed_port_count: Record<string, number>;
@@ -456,7 +463,7 @@ declare class IR_GRAPH_CONVERTER implements GRAPH_CONVERTER {
456
463
  };
457
464
  get_report_context(): ERC_REPORTER_CONTEXT;
458
465
  constructor(circuits: Record<string, ModuleCircuit>);
459
- convert_to_graph(designs: Record<string, IR_Graph>): true | Error[];
466
+ convert_to_graph(designs: Record<string, IR_Graph>): string[];
460
467
  add_node(id: string): void;
461
468
  add_pwr(pwr: PowerBase, shape: PowerShape, sch_name: string, param: PowerSymbolPort): void;
462
469
  add_connection(from: string, to: string): void;
@@ -482,6 +489,7 @@ declare function build_connection_graph(ctx: CONNECTION_GRAPH_BUILDER_CTX): Prom
482
489
  bundle_consumed_port_count: Record<string, number>;
483
490
  bundles: Record<string, BundleInfo>;
484
491
  };
492
+ invalid_port_ids: string[];
485
493
  pin_name_table: Record<string, string>;
486
494
  pin_module_name_table: Record<string, string>;
487
495
  }>;
@@ -497,8 +505,9 @@ declare function graph_ecr(ctx: Omit<ERC_INPUT, 'schematics'> & {
497
505
  bundle_consumed_port_count: Record<string, number>;
498
506
  bundles: Record<string, BundleInfo>;
499
507
  };
508
+ invalid_port_ids: string[];
500
509
  pin_name_table: Record<string, string>;
501
510
  pin_module_name_table: Record<string, string>;
502
511
  }>;
503
512
 
504
- export { type ADT_AdjacencyList, type ADT_Graph, type BundleInfo, type CG_SCHEMATIC, CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT, type CONNECTION_GRAPH_BUILDER_CTX, ConnectionGraphsBuilder, DEFAULT_ERC_SETTING, DEFAULT_PIN_MAP, DEFAULT_PP_ERROR_SEVERITY, DEFAULT_SEVERITY, DrivenPinTypes, DrivingPinTypes, ERCE_DRIVER_CONFLICT, ERCE_PIN_NOT_CONNECTED, ERCE_PIN_TO_PIN_ERROR, ERCE_T, ERCE_UNANNOTATED, type ERC_CONTEXT, type ERC_INPUT, type ERC_ITEM, type ERC_REPORT, type ERC_REPORTER_CONTEXT, ERC_SETTING, ERC_TESTER, type GRAPH_CONVERTER, INVALID_INPUT, IR_GRAPH_CONVERTER, MakerType, type MarkerBase, NetlistTester, PIN_COMPATIBILITY_MATRIX_TESTER, PIN_ERROR, type PIN_TO_PIN_TEST_CONTEXT, PP_DUPLICATED_SOURCES, PP_ERROR, PP_ILLEGAL_CONNECTION, PP_IMPEDANCE_SIGNAL_INTEGRITY, PP_INAPPROPRIATE_FUNC, PP_INCOMPATIBLE_DIGITAL_THRESHOLDS, PP_INCOMPATIBLE_SIGNAL_LEVELS, PP_INCOMPATIBLE_VOLTAGE_LEVELS, PP_INSUFFICIENT_DRIVER, PP_NOT_DRIVEN, PP_OVERCURRENT, PP_OVER_DRIVEN, PP_REQUIRES_CONNECTED_SOURCE_OR_BIDIR, PP_SIGNAL_LEVELS_NOT_CONTAINED_WITHIN_VOLTAGE, type ParameterPropagationTestContext, ParameterPropagationTester, PowerDrivingPinTypes, type RC_ITEM, type REPORT_ITEM, type SCH_ERC_ITEM, type SCH_MARKER, SEVERITY, build_connection_graph, fmt_erc_item_description, get_erc_severity, graph_ecr };
513
+ export { type ADT_AdjacencyList, type ADT_Graph, type BundleInfo, type CG_SCHEMATIC, CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT, type CONNECTION_GRAPH_BUILDER_CTX, ConnectionGraphsBuilder, DEFAULT_ERC_SETTING, DEFAULT_PIN_MAP, DEFAULT_PP_ERROR_SEVERITY, DEFAULT_SEVERITY, DrivenPinTypes, DrivingPinTypes, ERCE_DRIVER_CONFLICT, ERCE_PIN_NOT_CONNECTED, ERCE_PIN_TO_PIN_ERROR, ERCE_T, ERCE_UNANNOTATED, type ERC_CONTEXT, type ERC_INPUT, type ERC_ITEM, type ERC_REPORT, type ERC_REPORTER_CONTEXT, ERC_SETTING, ERC_TESTER, type GRAPH_CONVERTER, INVALID_INPUT, INVALID_PORT_ID_REFERENCED_IN_CONNECTION, IR_GRAPH_CONVERTER, MakerType, type MarkerBase, NetlistTester, PIN_COMPATIBILITY_MATRIX_TESTER, PIN_ERROR, type PIN_TO_PIN_TEST_CONTEXT, PP_DUPLICATED_SOURCES, PP_ERROR, PP_ILLEGAL_CONNECTION, PP_IMPEDANCE_SIGNAL_INTEGRITY, PP_INAPPROPRIATE_FUNC, PP_INCOMPATIBLE_DIGITAL_THRESHOLDS, PP_INCOMPATIBLE_SIGNAL_LEVELS, PP_INCOMPATIBLE_VOLTAGE_LEVELS, PP_INSUFFICIENT_DRIVER, PP_NOT_DRIVEN, PP_OVERCURRENT, PP_OVER_DRIVEN, PP_REQUIRES_CONNECTED_SOURCE_OR_BIDIR, PP_SIGNAL_LEVELS_NOT_CONTAINED_WITHIN_VOLTAGE, type ParameterPropagationTestContext, ParameterPropagationTester, PowerDrivingPinTypes, type RC_ITEM, type REPORT_ITEM, type SCH_ERC_ITEM, type SCH_MARKER, SEVERITY, build_connection_graph, fmt_erc_item_description, get_erc_severity, graph_ecr };
package/dist/index.d.ts CHANGED
@@ -169,6 +169,11 @@ declare const INVALID_INPUT: (eda_item_ids: string[], error_message: unknown) =>
169
169
  error_message: unknown;
170
170
  eda_item_ids: string[];
171
171
  };
172
+ declare const INVALID_PORT_ID_REFERENCED_IN_CONNECTION: (eda_item_ids: string[]) => {
173
+ error_code: PP_ERROR;
174
+ error_message: string;
175
+ eda_item_ids: string[];
176
+ };
172
177
 
173
178
  interface REPORT_ITEM {
174
179
  /**
@@ -287,7 +292,7 @@ type ADT_AdjacencyList = Set<string>;
287
292
  type ADT_Graph = Record<string, ADT_AdjacencyList>;
288
293
 
289
294
  interface GRAPH_CONVERTER {
290
- convert_to_graph(design: unknown): true | Error[];
295
+ convert_to_graph(design: unknown): void;
291
296
  get_graph(): ADT_Graph;
292
297
  get_connection_node_map(): ConnectionNodeMap;
293
298
  }
@@ -337,7 +342,8 @@ declare enum PP_ERROR {
337
342
  REQUIRES_CONNECTED_SOURCE_OR_BIDIR = "requires_connected_source_or_bidir",
338
343
  ILLEGAL_CONNECTION = "Illegal_connection",
339
344
  CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT = "connection_count_exceeds_bundle_limit",
340
- INVALID_INPUT = " INVALID_INPUT"
345
+ INVALID_INPUT = "Invalid input",
346
+ INVALID_PORT_ID_REFERENCED_IN_CONNECTION = "Invalid port id referenced in connection"
341
347
  }
342
348
  declare const DEFAULT_PP_ERROR_SEVERITY: Record<PP_ERROR, SEVERITY>;
343
349
 
@@ -449,6 +455,7 @@ declare class IR_GRAPH_CONVERTER implements GRAPH_CONVERTER {
449
455
  private schematics;
450
456
  private bundle_consumed_port_count;
451
457
  private bundles;
458
+ private invalid_port_id;
452
459
  private reporter_context;
453
460
  get_bundle_consumed_port_count(): {
454
461
  bundle_consumed_port_count: Record<string, number>;
@@ -456,7 +463,7 @@ declare class IR_GRAPH_CONVERTER implements GRAPH_CONVERTER {
456
463
  };
457
464
  get_report_context(): ERC_REPORTER_CONTEXT;
458
465
  constructor(circuits: Record<string, ModuleCircuit>);
459
- convert_to_graph(designs: Record<string, IR_Graph>): true | Error[];
466
+ convert_to_graph(designs: Record<string, IR_Graph>): string[];
460
467
  add_node(id: string): void;
461
468
  add_pwr(pwr: PowerBase, shape: PowerShape, sch_name: string, param: PowerSymbolPort): void;
462
469
  add_connection(from: string, to: string): void;
@@ -482,6 +489,7 @@ declare function build_connection_graph(ctx: CONNECTION_GRAPH_BUILDER_CTX): Prom
482
489
  bundle_consumed_port_count: Record<string, number>;
483
490
  bundles: Record<string, BundleInfo>;
484
491
  };
492
+ invalid_port_ids: string[];
485
493
  pin_name_table: Record<string, string>;
486
494
  pin_module_name_table: Record<string, string>;
487
495
  }>;
@@ -497,8 +505,9 @@ declare function graph_ecr(ctx: Omit<ERC_INPUT, 'schematics'> & {
497
505
  bundle_consumed_port_count: Record<string, number>;
498
506
  bundles: Record<string, BundleInfo>;
499
507
  };
508
+ invalid_port_ids: string[];
500
509
  pin_name_table: Record<string, string>;
501
510
  pin_module_name_table: Record<string, string>;
502
511
  }>;
503
512
 
504
- export { type ADT_AdjacencyList, type ADT_Graph, type BundleInfo, type CG_SCHEMATIC, CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT, type CONNECTION_GRAPH_BUILDER_CTX, ConnectionGraphsBuilder, DEFAULT_ERC_SETTING, DEFAULT_PIN_MAP, DEFAULT_PP_ERROR_SEVERITY, DEFAULT_SEVERITY, DrivenPinTypes, DrivingPinTypes, ERCE_DRIVER_CONFLICT, ERCE_PIN_NOT_CONNECTED, ERCE_PIN_TO_PIN_ERROR, ERCE_T, ERCE_UNANNOTATED, type ERC_CONTEXT, type ERC_INPUT, type ERC_ITEM, type ERC_REPORT, type ERC_REPORTER_CONTEXT, ERC_SETTING, ERC_TESTER, type GRAPH_CONVERTER, INVALID_INPUT, IR_GRAPH_CONVERTER, MakerType, type MarkerBase, NetlistTester, PIN_COMPATIBILITY_MATRIX_TESTER, PIN_ERROR, type PIN_TO_PIN_TEST_CONTEXT, PP_DUPLICATED_SOURCES, PP_ERROR, PP_ILLEGAL_CONNECTION, PP_IMPEDANCE_SIGNAL_INTEGRITY, PP_INAPPROPRIATE_FUNC, PP_INCOMPATIBLE_DIGITAL_THRESHOLDS, PP_INCOMPATIBLE_SIGNAL_LEVELS, PP_INCOMPATIBLE_VOLTAGE_LEVELS, PP_INSUFFICIENT_DRIVER, PP_NOT_DRIVEN, PP_OVERCURRENT, PP_OVER_DRIVEN, PP_REQUIRES_CONNECTED_SOURCE_OR_BIDIR, PP_SIGNAL_LEVELS_NOT_CONTAINED_WITHIN_VOLTAGE, type ParameterPropagationTestContext, ParameterPropagationTester, PowerDrivingPinTypes, type RC_ITEM, type REPORT_ITEM, type SCH_ERC_ITEM, type SCH_MARKER, SEVERITY, build_connection_graph, fmt_erc_item_description, get_erc_severity, graph_ecr };
513
+ export { type ADT_AdjacencyList, type ADT_Graph, type BundleInfo, type CG_SCHEMATIC, CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT, type CONNECTION_GRAPH_BUILDER_CTX, ConnectionGraphsBuilder, DEFAULT_ERC_SETTING, DEFAULT_PIN_MAP, DEFAULT_PP_ERROR_SEVERITY, DEFAULT_SEVERITY, DrivenPinTypes, DrivingPinTypes, ERCE_DRIVER_CONFLICT, ERCE_PIN_NOT_CONNECTED, ERCE_PIN_TO_PIN_ERROR, ERCE_T, ERCE_UNANNOTATED, type ERC_CONTEXT, type ERC_INPUT, type ERC_ITEM, type ERC_REPORT, type ERC_REPORTER_CONTEXT, ERC_SETTING, ERC_TESTER, type GRAPH_CONVERTER, INVALID_INPUT, INVALID_PORT_ID_REFERENCED_IN_CONNECTION, IR_GRAPH_CONVERTER, MakerType, type MarkerBase, NetlistTester, PIN_COMPATIBILITY_MATRIX_TESTER, PIN_ERROR, type PIN_TO_PIN_TEST_CONTEXT, PP_DUPLICATED_SOURCES, PP_ERROR, PP_ILLEGAL_CONNECTION, PP_IMPEDANCE_SIGNAL_INTEGRITY, PP_INAPPROPRIATE_FUNC, PP_INCOMPATIBLE_DIGITAL_THRESHOLDS, PP_INCOMPATIBLE_SIGNAL_LEVELS, PP_INCOMPATIBLE_VOLTAGE_LEVELS, PP_INSUFFICIENT_DRIVER, PP_NOT_DRIVEN, PP_OVERCURRENT, PP_OVER_DRIVEN, PP_REQUIRES_CONNECTED_SOURCE_OR_BIDIR, PP_SIGNAL_LEVELS_NOT_CONTAINED_WITHIN_VOLTAGE, type ParameterPropagationTestContext, ParameterPropagationTester, PowerDrivingPinTypes, type RC_ITEM, type REPORT_ITEM, type SCH_ERC_ITEM, type SCH_MARKER, SEVERITY, build_connection_graph, fmt_erc_item_description, get_erc_severity, graph_ecr };
package/dist/index.js CHANGED
@@ -46,6 +46,7 @@ __export(index_exports, {
46
46
  ERC_SETTING: () => ERC_SETTING,
47
47
  ERC_TESTER: () => ERC_TESTER,
48
48
  INVALID_INPUT: () => INVALID_INPUT,
49
+ INVALID_PORT_ID_REFERENCED_IN_CONNECTION: () => INVALID_PORT_ID_REFERENCED_IN_CONNECTION,
49
50
  IR_GRAPH_CONVERTER: () => IR_GRAPH_CONVERTER,
50
51
  MakerType: () => MakerType,
51
52
  NetlistTester: () => NetlistTester,
@@ -134,7 +135,8 @@ var PP_ERROR = /* @__PURE__ */ ((PP_ERROR2) => {
134
135
  PP_ERROR2["REQUIRES_CONNECTED_SOURCE_OR_BIDIR"] = "requires_connected_source_or_bidir";
135
136
  PP_ERROR2["ILLEGAL_CONNECTION"] = "Illegal_connection";
136
137
  PP_ERROR2["CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT"] = "connection_count_exceeds_bundle_limit";
137
- PP_ERROR2["INVALID_INPUT"] = " INVALID_INPUT";
138
+ PP_ERROR2["INVALID_INPUT"] = "Invalid input";
139
+ PP_ERROR2["INVALID_PORT_ID_REFERENCED_IN_CONNECTION"] = "Invalid port id referenced in connection";
138
140
  return PP_ERROR2;
139
141
  })(PP_ERROR || {});
140
142
  var DEFAULT_PP_ERROR_SEVERITY = {
@@ -170,7 +172,8 @@ var DEFAULT_PP_ERROR_SEVERITY = {
170
172
  ["requires_connected_source_or_bidir" /* REQUIRES_CONNECTED_SOURCE_OR_BIDIR */]: 16 /* RPT_SEVERITY_WARNING */,
171
173
  ["Illegal_connection" /* ILLEGAL_CONNECTION */]: 32 /* RPT_SEVERITY_ERROR */,
172
174
  ["connection_count_exceeds_bundle_limit" /* CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT */]: 32 /* RPT_SEVERITY_ERROR */,
173
- [" INVALID_INPUT" /* INVALID_INPUT */]: 16 /* RPT_SEVERITY_WARNING */
175
+ ["Invalid input" /* INVALID_INPUT */]: 16 /* RPT_SEVERITY_WARNING */,
176
+ ["Invalid port id referenced in connection" /* INVALID_PORT_ID_REFERENCED_IN_CONNECTION */]: 16 /* RPT_SEVERITY_WARNING */
174
177
  };
175
178
 
176
179
  // src/erc/parameter_propagation/tester.ts
@@ -284,11 +287,16 @@ var CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT = (bundle_id) => ({
284
287
  });
285
288
  var INVALID_INPUT = (eda_item_ids, error_message) => {
286
289
  return {
287
- error_code: " INVALID_INPUT" /* INVALID_INPUT */,
290
+ error_code: "Invalid input" /* INVALID_INPUT */,
288
291
  error_message,
289
292
  eda_item_ids
290
293
  };
291
294
  };
295
+ var INVALID_PORT_ID_REFERENCED_IN_CONNECTION = (eda_item_ids) => ({
296
+ error_code: "Invalid port id referenced in connection" /* INVALID_PORT_ID_REFERENCED_IN_CONNECTION */,
297
+ error_message: "Invalid port id referenced in connections.",
298
+ eda_item_ids
299
+ });
292
300
 
293
301
  // src/erc/parameter_propagation/link_testers/tester_impl.ts
294
302
  var import_electronics_model3 = require("@modular-circuit/electronics-model");
@@ -1202,7 +1210,7 @@ var ParameterPropagationTester = class {
1202
1210
  port_id: this.port_id,
1203
1211
  has_passive_port: this.has_passive_port
1204
1212
  },
1205
- valid_ports
1213
+ ports
1206
1214
  ).test();
1207
1215
  }
1208
1216
  visit_cc(cc) {
@@ -1211,14 +1219,38 @@ var ParameterPropagationTester = class {
1211
1219
  }
1212
1220
  this.link_map = (0, import_electronics_model4.gen_link_map)();
1213
1221
  const ports = [];
1222
+ const valid_port = (p) => {
1223
+ try {
1224
+ const zod_schema = (0, import_electronics_model4.get_port_schema)(p.param);
1225
+ if (!zod_schema) {
1226
+ this.ctx.report.erc_errors.push(
1227
+ INVALID_INPUT([p.uuid], {
1228
+ unknown_port_type: p
1229
+ })
1230
+ );
1231
+ return;
1232
+ }
1233
+ p.param = zod_schema.parse(p);
1234
+ ports.push(p);
1235
+ } catch (err) {
1236
+ if (err instanceof z.ZodError) {
1237
+ this.ctx.report.erc_errors.push(
1238
+ INVALID_INPUT([p.uuid], {
1239
+ input: p,
1240
+ issues: err.issues
1241
+ })
1242
+ );
1243
+ }
1244
+ }
1245
+ };
1214
1246
  for (const p of cc.nodes) {
1215
1247
  switch (p.type) {
1216
1248
  case import_electronics_model4.ConnectionNodeType.Port: {
1217
- ports.push(p);
1249
+ valid_port(p);
1218
1250
  break;
1219
1251
  }
1220
1252
  case import_electronics_model4.ConnectionNodeType.Power: {
1221
- ports.push({
1253
+ valid_port({
1222
1254
  type: import_electronics_model4.ConnectionNodeType.Port,
1223
1255
  param: p.param,
1224
1256
  label_shapes: {},
@@ -1634,6 +1666,7 @@ var IR_GRAPH_CONVERTER = class {
1634
1666
  this.schematics = {};
1635
1667
  this.bundle_consumed_port_count = {};
1636
1668
  this.bundles = {};
1669
+ this.invalid_port_id = /* @__PURE__ */ new Set();
1637
1670
  this.reporter_context = {
1638
1671
  pin_name_table: {},
1639
1672
  pin_module_name_table: {}
@@ -1649,7 +1682,6 @@ var IR_GRAPH_CONVERTER = class {
1649
1682
  return this.reporter_context;
1650
1683
  }
1651
1684
  convert_to_graph(designs) {
1652
- const errors = [];
1653
1685
  if (Object.keys(designs).length > 1) {
1654
1686
  throw new Error("Multiple designs are not supported");
1655
1687
  }
@@ -1767,7 +1799,18 @@ var IR_GRAPH_CONVERTER = class {
1767
1799
  this.add_node(uuid);
1768
1800
  this.connection_node_map[uuid] = { uuid, type: import_electronics_model8.ConnectionNodeType.Graphics };
1769
1801
  }
1802
+ const validate_wire = (wire) => {
1803
+ let valid = true;
1804
+ for (const id of [wire.from, wire.to]) {
1805
+ if (!(id in this.graph)) {
1806
+ this.invalid_port_id.add(id);
1807
+ valid = false;
1808
+ }
1809
+ }
1810
+ return valid;
1811
+ };
1770
1812
  const handel_wire_instance = (abstract_or_actual_wire, actual_wire_id) => {
1813
+ if (!validate_wire(abstract_or_actual_wire)) return;
1771
1814
  this.add_connection(abstract_or_actual_wire.from, abstract_or_actual_wire.to);
1772
1815
  this.connection_node_map[abstract_or_actual_wire.uuid] = {
1773
1816
  uuid: actual_wire_id,
@@ -1810,7 +1853,7 @@ var IR_GRAPH_CONVERTER = class {
1810
1853
  handel_wire_instance(connection, actual_wire_id);
1811
1854
  }
1812
1855
  }
1813
- return errors.length ? errors : true;
1856
+ return [...this.invalid_port_id];
1814
1857
  }
1815
1858
  add_node(id) {
1816
1859
  if (!this.graph[id]) this.graph[id] = /* @__PURE__ */ new Set();
@@ -1953,15 +1996,15 @@ var ConnectionGraphsBuilder = class {
1953
1996
  };
1954
1997
  async function build_connection_graph(ctx) {
1955
1998
  const converter = new IR_GRAPH_CONVERTER(await get_dependent_modules_definition(ctx));
1956
- const res = converter.convert_to_graph(ctx.schematics);
1957
- if (res !== true) throw new Error(`Failed to convert graph ${res.join(",")}`);
1999
+ const invalid_port_ids = converter.convert_to_graph(ctx.schematics);
1958
2000
  const cc_builder = new ConnectionGraphsBuilder(converter.get_connection_node_map());
1959
2001
  (0, import_utils3.test_connected_components)(converter.get_graph(), [cc_builder]);
1960
2002
  return {
1961
2003
  ...converter.get_report_context(),
1962
2004
  connection_graph: cc_builder.get_connection_graph(),
1963
2005
  cg_schematics: converter.get_schematics(),
1964
- bundle_consume_status: converter.get_bundle_consumed_port_count()
2006
+ bundle_consume_status: converter.get_bundle_consumed_port_count(),
2007
+ invalid_port_ids
1965
2008
  };
1966
2009
  }
1967
2010
 
@@ -1981,6 +2024,9 @@ async function graph_ecr(ctx) {
1981
2024
  console.warn(`Illegal bundle: ${port_id} , no associated labels`);
1982
2025
  }
1983
2026
  }
2027
+ for (const id of connection_graph.invalid_port_ids) {
2028
+ erc_report.erc_errors.push(INVALID_PORT_ID_REFERENCED_IN_CONNECTION([id]));
2029
+ }
1984
2030
  const tester = new ERC_TESTER(
1985
2031
  {
1986
2032
  ...ctx,
@@ -2008,6 +2054,7 @@ async function graph_ecr(ctx) {
2008
2054
  ERC_SETTING,
2009
2055
  ERC_TESTER,
2010
2056
  INVALID_INPUT,
2057
+ INVALID_PORT_ID_REFERENCED_IN_CONNECTION,
2011
2058
  IR_GRAPH_CONVERTER,
2012
2059
  MakerType,
2013
2060
  NetlistTester,
package/dist/index.mjs CHANGED
@@ -57,7 +57,8 @@ var PP_ERROR = /* @__PURE__ */ ((PP_ERROR2) => {
57
57
  PP_ERROR2["REQUIRES_CONNECTED_SOURCE_OR_BIDIR"] = "requires_connected_source_or_bidir";
58
58
  PP_ERROR2["ILLEGAL_CONNECTION"] = "Illegal_connection";
59
59
  PP_ERROR2["CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT"] = "connection_count_exceeds_bundle_limit";
60
- PP_ERROR2["INVALID_INPUT"] = " INVALID_INPUT";
60
+ PP_ERROR2["INVALID_INPUT"] = "Invalid input";
61
+ PP_ERROR2["INVALID_PORT_ID_REFERENCED_IN_CONNECTION"] = "Invalid port id referenced in connection";
61
62
  return PP_ERROR2;
62
63
  })(PP_ERROR || {});
63
64
  var DEFAULT_PP_ERROR_SEVERITY = {
@@ -93,7 +94,8 @@ var DEFAULT_PP_ERROR_SEVERITY = {
93
94
  ["requires_connected_source_or_bidir" /* REQUIRES_CONNECTED_SOURCE_OR_BIDIR */]: 16 /* RPT_SEVERITY_WARNING */,
94
95
  ["Illegal_connection" /* ILLEGAL_CONNECTION */]: 32 /* RPT_SEVERITY_ERROR */,
95
96
  ["connection_count_exceeds_bundle_limit" /* CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT */]: 32 /* RPT_SEVERITY_ERROR */,
96
- [" INVALID_INPUT" /* INVALID_INPUT */]: 16 /* RPT_SEVERITY_WARNING */
97
+ ["Invalid input" /* INVALID_INPUT */]: 16 /* RPT_SEVERITY_WARNING */,
98
+ ["Invalid port id referenced in connection" /* INVALID_PORT_ID_REFERENCED_IN_CONNECTION */]: 16 /* RPT_SEVERITY_WARNING */
97
99
  };
98
100
 
99
101
  // src/erc/parameter_propagation/tester.ts
@@ -214,11 +216,16 @@ var CONNECTIONS_COUNT_EXCEEDS_BUNDLE_LIMIT = (bundle_id) => ({
214
216
  });
215
217
  var INVALID_INPUT = (eda_item_ids, error_message) => {
216
218
  return {
217
- error_code: " INVALID_INPUT" /* INVALID_INPUT */,
219
+ error_code: "Invalid input" /* INVALID_INPUT */,
218
220
  error_message,
219
221
  eda_item_ids
220
222
  };
221
223
  };
224
+ var INVALID_PORT_ID_REFERENCED_IN_CONNECTION = (eda_item_ids) => ({
225
+ error_code: "Invalid port id referenced in connection" /* INVALID_PORT_ID_REFERENCED_IN_CONNECTION */,
226
+ error_message: "Invalid port id referenced in connections.",
227
+ eda_item_ids
228
+ });
222
229
 
223
230
  // src/erc/parameter_propagation/link_testers/tester_impl.ts
224
231
  import {
@@ -1143,7 +1150,7 @@ var ParameterPropagationTester = class {
1143
1150
  port_id: this.port_id,
1144
1151
  has_passive_port: this.has_passive_port
1145
1152
  },
1146
- valid_ports
1153
+ ports
1147
1154
  ).test();
1148
1155
  }
1149
1156
  visit_cc(cc) {
@@ -1152,14 +1159,38 @@ var ParameterPropagationTester = class {
1152
1159
  }
1153
1160
  this.link_map = gen_link_map();
1154
1161
  const ports = [];
1162
+ const valid_port = (p) => {
1163
+ try {
1164
+ const zod_schema = get_port_schema(p.param);
1165
+ if (!zod_schema) {
1166
+ this.ctx.report.erc_errors.push(
1167
+ INVALID_INPUT([p.uuid], {
1168
+ unknown_port_type: p
1169
+ })
1170
+ );
1171
+ return;
1172
+ }
1173
+ p.param = zod_schema.parse(p);
1174
+ ports.push(p);
1175
+ } catch (err) {
1176
+ if (err instanceof z.ZodError) {
1177
+ this.ctx.report.erc_errors.push(
1178
+ INVALID_INPUT([p.uuid], {
1179
+ input: p,
1180
+ issues: err.issues
1181
+ })
1182
+ );
1183
+ }
1184
+ }
1185
+ };
1155
1186
  for (const p of cc.nodes) {
1156
1187
  switch (p.type) {
1157
1188
  case ConnectionNodeType.Port: {
1158
- ports.push(p);
1189
+ valid_port(p);
1159
1190
  break;
1160
1191
  }
1161
1192
  case ConnectionNodeType.Power: {
1162
- ports.push({
1193
+ valid_port({
1163
1194
  type: ConnectionNodeType.Port,
1164
1195
  param: p.param,
1165
1196
  label_shapes: {},
@@ -1579,12 +1610,12 @@ import {
1579
1610
  block_is_associated_with_concrete_module
1580
1611
  } from "@modular-circuit/ir";
1581
1612
  import {
1613
+ KiCadSchematicFileExtension,
1582
1614
  deep_copy,
1583
1615
  fmt_module_name,
1584
1616
  gen_uuid,
1585
1617
  get_circuit_ports,
1586
- get_port_labels,
1587
- KiCadSchematicFileExtension
1618
+ get_port_labels
1588
1619
  } from "@modular-circuit/utils";
1589
1620
  var IR_GRAPH_CONVERTER = class {
1590
1621
  constructor(circuits) {
@@ -1594,6 +1625,7 @@ var IR_GRAPH_CONVERTER = class {
1594
1625
  this.schematics = {};
1595
1626
  this.bundle_consumed_port_count = {};
1596
1627
  this.bundles = {};
1628
+ this.invalid_port_id = /* @__PURE__ */ new Set();
1597
1629
  this.reporter_context = {
1598
1630
  pin_name_table: {},
1599
1631
  pin_module_name_table: {}
@@ -1609,7 +1641,6 @@ var IR_GRAPH_CONVERTER = class {
1609
1641
  return this.reporter_context;
1610
1642
  }
1611
1643
  convert_to_graph(designs) {
1612
- const errors = [];
1613
1644
  if (Object.keys(designs).length > 1) {
1614
1645
  throw new Error("Multiple designs are not supported");
1615
1646
  }
@@ -1727,7 +1758,18 @@ var IR_GRAPH_CONVERTER = class {
1727
1758
  this.add_node(uuid);
1728
1759
  this.connection_node_map[uuid] = { uuid, type: ConnectionNodeType3.Graphics };
1729
1760
  }
1761
+ const validate_wire = (wire) => {
1762
+ let valid = true;
1763
+ for (const id of [wire.from, wire.to]) {
1764
+ if (!(id in this.graph)) {
1765
+ this.invalid_port_id.add(id);
1766
+ valid = false;
1767
+ }
1768
+ }
1769
+ return valid;
1770
+ };
1730
1771
  const handel_wire_instance = (abstract_or_actual_wire, actual_wire_id) => {
1772
+ if (!validate_wire(abstract_or_actual_wire)) return;
1731
1773
  this.add_connection(abstract_or_actual_wire.from, abstract_or_actual_wire.to);
1732
1774
  this.connection_node_map[abstract_or_actual_wire.uuid] = {
1733
1775
  uuid: actual_wire_id,
@@ -1770,7 +1812,7 @@ var IR_GRAPH_CONVERTER = class {
1770
1812
  handel_wire_instance(connection, actual_wire_id);
1771
1813
  }
1772
1814
  }
1773
- return errors.length ? errors : true;
1815
+ return [...this.invalid_port_id];
1774
1816
  }
1775
1817
  add_node(id) {
1776
1818
  if (!this.graph[id]) this.graph[id] = /* @__PURE__ */ new Set();
@@ -1920,15 +1962,15 @@ var ConnectionGraphsBuilder = class {
1920
1962
  };
1921
1963
  async function build_connection_graph(ctx) {
1922
1964
  const converter = new IR_GRAPH_CONVERTER(await get_dependent_modules_definition(ctx));
1923
- const res = converter.convert_to_graph(ctx.schematics);
1924
- if (res !== true) throw new Error(`Failed to convert graph ${res.join(",")}`);
1965
+ const invalid_port_ids = converter.convert_to_graph(ctx.schematics);
1925
1966
  const cc_builder = new ConnectionGraphsBuilder(converter.get_connection_node_map());
1926
1967
  test_connected_components(converter.get_graph(), [cc_builder]);
1927
1968
  return {
1928
1969
  ...converter.get_report_context(),
1929
1970
  connection_graph: cc_builder.get_connection_graph(),
1930
1971
  cg_schematics: converter.get_schematics(),
1931
- bundle_consume_status: converter.get_bundle_consumed_port_count()
1972
+ bundle_consume_status: converter.get_bundle_consumed_port_count(),
1973
+ invalid_port_ids
1932
1974
  };
1933
1975
  }
1934
1976
 
@@ -1948,6 +1990,9 @@ async function graph_ecr(ctx) {
1948
1990
  console.warn(`Illegal bundle: ${port_id} , no associated labels`);
1949
1991
  }
1950
1992
  }
1993
+ for (const id of connection_graph.invalid_port_ids) {
1994
+ erc_report.erc_errors.push(INVALID_PORT_ID_REFERENCED_IN_CONNECTION([id]));
1995
+ }
1951
1996
  const tester = new ERC_TESTER(
1952
1997
  {
1953
1998
  ...ctx,
@@ -1974,6 +2019,7 @@ export {
1974
2019
  ERC_SETTING,
1975
2020
  ERC_TESTER,
1976
2021
  INVALID_INPUT,
2022
+ INVALID_PORT_ID_REFERENCED_IN_CONNECTION,
1977
2023
  IR_GRAPH_CONVERTER,
1978
2024
  MakerType,
1979
2025
  NetlistTester,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-circuit/perc",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Programmable Electronic Circuit Check",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "zod": "^4.3.6",
30
- "@modular-circuit/electronics-model": "0.2.2",
30
+ "@modular-circuit/electronics-model": "0.2.3",
31
31
  "@modular-circuit/ir": "0.2.1",
32
32
  "@modular-circuit/utils": "0.2.1"
33
33
  },