@graphty/graph-io 0.3.28 → 0.3.29

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.
Files changed (73) hide show
  1. package/dist/chunks/{choose-DrXtu_96.js → choose-DT5da6OC.js} +2 -2
  2. package/dist/chunks/{choose-DrXtu_96.js.map → choose-DT5da6OC.js.map} +1 -1
  3. package/dist/chunks/{constants-ikG85dT8.js → constants-DowRD9ai.js} +2 -2
  4. package/dist/chunks/{constants-ikG85dT8.js.map → constants-DowRD9ai.js.map} +1 -1
  5. package/dist/chunks/{escape-D1HPTUrP.js → escape-DQC5HWqF.js} +2 -2
  6. package/dist/chunks/{escape-D1HPTUrP.js.map → escape-DQC5HWqF.js.map} +1 -1
  7. package/dist/chunks/{export-CHd4tQE2.js → export-CVi12U7J.js} +81 -60
  8. package/dist/chunks/{export-CHd4tQE2.js.map → export-CVi12U7J.js.map} +1 -1
  9. package/dist/chunks/{exporter-D23CKNqF.js → exporter-C3Pa2PSd.js} +5 -5
  10. package/dist/chunks/{exporter-D23CKNqF.js.map → exporter-C3Pa2PSd.js.map} +1 -1
  11. package/dist/chunks/{exporter-DfWTgrti.js → exporter-CgsO2nSl.js} +4 -4
  12. package/dist/chunks/{exporter-DfWTgrti.js.map → exporter-CgsO2nSl.js.map} +1 -1
  13. package/dist/chunks/{exporter-Cl021ZIE.js → exporter-Cy_1da4c.js} +4 -4
  14. package/dist/chunks/{exporter-Cl021ZIE.js.map → exporter-Cy_1da4c.js.map} +1 -1
  15. package/dist/chunks/{exporter-DhtW6FxK.js → exporter-JubAlNWi.js} +34 -34
  16. package/dist/chunks/exporter-JubAlNWi.js.map +1 -0
  17. package/dist/chunks/{importer-CIAzt-wo.js → importer-BA_hZKo7.js} +4 -4
  18. package/dist/chunks/{importer-CIAzt-wo.js.map → importer-BA_hZKo7.js.map} +1 -1
  19. package/dist/chunks/{importer-BZB7iP9r.js → importer-CDXlxXlS.js} +5 -5
  20. package/dist/chunks/{importer-BZB7iP9r.js.map → importer-CDXlxXlS.js.map} +1 -1
  21. package/dist/chunks/{importer-BVRE--Un.js → importer-DLz2Vb4q.js} +3 -3
  22. package/dist/chunks/{importer-BVRE--Un.js.map → importer-DLz2Vb4q.js.map} +1 -1
  23. package/dist/chunks/{importer-B2W_58pz.js → importer-DVxzzibh.js} +4 -4
  24. package/dist/chunks/{importer-B2W_58pz.js.map → importer-DVxzzibh.js.map} +1 -1
  25. package/dist/chunks/{importer-BSALvkui.js → importer-Dej72hIF.js} +6 -6
  26. package/dist/chunks/{importer-BSALvkui.js.map → importer-Dej72hIF.js.map} +1 -1
  27. package/dist/chunks/{importer-z_FL4VMb.js → importer-lLH9gQF_.js} +5 -5
  28. package/dist/chunks/{importer-z_FL4VMb.js.map → importer-lLH9gQF_.js.map} +1 -1
  29. package/dist/chunks/{importer-DpEW5zeG.js → importer-q-R-Q98w.js} +4 -4
  30. package/dist/chunks/{importer-DpEW5zeG.js.map → importer-q-R-Q98w.js.map} +1 -1
  31. package/dist/chunks/{json-elements-BAmNBZok.js → json-elements-1IUzkRNy.js} +3 -3
  32. package/dist/chunks/{json-elements-BAmNBZok.js.map → json-elements-1IUzkRNy.js.map} +1 -1
  33. package/dist/chunks/{ontology-export-Bab4eUA8.js → ontology-export-b0GLNIj-.js} +2 -2
  34. package/dist/chunks/{ontology-export-Bab4eUA8.js.map → ontology-export-b0GLNIj-.js.map} +1 -1
  35. package/dist/chunks/{records-CdlvL4RO.js → records-CdyqwXeY.js} +2 -2
  36. package/dist/chunks/{records-CdlvL4RO.js.map → records-CdyqwXeY.js.map} +1 -1
  37. package/dist/chunks/{text-DzXjAiTl.js → text-CDgjbkLC.js} +2 -2
  38. package/dist/chunks/{text-DzXjAiTl.js.map → text-CDgjbkLC.js.map} +1 -1
  39. package/dist/csv.js +22 -15
  40. package/dist/csv.js.map +1 -1
  41. package/dist/cx.js +1 -1
  42. package/dist/cx2.js +2 -2
  43. package/dist/cys.js +1 -1
  44. package/dist/dot.js +1 -1
  45. package/dist/gexf.js +2 -2
  46. package/dist/gml.js +3 -3
  47. package/dist/graph-io.js +26 -26
  48. package/dist/graphml.js +2 -2
  49. package/dist/json.js +1 -1
  50. package/dist/neo4j.js +3 -3
  51. package/dist/obo.js +1 -1
  52. package/dist/pajek.js +1 -1
  53. package/dist/src/common/export.d.ts +6 -0
  54. package/dist/src/common/export.d.ts.map +1 -1
  55. package/dist/src/common/export.js +62 -28
  56. package/dist/src/common/export.js.map +1 -1
  57. package/dist/src/formats/csv/exporter.d.ts.map +1 -1
  58. package/dist/src/formats/csv/exporter.js +18 -7
  59. package/dist/src/formats/csv/exporter.js.map +1 -1
  60. package/dist/src/formats/obo/syntax.d.ts +4 -0
  61. package/dist/src/formats/obo/syntax.d.ts.map +1 -1
  62. package/dist/src/formats/obo/syntax.js +35 -31
  63. package/dist/src/formats/obo/syntax.js.map +1 -1
  64. package/dist/src/types.d.ts +6 -0
  65. package/dist/src/types.d.ts.map +1 -1
  66. package/dist/src/types.js.map +1 -1
  67. package/dist/xgmml.js +2 -2
  68. package/package.json +1 -1
  69. package/src/common/export.ts +105 -62
  70. package/src/formats/csv/exporter.ts +19 -15
  71. package/src/formats/obo/syntax.ts +35 -31
  72. package/src/types.ts +6 -0
  73. package/dist/chunks/exporter-DhtW6FxK.js.map +0 -1
