@modular-circuit/perc 0.2.4 → 0.2.6

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");
@@ -1174,35 +1182,13 @@ var ParameterPropagationTester = class {
1174
1182
  this.has_passive_port = false;
1175
1183
  }
1176
1184
  run_test(CtorClass, ports) {
1177
- const valid_ports = [];
1178
- for (const p of ports) {
1179
- const id = this.port_id.get(p);
1180
- try {
1181
- const zod_schema = (0, import_electronics_model4.get_port_schema)(p);
1182
- if (!zod_schema) {
1183
- this.ctx.report.erc_errors.push(INVALID_INPUT(id ? [id] : [], `Unknown port type in ${JSON.stringify(p)}`));
1184
- continue;
1185
- }
1186
- valid_ports.push(zod_schema.parse(p));
1187
- } catch (err) {
1188
- if (err instanceof z.ZodError) {
1189
- this.ctx.report.erc_errors.push(
1190
- INVALID_INPUT(id ? [id] : [], {
1191
- input: p,
1192
- issues: err.issues
1193
- })
1194
- );
1195
- }
1196
- }
1197
- }
1198
- if (!valid_ports.length) return;
1199
1185
  return new CtorClass(
1200
1186
  {
1201
1187
  report: this.ctx.report,
1202
1188
  port_id: this.port_id,
1203
1189
  has_passive_port: this.has_passive_port
1204
1190
  },
1205
- valid_ports
1191
+ ports
1206
1192
  ).test();
1207
1193
  }
