@graphty/graph-io 0.0.0 → 0.2.1
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/LICENSE +21 -0
- package/README.md +250 -28
- package/dist/chunks/children-CL3Cy0ez.js +238 -0
- package/dist/chunks/children-CL3Cy0ez.js.map +1 -0
- package/dist/chunks/escape-DyI8JofU.js +938 -0
- package/dist/chunks/escape-DyI8JofU.js.map +1 -0
- package/dist/chunks/importer-CQnJuWJw.js +2987 -0
- package/dist/chunks/importer-CQnJuWJw.js.map +1 -0
- package/dist/chunks/importer-CpCpfbxr.js +2015 -0
- package/dist/chunks/importer-CpCpfbxr.js.map +1 -0
- package/dist/chunks/importer-DbnGYr3_.js +2342 -0
- package/dist/chunks/importer-DbnGYr3_.js.map +1 -0
- package/dist/chunks/importer-GozH8DkN.js +3050 -0
- package/dist/chunks/importer-GozH8DkN.js.map +1 -0
- package/dist/chunks/records-CGpxszm1.js +605 -0
- package/dist/chunks/records-CGpxszm1.js.map +1 -0
- package/dist/chunks/text-CajMdVFy.js +189 -0
- package/dist/chunks/text-CajMdVFy.js.map +1 -0
- package/dist/chunks/writer-DxSKC7TL.js +2842 -0
- package/dist/chunks/writer-DxSKC7TL.js.map +1 -0
- package/dist/csv.d.ts +1 -0
- package/dist/csv.js +1702 -0
- package/dist/csv.js.map +1 -0
- package/dist/dot.d.ts +1 -0
- package/dist/dot.js +8 -0
- package/dist/dot.js.map +1 -0
- package/dist/gexf.d.ts +1 -0
- package/dist/gexf.js +3466 -0
- package/dist/gexf.js.map +1 -0
- package/dist/gml.d.ts +1 -0
- package/dist/gml.js +2647 -0
- package/dist/gml.js.map +1 -0
- package/dist/graph-io.d.ts +1 -0
- package/dist/graph-io.js +790 -0
- package/dist/graph-io.js.map +1 -0
- package/dist/graphml.d.ts +1 -0
- package/dist/graphml.js +8 -0
- package/dist/graphml.js.map +1 -0
- package/dist/json.d.ts +1 -0
- package/dist/json.js +11 -0
- package/dist/json.js.map +1 -0
- package/dist/neo4j.d.ts +1 -0
- package/dist/neo4j.js +2046 -0
- package/dist/neo4j.js.map +1 -0
- package/dist/pajek.d.ts +1 -0
- package/dist/pajek.js +8 -0
- package/dist/pajek.js.map +1 -0
- package/dist/src/children.d.ts +134 -0
- package/dist/src/children.d.ts.map +1 -0
- package/dist/src/children.js +274 -0
- package/dist/src/children.js.map +1 -0
- package/dist/src/common/attributes.d.ts +229 -0
- package/dist/src/common/attributes.d.ts.map +1 -0
- package/dist/src/common/attributes.js +368 -0
- package/dist/src/common/attributes.js.map +1 -0
- package/dist/src/common/codes.d.ts +105 -0
- package/dist/src/common/codes.d.ts.map +1 -0
- package/dist/src/common/codes.js +107 -0
- package/dist/src/common/codes.js.map +1 -0
- package/dist/src/common/declared-types.d.ts +84 -0
- package/dist/src/common/declared-types.d.ts.map +1 -0
- package/dist/src/common/declared-types.js +326 -0
- package/dist/src/common/declared-types.js.map +1 -0
- package/dist/src/common/direction.d.ts +206 -0
- package/dist/src/common/direction.d.ts.map +1 -0
- package/dist/src/common/direction.js +370 -0
- package/dist/src/common/direction.js.map +1 -0
- package/dist/src/common/escape.d.ts +92 -0
- package/dist/src/common/escape.d.ts.map +1 -0
- package/dist/src/common/escape.js +212 -0
- package/dist/src/common/escape.js.map +1 -0
- package/dist/src/common/export.d.ts +249 -0
- package/dist/src/common/export.d.ts.map +1 -0
- package/dist/src/common/export.js +594 -0
- package/dist/src/common/export.js.map +1 -0
- package/dist/src/common/format.d.ts +59 -0
- package/dist/src/common/format.d.ts.map +1 -0
- package/dist/src/common/format.js +106 -0
- package/dist/src/common/format.js.map +1 -0
- package/dist/src/common/ids.d.ts +83 -0
- package/dist/src/common/ids.d.ts.map +1 -0
- package/dist/src/common/ids.js +158 -0
- package/dist/src/common/ids.js.map +1 -0
- package/dist/src/common/input.d.ts +100 -0
- package/dist/src/common/input.d.ts.map +1 -0
- package/dist/src/common/input.js +335 -0
- package/dist/src/common/input.js.map +1 -0
- package/dist/src/common/lists.d.ts +34 -0
- package/dist/src/common/lists.d.ts.map +1 -0
- package/dist/src/common/lists.js +185 -0
- package/dist/src/common/lists.js.map +1 -0
- package/dist/src/common/options.d.ts +108 -0
- package/dist/src/common/options.d.ts.map +1 -0
- package/dist/src/common/options.js +265 -0
- package/dist/src/common/options.js.map +1 -0
- package/dist/src/common/report.d.ts +187 -0
- package/dist/src/common/report.d.ts.map +1 -0
- package/dist/src/common/report.js +274 -0
- package/dist/src/common/report.js.map +1 -0
- package/dist/src/common/temporal.d.ts +71 -0
- package/dist/src/common/temporal.d.ts.map +1 -0
- package/dist/src/common/temporal.js +266 -0
- package/dist/src/common/temporal.js.map +1 -0
- package/dist/src/common/text.d.ts +104 -0
- package/dist/src/common/text.d.ts.map +1 -0
- package/dist/src/common/text.js +255 -0
- package/dist/src/common/text.js.map +1 -0
- package/dist/src/common/weights.d.ts +77 -0
- package/dist/src/common/weights.d.ts.map +1 -0
- package/dist/src/common/weights.js +156 -0
- package/dist/src/common/weights.js.map +1 -0
- package/dist/src/common/writer.d.ts +51 -0
- package/dist/src/common/writer.d.ts.map +1 -0
- package/dist/src/common/writer.js +108 -0
- package/dist/src/common/writer.js.map +1 -0
- package/dist/src/common/xml.d.ts +245 -0
- package/dist/src/common/xml.d.ts.map +1 -0
- package/dist/src/common/xml.js +942 -0
- package/dist/src/common/xml.js.map +1 -0
- package/dist/src/formats/csv/exporter.d.ts +70 -0
- package/dist/src/formats/csv/exporter.d.ts.map +1 -0
- package/dist/src/formats/csv/exporter.js +682 -0
- package/dist/src/formats/csv/exporter.js.map +1 -0
- package/dist/src/formats/csv/header.d.ts +66 -0
- package/dist/src/formats/csv/header.d.ts.map +1 -0
- package/dist/src/formats/csv/header.js +152 -0
- package/dist/src/formats/csv/header.js.map +1 -0
- package/dist/src/formats/csv/importer.d.ts +82 -0
- package/dist/src/formats/csv/importer.d.ts.map +1 -0
- package/dist/src/formats/csv/importer.js +849 -0
- package/dist/src/formats/csv/importer.js.map +1 -0
- package/dist/src/formats/csv/index.d.ts +60 -0
- package/dist/src/formats/csv/index.d.ts.map +1 -0
- package/dist/src/formats/csv/index.js +63 -0
- package/dist/src/formats/csv/index.js.map +1 -0
- package/dist/src/formats/csv/records.d.ts +188 -0
- package/dist/src/formats/csv/records.d.ts.map +1 -0
- package/dist/src/formats/csv/records.js +702 -0
- package/dist/src/formats/csv/records.js.map +1 -0
- package/dist/src/formats/csv/values.d.ts +105 -0
- package/dist/src/formats/csv/values.d.ts.map +1 -0
- package/dist/src/formats/csv/values.js +192 -0
- package/dist/src/formats/csv/values.js.map +1 -0
- package/dist/src/formats/dot/exporter.d.ts +52 -0
- package/dist/src/formats/dot/exporter.d.ts.map +1 -0
- package/dist/src/formats/dot/exporter.js +836 -0
- package/dist/src/formats/dot/exporter.js.map +1 -0
- package/dist/src/formats/dot/importer.d.ts +102 -0
- package/dist/src/formats/dot/importer.d.ts.map +1 -0
- package/dist/src/formats/dot/importer.js +1291 -0
- package/dist/src/formats/dot/importer.js.map +1 -0
- package/dist/src/formats/dot/index.d.ts +7 -0
- package/dist/src/formats/dot/index.d.ts.map +1 -0
- package/dist/src/formats/dot/index.js +7 -0
- package/dist/src/formats/dot/index.js.map +1 -0
- package/dist/src/formats/dot/names.d.ts +29 -0
- package/dist/src/formats/dot/names.d.ts.map +1 -0
- package/dist/src/formats/dot/names.js +28 -0
- package/dist/src/formats/dot/names.js.map +1 -0
- package/dist/src/formats/dot/tokenizer.d.ts +114 -0
- package/dist/src/formats/dot/tokenizer.d.ts.map +1 -0
- package/dist/src/formats/dot/tokenizer.js +341 -0
- package/dist/src/formats/dot/tokenizer.js.map +1 -0
- package/dist/src/formats/gexf/exporter.d.ts +56 -0
- package/dist/src/formats/gexf/exporter.d.ts.map +1 -0
- package/dist/src/formats/gexf/exporter.js +1395 -0
- package/dist/src/formats/gexf/exporter.js.map +1 -0
- package/dist/src/formats/gexf/importer.d.ts +73 -0
- package/dist/src/formats/gexf/importer.d.ts.map +1 -0
- package/dist/src/formats/gexf/importer.js +1880 -0
- package/dist/src/formats/gexf/importer.js.map +1 -0
- package/dist/src/formats/gexf/index.d.ts +96 -0
- package/dist/src/formats/gexf/index.d.ts.map +1 -0
- package/dist/src/formats/gexf/index.js +97 -0
- package/dist/src/formats/gexf/index.js.map +1 -0
- package/dist/src/formats/gexf/schema.d.ts +135 -0
- package/dist/src/formats/gexf/schema.d.ts.map +1 -0
- package/dist/src/formats/gexf/schema.js +323 -0
- package/dist/src/formats/gexf/schema.js.map +1 -0
- package/dist/src/formats/gml/exporter.d.ts +69 -0
- package/dist/src/formats/gml/exporter.d.ts.map +1 -0
- package/dist/src/formats/gml/exporter.js +1093 -0
- package/dist/src/formats/gml/exporter.js.map +1 -0
- package/dist/src/formats/gml/importer.d.ts +66 -0
- package/dist/src/formats/gml/importer.d.ts.map +1 -0
- package/dist/src/formats/gml/importer.js +1331 -0
- package/dist/src/formats/gml/importer.js.map +1 -0
- package/dist/src/formats/gml/index.d.ts +85 -0
- package/dist/src/formats/gml/index.d.ts.map +1 -0
- package/dist/src/formats/gml/index.js +88 -0
- package/dist/src/formats/gml/index.js.map +1 -0
- package/dist/src/formats/gml/syntax.d.ts +186 -0
- package/dist/src/formats/gml/syntax.d.ts.map +1 -0
- package/dist/src/formats/gml/syntax.js +467 -0
- package/dist/src/formats/gml/syntax.js.map +1 -0
- package/dist/src/formats/graphml/constants.d.ts +169 -0
- package/dist/src/formats/graphml/constants.d.ts.map +1 -0
- package/dist/src/formats/graphml/constants.js +165 -0
- package/dist/src/formats/graphml/constants.js.map +1 -0
- package/dist/src/formats/graphml/exporter.d.ts +34 -0
- package/dist/src/formats/graphml/exporter.d.ts.map +1 -0
- package/dist/src/formats/graphml/exporter.js +1176 -0
- package/dist/src/formats/graphml/exporter.js.map +1 -0
- package/dist/src/formats/graphml/importer.d.ts +31 -0
- package/dist/src/formats/graphml/importer.d.ts.map +1 -0
- package/dist/src/formats/graphml/importer.js +1607 -0
- package/dist/src/formats/graphml/importer.js.map +1 -0
- package/dist/src/formats/graphml/index.d.ts +8 -0
- package/dist/src/formats/graphml/index.d.ts.map +1 -0
- package/dist/src/formats/graphml/index.js +8 -0
- package/dist/src/formats/graphml/index.js.map +1 -0
- package/dist/src/formats/graphml/tree.d.ts +72 -0
- package/dist/src/formats/graphml/tree.d.ts.map +1 -0
- package/dist/src/formats/graphml/tree.js +290 -0
- package/dist/src/formats/graphml/tree.js.map +1 -0
- package/dist/src/formats/json/dialect.d.ts +125 -0
- package/dist/src/formats/json/dialect.d.ts.map +1 -0
- package/dist/src/formats/json/dialect.js +262 -0
- package/dist/src/formats/json/dialect.js.map +1 -0
- package/dist/src/formats/json/exporter.d.ts +89 -0
- package/dist/src/formats/json/exporter.d.ts.map +1 -0
- package/dist/src/formats/json/exporter.js +1358 -0
- package/dist/src/formats/json/exporter.js.map +1 -0
- package/dist/src/formats/json/importer.d.ts +108 -0
- package/dist/src/formats/json/importer.d.ts.map +1 -0
- package/dist/src/formats/json/importer.js +1838 -0
- package/dist/src/formats/json/importer.js.map +1 -0
- package/dist/src/formats/json/index.d.ts +8 -0
- package/dist/src/formats/json/index.d.ts.map +1 -0
- package/dist/src/formats/json/index.js +8 -0
- package/dist/src/formats/json/index.js.map +1 -0
- package/dist/src/formats/neo4j/exporter.d.ts +68 -0
- package/dist/src/formats/neo4j/exporter.d.ts.map +1 -0
- package/dist/src/formats/neo4j/exporter.js +1055 -0
- package/dist/src/formats/neo4j/exporter.js.map +1 -0
- package/dist/src/formats/neo4j/header.d.ts +52 -0
- package/dist/src/formats/neo4j/header.d.ts.map +1 -0
- package/dist/src/formats/neo4j/header.js +131 -0
- package/dist/src/formats/neo4j/header.js.map +1 -0
- package/dist/src/formats/neo4j/importer.d.ts +73 -0
- package/dist/src/formats/neo4j/importer.d.ts.map +1 -0
- package/dist/src/formats/neo4j/importer.js +932 -0
- package/dist/src/formats/neo4j/importer.js.map +1 -0
- package/dist/src/formats/neo4j/index.d.ts +79 -0
- package/dist/src/formats/neo4j/index.d.ts.map +1 -0
- package/dist/src/formats/neo4j/index.js +83 -0
- package/dist/src/formats/neo4j/index.js.map +1 -0
- package/dist/src/formats/pajek/exporter.d.ts +58 -0
- package/dist/src/formats/pajek/exporter.d.ts.map +1 -0
- package/dist/src/formats/pajek/exporter.js +825 -0
- package/dist/src/formats/pajek/exporter.js.map +1 -0
- package/dist/src/formats/pajek/importer.d.ts +88 -0
- package/dist/src/formats/pajek/importer.d.ts.map +1 -0
- package/dist/src/formats/pajek/importer.js +1047 -0
- package/dist/src/formats/pajek/importer.js.map +1 -0
- package/dist/src/formats/pajek/index.d.ts +7 -0
- package/dist/src/formats/pajek/index.d.ts.map +1 -0
- package/dist/src/formats/pajek/index.js +7 -0
- package/dist/src/formats/pajek/index.js.map +1 -0
- package/dist/src/formats/pajek/syntax.d.ts +112 -0
- package/dist/src/formats/pajek/syntax.d.ts.map +1 -0
- package/dist/src/formats/pajek/syntax.js +269 -0
- package/dist/src/formats/pajek/syntax.js.map +1 -0
- package/dist/src/index.d.ts +35 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +39 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/registry.d.ts +207 -0
- package/dist/src/registry.d.ts.map +1 -0
- package/dist/src/registry.js +481 -0
- package/dist/src/registry.js.map +1 -0
- package/dist/src/sniff.d.ts +104 -0
- package/dist/src/sniff.d.ts.map +1 -0
- package/dist/src/sniff.js +357 -0
- package/dist/src/sniff.js.map +1 -0
- package/dist/src/types.d.ts +238 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +29 -0
- package/dist/src/types.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +122 -7
- package/src/children.ts +335 -0
- package/src/common/attributes.ts +520 -0
- package/src/common/codes.ts +153 -0
- package/src/common/declared-types.ts +374 -0
- package/src/common/direction.ts +518 -0
- package/src/common/escape.ts +231 -0
- package/src/common/export.ts +817 -0
- package/src/common/format.ts +111 -0
- package/src/common/ids.ts +176 -0
- package/src/common/input.ts +378 -0
- package/src/common/lists.ts +196 -0
- package/src/common/options.ts +377 -0
- package/src/common/report.ts +352 -0
- package/src/common/temporal.ts +302 -0
- package/src/common/text.ts +294 -0
- package/src/common/weights.ts +202 -0
- package/src/common/writer.ts +123 -0
- package/src/common/xml.ts +1053 -0
- package/src/formats/csv/exporter.ts +894 -0
- package/src/formats/csv/header.ts +172 -0
- package/src/formats/csv/importer.ts +1104 -0
- package/src/formats/csv/index.ts +88 -0
- package/src/formats/csv/records.ts +813 -0
- package/src/formats/csv/values.ts +224 -0
- package/src/formats/dot/exporter.ts +1014 -0
- package/src/formats/dot/importer.ts +1549 -0
- package/src/formats/dot/index.ts +7 -0
- package/src/formats/dot/names.ts +40 -0
- package/src/formats/dot/tokenizer.ts +384 -0
- package/src/formats/gexf/exporter.ts +1696 -0
- package/src/formats/gexf/importer.ts +2333 -0
- package/src/formats/gexf/index.ts +142 -0
- package/src/formats/gexf/schema.ts +361 -0
- package/src/formats/gml/exporter.ts +1404 -0
- package/src/formats/gml/importer.ts +1591 -0
- package/src/formats/gml/index.ts +128 -0
- package/src/formats/gml/syntax.ts +545 -0
- package/src/formats/graphml/constants.ts +225 -0
- package/src/formats/graphml/exporter.ts +1458 -0
- package/src/formats/graphml/importer.ts +2027 -0
- package/src/formats/graphml/index.ts +8 -0
- package/src/formats/graphml/tree.ts +318 -0
- package/src/formats/json/dialect.ts +317 -0
- package/src/formats/json/exporter.ts +1616 -0
- package/src/formats/json/importer.ts +2271 -0
- package/src/formats/json/index.ts +8 -0
- package/src/formats/neo4j/exporter.ts +1287 -0
- package/src/formats/neo4j/header.ts +156 -0
- package/src/formats/neo4j/importer.ts +1220 -0
- package/src/formats/neo4j/index.ts +116 -0
- package/src/formats/pajek/exporter.ts +1000 -0
- package/src/formats/pajek/importer.ts +1311 -0
- package/src/formats/pajek/index.ts +7 -0
- package/src/formats/pajek/syntax.ts +307 -0
- package/src/index.ts +244 -0
- package/src/registry.ts +617 -0
- package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0E;AAC1E,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAA2C,CAAC;AAE/F,8FAA8F;AAC9F,eAAO,MAAM,eAAe,aAAa,CAAC;AAE1C,wFAAwF;AACxF,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC,kFAAkF;AAClF,eAAO,MAAM,aAAa,WAAW,CAAC"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the JSON importer and exporter share (design sections 8.2 and 8.5): the dialect names, the
|
|
3
|
+
* reserved `meta.extra.json` shape record the importer writes and the exporter reads back, the
|
|
4
|
+
* per-dialect capability tables, the fixed key sets of each dialect and the small JSON value
|
|
5
|
+
* helpers both sides use.
|
|
6
|
+
*
|
|
7
|
+
* Dialects: NetworkX node-link (`nodes` + `links` / `edges`, graph-level `directed` / `multigraph`
|
|
8
|
+
* / `graph`), the d3 lineage of the same shape (`links`, `name` ids, integer index endpoints),
|
|
9
|
+
* JSON Graph Format v2 (`graph.nodes` keyed by id, per-edge `directed`, hyperedges), Cytoscape.js
|
|
10
|
+
* elements (`data.id` / `data.source` / `data.target`, `position`, `classes`, `data.parent`),
|
|
11
|
+
* graphology serialisation (`key` / `attributes`, `undirected` edges, `options.type` / `multi`) and
|
|
12
|
+
* vis.js (`from` / `to`).
|
|
13
|
+
*/
|
|
14
|
+
import { capabilities } from "../../common/export.js";
|
|
15
|
+
/** Every dialect name, for option checking and messages. */
|
|
16
|
+
export const JSON_DIALECTS = Object.freeze([
|
|
17
|
+
"node-link",
|
|
18
|
+
"d3",
|
|
19
|
+
"jgf",
|
|
20
|
+
"cytoscape",
|
|
21
|
+
"graphology",
|
|
22
|
+
"vis",
|
|
23
|
+
]);
|
|
24
|
+
/** The key under `meta.extra` that holds the shape record (design section 8.5). */
|
|
25
|
+
export const META_KEY = "json";
|
|
26
|
+
/**
|
|
27
|
+
* Whether a value is a plain JSON object (not null, not an array).
|
|
28
|
+
* @param value - any value
|
|
29
|
+
* @returns true for an object that is not an array
|
|
30
|
+
*/
|
|
31
|
+
export function isJsonObject(value) {
|
|
32
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether a record has an own property; JSON.parse output is checked with hasOwnProperty so a key
|
|
36
|
+
* named "constructor" or "__proto__" is never read from the prototype.
|
|
37
|
+
* @param record - the record
|
|
38
|
+
* @param key - the key
|
|
39
|
+
* @returns true when the key is an own property
|
|
40
|
+
*/
|
|
41
|
+
export function hasKey(record, key) {
|
|
42
|
+
return Object.prototype.hasOwnProperty.call(record, key);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Whether a text names a dialect.
|
|
46
|
+
* @param value - any value
|
|
47
|
+
* @returns true for one of JSON_DIALECTS
|
|
48
|
+
*/
|
|
49
|
+
export function isJsonDialect(value) {
|
|
50
|
+
return typeof value === "string" && JSON_DIALECTS.includes(value);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The dialect of a parsed JSON document, by the shape rules of design section 8.2 (Cytoscape:
|
|
54
|
+
* `elements` or a top-level array of `{ data }` elements; JGF: `graph.nodes` / `graph.edges` or
|
|
55
|
+
* `graphs[]`; graphology: `options.type` / `options.multi`, `key` nodes without `id`, edges with
|
|
56
|
+
* `undirected` or an `attributes` record; vis: edges with `from` / `to`; d3: `links` without
|
|
57
|
+
* `directed` / `multigraph` / `graph`; else node-link). Pure: the importer wraps it with its issue
|
|
58
|
+
* codes, the registry's sniff() uses it on a head that parses as a whole document.
|
|
59
|
+
* @param root - the parsed document
|
|
60
|
+
* @returns the dialect, or null when the document is not a graph document in any dialect
|
|
61
|
+
*/
|
|
62
|
+
export function sniffJsonDialect(root) {
|
|
63
|
+
if (Array.isArray(root)) {
|
|
64
|
+
const first = firstJsonObject(root);
|
|
65
|
+
return root.length === 0 || (first !== null && isJsonObject(first.data)) ? "cytoscape" : null;
|
|
66
|
+
}
|
|
67
|
+
if (!isJsonObject(root)) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
if (hasKey(root, "elements")) {
|
|
71
|
+
return "cytoscape";
|
|
72
|
+
}
|
|
73
|
+
if (isJsonObject(root.graph) && (hasKey(root.graph, "nodes") || hasKey(root.graph, "edges"))) {
|
|
74
|
+
return "jgf";
|
|
75
|
+
}
|
|
76
|
+
if (Array.isArray(root.graphs)) {
|
|
77
|
+
return "jgf";
|
|
78
|
+
}
|
|
79
|
+
if (!hasKey(root, "nodes") && !hasKey(root, "edges") && !hasKey(root, "links")) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const firstNode = firstJsonObject(root.nodes);
|
|
83
|
+
const firstEdge = firstJsonObject(hasKey(root, "edges") ? root.edges : root.links);
|
|
84
|
+
if (isJsonObject(root.options) && (hasKey(root.options, "type") || hasKey(root.options, "multi"))) {
|
|
85
|
+
return "graphology";
|
|
86
|
+
}
|
|
87
|
+
if (firstNode !== null && hasKey(firstNode, "key") && !hasKey(firstNode, "id")) {
|
|
88
|
+
return "graphology";
|
|
89
|
+
}
|
|
90
|
+
if (firstEdge !== null && !hasKey(firstEdge, "from")) {
|
|
91
|
+
if (hasKey(firstEdge, "undirected") || isJsonObject(firstEdge.attributes)) {
|
|
92
|
+
return "graphology";
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (firstEdge !== null && hasKey(firstEdge, "from") && hasKey(firstEdge, "to") && !hasKey(firstEdge, "source")) {
|
|
96
|
+
return "vis";
|
|
97
|
+
}
|
|
98
|
+
const bare = !hasKey(root, "directed") && !hasKey(root, "multigraph") && !hasKey(root, "graph");
|
|
99
|
+
return bare && hasKey(root, "links") ? "d3" : "node-link";
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The first object of an array, or null.
|
|
103
|
+
* @param value - maybe an array
|
|
104
|
+
* @returns the first element that is an object
|
|
105
|
+
*/
|
|
106
|
+
function firstJsonObject(value) {
|
|
107
|
+
if (!Array.isArray(value)) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const found = value.find((item) => isJsonObject(item));
|
|
111
|
+
return isJsonObject(found) ? found : null;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The shape record of a snapshot's metadata, or an empty record when the snapshot did not come
|
|
115
|
+
* from the JSON importer.
|
|
116
|
+
* @param meta - the snapshot's metadata
|
|
117
|
+
* @returns the fields found under `meta.extra.json`, each only when it has the expected type
|
|
118
|
+
*/
|
|
119
|
+
export function shapeMetaOf(meta) {
|
|
120
|
+
const raw = meta.extra[META_KEY];
|
|
121
|
+
if (!isJsonObject(raw)) {
|
|
122
|
+
return {};
|
|
123
|
+
}
|
|
124
|
+
const text = (key) => (typeof raw[key] === "string" ? raw[key] : undefined);
|
|
125
|
+
const flag = (key) => (typeof raw[key] === "boolean" ? raw[key] : undefined);
|
|
126
|
+
const { nodeIdKey } = raw;
|
|
127
|
+
return {
|
|
128
|
+
dialect: isJsonDialect(raw.dialect) ? raw.dialect : undefined,
|
|
129
|
+
edgesKey: text("edgesKey"),
|
|
130
|
+
nodeIdKey: nodeIdKey === null || typeof nodeIdKey === "string" ? nodeIdKey : undefined,
|
|
131
|
+
indexLinks: flag("indexLinks"),
|
|
132
|
+
sourceKey: text("sourceKey"),
|
|
133
|
+
targetKey: text("targetKey"),
|
|
134
|
+
id: text("id"),
|
|
135
|
+
type: text("type"),
|
|
136
|
+
allowSelfLoops: flag("allowSelfLoops"),
|
|
137
|
+
cytoscape: isJsonObject(raw.cytoscape) ? raw.cytoscape : undefined,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/** The direction a dialect assumes when the file declares none (design section 8.4, `defaultDirected`). */
|
|
141
|
+
export const DIALECT_DEFAULT_DIRECTED = Object.freeze({
|
|
142
|
+
"node-link": false,
|
|
143
|
+
d3: false,
|
|
144
|
+
jgf: true,
|
|
145
|
+
cytoscape: true,
|
|
146
|
+
graphology: true,
|
|
147
|
+
vis: false,
|
|
148
|
+
});
|
|
149
|
+
/**
|
|
150
|
+
* The dtypes a JSON dialect keeps as declared: JSON declares no types, so a value reads back as
|
|
151
|
+
* what the importer's inference gives it (design section 5.1: integral numbers i32, other numbers
|
|
152
|
+
* f64, booleans, strings). f32 values re-read as f64 differ from the f32 ones, u32 / u8 come back
|
|
153
|
+
* i32, dict comes back string, a multi-component or list value comes back json.
|
|
154
|
+
*/
|
|
155
|
+
const JSON_DTYPES = Object.freeze(["f64", "i32", "bool", "string"]);
|
|
156
|
+
const COMMON = {
|
|
157
|
+
multiEdges: true,
|
|
158
|
+
selfLoops: true,
|
|
159
|
+
idCharset: "any",
|
|
160
|
+
dtypes: JSON_DTYPES,
|
|
161
|
+
components: false,
|
|
162
|
+
lists: false,
|
|
163
|
+
json: true,
|
|
164
|
+
defaults: false,
|
|
165
|
+
options: false,
|
|
166
|
+
temporal: "none",
|
|
167
|
+
positions: false,
|
|
168
|
+
viz: false,
|
|
169
|
+
};
|
|
170
|
+
const TABLES = Object.freeze({
|
|
171
|
+
"node-link": capabilities({
|
|
172
|
+
...COMMON,
|
|
173
|
+
mixedDirection: false,
|
|
174
|
+
edgeIds: "none",
|
|
175
|
+
hierarchy: false,
|
|
176
|
+
graphAttributes: true,
|
|
177
|
+
}),
|
|
178
|
+
d3: capabilities({
|
|
179
|
+
...COMMON,
|
|
180
|
+
mixedDirection: false,
|
|
181
|
+
edgeIds: "none",
|
|
182
|
+
hierarchy: false,
|
|
183
|
+
graphAttributes: false,
|
|
184
|
+
}),
|
|
185
|
+
jgf: capabilities({
|
|
186
|
+
...COMMON,
|
|
187
|
+
mixedDirection: true,
|
|
188
|
+
edgeIds: "optional",
|
|
189
|
+
hierarchy: false,
|
|
190
|
+
graphAttributes: true,
|
|
191
|
+
}),
|
|
192
|
+
cytoscape: capabilities({
|
|
193
|
+
...COMMON,
|
|
194
|
+
positions: true,
|
|
195
|
+
mixedDirection: false,
|
|
196
|
+
edgeIds: "required",
|
|
197
|
+
hierarchy: true,
|
|
198
|
+
graphAttributes: true,
|
|
199
|
+
}),
|
|
200
|
+
graphology: capabilities({
|
|
201
|
+
...COMMON,
|
|
202
|
+
mixedDirection: true,
|
|
203
|
+
edgeIds: "optional",
|
|
204
|
+
hierarchy: false,
|
|
205
|
+
graphAttributes: true,
|
|
206
|
+
}),
|
|
207
|
+
vis: capabilities({
|
|
208
|
+
...COMMON,
|
|
209
|
+
mixedDirection: false,
|
|
210
|
+
edgeIds: "optional",
|
|
211
|
+
hierarchy: false,
|
|
212
|
+
graphAttributes: false,
|
|
213
|
+
}),
|
|
214
|
+
});
|
|
215
|
+
/**
|
|
216
|
+
* What one dialect can express (design section 8.5): positions and visual columns are written as
|
|
217
|
+
* plain attributes (an array for a multi-component column) and read back without their role,
|
|
218
|
+
* except Cytoscape's `position` object; containment only as the Cytoscape `data.parent`; mixed
|
|
219
|
+
* direction only where the dialect carries a per-edge flag (JGF `directed`, graphology
|
|
220
|
+
* `undirected`); edge ids where the dialect has a slot (not node-link / d3); nothing temporal;
|
|
221
|
+
* graph attributes everywhere but d3 (the bare shape) and vis.
|
|
222
|
+
* @param dialect - the dialect
|
|
223
|
+
* @returns its frozen capability table
|
|
224
|
+
*/
|
|
225
|
+
export function dialectCapabilities(dialect) {
|
|
226
|
+
return TABLES[dialect];
|
|
227
|
+
}
|
|
228
|
+
/** The Cytoscape element-level keys (everything else on an element lives under `data`). */
|
|
229
|
+
export const CYTOSCAPE_ELEMENT_KEYS = new Set([
|
|
230
|
+
"selected",
|
|
231
|
+
"selectable",
|
|
232
|
+
"locked",
|
|
233
|
+
"grabbable",
|
|
234
|
+
"pannable",
|
|
235
|
+
"removed",
|
|
236
|
+
"scratch",
|
|
237
|
+
"renderedPosition",
|
|
238
|
+
]);
|
|
239
|
+
/** The Cytoscape element keys the importer maps structurally rather than to columns. */
|
|
240
|
+
export const CYTOSCAPE_STRUCTURAL_KEYS = new Set(["data", "group", "position", "classes"]);
|
|
241
|
+
/**
|
|
242
|
+
* The suffix the importer appends to a column name that collides with a structural column or a
|
|
243
|
+
* reserved key of its dialect (design section 5.6 names collisions deterministically); the exporter
|
|
244
|
+
* strips it when the value goes back to the level the suffix names.
|
|
245
|
+
*/
|
|
246
|
+
export const SUFFIX = Object.freeze({
|
|
247
|
+
/** A Cytoscape `data` key or a JGF / graphology attribute that collides with a structural column. */
|
|
248
|
+
data: "#data",
|
|
249
|
+
/** An element-level key the dialect does not define (Cytoscape, JGF, graphology). */
|
|
250
|
+
element: "#element",
|
|
251
|
+
});
|
|
252
|
+
/** The default source keys of a node-link edge record, tried in order (as fromRecords does). */
|
|
253
|
+
export const NODE_LINK_SOURCE_KEYS = Object.freeze(["source", "src", "from"]);
|
|
254
|
+
/** The default target keys of a node-link edge record, tried in order. */
|
|
255
|
+
export const NODE_LINK_TARGET_KEYS = Object.freeze(["target", "dst", "to"]);
|
|
256
|
+
/** The name of the position column every JSON dialect writes / reads (design section 5.2). */
|
|
257
|
+
export const POSITION_COLUMN = "position";
|
|
258
|
+
/** The name of the Cytoscape classes column (a list of strings with role "classes"). */
|
|
259
|
+
export const CLASSES_COLUMN = "classes";
|
|
260
|
+
/** The name of the Cytoscape parent column (u32 refersTo node, role "parent"). */
|
|
261
|
+
export const PARENT_COLUMN = "parent";
|
|
262
|
+
//# sourceMappingURL=dialect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialect.js","sourceRoot":"","sources":["../../../../src/formats/json/dialect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAMtD,4DAA4D;AAC5D,MAAM,CAAC,MAAM,aAAa,GAA2B,MAAM,CAAC,MAAM,CAAC;IAC/D,WAAW;IACX,IAAI;IACJ,KAAK;IACL,WAAW;IACX,YAAY;IACZ,KAAK;CACR,CAAC,CAAC;AAEH,mFAAmF;AACnF,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC;AA8B/B;;;;GAIG;AACH,MAAM,UAAU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): one GraphExporter with a `dialect` option writing
|
|
3
|
+
* NetworkX node-link (the default), d3 (`links`, optional index endpoints), JSON Graph Format v2,
|
|
4
|
+
* Cytoscape.js elements, graphology serialisation or vis.js. The dialect defaults to the one the
|
|
5
|
+
* importer recorded under `meta.extra.json` so a JSON file re-exported as JSON keeps its shape,
|
|
6
|
+
* and to node-link for a snapshot from any other source.
|
|
7
|
+
*
|
|
8
|
+
* check() runs the generic capability pre-flight against the dialect's table and appends the
|
|
9
|
+
* dialect-specific notes (non-finite numbers written as null, JGF id stringification / collisions
|
|
10
|
+
* / node order, direction dropped by Cytoscape and vis, mutual pairs expanded, reserved key
|
|
11
|
+
* collisions, positions written as plain attributes, a Cytoscape `parents` column) before anything
|
|
12
|
+
* is written; the same column plan drives write(), so the notes and the output agree.
|
|
13
|
+
*
|
|
14
|
+
* Every column without a structural slot in the dialect is written as a plain attribute under its
|
|
15
|
+
* column name; an f32 value is written as the shortest decimal that round-trips through
|
|
16
|
+
* Math.fround (design section 3.7); a multi-component value is an array; a list is an array; a json
|
|
17
|
+
* value is its JSON text; an unset row writes no key (design section 5.3). Non-finite numbers,
|
|
18
|
+
* which JSON cannot carry, become null and are reported.
|
|
19
|
+
*/
|
|
20
|
+
import { type ExportCapabilities, type GraphExporter } from "../../types.js";
|
|
21
|
+
import { type JsonDialect } from "./dialect.js";
|
|
22
|
+
/** The format-specific options of the JSON exporter. */
|
|
23
|
+
export interface JsonExportOptions {
|
|
24
|
+
/** The dialect to write; default: the dialect the importer recorded, else "node-link". */
|
|
25
|
+
dialect?: JsonDialect | undefined;
|
|
26
|
+
/** Spaces per indentation level; 0 (default) writes compact JSON. */
|
|
27
|
+
indent?: number | undefined;
|
|
28
|
+
/** node-link / d3: the key of the edge array; default: the recorded key, else "edges" (d3: "links"). */
|
|
29
|
+
edgesKey?: string | undefined;
|
|
30
|
+
/** node-link / d3 / vis: the node id key; default: the recorded key, else "id". */
|
|
31
|
+
nodeIdKey?: string | undefined;
|
|
32
|
+
/** node-link / d3: write endpoints as node array positions; default: the recorded flag, else false. */
|
|
33
|
+
indexLinks?: boolean | undefined;
|
|
34
|
+
/** node-link / d3 / vis: the source key; default: the recorded key, else "source" (vis: "from"). */
|
|
35
|
+
sourceKey?: string | undefined;
|
|
36
|
+
/** node-link / d3 / vis: the target key; default: the recorded key, else "target" (vis: "to"). */
|
|
37
|
+
targetKey?: string | undefined;
|
|
38
|
+
/** The key the weight is written under; default: the key the JSON importer read it from, else "weight". */
|
|
39
|
+
weightKey?: string | undefined;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The LossNote codes of the JSON exporter's check(): the dialect-specific ones and, aliased, the
|
|
43
|
+
* shared ones it records (`LOSS` holds the rest of the generic pre-flight's codes). A key is the
|
|
44
|
+
* code without its severity prefix.
|
|
45
|
+
*/
|
|
46
|
+
export declare const JSON_LOSS: Readonly<{
|
|
47
|
+
/** Non-finite numbers (columns, weights) are written as null. */
|
|
48
|
+
NONFINITE_AS_NULL: "W_NONFINITE_AS_NULL";
|
|
49
|
+
/** Cytoscape, vis and d3 carry no direction; the file re-imports with the dialect's default direction. */
|
|
50
|
+
DIRECTION_DROPPED: "W_DIRECTION_DROPPED";
|
|
51
|
+
/** GEXF mutual pairs are written as two directed edges. */
|
|
52
|
+
MUTUAL_EXPANDED: "W_MUTUAL_EXPANDED";
|
|
53
|
+
/** JGF keys its nodes by string; numeric ids re-import as text unless ids: "canonical". */
|
|
54
|
+
NUMERIC_IDS_STRINGIFIED: "W_NUMERIC_IDS_STRINGIFIED";
|
|
55
|
+
/** JGF: two ids have the same text; export() throws E_INVALID_ID. */
|
|
56
|
+
ID_TEXT_COLLISION: "E_ID_TEXT_COLLISION";
|
|
57
|
+
/** JGF: integer-like id keys are enumerated first and ascending by JSON parsers; node order changes on re-import. */
|
|
58
|
+
NODE_ORDER: "W_NODE_ORDER";
|
|
59
|
+
/** A column named like a reserved key of the dialect (id, source, target, ...) is skipped. */
|
|
60
|
+
RESERVED_KEY: "W_RESERVED_KEY";
|
|
61
|
+
/** A plain edge column named like the weight key reads back as THE weight (or is skipped when weights are written). */
|
|
62
|
+
WEIGHT_KEY_CLASH: "W_WEIGHT_KEY_CLASH";
|
|
63
|
+
/** A position column without a slot (every dialect but Cytoscape) is a plain array attribute; the role is lost. */
|
|
64
|
+
POSITIONS_DROPPED: "W_POSITIONS_DROPPED";
|
|
65
|
+
/** Cytoscape positions are 2D; non-zero z values are dropped. */
|
|
66
|
+
POSITION_Z_DROPPED: "W_POSITION_Z_DROPPED";
|
|
67
|
+
/** Cytoscape has a single parent; a `parents` list column cannot be written. */
|
|
68
|
+
PARENTS_DROPPED: "W_PARENTS_DROPPED";
|
|
69
|
+
/** node-link / d3 have no edge id slot; the id column is written as a plain attribute. */
|
|
70
|
+
EDGE_IDS_DROPPED: "W_EDGE_IDS_DROPPED";
|
|
71
|
+
/** An f64 column of integral values reads back as i32 (JSON declares no types). */
|
|
72
|
+
INTEGRAL_F64_AS_I32: "W_INTEGRAL_F64_AS_I32";
|
|
73
|
+
/** A role column the dialect has no slot for is a plain attribute; the role is lost. */
|
|
74
|
+
ROLE_DROPPED: "W_ROLE_DROPPED";
|
|
75
|
+
/** A column without a set cell is not written (JSON declares no columns). */
|
|
76
|
+
EMPTY_COLUMN_DROPPED: "W_EMPTY_COLUMN_DROPPED";
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* The JSON exporter plugin (design section 8.5). `capabilities` is the node-link table (the
|
|
80
|
+
* default dialect); check() applies the table of the dialect actually selected.
|
|
81
|
+
*/
|
|
82
|
+
export declare const jsonExporter: GraphExporter<JsonExportOptions>;
|
|
83
|
+
/**
|
|
84
|
+
* The capability table of one dialect, for callers that pick a dialect before check().
|
|
85
|
+
* @param dialect - the dialect
|
|
86
|
+
* @returns the frozen table
|
|
87
|
+
*/
|
|
88
|
+
export declare function jsonCapabilities(dialect: JsonDialect): ExportCapabilities;
|
|
89
|
+
//# sourceMappingURL=exporter.d.ts.map
|
|
@@ -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