@@ -3623,56 +3623,10 @@ function checkCapabilities(snapshot, caps, options, extras = {}) {
3623
3623
  const note = (code, message, column = null, count = null) => {
3624
3624
  notes.push(Object.freeze({ code, message, column, count }));
3625
3625
  };
3626
- const mixed = countMixedEdges(snapshot);
3627
- if (mixed > 0 && !caps.mixedDirection) {
3628
- if (options.onMixedDirection === "error") {
3629
- note(
3630
- LOSS.MIXED_DIRECTION_ERROR,
3631
- `${mixed} undirected edge${plural(mixed)} in a directed graph, and the format holds one direction per file, so the save fails unless onMixedDirection is "directed" or "undirected"`,
3632
- null,
3633
- mixed
3634
- );
3635
- } else {
3636
- note(
3637
- LOSS.MIXED_DIRECTION,
3638
- `${mixed} undirected edge${plural(mixed)} in a directed graph ${agree(mixed, "is", "are")} written as ${options.onMixedDirection} (onMixedDirection), and the format holds one direction per file`,
3639
- null,
3640
- mixed
3641
- );
3642
- }
3643
- }
3644
- if (snapshot.flags.multigraph && !caps.multiEdges) {
3645
- const parallel = countParallelArcs(snapshot);
3646
- note(
3647
- LOSS.MULTI_EDGES,
3648
- `${parallel} parallel edge${plural(parallel)}; the format has no parallel edges`,
3649
- null,
3650
- parallel
3651
- );
3652
- }
3653
- if (snapshot.selfLoopCount > 0 && !caps.selfLoops) {
3654
- note(
3655
- LOSS.SELF_LOOPS,
3656
- `${snapshot.selfLoopCount} self-loop${plural(snapshot.selfLoopCount)}; the format has no self-loops`,
3657
- null,
3658
- snapshot.selfLoopCount
3659
- );
3660
- }
3661
- const edgeIds = snapshot.edges.byRole("id");
3662
- if (caps.edgeIds === "required" && edgeIds === null && snapshot.edgeCount > 0) {
3663
- note(
3664
- LOSS.EDGE_IDS_GENERATED,
3665
- "the format requires edge ids, and the graph has none; the edges are written with generated ids, which read back as a new edge id column",
3666
- null,
3667
- snapshot.edgeCount
3668
- );
3669
- } else if (caps.edgeIds === "none" && edgeIds !== null) {
3670
- note(
3671
- LOSS.EDGE_IDS_DROPPED,
3672
- `edge id column "${edgeIds.meta.name}" cannot be written`,
3673
- edgeIds.meta.name,
3674
- snapshot.edgeCount
3675
- );
3626
+ const tables = extras.tables ?? ["node", "edge", "graph"];
3627
+ const edges = tables.includes("edge");
3628
+ if (edges) {
3629
+ checkEdgeStructure(snapshot, caps, options, note);
3676
3630
  }
3677
3631
  const unrepresentable = countUnrepresentableIds(snapshot, caps.idCharset);
3678
3632
  if (unrepresentable > 0) {
@@ -3716,23 +3670,37 @@ function checkCapabilities(snapshot, caps, options, extras = {}) {
3716
3670
  );
3717
3671
  }
3718
3672
  }
3719
- checkWeights(snapshot, extras, note);
3720
- checkColumns(snapshot.nodes, "node", caps, extras, note);
3721
- checkColumns(snapshot.edges, "edge", caps, extras, note);
3722
- const graphColumns = snapshot.graph.names();
3673
+ if (edges) {
3674
+ checkWeights(snapshot, extras, note);
3675
+ }
3676
+ if (tables.includes("node")) {
3677
+ checkColumns(snapshot.nodes, "node", caps, extras, note);
3678
+ }
3679
+ if (edges) {
3680
+ checkColumns(snapshot.edges, "edge", caps, extras, note);
3681
+ }
3682
+ const graphColumns = tables.includes("graph") ? snapshot.graph.names() : [];
3723
3683
  if (graphColumns.length > 0) {
3724
3684
  if (caps.graphAttributes) {
3725
3685
  checkColumns(snapshot.graph, "graph", caps, extras, note);
3726
3686
  } else {
3727
- note(
3728
- LOSS.GRAPH_ATTRIBUTES,
3729
- `${graphColumns.length} graph attribute${plural(graphColumns.length)} cannot be written`,
3730
- null,
3731
- graphColumns.length
3687
+ notes.push(
3688
+ Object.freeze({
3689
+ code: LOSS.GRAPH_ATTRIBUTES,
3690
+ message: `${graphColumns.length} graph attribute${plural(graphColumns.length)} cannot be written`,
3691
+ column: null,
3692
+ count: graphColumns.length,
3693
+ columns: Object.freeze([...graphColumns])
3694
+ })
3732
3695
  );
3733
3696
  }
3734
3697
  }
3735
3698
  for (const [name, table] of snapshot.extensions) {
3699
+ const [, kind] = name.split(":");
3700
+ const owner = name.startsWith("temporal:") && (kind === "node" || kind === "edge") ? kind : "graph";
3701
+ if (!tables.includes(owner)) {
3702
+ continue;
3703
+ }
3736
3704
  if (name.startsWith("temporal:")) {
3737
3705
  if (caps.temporal !== "dynamic-values") {
3738
3706
  note(
@@ -3753,6 +3721,59 @@ function checkCapabilities(snapshot, caps, options, extras = {}) {
3753
3721
  }
3754
3722
  return notes;
3755
3723
  }
3724
+ function checkEdgeStructure(snapshot, caps, options, note) {
3725
+ const mixed = countMixedEdges(snapshot);
3726
+ if (mixed > 0 && !caps.mixedDirection) {
3727
+ if (options.onMixedDirection === "error") {
3728
+ note(
3729
+ LOSS.MIXED_DIRECTION_ERROR,
3730
+ `${mixed} undirected edge${plural(mixed)} in a directed graph, and the format holds one direction per file, so the save fails unless onMixedDirection is "directed" or "undirected"`,
3731
+ null,
3732
+ mixed
3733
+ );
3734
+ } else {
3735
+ note(
3736
+ LOSS.MIXED_DIRECTION,
3737
+ `${mixed} undirected edge${plural(mixed)} in a directed graph ${agree(mixed, "is", "are")} written as ${options.onMixedDirection} (onMixedDirection), and the format holds one direction per file`,
3738
+ null,
3739
+ mixed
3740
+ );
3741
+ }
3742
+ }
3743
+ if (snapshot.flags.multigraph && !caps.multiEdges) {
3744
+ const parallel = countParallelArcs(snapshot);
3745
+ note(
3746
+ LOSS.MULTI_EDGES,
3747
+ `${parallel} parallel edge${plural(parallel)}; the format has no parallel edges`,
3748
+ null,
3749
+ parallel
3750
+ );
3751
+ }
3752
+ if (snapshot.selfLoopCount > 0 && !caps.selfLoops) {
3753
+ note(
3754
+ LOSS.SELF_LOOPS,
3755
+ `${snapshot.selfLoopCount} self-loop${plural(snapshot.selfLoopCount)}; the format has no self-loops`,
3756
+ null,
3757
+ snapshot.selfLoopCount
3758
+ );
3759
+ }
3760
+ const edgeIds = snapshot.edges.byRole("id");
3761
+ if (caps.edgeIds === "required" && edgeIds === null && snapshot.edgeCount > 0) {
3762
+ note(
3763
+ LOSS.EDGE_IDS_GENERATED,
3764
+ "the format requires edge ids, and the graph has none; the edges are written with generated ids, which read back as a new edge id column",
3765
+ null,
3766
+ snapshot.edgeCount
3767
+ );
3768
+ } else if (caps.edgeIds === "none" && edgeIds !== null) {
3769
+ note(
3770
+ LOSS.EDGE_IDS_DROPPED,
3771
+ `edge id column "${edgeIds.meta.name}" cannot be written`,
3772
+ edgeIds.meta.name,
3773
+ snapshot.edgeCount
3774
+ );
3775
+ }
3776
+ }
3756
3777
  function charsetText(charset, n) {
3757
3778
  const are = agree(n, "is", "are");
3758
3779
  switch (charset) {
@@ -4330,4 +4351,4 @@ export {
4330
4351
  INVALID_ENCODING_CODE as y,
4331
4352
  INVALID_UTF8_CODE as z
4332
4353
  };
4333
- //# sourceMappingURL=export-CHd4tQE2.js.map
4354
+ //# sourceMappingURL=export-CVi12U7J.js.map