@graphty/graph-io 0.2.4 → 0.3.0

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 (180) hide show
  1. package/README.md +29 -7
  2. package/dist/chunks/{escape-DyI8JofU.js → escape-CKied3Ri.js} +16 -10
  3. package/dist/chunks/escape-CKied3Ri.js.map +1 -0
  4. package/dist/chunks/{importer-DbnGYr3_.js → importer-C6QcIRIb.js} +129 -39
  5. package/dist/chunks/importer-C6QcIRIb.js.map +1 -0
  6. package/dist/chunks/{importer-CpCpfbxr.js → importer-D5pAsweZ.js} +136 -31
  7. package/dist/chunks/importer-D5pAsweZ.js.map +1 -0
  8. package/dist/chunks/{importer-GozH8DkN.js → importer-DbMrAR_w.js} +10 -4
  9. package/dist/chunks/importer-DbMrAR_w.js.map +1 -0
  10. package/dist/chunks/{importer-CQnJuWJw.js → importer-DkzjTvHc.js} +82 -40
  11. package/dist/chunks/importer-DkzjTvHc.js.map +1 -0
  12. package/dist/chunks/{records-CGpxszm1.js → records-BKSMowhR.js} +3 -3
  13. package/dist/chunks/{records-CGpxszm1.js.map → records-BKSMowhR.js.map} +1 -1
  14. package/dist/chunks/{text-CajMdVFy.js → text-Dr0Ifpag.js} +2 -2
  15. package/dist/chunks/{text-CajMdVFy.js.map → text-Dr0Ifpag.js.map} +1 -1
  16. package/dist/chunks/{writer-DxSKC7TL.js → writer-BdMak4_J.js} +341 -112
  17. package/dist/chunks/writer-BdMak4_J.js.map +1 -0
  18. package/dist/csv.js +24 -6
  19. package/dist/csv.js.map +1 -1
  20. package/dist/dot.js +1 -1
  21. package/dist/gexf.js +42 -10
  22. package/dist/gexf.js.map +1 -1
  23. package/dist/gml.js +69 -25
  24. package/dist/gml.js.map +1 -1
  25. package/dist/graph-io.js +186 -129
  26. package/dist/graph-io.js.map +1 -1
  27. package/dist/graphml.js +1 -1
  28. package/dist/json.js +1 -1
  29. package/dist/neo4j.js +10 -4
  30. package/dist/neo4j.js.map +1 -1
  31. package/dist/pajek.js +1 -1
  32. package/dist/src/common/codes.d.ts +6 -0
  33. package/dist/src/common/codes.d.ts.map +1 -1
  34. package/dist/src/common/codes.js +6 -0
  35. package/dist/src/common/codes.js.map +1 -1
  36. package/dist/src/common/escape.d.ts +5 -4
  37. package/dist/src/common/escape.d.ts.map +1 -1
  38. package/dist/src/common/escape.js +6 -5
  39. package/dist/src/common/escape.js.map +1 -1
  40. package/dist/src/common/format.d.ts +3 -3
  41. package/dist/src/common/format.js +5 -5
  42. package/dist/src/common/format.js.map +1 -1
  43. package/dist/src/common/input.d.ts +24 -6
  44. package/dist/src/common/input.d.ts.map +1 -1
  45. package/dist/src/common/input.js +259 -23
  46. package/dist/src/common/input.js.map +1 -1
  47. package/dist/src/common/options.d.ts +2 -0
  48. package/dist/src/common/options.d.ts.map +1 -1
  49. package/dist/src/common/options.js +17 -0
  50. package/dist/src/common/options.js.map +1 -1
  51. package/dist/src/common/text.js +4 -4
  52. package/dist/src/common/text.js.map +1 -1
  53. package/dist/src/common/weights.d.ts.map +1 -1
  54. package/dist/src/common/weights.js +8 -0
  55. package/dist/src/common/weights.js.map +1 -1
  56. package/dist/src/common/xml.d.ts +7 -0
  57. package/dist/src/common/xml.d.ts.map +1 -1
  58. package/dist/src/common/xml.js +12 -0
  59. package/dist/src/common/xml.js.map +1 -1
  60. package/dist/src/formats/csv/exporter.d.ts +5 -1
  61. package/dist/src/formats/csv/exporter.d.ts.map +1 -1
  62. package/dist/src/formats/csv/exporter.js +8 -1
  63. package/dist/src/formats/csv/exporter.js.map +1 -1
  64. package/dist/src/formats/csv/importer.d.ts.map +1 -1
  65. package/dist/src/formats/csv/importer.js +1 -0
  66. package/dist/src/formats/csv/importer.js.map +1 -1
  67. package/dist/src/formats/csv/index.d.ts +6 -0
  68. package/dist/src/formats/csv/index.d.ts.map +1 -1
  69. package/dist/src/formats/csv/index.js +7 -1
  70. package/dist/src/formats/csv/index.js.map +1 -1
  71. package/dist/src/formats/csv/records.js +1 -1
  72. package/dist/src/formats/csv/records.js.map +1 -1
  73. package/dist/src/formats/dot/exporter.d.ts +1 -1
  74. package/dist/src/formats/dot/exporter.d.ts.map +1 -1
  75. package/dist/src/formats/dot/exporter.js +3 -3
  76. package/dist/src/formats/dot/exporter.js.map +1 -1
  77. package/dist/src/formats/dot/importer.d.ts +6 -0
  78. package/dist/src/formats/dot/importer.d.ts.map +1 -1
  79. package/dist/src/formats/dot/importer.js +151 -24
  80. package/dist/src/formats/dot/importer.js.map +1 -1
  81. package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
  82. package/dist/src/formats/gexf/exporter.js +32 -7
  83. package/dist/src/formats/gexf/exporter.js.map +1 -1
  84. package/dist/src/formats/gexf/importer.d.ts.map +1 -1
  85. package/dist/src/formats/gexf/importer.js +2 -2
  86. package/dist/src/formats/gexf/importer.js.map +1 -1
  87. package/dist/src/formats/gexf/index.d.ts +6 -0
  88. package/dist/src/formats/gexf/index.d.ts.map +1 -1
  89. package/dist/src/formats/gexf/index.js +7 -1
  90. package/dist/src/formats/gexf/index.js.map +1 -1
  91. package/dist/src/formats/gml/importer.d.ts +2 -2
  92. package/dist/src/formats/gml/importer.d.ts.map +1 -1
  93. package/dist/src/formats/gml/importer.js +66 -25
  94. package/dist/src/formats/gml/importer.js.map +1 -1
  95. package/dist/src/formats/gml/index.d.ts +7 -1
  96. package/dist/src/formats/gml/index.d.ts.map +1 -1
  97. package/dist/src/formats/gml/index.js +8 -2
  98. package/dist/src/formats/gml/index.js.map +1 -1
  99. package/dist/src/formats/graphml/constants.d.ts +6 -0
  100. package/dist/src/formats/graphml/constants.d.ts.map +1 -1
  101. package/dist/src/formats/graphml/constants.js +7 -1
  102. package/dist/src/formats/graphml/constants.js.map +1 -1
  103. package/dist/src/formats/graphml/importer.d.ts.map +1 -1
  104. package/dist/src/formats/graphml/importer.js +2 -2
  105. package/dist/src/formats/graphml/importer.js.map +1 -1
  106. package/dist/src/formats/json/exporter.d.ts.map +1 -1
  107. package/dist/src/formats/json/exporter.js +14 -5
  108. package/dist/src/formats/json/exporter.js.map +1 -1
  109. package/dist/src/formats/json/importer.d.ts +8 -0
  110. package/dist/src/formats/json/importer.d.ts.map +1 -1
  111. package/dist/src/formats/json/importer.js +84 -37
  112. package/dist/src/formats/json/importer.js.map +1 -1
  113. package/dist/src/formats/neo4j/importer.js +1 -1
  114. package/dist/src/formats/neo4j/importer.js.map +1 -1
  115. package/dist/src/formats/neo4j/index.d.ts +6 -0
  116. package/dist/src/formats/neo4j/index.d.ts.map +1 -1
  117. package/dist/src/formats/neo4j/index.js +7 -1
  118. package/dist/src/formats/neo4j/index.js.map +1 -1
  119. package/dist/src/formats/pajek/exporter.d.ts +2 -0
  120. package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
  121. package/dist/src/formats/pajek/exporter.js +13 -2
  122. package/dist/src/formats/pajek/exporter.js.map +1 -1
  123. package/dist/src/formats/pajek/importer.d.ts +8 -2
  124. package/dist/src/formats/pajek/importer.d.ts.map +1 -1
  125. package/dist/src/formats/pajek/importer.js +122 -26
  126. package/dist/src/formats/pajek/importer.js.map +1 -1
  127. package/dist/src/index.d.ts +1 -1
  128. package/dist/src/index.d.ts.map +1 -1
  129. package/dist/src/index.js +1 -1
  130. package/dist/src/index.js.map +1 -1
  131. package/dist/src/registry.d.ts +26 -0
  132. package/dist/src/registry.d.ts.map +1 -1
  133. package/dist/src/registry.js +101 -35
  134. package/dist/src/registry.js.map +1 -1
  135. package/dist/src/sniff.d.ts +1 -1
  136. package/dist/src/sniff.d.ts.map +1 -1
  137. package/dist/src/sniff.js +6 -1
  138. package/dist/src/sniff.js.map +1 -1
  139. package/dist/src/types.d.ts +22 -3
  140. package/dist/src/types.d.ts.map +1 -1
  141. package/dist/src/types.js.map +1 -1
  142. package/package.json +4 -3
  143. package/src/common/codes.ts +9 -0
  144. package/src/common/escape.ts +6 -5
  145. package/src/common/format.ts +5 -5
  146. package/src/common/input.ts +293 -22
  147. package/src/common/options.ts +24 -0
  148. package/src/common/text.ts +4 -4
  149. package/src/common/weights.ts +9 -0
  150. package/src/common/xml.ts +14 -0
  151. package/src/formats/csv/exporter.ts +12 -1
  152. package/src/formats/csv/importer.ts +1 -0
  153. package/src/formats/csv/index.ts +9 -0
  154. package/src/formats/csv/records.ts +1 -1
  155. package/src/formats/dot/exporter.ts +3 -3
  156. package/src/formats/dot/importer.ts +172 -32
  157. package/src/formats/gexf/exporter.ts +38 -7
  158. package/src/formats/gexf/importer.ts +12 -2
  159. package/src/formats/gexf/index.ts +9 -0
  160. package/src/formats/gml/importer.ts +75 -22
  161. package/src/formats/gml/index.ts +10 -1
  162. package/src/formats/graphml/constants.ts +9 -0
  163. package/src/formats/graphml/importer.ts +9 -2
  164. package/src/formats/json/exporter.ts +14 -5
  165. package/src/formats/json/importer.ts +104 -36
  166. package/src/formats/neo4j/importer.ts +1 -1
  167. package/src/formats/neo4j/index.ts +9 -0
  168. package/src/formats/pajek/exporter.ts +19 -2
  169. package/src/formats/pajek/importer.ts +145 -28
  170. package/src/index.ts +1 -0
  171. package/src/registry.ts +131 -40
  172. package/src/sniff.ts +6 -1
  173. package/src/types.ts +26 -3
  174. package/dist/chunks/escape-DyI8JofU.js.map +0 -1
  175. package/dist/chunks/importer-CQnJuWJw.js.map +0 -1
  176. package/dist/chunks/importer-CpCpfbxr.js.map +0 -1
  177. package/dist/chunks/importer-DbnGYr3_.js.map +0 -1
  178. package/dist/chunks/importer-GozH8DkN.js.map +0 -1
  179. package/dist/chunks/writer-DxSKC7TL.js.map +0 -1
  180. package/dist/tsconfig.build.tsbuildinfo +0 -1
