@graphty/graph-io 0.3.27 → 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 (109) 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-CVi12U7J.js.map +1 -0
  9. package/dist/chunks/{exporter-D23CKNqF.js → exporter-C3Pa2PSd.js} +5 -5
  10. package/dist/chunks/exporter-C3Pa2PSd.js.map +1 -0
  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-IHv4nkCm.js → exporter-Cy_1da4c.js} +72 -48
  14. package/dist/chunks/exporter-Cy_1da4c.js.map +1 -0
  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-B1wmPQjr.js → importer-CDXlxXlS.js} +35 -9
  20. package/dist/chunks/importer-CDXlxXlS.js.map +1 -0
  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-Dej72hIF.js.map +1 -0
  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 +33 -16
  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 +18 -9
  47. package/dist/gml.js.map +1 -1
  48. package/dist/graph-io.js +26 -26
  49. package/dist/graph-io.js.map +1 -1
  50. package/dist/graphml.js +2 -2
  51. package/dist/json.js +1 -1
  52. package/dist/neo4j.js +3 -3
  53. package/dist/obo.js +1 -1
  54. package/dist/pajek.js +1 -1
  55. package/dist/src/common/declared-types.d.ts.map +1 -1
  56. package/dist/src/common/declared-types.js.map +1 -1
  57. package/dist/src/common/export.d.ts +6 -0
  58. package/dist/src/common/export.d.ts.map +1 -1
  59. package/dist/src/common/export.js +62 -28
  60. package/dist/src/common/export.js.map +1 -1
  61. package/dist/src/common/zip.js.map +1 -1
  62. package/dist/src/formats/csv/exporter.d.ts.map +1 -1
  63. package/dist/src/formats/csv/exporter.js +18 -7
  64. package/dist/src/formats/csv/exporter.js.map +1 -1
  65. package/dist/src/formats/csv/importer.d.ts.map +1 -1
  66. package/dist/src/formats/csv/importer.js +20 -2
  67. package/dist/src/formats/csv/importer.js.map +1 -1
  68. package/dist/src/formats/cx2/exporter.d.ts.map +1 -1
  69. package/dist/src/formats/cx2/exporter.js +84 -33
  70. package/dist/src/formats/cx2/exporter.js.map +1 -1
  71. package/dist/src/formats/dot/exporter.js +30 -4
  72. package/dist/src/formats/dot/exporter.js.map +1 -1
  73. package/dist/src/formats/dot/importer.js.map +1 -1
  74. package/dist/src/formats/gml/exporter.d.ts.map +1 -1
  75. package/dist/src/formats/gml/exporter.js +23 -6
  76. package/dist/src/formats/gml/exporter.js.map +1 -1
  77. package/dist/src/formats/obo/syntax.d.ts +4 -0
  78. package/dist/src/formats/obo/syntax.d.ts.map +1 -1
  79. package/dist/src/formats/obo/syntax.js +35 -31
  80. package/dist/src/formats/obo/syntax.js.map +1 -1
  81. package/dist/src/formats/pajek/importer.js.map +1 -1
  82. package/dist/src/registry.d.ts.map +1 -1
  83. package/dist/src/registry.js.map +1 -1
  84. package/dist/src/sniff.d.ts.map +1 -1
  85. package/dist/src/sniff.js.map +1 -1
  86. package/dist/src/types.d.ts +6 -0
  87. package/dist/src/types.d.ts.map +1 -1
  88. package/dist/xgmml.js +2 -2
  89. package/package.json +2 -2
  90. package/src/common/declared-types.ts +1 -10
  91. package/src/common/export.ts +105 -62
  92. package/src/common/zip.ts +1 -1
  93. package/src/formats/csv/exporter.ts +19 -15
  94. package/src/formats/csv/importer.ts +21 -2
  95. package/src/formats/cx2/exporter.ts +123 -49
  96. package/src/formats/dot/exporter.ts +37 -4
  97. package/src/formats/dot/importer.ts +1 -1
  98. package/src/formats/gml/exporter.ts +24 -6
  99. package/src/formats/obo/syntax.ts +35 -31
  100. package/src/formats/pajek/importer.ts +1 -1
  101. package/src/registry.ts +9 -10
  102. package/src/sniff.ts +2 -21
  103. package/src/types.ts +7 -7
  104. package/dist/chunks/export-CHd4tQE2.js.map +0 -1
  105. package/dist/chunks/exporter-D23CKNqF.js.map +0 -1
  106. package/dist/chunks/exporter-DhtW6FxK.js.map +0 -1
  107. package/dist/chunks/exporter-IHv4nkCm.js.map +0 -1
  108. package/dist/chunks/importer-B1wmPQjr.js.map +0 -1
  109. package/dist/chunks/importer-BSALvkui.js.map +0 -1
