@graphty/graph-io 0.3.2 → 0.3.4
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/README.md +17 -4
- package/dist/chunks/{escape-CKied3Ri.js → escape-DXbOoLKl.js} +23 -5
- package/dist/chunks/{escape-CKied3Ri.js.map → escape-DXbOoLKl.js.map} +1 -1
- package/dist/chunks/{importer-DbMrAR_w.js → importer-B9qF4e32.js} +37 -2
- package/dist/chunks/importer-B9qF4e32.js.map +1 -0
- package/dist/chunks/{importer-DkzjTvHc.js → importer-BOxwmef_.js} +360 -16
- package/dist/chunks/importer-BOxwmef_.js.map +1 -0
- package/dist/chunks/{importer-D5pAsweZ.js → importer-C2caVvl6.js} +2 -2
- package/dist/chunks/{importer-D5pAsweZ.js.map → importer-C2caVvl6.js.map} +1 -1
- package/dist/chunks/{importer-C6QcIRIb.js → importer-xoHpRG5x.js} +2 -2
- package/dist/chunks/{importer-C6QcIRIb.js.map → importer-xoHpRG5x.js.map} +1 -1
- package/dist/csv.js +1 -1
- package/dist/dot.js +1 -1
- package/dist/gexf.js +1 -1
- package/dist/gml.js +34 -13
- package/dist/gml.js.map +1 -1
- package/dist/graph-io.js +9 -9
- package/dist/graph-io.js.map +1 -1
- package/dist/graphml.js +1 -1
- package/dist/json.js +1 -1
- package/dist/neo4j.js +60 -2
- package/dist/neo4j.js.map +1 -1
- package/dist/pajek.js +1 -1
- package/dist/src/common/escape.d.ts +4 -2
- package/dist/src/common/escape.d.ts.map +1 -1
- package/dist/src/common/escape.js +31 -5
- package/dist/src/common/escape.js.map +1 -1
- package/dist/src/formats/gml/importer.d.ts +2 -0
- package/dist/src/formats/gml/importer.d.ts.map +1 -1
- package/dist/src/formats/gml/importer.js +19 -5
- package/dist/src/formats/gml/importer.js.map +1 -1
- package/dist/src/formats/gml/index.d.ts +2 -0
- package/dist/src/formats/gml/index.d.ts.map +1 -1
- package/dist/src/formats/gml/index.js +3 -1
- package/dist/src/formats/gml/index.js.map +1 -1
- package/dist/src/formats/gml/syntax.d.ts +2 -0
- package/dist/src/formats/gml/syntax.d.ts.map +1 -1
- package/dist/src/formats/gml/syntax.js +8 -1
- package/dist/src/formats/gml/syntax.js.map +1 -1
- package/dist/src/formats/graphml/constants.d.ts +4 -0
- package/dist/src/formats/graphml/constants.d.ts.map +1 -1
- package/dist/src/formats/graphml/constants.js +4 -0
- package/dist/src/formats/graphml/constants.js.map +1 -1
- package/dist/src/formats/graphml/importer.d.ts.map +1 -1
- package/dist/src/formats/graphml/importer.js +28 -0
- package/dist/src/formats/graphml/importer.js.map +1 -1
- package/dist/src/formats/json/dialect.d.ts +21 -4
- package/dist/src/formats/json/dialect.d.ts.map +1 -1
- package/dist/src/formats/json/dialect.js +29 -4
- package/dist/src/formats/json/dialect.js.map +1 -1
- package/dist/src/formats/json/exporter.d.ts.map +1 -1
- package/dist/src/formats/json/exporter.js +27 -7
- package/dist/src/formats/json/exporter.js.map +1 -1
- package/dist/src/formats/json/importer.d.ts +19 -4
- package/dist/src/formats/json/importer.d.ts.map +1 -1
- package/dist/src/formats/json/importer.js +369 -8
- package/dist/src/formats/json/importer.js.map +1 -1
- package/dist/src/formats/json/index.d.ts +1 -1
- package/dist/src/formats/json/index.d.ts.map +1 -1
- package/dist/src/formats/json/index.js +1 -1
- package/dist/src/formats/json/index.js.map +1 -1
- package/dist/src/formats/neo4j/importer.d.ts +5 -0
- package/dist/src/formats/neo4j/importer.d.ts.map +1 -1
- package/dist/src/formats/neo4j/importer.js +57 -1
- package/dist/src/formats/neo4j/importer.js.map +1 -1
- package/dist/src/formats/neo4j/index.d.ts +2 -0
- package/dist/src/formats/neo4j/index.d.ts.map +1 -1
- package/dist/src/formats/neo4j/index.js +3 -1
- package/dist/src/formats/neo4j/index.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/sniff.d.ts +3 -3
- package/dist/src/sniff.d.ts.map +1 -1
- package/dist/src/sniff.js.map +1 -1
- package/package.json +2 -2
- package/src/common/escape.ts +5 -4
- package/src/formats/json/dialect.ts +40 -6
- package/src/formats/json/exporter.ts +28 -7
- package/src/formats/json/importer.ts +411 -21
- package/src/formats/json/index.ts +7 -1
- package/src/formats/neo4j/exporter.ts +43 -6
- package/src/formats/neo4j/importer.ts +56 -11
- package/src/formats/neo4j/index.ts +10 -3
- package/src/formats/pajek/exporter.ts +3 -1
- package/src/formats/pajek/importer.ts +284 -60
- package/src/formats/pajek/syntax.ts +98 -12
- package/src/index.ts +2 -0
- package/src/sniff.ts +3 -3
- package/dist/chunks/importer-DbMrAR_w.js.map +0 -1
- package/dist/chunks/importer-DkzjTvHc.js.map +0 -1
package/dist/csv.js
CHANGED
|
@@ -2,7 +2,7 @@ import { a$ as DICT_SAMPLE_ROWS, a_ as DictHeuristic, X as ROLE_TAKEN_CODE$1, o
|
|
|
2
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
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-
|
|
5
|
+
import { n as quoteCsvCell } from "./chunks/escape-DXbOoLKl.js";
|
|
6
6
|
const SOURCE_NAMES = Object.freeze([
|
|
7
7
|
"source",
|
|
8
8
|
"src",
|
package/dist/dot.js
CHANGED
package/dist/gexf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { aM as TIME_TEXT_ROLE, aN as TIME_TEXT_SUFFIX, aF as resolveImportOptions, I as ImportReportBuilder, aC as reportSinkOptions, aD as reportUnusedOptions, t as textChunks, aa as XML_SYNTAX_CODE, a as throwIfAborted, v as IdCoercer, l as DirectionResolver, _ as STRAY_TEXT_CODE, K as NO_GRAPH_CODE, d as COUNT_HINT_CODE, aw as isWeightField, aO as declareAttribute, ai as declareResolved, y as MISSING_ID_CODE, k as DUPLICATE_NODE_CODE, a6 as UNKNOWN_PARENT_CODE, M as MISSING_ENDPOINT_CODE, i as DUPLICATE_EDGE_ID_CODE, aA as parseWeightText, aP as parseDeclaredTemporal, ah as declareCompanion, aQ as parseDeclaredValue, aR as losesPrecision, T as PRECISION_CODE, aS as parseTimeText, aT as splitListText, a4 as UNKNOWN_ELEMENT_CODE, o as ID_MERGED_CODE, aU as timeTextCompanion, aV as parseDecimalText, ac as capabilities, L as LOSS, ax as joinText, ak as encodeChunks, aG as sanitizeIds, az as pairFolding, al as explicitWeights, aE as resolveExportOptions, ad as checkCapabilities, aW as formatTimeValue, an as formatF32, ao as formatF64, aX as mapDeclaredType, aY as joinListText, aZ as formatTemporal, aq as formatInteger, at as isCanonicalIntegerText, 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, X as ROLE_TAKEN_CODE, C as COLUMN_RENAMED_CODE, b as BAD_OPTIONS_CODE, B as BAD_DEFAULT_CODE, a3 as UNKNOWN_ATTR_TYPE_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
2
|
import { GraphFormatError, INVALID_INDEX, MAX_COUNT } from "@graphty/graph-format";
|
|
3
|
-
import { t as tokenizeXml, d as xmlDeclaredEncoding, X as XmlSyntaxError, l as localName, e as isWhitespace, x as xmlIllegalTextNotes, f as escapeXmlText, g as escapeXmlAttribute } from "./chunks/escape-
|
|
3
|
+
import { t as tokenizeXml, d as xmlDeclaredEncoding, X as XmlSyntaxError, l as localName, e as isWhitespace, x as xmlIllegalTextNotes, f as escapeXmlText, g as escapeXmlAttribute } from "./chunks/escape-DXbOoLKl.js";
|
|
4
4
|
const GEXF_FORMAT = "gexf";
|
|
5
5
|
const GEXF_NAMESPACES = {
|
|
6
6
|
"1.2": { gexf: "http://www.gexf.net/1.2draft", viz: "http://www.gexf.net/1.2draft/viz" },
|
package/dist/gml.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $ as SYNTAX_CODE, ax as joinText, ak as encodeChunks, ad as checkCapabilities, L as LOSS, az as pairFolding, ac as capabilities, aE as resolveExportOptions, a_ as DictHeuristic, aq as formatInteger, aG as sanitizeIds, aJ as countMixedEdges, al as explicitWeights, a$ as DICT_SAMPLE_ROWS, ap as formatGmlReal, X as ROLE_TAKEN_CODE$1, T as PRECISION_CODE$1, k as DUPLICATE_NODE_CODE$1, M as MISSING_ENDPOINT_CODE$1, y as MISSING_ID_CODE$1, A as MULTIPLE_GRAPHS_CODE, K as NO_GRAPH_CODE$1, aF as resolveImportOptions, I as ImportReportBuilder, aD as reportUnusedOptions, aB as readText, a as throwIfAborted, aC as reportSinkOptions, v as IdCoercer, l as DirectionResolver, aL as uniqueColumnName, aK as weightFromValue, aA as parseWeightText, ai as declareResolved, 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, o as ID_MERGED_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
2
|
import { GraphFormatError, INVALID_INDEX } from "@graphty/graph-format";
|
|
3
|
-
import { j as decodeGmlString, k as quoteGmlString } from "./chunks/escape-
|
|
3
|
+
import { j as decodeGmlString, k as quoteGmlString } from "./chunks/escape-DXbOoLKl.js";
|
|
4
4
|
const TOKEN_WORD = 0;
|
|
5
5
|
const TOKEN_INT = 1;
|
|
6
6
|
const TOKEN_REAL = 2;
|
|
@@ -43,6 +43,7 @@ class GmlTokens {
|
|
|
43
43
|
*/
|
|
44
44
|
constructor(text, capacity = 1024) {
|
|
45
45
|
this.count = 0;
|
|
46
|
+
this.onUnknownEntity = null;
|
|
46
47
|
this.text = text;
|
|
47
48
|
this.kind = new Uint8Array(capacity);
|
|
48
49
|
this.start = new Uint32Array(capacity);
|
|
@@ -81,7 +82,14 @@ class GmlTokens {
|
|
|
81
82
|
* @returns the body with character references decoded
|
|
82
83
|
*/
|
|
83
84
|
stringOf(i) {
|
|
84
|
-
|
|
85
|
+
const text = this.textOf(i);
|
|
86
|
+
if (text.indexOf("&") < 0) {
|
|
87
|
+
return text;
|
|
88
|
+
}
|
|
89
|
+
const report = this.onUnknownEntity;
|
|
90
|
+
return decodeGmlString(text, report === null ? void 0 : (entity) => {
|
|
91
|
+
report(entity, this.line[i]);
|
|
92
|
+
});
|
|
85
93
|
}
|
|
86
94
|
/**
|
|
87
95
|
* Whether a token is a `[` or `]`.
|
|
@@ -1346,6 +1354,7 @@ const REPEATED_KEY_CODE = "E_GML_REPEATED_KEY";
|
|
|
1346
1354
|
const ELEMENT_TYPE_CODE = "E_GML_ELEMENT_TYPE";
|
|
1347
1355
|
const FLAG_TYPE_CODE = "E_GML_FLAG_TYPE";
|
|
1348
1356
|
const FLAG_VALUE_CODE = "W_GML_FLAG_VALUE";
|
|
1357
|
+
const UNKNOWN_ENTITY_CODE = "W_GML_UNKNOWN_ENTITY";
|
|
1349
1358
|
const PRECISION_CODE = PRECISION_CODE$1;
|
|
1350
1359
|
const ROLE_TAKEN_CODE = ROLE_TAKEN_CODE$1;
|
|
1351
1360
|
const ID_DROPPED_CODE = "W_GML_ID_DROPPED";
|
|
@@ -1442,6 +1451,15 @@ class GmlImport {
|
|
|
1442
1451
|
*/
|
|
1443
1452
|
run(tokens) {
|
|
1444
1453
|
this.tokens = tokens;
|
|
1454
|
+
tokens.onUnknownEntity = (entity, line) => {
|
|
1455
|
+
this.report.warnOnce(
|
|
1456
|
+
"parse-error",
|
|
1457
|
+
UNKNOWN_ENTITY_CODE,
|
|
1458
|
+
`unknown character entity ${entity} is kept as written`,
|
|
1459
|
+
{ line, element: entity },
|
|
1460
|
+
`${UNKNOWN_ENTITY_CODE}:${entity}`
|
|
1461
|
+
);
|
|
1462
|
+
};
|
|
1445
1463
|
this.scan();
|
|
1446
1464
|
this.push();
|
|
1447
1465
|
}
|
|
@@ -1534,7 +1552,7 @@ class GmlImport {
|
|
|
1534
1552
|
continue;
|
|
1535
1553
|
}
|
|
1536
1554
|
} else {
|
|
1537
|
-
if (key === "source" || key === "target") {
|
|
1555
|
+
if (key === "source" || key === "target" || key === "directed") {
|
|
1538
1556
|
continue;
|
|
1539
1557
|
}
|
|
1540
1558
|
if (key === weightFrom) {
|
|
@@ -1782,7 +1800,7 @@ class GmlImport {
|
|
|
1782
1800
|
this.report.error(
|
|
1783
1801
|
"validation-error",
|
|
1784
1802
|
FLAG_TYPE_CODE,
|
|
1785
|
-
`
|
|
1803
|
+
`flag "${name}" must be the integer 0 or 1, found ${describeValue(t, v)}`,
|
|
1786
1804
|
{ line: t.line[v], element: name }
|
|
1787
1805
|
);
|
|
1788
1806
|
return null;
|
|
@@ -1792,7 +1810,7 @@ class GmlImport {
|
|
|
1792
1810
|
this.report.warning(
|
|
1793
1811
|
"validation-error",
|
|
1794
1812
|
FLAG_VALUE_CODE,
|
|
1795
|
-
`
|
|
1813
|
+
`flag "${name}" is ${n}; read as ${n !== 0 ? "1" : "0"}`,
|
|
1796
1814
|
{ line: t.line[v], element: name }
|
|
1797
1815
|
);
|
|
1798
1816
|
}
|
|
@@ -1990,12 +2008,15 @@ class GmlImport {
|
|
|
1990
2008
|
let sourceTok = -1;
|
|
1991
2009
|
let targetTok = -1;
|
|
1992
2010
|
let weightTok = -1;
|
|
2011
|
+
let directedTok = -1;
|
|
1993
2012
|
for (let p = open + 1; p < close; p = t.nextPair(p)) {
|
|
1994
2013
|
const key = t.textOf(p);
|
|
1995
2014
|
if (key === "source") {
|
|
1996
2015
|
sourceTok = this.structuralToken(sourceTok, p, "source");
|
|
1997
2016
|
} else if (key === "target") {
|
|
1998
2017
|
targetTok = this.structuralToken(targetTok, p, "target");
|
|
2018
|
+
} else if (key === "directed") {
|
|
2019
|
+
directedTok = this.structuralToken(directedTok, p, "directed");
|
|
1999
2020
|
} else if (key === options.weightFrom) {
|
|
2000
2021
|
weightTok = p + 1;
|
|
2001
2022
|
}
|
|
@@ -2011,13 +2032,11 @@ class GmlImport {
|
|
|
2011
2032
|
const before = sink.edgeCount;
|
|
2012
2033
|
const sourceNew = sink.indexOf(source) === INVALID_INDEX;
|
|
2013
2034
|
const targetNew = source !== target && sink.indexOf(target) === INVALID_INDEX;
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
{ line, element }
|
|
2020
|
-
);
|
|
2035
|
+
const directed = this.readFlag(directedTok, "directed") ?? this.headerDirected;
|
|
2036
|
+
edge = this.requireResolver().addEdge(source, target, directed ? "directed" : "undirected", weight, {
|
|
2037
|
+
line,
|
|
2038
|
+
element
|
|
2039
|
+
});
|
|
2021
2040
|
report.counts.edges += sink.edgeCount - before;
|
|
2022
2041
|
report.counts.nodes += (sourceNew ? 1 : 0) + (targetNew ? 1 : 0);
|
|
2023
2042
|
} catch (err) {
|
|
@@ -2029,7 +2048,7 @@ class GmlImport {
|
|
|
2029
2048
|
try {
|
|
2030
2049
|
for (let p = open + 1; p < close; p = t.nextPair(p)) {
|
|
2031
2050
|
const key = t.textOf(p);
|
|
2032
|
-
if (key === "source" || key === "target" || key === options.weightFrom) {
|
|
2051
|
+
if (key === "source" || key === "target" || key === "directed" || key === options.weightFrom) {
|
|
2033
2052
|
continue;
|
|
2034
2053
|
}
|
|
2035
2054
|
const plan = this.edgePlans.get(key);
|
|
@@ -2637,6 +2656,8 @@ const GML_ISSUE = Object.freeze({
|
|
|
2637
2656
|
FLAG_TYPE: FLAG_TYPE_CODE,
|
|
2638
2657
|
/** A `directed` / `multigraph` flag outside 0 / 1, or repeated. */
|
|
2639
2658
|
FLAG_VALUE: FLAG_VALUE_CODE,
|
|
2659
|
+
/** A named entity in a string that no table decodes; kept as written. */
|
|
2660
|
+
UNKNOWN_ENTITY: UNKNOWN_ENTITY_CODE,
|
|
2640
2661
|
/** An integer beyond 2^53 rounded to f64. */
|
|
2641
2662
|
PRECISION: PRECISION_CODE,
|
|
2642
2663
|
/** A column renamed `<name>#<key>` because the sink held the name with another shape. */
|