package/dist/csv.js CHANGED
@@ -1,8 +1,8 @@
1
- import { aY as DICT_SAMPLE_ROWS, aX as DictHeuristic, V as ROLE_TAKEN_CODE$1, n as ID_MERGED_CODE$1, i as DUPLICATE_EDGE_ID_CODE$1, k as DUPLICATE_NODE_CODE$1, w as MISSING_ID_CODE$1, M as MISSING_ENDPOINT_CODE$1, m as EMPTY_INPUT_CODE$1, aC as resolveImportOptions, I as ImportReportBuilder, az as reportSinkOptions, aA as reportUnusedOptions, l as DirectionResolver, s as IdCoercer, a as throwIfAborted, ax as parseWeightText, aI as uniqueColumnName, S as RENAMED_CODE, af as declareResolved, a9 as capabilities, L as LOSS, au as joinText, ah as encodeChunks, aa as checkCapabilities, aB as resolveExportOptions, aw as pairFolding, aG as countMixedEdges, ai as explicitWeights, aV as joinListText, an as formatInteger, aj as formatDecimal, a8 as canonicalId, x as MIXED_DIRECTION_CODE, g as DIRECTION_FORCED_CODE, h as DIRECTION_REFUSED_CODE, W as SINK_OPTION_CODE, J as OPTION_IGNORED_CODE, C as COLUMN_RENAMED_CODE, r as INVALID_UTF8_CODE } from "./chunks/writer-DxSKC7TL.js";
2
- import { i as inferTextDtype, T as TextCellWriter, p as parseTextCell, W as WIDENING_UNSUPPORTED_CODE } from "./chunks/text-CajMdVFy.js";
1
+ import { a$ as DICT_SAMPLE_ROWS, a_ as DictHeuristic, X as ROLE_TAKEN_CODE$1, o as ID_MERGED_CODE$1, i as DUPLICATE_EDGE_ID_CODE$1, k as DUPLICATE_NODE_CODE$1, y as MISSING_ID_CODE$1, M as MISSING_ENDPOINT_CODE$1, m as EMPTY_INPUT_CODE$1, aF as resolveImportOptions, I as ImportReportBuilder, aC as reportSinkOptions, aD as reportUnusedOptions, l as DirectionResolver, v as IdCoercer, a as throwIfAborted, aA as parseWeightText, aL as uniqueColumnName, U as RENAMED_CODE, ai as declareResolved, ac as capabilities, L as LOSS, ax as joinText, ak as encodeChunks, ad as checkCapabilities, aE as resolveExportOptions, az as pairFolding, aJ as countMixedEdges, al as explicitWeights, aY as joinListText, aq as formatInteger, am as formatDecimal, ab as canonicalId, z as MIXED_DIRECTION_CODE, g as DIRECTION_FORCED_CODE, h as DIRECTION_REFUSED_CODE, Y as SINK_OPTION_CODE, P as OPTION_IGNORED_CODE, C as COLUMN_RENAMED_CODE, a5 as UNKNOWN_ENCODING_CODE, n as ENCODING_FALLBACK_CODE, s as INVALID_ENCODING_CODE, u as INVALID_UTF8_CODE } from "./chunks/writer-BdMak4_J.js";
2
+ import { i as inferTextDtype, T as TextCellWriter, p as parseTextCell, W as WIDENING_UNSUPPORTED_CODE } from "./chunks/text-Dr0Ifpag.js";
3
3
  import { GraphFormatError, INVALID_INDEX } from "@graphty/graph-format";