package/dist/csv.js CHANGED
@@ -1,8 +1,8 @@
1
- import { b as plural, bV as DICT_SAMPLE_ROWS, ac as DictHeuristic, R as ROLE_TAKEN_CODE$1, I as ID_MERGED_CODE$1, m as DUPLICATE_EDGE_ID_CODE$1, n as DUPLICATE_NODE_CODE$1, t as MISSING_ID_CODE$1, s as MISSING_ENDPOINT_CODE$1, E as EMPTY_INPUT_CODE$1, al as resolveImportOptions, a8 as ImportReportBuilder, ao as reportSinkOptions, an as reportUnusedOptions, aq as DirectionResolver, ar as IdCoercer, am as throwIfAborted, O as OPTION_IGNORED_CODE, aL as parseWeightText, a0 as uniqueColumnName, ay as RENAMED_CODE, a1 as declareResolved, c as capabilities, L as LOSS, a as checkCapabilities, r as resolveExportOptions, p as pairFolding, bE as countMixedEdges, $ as agree, e as explicitWeights, b$ as otherFormatDialect, bT as joinListText, aG as formatInteger, aF as formatDecimal, aH as canonicalId, M as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, d as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, C as COLUMN_RENAMED_CODE, w as UNKNOWN_ENCODING_CODE, x as ENCODING_FALLBACK_CODE, y as INVALID_ENCODING_CODE, z as INVALID_UTF8_CODE, P as PRECISION_CODE, F as ELEMENT_ISSUE, G as INPUT_ISSUE } from "./chunks/export-CHd4tQE2.js";
2
- import { i as inferTextDtype, T as TextCellWriter, p as parseTextCell, W as WIDENING_UNSUPPORTED_CODE } from "./chunks/text-DzXjAiTl.js";
1
+ import { b as plural, bV as DICT_SAMPLE_ROWS, ac as DictHeuristic, R as ROLE_TAKEN_CODE$1, I as ID_MERGED_CODE$1, m as DUPLICATE_EDGE_ID_CODE$1, n as DUPLICATE_NODE_CODE$1, t as MISSING_ID_CODE$1, s as MISSING_ENDPOINT_CODE$1, E as EMPTY_INPUT_CODE$1, al as resolveImportOptions, a8 as ImportReportBuilder, ao as reportSinkOptions, an as reportUnusedOptions, aq as DirectionResolver, ar as IdCoercer, am as throwIfAborted, O as OPTION_IGNORED_CODE, aL as parseWeightText, a0 as uniqueColumnName, ay as RENAMED_CODE, a1 as declareResolved, c as capabilities, L as LOSS, a as checkCapabilities, r as resolveExportOptions, p as pairFolding, bE as countMixedEdges, $ as agree, e as explicitWeights, b$ as otherFormatDialect, bT as joinListText, aG as formatInteger, aF as formatDecimal, aH as canonicalId, M as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, d as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, C as COLUMN_RENAMED_CODE, w as UNKNOWN_ENCODING_CODE, x as ENCODING_FALLBACK_CODE, y as INVALID_ENCODING_CODE, z as INVALID_UTF8_CODE, P as PRECISION_CODE, F as ELEMENT_ISSUE, G as INPUT_ISSUE } from "./chunks/export-CVi12U7J.js";
2
+ import { i as inferTextDtype, T as TextCellWriter, p as parseTextCell, W as WIDENING_UNSUPPORTED_CODE } from "./chunks/text-CDgjbkLC.js";
3
3
  import { GraphFormatError, INVALID_INDEX } from "@graphty/graph-format";
4
- import { s as stripLeadingComments, a as sniffNewline, b as sniffDelimiter, D as DELIMITER_CANDIDATES, c as checkRecordSyntax, C as CsvRecordReader, d as splitRecords, B as BAD_QUOTE_CODE, U as UNCLOSED_QUOTE_CODE } from "./chunks/records-CdlvL4RO.js";
5
- import { o as quoteCsvCell } from "./chunks/escape-D1HPTUrP.js";
4
+ import { s as stripLeadingComments, a as sniffNewline, b as sniffDelimiter, D as DELIMITER_CANDIDATES, c as checkRecordSyntax, C as CsvRecordReader, d as splitRecords, B as BAD_QUOTE_CODE, U as UNCLOSED_QUOTE_CODE } from "./chunks/records-CdyqwXeY.js";
5
+ import { o as quoteCsvCell } from "./chunks/escape-DQC5HWqF.js";
6
6
  import { j as joinText, e as encodeChunks } from "./chunks/writer-DxjgHwSe.js";
