@graphty/graph-io 0.3.8 → 0.3.10
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 +29 -5
- package/dist/chunks/{escape-BjmIaFFo.js → escape-D1f9-cwf.js} +4 -4
- package/dist/chunks/{escape-BjmIaFFo.js.map → escape-D1f9-cwf.js.map} +1 -1
- package/dist/chunks/{importer-BddBW3sf.js → importer-9PxhqH4v.js} +336 -92
- package/dist/chunks/importer-9PxhqH4v.js.map +1 -0
- package/dist/chunks/{importer-DfI8POXb.js → importer-B8lsjFWx.js} +6 -5
- package/dist/chunks/importer-B8lsjFWx.js.map +1 -0
- package/dist/chunks/{importer-BtHFICnf.js → importer-C3HcYWAn.js} +5 -3
- package/dist/chunks/importer-C3HcYWAn.js.map +1 -0
- package/dist/chunks/{importer-BOxwmef_.js → importer-C7mnGdr_.js} +125 -8
- package/dist/chunks/importer-C7mnGdr_.js.map +1 -0
- package/dist/chunks/{records-BKSMowhR.js → records-IHsCfv7s.js} +20 -7
- package/dist/chunks/records-IHsCfv7s.js.map +1 -0
- package/dist/chunks/{writer-BdMak4_J.js → writer-BtWpUaiH.js} +4 -4
- package/dist/chunks/{writer-BdMak4_J.js.map → writer-BtWpUaiH.js.map} +1 -1
- package/dist/csv.js +239 -18
- package/dist/csv.js.map +1 -1
- package/dist/dot.js +1 -1
- package/dist/gexf.js +72 -33
- package/dist/gexf.js.map +1 -1
- package/dist/gml.js +44 -23
- package/dist/gml.js.map +1 -1
- package/dist/graph-io.js +11 -11
- package/dist/graphml.js +1 -1
- package/dist/json.js +1 -1
- package/dist/neo4j.js +5 -4
- package/dist/neo4j.js.map +1 -1
- package/dist/pajek.js +1 -1
- package/dist/src/common/export.js +1 -1
- package/dist/src/common/export.js.map +1 -1
- package/dist/src/formats/csv/exporter.d.ts +15 -4
- package/dist/src/formats/csv/exporter.d.ts.map +1 -1
- package/dist/src/formats/csv/exporter.js +125 -6
- package/dist/src/formats/csv/exporter.js.map +1 -1
- package/dist/src/formats/csv/importer.d.ts +36 -4
- package/dist/src/formats/csv/importer.d.ts.map +1 -1
- package/dist/src/formats/csv/importer.js +169 -8
- package/dist/src/formats/csv/importer.js.map +1 -1
- package/dist/src/formats/csv/records.d.ts +14 -1
- package/dist/src/formats/csv/records.d.ts.map +1 -1
- package/dist/src/formats/csv/records.js +28 -7
- package/dist/src/formats/csv/records.js.map +1 -1
- package/dist/src/formats/dot/exporter.d.ts.map +1 -1
- package/dist/src/formats/dot/exporter.js +2 -0
- package/dist/src/formats/dot/exporter.js.map +1 -1
- package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
- package/dist/src/formats/gexf/exporter.js +36 -10
- package/dist/src/formats/gexf/exporter.js.map +1 -1
- package/dist/src/formats/gexf/importer.d.ts +9 -4
- package/dist/src/formats/gexf/importer.d.ts.map +1 -1
- package/dist/src/formats/gexf/importer.js +44 -21
- package/dist/src/formats/gexf/importer.js.map +1 -1
- package/dist/src/formats/gexf/index.d.ts +1 -1
- package/dist/src/formats/gexf/index.d.ts.map +1 -1
- package/dist/src/formats/gexf/index.js +1 -1
- package/dist/src/formats/gexf/index.js.map +1 -1
- package/dist/src/formats/gexf/schema.d.ts +2 -0
- package/dist/src/formats/gexf/schema.d.ts.map +1 -1
- package/dist/src/formats/gexf/schema.js +18 -0
- package/dist/src/formats/gexf/schema.js.map +1 -1
- package/dist/src/formats/gml/exporter.d.ts.map +1 -1
- package/dist/src/formats/gml/exporter.js +1 -0
- package/dist/src/formats/gml/exporter.js.map +1 -1
- package/dist/src/formats/gml/importer.d.ts +7 -4
- package/dist/src/formats/gml/importer.d.ts.map +1 -1
- package/dist/src/formats/gml/importer.js +32 -19
- package/dist/src/formats/gml/importer.js.map +1 -1
- package/dist/src/formats/gml/index.d.ts +3 -1
- package/dist/src/formats/gml/index.d.ts.map +1 -1
- package/dist/src/formats/gml/index.js +4 -2
- package/dist/src/formats/gml/index.js.map +1 -1
- package/dist/src/formats/graphml/constants.d.ts +2 -0
- package/dist/src/formats/graphml/constants.d.ts.map +1 -1
- package/dist/src/formats/graphml/constants.js +2 -0
- package/dist/src/formats/graphml/constants.js.map +1 -1
- package/dist/src/formats/graphml/exporter.d.ts.map +1 -1
- package/dist/src/formats/graphml/exporter.js +14 -2
- package/dist/src/formats/graphml/exporter.js.map +1 -1
- package/dist/src/formats/graphml/importer.d.ts +2 -1
- package/dist/src/formats/graphml/importer.d.ts.map +1 -1
- package/dist/src/formats/graphml/importer.js +91 -27
- package/dist/src/formats/graphml/importer.js.map +1 -1
- package/dist/src/formats/graphml/yfiles.d.ts +62 -0
- package/dist/src/formats/graphml/yfiles.d.ts.map +1 -0
- package/dist/src/formats/graphml/yfiles.js +269 -0
- package/dist/src/formats/graphml/yfiles.js.map +1 -0
- package/dist/src/formats/json/exporter.d.ts.map +1 -1
- package/dist/src/formats/json/exporter.js +9 -1
- package/dist/src/formats/json/exporter.js.map +1 -1
- package/dist/src/formats/json/importer.d.ts +14 -0
- package/dist/src/formats/json/importer.d.ts.map +1 -1
- package/dist/src/formats/json/importer.js +165 -4
- package/dist/src/formats/json/importer.js.map +1 -1
- package/dist/src/formats/neo4j/exporter.d.ts.map +1 -1
- package/dist/src/formats/neo4j/exporter.js +1 -0
- package/dist/src/formats/neo4j/exporter.js.map +1 -1
- package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
- package/dist/src/formats/pajek/exporter.js +3 -2
- package/dist/src/formats/pajek/exporter.js.map +1 -1
- package/package.json +2 -2
- package/src/common/export.ts +1 -1
- package/src/formats/csv/exporter.ts +140 -10
- package/src/formats/csv/importer.ts +207 -18
- package/src/formats/csv/records.ts +41 -6
- package/src/formats/dot/exporter.ts +2 -0
- package/src/formats/gexf/exporter.ts +40 -11
- package/src/formats/gexf/importer.ts +47 -25
- package/src/formats/gexf/index.ts +1 -1
- package/src/formats/gexf/schema.ts +18 -0
- package/src/formats/gml/exporter.ts +1 -0
- package/src/formats/gml/importer.ts +47 -24
- package/src/formats/gml/index.ts +4 -1
- package/src/formats/graphml/constants.ts +2 -0
- package/src/formats/graphml/exporter.ts +21 -2
- package/src/formats/graphml/importer.ts +99 -28
- package/src/formats/graphml/yfiles.ts +292 -0
- package/src/formats/json/exporter.ts +9 -1
- package/src/formats/json/importer.ts +202 -4
- package/src/formats/neo4j/exporter.ts +1 -0
- package/src/formats/pajek/exporter.ts +3 -1
- package/dist/chunks/importer-BOxwmef_.js.map +0 -1
- package/dist/chunks/importer-BddBW3sf.js.map +0 -1
- package/dist/chunks/importer-BtHFICnf.js.map +0 -1
- package/dist/chunks/importer-DfI8POXb.js.map +0 -1
- package/dist/chunks/records-BKSMowhR.js.map +0 -1
package/dist/gml.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
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-BtWpUaiH.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-D1f9-cwf.js";
|
|
4
4
|
const TOKEN_WORD = 0;
|
|
5
5
|
const TOKEN_INT = 1;
|
|
6
6
|
const TOKEN_REAL = 2;
|
|
@@ -395,7 +395,8 @@ const SKIPPED_ROLES = /* @__PURE__ */ new Set([
|
|
|
395
395
|
"timestamp",
|
|
396
396
|
"timestamps",
|
|
397
397
|
"spells",
|
|
398
|
-
"open"
|
|
398
|
+
"open",
|
|
399
|
+
"spellsOpen"
|
|
399
400
|
]);
|
|
400
401
|
const NODE_RESERVED = /* @__PURE__ */ new Set(["id"]);
|
|
401
402
|
const EDGE_RESERVED = /* @__PURE__ */ new Set(["source", "target"]);
|
|
@@ -1349,6 +1350,7 @@ const MISSING_ID_CODE = MISSING_ID_CODE$1;
|
|
|
1349
1350
|
const MISSING_LABEL_CODE = "E_GML_MISSING_LABEL";
|
|
1350
1351
|
const MISSING_ENDPOINT_CODE = MISSING_ENDPOINT_CODE$1;
|
|
1351
1352
|
const ID_TYPE_CODE = "E_GML_ID_TYPE";
|
|
1353
|
+
const STRING_ID_CODE = "W_GML_STRING_ID";
|
|
1352
1354
|
const DUPLICATE_NODE_CODE = DUPLICATE_NODE_CODE$1;
|
|
1353
1355
|
const REPEATED_KEY_CODE = "E_GML_REPEATED_KEY";
|
|
1354
1356
|
const ELEMENT_TYPE_CODE = "E_GML_ELEMENT_TYPE";
|
|
@@ -1933,7 +1935,7 @@ class GmlImport {
|
|
|
1933
1935
|
if (idTok < 0) {
|
|
1934
1936
|
throw new GraphFormatError("E_INVALID_ID", "node has no id", { reason: "missing id" });
|
|
1935
1937
|
}
|
|
1936
|
-
const fileId = this.
|
|
1938
|
+
const fileId = this.coerceFileId(idTok, this.fileIdOf(idTok, "id"));
|
|
1937
1939
|
if (originalTok >= 0) {
|
|
1938
1940
|
sinkId = this.restoredId(originalTok);
|
|
1939
1941
|
} else {
|
|
@@ -1950,7 +1952,7 @@ class GmlImport {
|
|
|
1950
1952
|
sinkId = ordinal;
|
|
1951
1953
|
break;
|
|
1952
1954
|
default:
|
|
1953
|
-
sinkId =
|
|
1955
|
+
sinkId = fileId;
|
|
1954
1956
|
}
|
|
1955
1957
|
}
|
|
1956
1958
|
if (this.idMap !== null) {
|
|
@@ -2080,23 +2082,46 @@ class GmlImport {
|
|
|
2080
2082
|
return p + 1;
|
|
2081
2083
|
}
|
|
2082
2084
|
/**
|
|
2083
|
-
* The
|
|
2084
|
-
*
|
|
2085
|
+
* The value of an id / source / target token: an integer (the GML spec's type) as a number, a
|
|
2086
|
+
* string (NetworkX and Gephi write them) as its text with one warning per file.
|
|
2085
2087
|
* @param v - the value token
|
|
2086
2088
|
* @param key - the key name, for the error
|
|
2087
|
-
* @returns the number
|
|
2089
|
+
* @returns the number or the string
|
|
2088
2090
|
*/
|
|
2089
|
-
|
|
2091
|
+
fileIdOf(v, key) {
|
|
2090
2092
|
const t = this.requireTokens();
|
|
2093
|
+
if (t.kind[v] === TOKEN_STRING) {
|
|
2094
|
+
this.report.warnOnce(
|
|
2095
|
+
"validation-error",
|
|
2096
|
+
STRING_ID_CODE,
|
|
2097
|
+
`${key} is the string "${t.textOf(v)}"; GML ids are integers, string ids are kept under the ids rule`,
|
|
2098
|
+
{ line: t.line[v], element: t.stringOf(v) }
|
|
2099
|
+
);
|
|
2100
|
+
return t.stringOf(v);
|
|
2101
|
+
}
|
|
2091
2102
|
if (t.kind[v] !== TOKEN_INT) {
|
|
2092
|
-
throw new GraphFormatError(
|
|
2093
|
-
|
|
2094
|
-
key,
|
|
2095
|
-
|
|
2096
|
-
|
|
2103
|
+
throw new GraphFormatError(
|
|
2104
|
+
"E_INVALID_ID",
|
|
2105
|
+
`${key} must be an integer or a string, found ${describeValue(t, v)}`,
|
|
2106
|
+
{
|
|
2107
|
+
reason: "not an integer",
|
|
2108
|
+
key,
|
|
2109
|
+
value: t.kind[v] === TOKEN_OPEN ? "[...]" : t.textOf(v)
|
|
2110
|
+
}
|
|
2111
|
+
);
|
|
2097
2112
|
}
|
|
2098
2113
|
return Number(t.textOf(v));
|
|
2099
2114
|
}
|
|
2115
|
+
/**
|
|
2116
|
+
* Coerce an id / source / target value under the `ids` rule: a string by its text, an integer
|
|
2117
|
+
* through coerceInteger().
|
|
2118
|
+
* @param v - the value token
|
|
2119
|
+
* @param id - its value (fileIdOf())
|
|
2120
|
+
* @returns the id
|
|
2121
|
+
*/
|
|
2122
|
+
coerceFileId(v, id) {
|
|
2123
|
+
return typeof id === "string" ? this.coercer.text(id) : this.coerceInteger(v, id);
|
|
2124
|
+
}
|
|
2100
2125
|
/**
|
|
2101
2126
|
* Coerce an integer id token under the `ids` rule: a safe integer passes as a typed number
|
|
2102
2127
|
* (so `01` is 1 and `-0` is 0), a larger one goes through the text rule (a string under
|
|
@@ -2156,14 +2181,8 @@ class GmlImport {
|
|
|
2156
2181
|
* @returns the id
|
|
2157
2182
|
*/
|
|
2158
2183
|
endpoint(v, key) {
|
|
2159
|
-
const
|
|
2160
|
-
|
|
2161
|
-
const mapped = this.idMap.get(n);
|
|
2162
|
-
if (mapped !== void 0) {
|
|
2163
|
-
return mapped;
|
|
2164
|
-
}
|
|
2165
|
-
}
|
|
2166
|
-
return this.coerceInteger(v, n);
|
|
2184
|
+
const id = this.coerceFileId(v, this.fileIdOf(v, key));
|
|
2185
|
+
return this.idMap?.get(id) ?? id;
|
|
2167
2186
|
}
|
|
2168
2187
|
/**
|
|
2169
2188
|
* The weight of an edge from its weight token.
|
|
@@ -2644,8 +2663,10 @@ const GML_ISSUE = Object.freeze({
|
|
|
2644
2663
|
MISSING_LABEL: MISSING_LABEL_CODE,
|
|
2645
2664
|
/** An edge without `source` or `target`. */
|
|
2646
2665
|
MISSING_ENDPOINT: MISSING_ENDPOINT_CODE,
|
|
2647
|
-
/** A node id, source or target that is
|
|
2666
|
+
/** A node id, source or target that is neither an integer nor a string. */
|
|
2648
2667
|
ID_TYPE: ID_TYPE_CODE,
|
|
2668
|
+
/** String node ids, sources or targets (outside the spec's integers), kept under the ids rule; warned once. */
|
|
2669
|
+
STRING_ID: STRING_ID_CODE,
|
|
2649
2670
|
/** A node id declared twice (later keys overwrite). */
|
|
2650
2671
|
DUPLICATE_NODE: DUPLICATE_NODE_CODE,
|
|
2651
2672
|
/** A structural key repeated in one element. */
|