1208
1194
  visit_cc(cc) {
@@ -1211,14 +1197,38 @@ var ParameterPropagationTester = class {
1211
1197
  }
1212
1198
  this.link_map = (0, import_electronics_model4.gen_link_map)();
1213
1199
  const ports = [];
1200
+ const valid_port = (p) => {
1201
+ try {
1202
+ const zod_schema = (0, import_electronics_model4.get_port_schema)(p.param);
1203
+ if (!zod_schema) {
1204
+ this.ctx.report.erc_errors.push(
1205
+ INVALID_INPUT([p.uuid], {
1206
+ unknown_port_type: p
1207
+ })
1208
+ );
1209
+ return;
1210
+ }
1211
+ p.param = zod_schema.parse(p.param);
1212
+ ports.push(p);
1213
+ } catch (err) {
1214
+ if (err instanceof z.ZodError) {
1215
+ this.ctx.report.erc_errors.push(
1216
+ INVALID_INPUT([p.uuid], {
1217
+ input: p,
1218
+ issues: err.issues
1219
+ })
1220
+ );
1221
+ }
1222
+ }
1223
+ };
1214
1224
  for (const p of cc.nodes) {
1215
1225
  switch (p.type) {
1216
1226
  case import_electronics_model4.ConnectionNodeType.Port: {
1217
- ports.push(p);
1227
+ valid_port(p);
1218
1228
  break;
1219
1229
  }
1220
1230
  case import_electronics_model4.ConnectionNodeType.Power: {
1221
- ports.push({
1231
+ valid_port({
1222
1232
  type: import_electronics_model4.ConnectionNodeType.Port,
1223
1233
  param: p.param,
1224
1234
  label_shapes: {},
@@ -1634,6 +1644,7 @@ var IR_GRAPH_CONVERTER = class {
1634
1644
  this.schematics = {};
1635
1645
  this.bundle_consumed_port_count = {};
1636
1646
  this.bundles = {};
1647
+ this.invalid_port_id = /* @__PURE__ */ new Set();
1637
1648
  this.reporter_context = {
1638
1649
  pin_name_table: {},
1639
1650
  pin_module_name_table: {}
@@ -1649,7 +1660,6 @@ var IR_GRAPH_CONVERTER = class {
1649
1660
  return this.reporter_context;
1650
1661
  }
1651
1662
  convert_to_graph(designs) {
1652
- const errors = [];
1653
1663
  if (Object.keys(designs).length > 1) {
1654
1664
  throw new Error("Multiple designs are not supported");
1655
1665
  }
@@ -1767,7 +1777,18 @@ var IR_GRAPH_CONVERTER = class {
1767
1777
  this.add_node(uuid);
1768
1778
  this.connection_node_map[uuid] = { uuid, type: import_electronics_model8.ConnectionNodeType.Graphics };
1769
1779
  }
1780
+ const validate_wire = (wire) => {
1781
+ let valid = true;
1782
+ for (const id of [wire.from, wire.to]) {
1783
+ if (!(id in this.graph)) {
1784
+ this.invalid_port_id.add(id);
1785
+ valid = false;
1786
+ }
1787
+ }
1788
+ return valid;
1789
+ };
1770
1790
  const handel_wire_instance = (abstract_or_actual_wire, actual_wire_id) => {
1791
+ if (!validate_wire(abstract_or_actual_wire)) return;
1771
1792
  this.add_connection(abstract_or_actual_wire.from, abstract_or_actual_wire.to);
1772
1793
  this.connection_node_map[abstract_or_actual_wire.uuid] = {
1773
1794
  uuid: actual_wire_id,
@@ -1810,7 +1831,7 @@ var IR_GRAPH_CONVERTER = class {
1810
1831
  handel_wire_instance(connection, actual_wire_id);
1811
1832
  }
1812
1833
  }
1813
- return errors.length ? errors : true;
1834
+ return [...this.invalid_port_id];
1814
1835
  }
1815
1836
  add_node(id) {
1816
1837
  if (!this.graph[id]) this.graph[id] = /* @__PURE__ */ new Set();
@@ -1953,15 +1974,15 @@ var ConnectionGraphsBuilder = class {
1953
1974
  };
1954
1975
  async function build_connection_graph(ctx) {
1955
1976
  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(",")}`);
1977
+ const invalid_port_ids = converter.convert_to_graph(ctx.schematics);
1958
1978
  const cc_builder = new ConnectionGraphsBuilder(converter.get_connection_node_map());
1959
1979
  (0, import_utils3.test_connected_components)(converter.get_graph(), [cc_builder]);
1960
1980
  return {
1961
1981
  ...converter.get_report_context(),
1962
1982
  connection_graph: cc_builder.get_connection_graph(),
1963
1983
  cg_schematics: converter.get_schematics(),
1964
- bundle_consume_status: converter.get_bundle_consumed_port_count()
1984
+ bundle_consume_status: converter.get_bundle_consumed_port_count(),
1985
+ invalid_port_ids
1965
1986
  };
1966
1987
  }
1967
1988
 
@@ -1981,6 +2002,9 @@ async function graph_ecr(ctx) {
1981
2002
  console.warn(`Illegal bundle: ${port_id} , no associated labels`);
1982
2003
  }
1983
2004
  }
2005
+ for (const id of connection_graph.invalid_port_ids) {
2006
+ erc_report.erc_errors.push(INVALID_PORT_ID_REFERENCED_IN_CONNECTION([id]));
2007
+ }
1984
2008
  const tester = new ERC_TESTER(
1985
2009
  {
1986
2010
  ...ctx,
@@ -2008,6 +2032,7 @@ async function graph_ecr(ctx) {
2008
2032
  ERC_SETTING,
2009
2033
  ERC_TESTER,
2010
2034
  INVALID_INPUT,
2035
+ INVALID_PORT_ID_REFERENCED_IN_CONNECTION,
2011
2036
  IR_GRAPH_CONVERTER,
2012
2037
  MakerType,
2013
2038
  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 {
@@ -1115,35 +1122,13 @@ var ParameterPropagationTester = class {
1115
1122
  this.has_passive_port = false;
1116
1123
  }
1117
1124
  run_test(CtorClass, ports) {
1118
- const valid_ports = [];
1119
- for (const p of ports) {
1120
- const id = this.port_id.get(p);
1121
- try {
1122
- const zod_schema = get_port_schema(p);
1123
- if (!zod_schema) {
1124
- this.ctx.report.erc_errors.push(INVALID_INPUT(id ? [id] : [], `Unknown port type in ${JSON.stringify(p)}`));
1125
- continue;
1126
- }
1127
- valid_ports.push(zod_schema.parse(p));
1128
- } catch (err) {
1129
- if (err instanceof z.ZodError) {
1130
- this.ctx.report.erc_errors.push(
1131
- INVALID_INPUT(id ? [id] : [], {
1132
- input: p,
1133
- issues: err.issues
1134
- })
1135
- );
1136
- }
1137
- }
1138
- }
1139
- if (!valid_ports.length) return;
1140
1125
  return new CtorClass(
1141
1126
  {
1142
1127
  report: this.ctx.report,
1143
1128
  port_id: this.port_id,
1144
1129
  has_passive_port: this.has_passive_port
1145
1130
  },
1146
- valid_ports
1131
+ ports
1147
1132
  ).test();
1148
1133
  }
1149
1134
  visit_cc(cc) {
@@ -1152,14 +1137,38 @@ var ParameterPropagationTester = class {
1152
1137
  }
1153
1138
  this.link_map = gen_link_map();
1154
1139
  const ports = [];
1140
+ const valid_port = (p) => {
1141
+ try {
1142
+ const zod_schema = get_port_schema(p.param);
1143
+ if (!zod_schema) {
1144
+ this.ctx.report.erc_errors.push(
1145
+ INVALID_INPUT([p.uuid], {
1146
+ unknown_port_type: p
1147
+ })
1148
+ );
1149
+ return;
1150
+ }
1151
+ p.param = zod_schema.parse(p.param);
1152
+ ports.push(p);
1153
+ } catch (err) {
1154
+ if (err instanceof z.ZodError) {
1155
+ this.ctx.report.erc_errors.push(
1156
+ INVALID_INPUT([p.uuid], {
1157
+ input: p,
1158
+ issues: err.issues
1159
+ })
1160
+ );
1161
+ }
1162
+ }
1163
+ };
1155
1164
  for (const p of cc.nodes) {
1156
1165
  switch (p.type) {
1157
1166
  case ConnectionNodeType.Port: {
1158
- ports.push(p);
1167
+ valid_port(p);
1159
1168
  break;
1160
1169
  }
1161
1170
  case ConnectionNodeType.Power: {
1162
- ports.push({
1171
+ valid_port({
1163
1172
  type: ConnectionNodeType.Port,
1164
1173
  param: p.param,
1165
1174
  label_shapes: {},
@@ -1594,6 +1603,7 @@ var IR_GRAPH_CONVERTER = class {
1594
1603
  this.schematics = {};
1595
1604
  this.bundle_consumed_port_count = {};
1596
1605
  this.bundles = {};
1606
+ this.invalid_port_id = /* @__PURE__ */ new Set();
1597
1607
  this.reporter_context = {
1598
1608
  pin_name_table: {},
1599
1609
  pin_module_name_table: {}
@@ -1609,7 +1619,6 @@ var IR_GRAPH_CONVERTER = class {
1609
1619
  return this.reporter_context;
1610
1620
  }
1611
1621
  convert_to_graph(designs) {
1612
- const errors = [];
1613
1622
  if (Object.keys(designs).length > 1) {
1614
1623
  throw new Error("Multiple designs are not supported");
1615
1624
  }
@@ -1727,7 +1736,18 @@ var IR_GRAPH_CONVERTER = class {
1727
1736
  this.add_node(uuid);
1728
1737
  this.connection_node_map[uuid] = { uuid, type: ConnectionNodeType3.Graphics };
1729
1738
  }
1739
+ const validate_wire = (wire) => {
1740
+ let valid = true;
1741
+ for (const id of [wire.from, wire.to]) {
1742
+ if (!(id in this.graph)) {
1743
+ this.invalid_port_id.add(id);
1744
+ valid = false;
1745
+ }
1746
+ }
1747
+ return valid;
1748
+ };
1730
1749
  const handel_wire_instance = (abstract_or_actual_wire, actual_wire_id) => {
1750
+ if (!validate_wire(abstract_or_actual_wire)) return;
1731
1751
  this.add_connection(abstract_or_actual_wire.from, abstract_or_actual_wire.to);
1732
1752
  this.connection_node_map[abstract_or_actual_wire.uuid] = {
1733
1753
  uuid: actual_wire_id,
@@ -1770,7 +1790,7 @@ var IR_GRAPH_CONVERTER = class {
1770
1790
  handel_wire_instance(connection, actual_wire_id);
1771
1791
  }
1772
1792
  }
1773
- return errors.length ? errors : true;
1793
+ return [...this.invalid_port_id];
1774
1794
  }
1775
1795
  add_node(id) {
1776
1796
  if (!this.graph[id]) this.graph[id] = /* @__PURE__ */ new Set();
@@ -1920,15 +1940,15 @@ var ConnectionGraphsBuilder = class {
1920
1940
  };
1921
1941
  async function build_connection_graph(ctx) {
1922
1942
  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(",")}`);
1943
+ const invalid_port_ids = converter.convert_to_graph(ctx.schematics);
1925
1944
  const cc_builder = new ConnectionGraphsBuilder(converter.get_connection_node_map());
1926
1945
  test_connected_components(converter.get_graph(), [cc_builder]);
1927
1946
  return {
1928
1947
  ...converter.get_report_context(),
1929
1948
  connection_graph: cc_builder.get_connection_graph(),
1930
1949
  cg_schematics: converter.get_schematics(),
1931
- bundle_consume_status: converter.get_bundle_consumed_port_count()
1950
+ bundle_consume_status: converter.get_bundle_consumed_port_count(),
1951
+ invalid_port_ids
1932
1952
  };
1933
1953
  }
1934
1954
 
@@ -1948,6 +1968,9 @@ async function graph_ecr(ctx) {
1948
1968
  console.warn(`Illegal bundle: ${port_id} , no associated labels`);
1949
1969
  }
1950
1970
  }
1971
+ for (const id of connection_graph.invalid_port_ids) {
1972
+ erc_report.erc_errors.push(INVALID_PORT_ID_REFERENCED_IN_CONNECTION([id]));
1973
+ }
1951
1974
  const tester = new ERC_TESTER(
1952
1975
  {
1953
1976
  ...ctx,
@@ -1974,6 +1997,7 @@ export {
1974
1997
  ERC_SETTING,
1975
1998
  ERC_TESTER,
1976
1999
  INVALID_INPUT,
2000
+ INVALID_PORT_ID_REFERENCED_IN_CONNECTION,
1977
2001
  IR_GRAPH_CONVERTER,
1978
2002
  MakerType,
1979
2003
  NetlistTester,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-circuit/perc",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Programmable Electronic Circuit Check",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",