7
7
  const SOURCE_NAMES = Object.freeze([
8
8
  "source",
@@ -1606,7 +1606,7 @@ function sniff(head) {
1606
1606
  label = "utf-16be";
1607
1607
  }
1608
1608
  const body = stripLeadingComments(new TextDecoder(label).decode(head.subarray(0, HEAD_BYTES)), COMMENT_CHARS);
1609
- if (body.trim().length === 0 || OTHER_FORMATS.some((r) => r.test(body))) {
1609
+ if (body.trim().length === 0 || hasControlCharacter(body) || OTHER_FORMATS.some((r) => r.test(body))) {
1610
1610
  return 0;
1611
1611
  }
1612
1612
  const newline = sniffNewline(body);
@@ -1628,6 +1628,16 @@ function sniff(head) {
1628
1628
  }
1629
1629
  return looksLikeProse(body, newline, delimiter) ? 0 : 0.3;
1630
1630
  }
1631
+ function hasControlCharacter(text) {
1632
+ const last = text.length - 1;
1633
+ for (let i = 0; i <= last; i++) {
1634
+ const c = text.codePointAt(i) ?? 0;
1635
+ if (c < 32 && c !== 9 && c !== 10 && c !== 13 && !(c === 26 && i === last)) {
1636
+ return true;
1637
+ }
1638
+ }
1639
+ return false;
1640
+ }
1631
1641
  const SENTENCE = /[A-Za-z]{2}[.!?](?:\s|$)/;
1632
1642
  function looksLikeProse(body, newline, delimiter) {
1633
1643
  const lines2 = body.split(newline).filter((l) => l.trim() !== "");
@@ -1901,15 +1911,18 @@ function cellText(column, row) {
1901
1911
  }
1902
1912
  }
1903
1913
  }
1904
- function nodeTableNote(names, table, note) {
1914
+ function nodeTableNote(names, table, notes) {
1905
1915
  const written = names.length;
1906
1916
  if (written > 0) {
1907
1917
  const shown = names.slice(0, 3).map((n) => JSON.stringify(n)).join(", ") + (written > 3 ? ", ..." : "");
1908
- note(
1909
- CSV_LOSS.NODE_TABLE,
1910
- `the ${table === "adjacency" ? "adjacency" : "edge"} table has no room for node attributes: ${written} node column${plural(written)} (${shown}) ${agree(written, "is", "are")} written only by a second export with table: "nodes"`,
1911
- null,
1912
- written
1918
+ notes.push(
1919
+ Object.freeze({
1920
+ code: CSV_LOSS.NODE_TABLE,
1921
+ message: `the ${table === "adjacency" ? "adjacency" : "edge"} table has no room for node attributes: ${written} node column${plural(written)} (${shown}) ${agree(written, "is", "are")} written only by a second export with table: "nodes"`,
1922
+ column: null,
1923
+ count: written,
1924
+ columns: Object.freeze([...names])
1925
+ })
1913
1926
  );
1914
1927
  }
1915
1928
  }
@@ -1970,7 +1983,7 @@ function planExport(snapshot, options, values) {
1970
1983
  edgeRows.push(e);
1971
1984
  }
1972
1985
  }
1973
- if (csv.dialect.type === null || csv.table === "adjacency") {
1986
+ if (csv.table !== "nodes" && (csv.dialect.type === null || csv.table === "adjacency")) {
1974
1987
  const where = csv.table === "adjacency" ? "an adjacency table" : "the generic dialect";
1975
1988
  const mixed = countMixedEdges(snapshot);
1976
1989
  if (!snapshot.directed) {
@@ -1996,7 +2009,7 @@ function planExport(snapshot, options, values) {
1996
2009
  0
1997
2010
  );
1998
2011
  }
1999
- if (folding.mutualCount > 0) {
2012
+ if (folding.mutualCount > 0 && csv.table !== "nodes") {
2000
2013
  note(
2001
2014
  CSV_LOSS.MUTUAL_EXPANDED,
2002
2015
  `${folding.mutualCount} mutual pair${plural(folding.mutualCount)} ${agree(folding.mutualCount, "is", "are")} written as two directed rows; the mutual mark is lost`,
@@ -2067,7 +2080,7 @@ function planExport(snapshot, options, values) {
2067
2080
  nodeTableNote(
2068
2081
  [...nodeLabel === null ? [] : [nodeLabel.meta.name], ...nodeColumns.map((c) => c.column.meta.name)],
2069
2082
  csv.table,
2070
- note
2083
+ notes
2071
2084
  );
2072
2085
  }
2073
2086
  return {
@@ -2453,7 +2466,8 @@ function headerlessNotes(plan) {
2453
2466
  code: CSV_LOSS.HEADERLESS,
2454
2467
  message: `without a header the file is read back by position (${csv.table === "nodes" ? "id" : "source, target, weight"}, then unnamed columns), so ${names.length === 1 ? "the column" : "the columns"} ${shown} ${agree(names.length, "reads", "read")} back unnamed or in another column's place; write the header, or for an edge list pass dialect: "generic" and write only source, target and weight`,
2455
2468
  column: null,
2456
- count: names.length
2469
+ count: names.length,
2470
+ columns: Object.freeze([...names])
2457
2471
  })
2458
2472
  ];
2459
2473
  }
@@ -2482,7 +2496,10 @@ function headerlessEdgeColumns(plan) {
2482
2496
  function check(snapshot, options) {
2483
2497
  const plan = planExport(snapshot, options, true);
2484
2498
  return Object.freeze([
2485
- ...checkCapabilities(snapshot, CSV_CAPABILITIES, plan.common, { roles: KEPT_ROLES }),
2499
+ ...checkCapabilities(snapshot, CSV_CAPABILITIES, plan.common, {
2500
+ roles: KEPT_ROLES,
2501
+ ...plan.csv.table === "nodes" ? { tables: ["node"] } : {}
2502
+ }),
2486
2503
  ...plan.notes,
2487
2504
  ...headerlessNotes(plan)
2488
2505
  ]);