4
- import { s as sniffNewline, a as sniffDelimiter, C as CsvRecordReader, B as BAD_QUOTE_CODE, U as UNCLOSED_QUOTE_CODE } from "./chunks/records-CGpxszm1.js";
5
- import { m as quoteCsvCell } from "./chunks/escape-DyI8JofU.js";
4
+ import { s as sniffNewline, a as sniffDelimiter, C as CsvRecordReader, B as BAD_QUOTE_CODE, U as UNCLOSED_QUOTE_CODE } from "./chunks/records-BKSMowhR.js";
5
+ import { n as quoteCsvCell } from "./chunks/escape-CKied3Ri.js";
6
6
  const SOURCE_NAMES = Object.freeze([
7
7
  "source",
8
8
  "src",
@@ -440,7 +440,8 @@ class TableReader {
440
440
  delimiter: state.csv.delimiter,
441
441
  comments: COMMENT_CHARS,
442
442
  signal: state.common.signal,
443
- onProgress: progress ? state.common.onProgress : null
443
+ onProgress: progress ? state.common.onProgress : null,
444
+ encoding: state.common.encoding
444
445
  };
445
446
  this.reader = new CsvRecordReader(input, state.report, readerOptions);
446
447
  }
@@ -1041,7 +1042,11 @@ const CSV_LOSS = Object.freeze({
1041
1042
  ID_TEXT_COLLISION: LOSS.ID_TEXT_COLLISION,
1042
1043
  /** Ids whose text reads back as the other type under the canonical rule. */
1043
1044
  ID_TEXT_TYPE: LOSS.ID_TEXT_TYPE,
1044
- /** The generic dialect has no direction column; an undirected or mixed graph reads back as directed. */
1045
+ /**
1046
+ * The generic dialect has no direction column; an undirected or mixed graph reads back as
1047
+ * directed. The Gephi dialect loses the direction of an undirected graph without edges (no
1048
+ * row carries a Type cell).
1049
+ */
1045
1050
  DIRECTION_DROPPED: "W_CSV_DIRECTION_DROPPED",
1046
1051
  /** Mutual pairs are written as two directed rows. */
1047
1052
  MUTUAL_EXPANDED: LOSS.MUTUAL_EXPANDED,
@@ -1267,6 +1272,13 @@ function planExport(snapshot, options, values) {
1267
1272
  mixed
1268
1273
  );
1269
1274
  }
1275
+ } else if (csv.table === "edges" && !snapshot.directed && edgeRows.length === 0) {
1276
+ note(
1277
+ CSV_LOSS.DIRECTION_DROPPED,
1278
+ "the direction lives in the Type cell of each edge row; an undirected graph without edges reads back as directed",
1279
+ null,
1280
+ 0
1281
+ );
1270
1282
  }
1271
1283
  if (folding.mutualCount > 0) {
1272
1284
  note(
@@ -1649,6 +1661,12 @@ const CSV_ISSUE = Object.freeze({
1649
1661
  EMPTY_INPUT: EMPTY_INPUT_CODE,
1650
1662
  /** The input holds invalid UTF-8 (fatal). */
1651
1663
  INVALID_UTF8: INVALID_UTF8_CODE,
1664
+ /** Invalid bytes in the encoding a BOM, a declaration or the encoding option chose (fatal). */
1665
+ INVALID_ENCODING: INVALID_ENCODING_CODE,
1666
+ /** Bytes that are not UTF-8 and declare no encoding were read as windows-1252. */
1667
+ ENCODING_FALLBACK: ENCODING_FALLBACK_CODE,
1668
+ /** A declared encoding the platform cannot decode was ignored. */
1669
+ UNKNOWN_ENCODING: UNKNOWN_ENCODING_CODE,
1652
1670
  /** The header names neither endpoint columns nor an id column (fatal). */
1653
1671
  NO_ENDPOINT_COLUMNS: NO_ENDPOINT_COLUMNS_CODE,
1654
1672
  /** A node table without an id column (fatal). */