@graphty/graph-io 0.3.2 → 0.3.3
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/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-BELrICWM.js} +12 -1
- package/dist/chunks/importer-BELrICWM.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/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/importer.d.ts +2 -0
- package/dist/src/formats/json/importer.d.ts.map +1 -1
- package/dist/src/formats/json/importer.js +13 -0
- package/dist/src/formats/json/importer.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/package.json +2 -2
- package/dist/chunks/importer-DbMrAR_w.js.map +0 -1
- package/dist/chunks/importer-DkzjTvHc.js.map +0 -1
package/dist/graph-io.js
CHANGED
|
@@ -4,22 +4,22 @@ import { C as C2, c as c2, a } from "./chunks/children-CL3Cy0ez.js";
|
|
|
4
4
|
import { GraphFormatError, GraphBuilder } from "@graphty/graph-format";
|
|
5
5
|
import { csvImporter, csvExporter } from "./csv.js";
|
|
6
6
|
import { CSV_CAPABILITIES, CSV_ISSUE, CSV_LOSS } from "./csv.js";
|
|
7
|
-
import { b as dotImporter, d as dotExporter } from "./chunks/importer-
|
|
8
|
-
import { D as D2, a as a10 } from "./chunks/importer-
|
|
7
|
+
import { b as dotImporter, d as dotExporter } from "./chunks/importer-xoHpRG5x.js";
|
|
8
|
+
import { D as D2, a as a10 } from "./chunks/importer-xoHpRG5x.js";
|
|
9
9
|
import { gexfImporter, gexfExporter } from "./gexf.js";
|
|
10
10
|
import { GEXF_1_2_CAPABILITIES, GEXF_ISSUE, GEXF_LOSS } from "./gexf.js";
|
|
11
11
|
import { gmlImporter, gmlExporter } from "./gml.js";
|
|
12
12
|
import { GML_ISSUE, GML_LOSS } from "./gml.js";
|
|
13
|
-
import { b as graphmlImporter, g as graphmlExporter } from "./chunks/importer-
|
|
14
|
-
import { G as G2, a as a11 } from "./chunks/importer-
|
|
15
|
-
import { s as sniffJsonDialect, e as jsonImporter, c as jsonExporter } from "./chunks/importer-
|
|
16
|
-
import { J as J2, a as a12, b as b2, d as d2, j as j2 } from "./chunks/importer-
|
|
13
|
+
import { b as graphmlImporter, g as graphmlExporter } from "./chunks/importer-B9qF4e32.js";
|
|
14
|
+
import { G as G2, a as a11 } from "./chunks/importer-B9qF4e32.js";
|
|
15
|
+
import { s as sniffJsonDialect, e as jsonImporter, c as jsonExporter } from "./chunks/importer-BELrICWM.js";
|
|
16
|
+
import { J as J2, a as a12, b as b2, d as d2, j as j2 } from "./chunks/importer-BELrICWM.js";
|
|
17
17
|
import { neo4jImporter, neo4jExporter } from "./neo4j.js";
|
|
18
18
|
import { ID_SPACE_COLUMN, LABELS_COLUMN, NEO4J_CAPABILITIES, NEO4J_ISSUE, NEO4J_LOSS, TYPE_COLUMN } from "./neo4j.js";
|
|
19
|
-
import { b as pajekImporter, p as pajekExporter } from "./chunks/importer-
|
|
20
|
-
import { P as P2, a as a13 } from "./chunks/importer-
|
|
19
|
+
import { b as pajekImporter, p as pajekExporter } from "./chunks/importer-C2caVvl6.js";
|
|
20
|
+
import { P as P2, a as a13 } from "./chunks/importer-C2caVvl6.js";
|
|
21
21
|
import { T as T2, W as W2, i as i2, a as a14, p as p2 } from "./chunks/text-Dr0Ifpag.js";
|
|
22
|
-
import { X as X2, a as a15, h as h2, t as t2, x as x2 } from "./chunks/escape-
|
|
22
|
+
import { X as X2, a as a15, h as h2, t as t2, x as x2 } from "./chunks/escape-DXbOoLKl.js";
|
|
23
23
|
const GRAPH_FORMATS = Object.freeze([
|
|
24
24
|
"json",
|
|
25
25
|
"graphml",
|
package/dist/graphml.js
CHANGED
package/dist/json.js
CHANGED
package/dist/neo4j.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { X as ROLE_TAKEN_CODE$1, o as ID_MERGED_CODE$1, k as DUPLICATE_NODE_CODE$1, M as MISSING_ENDPOINT_CODE$1, y as MISSING_ID_CODE$1, aF as resolveImportOptions, I as ImportReportBuilder, aC as reportSinkOptions, aD as reportUnusedOptions, a as throwIfAborted, v as IdCoercer, l as DirectionResolver, w as ImportError, aO as declareAttribute, b1 as declareOn, aL as uniqueColumnName, U as RENAMED_CODE, aA as parseWeightText, aP as parseDeclaredTemporal, aQ as parseDeclaredValue, aR as losesPrecision, ah as declareCompanion, T as PRECISION_CODE, aT as splitListText, au as isImportInput, b0 as takenIn, ar as inputLength, ac as capabilities, p as ID_TEXT_COLLISION_CODE, q as ID_TEXT_TYPE_CODE, ax as joinText, ak as encodeChunks, aE as resolveExportOptions, ad as checkCapabilities, az as pairFolding, L as LOSS, aX as mapDeclaredType, al as explicitWeights, at as isCanonicalIntegerText, aZ as formatTemporal, ao as formatF64, an as formatF32, aq as formatInteger, Y as SINK_OPTION_CODE, P as OPTION_IGNORED_CODE, C as COLUMN_RENAMED_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, a8 as WEIGHT_KEY_CLASH_CODE, W as ROLE_DROPPED_CODE, J as MUTUAL_EXPANDED_CODE } from "./chunks/writer-BdMak4_J.js";
|
|
2
2
|
import { c as checkRecordSyntax, R as RecordReader, B as BAD_QUOTE_CODE, U as UNCLOSED_QUOTE_CODE } from "./chunks/records-BKSMowhR.js";
|
|
3
3
|
import { GraphFormatError, INVALID_INDEX } from "@graphty/graph-format";
|
|
4
|
-
import { n as quoteCsvCell } from "./chunks/escape-
|
|
4
|
+
import { n as quoteCsvCell } from "./chunks/escape-DXbOoLKl.js";
|
|
5
5
|
const STRUCTURAL = /* @__PURE__ */ new Set(["ID", "LABEL", "START_ID", "END_ID", "TYPE", "IGNORE"]);
|
|
6
6
|
const SPACE_KINDS = /* @__PURE__ */ new Set(["ID", "START_ID", "END_ID"]);
|
|
7
7
|
const HEADER_MARKER = /^[^:{}()]*:\s*(ID|START_ID|END_ID)\s*(\(|\{|$)/i;
|
|
@@ -95,6 +95,7 @@ const MISSING_ID_CODE = MISSING_ID_CODE$1;
|
|
|
95
95
|
const MISSING_ENDPOINT_CODE = MISSING_ENDPOINT_CODE$1;
|
|
96
96
|
const DUPLICATE_NODE_CODE = DUPLICATE_NODE_CODE$1;
|
|
97
97
|
const ID_SPACE_COLLISION_CODE = "E_NEO4J_ID_SPACE_COLLISION";
|
|
98
|
+
const ENDPOINT_SPACE_CODE = "E_NEO4J_ENDPOINT_SPACE";
|
|
98
99
|
const ID_MERGED_CODE = ID_MERGED_CODE$1;
|
|
99
100
|
const HEADER_OPTION_CODE = "W_NEO4J_HEADER_OPTION_IGNORED";
|
|
100
101
|
const ROLE_TAKEN_CODE = ROLE_TAKEN_CODE$1;
|
|
@@ -223,6 +224,14 @@ class NodeRegistry {
|
|
|
223
224
|
}
|
|
224
225
|
return previous === code ? "duplicate" : "collision";
|
|
225
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* The space code a node row declared a node in.
|
|
229
|
+
* @param index - the node index
|
|
230
|
+
* @returns the code, or 0 when no node row declared the node
|
|
231
|
+
*/
|
|
232
|
+
codeAt(index) {
|
|
233
|
+
return index < this.codes.length ? this.codes[index] : 0;
|
|
234
|
+
}
|
|
226
235
|
}
|
|
227
236
|
class ProgressTracker {
|
|
228
237
|
/**
|
|
@@ -494,7 +503,19 @@ class Neo4jImportSession {
|
|
|
494
503
|
weightCell = fields.findIndex((field) => field.kind === "PROPERTY" && field.name === weightFrom);
|
|
495
504
|
}
|
|
496
505
|
const properties = this.declareProperties("edge", fields, line, weightCell);
|
|
497
|
-
|
|
506
|
+
const { space: startSpace } = fields[startCell];
|
|
507
|
+
const { space: endSpace } = fields[endCell];
|
|
508
|
+
return {
|
|
509
|
+
kind: "relationship",
|
|
510
|
+
width: fields.length,
|
|
511
|
+
startCell,
|
|
512
|
+
endCell,
|
|
513
|
+
startSpaceCode: startSpace === null ? 0 : this.registry.codeOf(startSpace),
|
|
514
|
+
endSpaceCode: endSpace === null ? 0 : this.registry.codeOf(endSpace),
|
|
515
|
+
typeCell,
|
|
516
|
+
weightCell,
|
|
517
|
+
properties
|
|
518
|
+
};
|
|
498
519
|
}
|
|
499
520
|
/**
|
|
500
521
|
* Declare every PROPERTY field of a header.
|
|
@@ -741,6 +762,22 @@ class Neo4jImportSession {
|
|
|
741
762
|
report.counts.skippedEdges++;
|
|
742
763
|
return;
|
|
743
764
|
}
|
|
765
|
+
let wrongSpace = null;
|
|
766
|
+
if (this.wrongSpace(source, section.startSpaceCode)) {
|
|
767
|
+
wrongSpace = startText;
|
|
768
|
+
} else if (this.wrongSpace(target, section.endSpaceCode)) {
|
|
769
|
+
wrongSpace = endText;
|
|
770
|
+
}
|
|
771
|
+
if (wrongSpace !== null) {
|
|
772
|
+
report.error(
|
|
773
|
+
"missing-value",
|
|
774
|
+
ENDPOINT_SPACE_CODE,
|
|
775
|
+
`endpoint ${wrongSpace} is not a node of its declared id space (a node of another id space has that id); the row is skipped`,
|
|
776
|
+
{ line, element }
|
|
777
|
+
);
|
|
778
|
+
report.counts.skippedEdges++;
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
744
781
|
let weight;
|
|
745
782
|
if (section.weightCell >= 0) {
|
|
746
783
|
try {
|
|
@@ -773,6 +810,25 @@ class Neo4jImportSession {
|
|
|
773
810
|
this.reportPrecision(line, element);
|
|
774
811
|
report.counts.edges++;
|
|
775
812
|
}
|
|
813
|
+
/**
|
|
814
|
+
* Whether an endpoint id belongs to a node a node row declared in another id space than the
|
|
815
|
+
* endpoint's header declares. An endpoint without a declared space, or a node no row declared
|
|
816
|
+
* yet, is looked up by id alone.
|
|
817
|
+
* @param id - the endpoint id
|
|
818
|
+
* @param spaceCode - the endpoint's space code, 0 for none
|
|
819
|
+
* @returns true when the endpoint resolves to a node of another space
|
|
820
|
+
*/
|
|
821
|
+
wrongSpace(id, spaceCode) {
|
|
822
|
+
if (spaceCode === 0) {
|
|
823
|
+
return false;
|
|
824
|
+
}
|
|
825
|
+
const index = this.sink.indexOf(id);
|
|
826
|
+
if (index < 0) {
|
|
827
|
+
return false;
|
|
828
|
+
}
|
|
829
|
+
const declared = this.registry.codeAt(index);
|
|
830
|
+
return declared !== 0 && declared !== spaceCode;
|
|
831
|
+
}
|
|
776
832
|
/**
|
|
777
833
|
* Coerce an id cell, reporting a merge under `ids: "number"` and an invalid id as an error.
|
|
778
834
|
* @param text - the cell
|
|
@@ -1996,6 +2052,8 @@ const NEO4J_ISSUE = Object.freeze({
|
|
|
1996
2052
|
DUPLICATE_NODE: DUPLICATE_NODE_CODE,
|
|
1997
2053
|
/** A node id declared in two id spaces. */
|
|
1998
2054
|
ID_SPACE_COLLISION: ID_SPACE_COLLISION_CODE,
|
|
2055
|
+
/** A relationship endpoint whose id belongs to a node of another id space; the row is skipped. */
|
|
2056
|
+
ENDPOINT_SPACE: ENDPOINT_SPACE_CODE,
|
|
1999
2057
|
/** Two id texts merged into one number under ids "number". */
|
|
2000
2058
|
ID_MERGED: ID_MERGED_CODE,
|
|
2001
2059
|
/** A header brace option the importer does not apply. */
|