@graphty/graph-io 0.3.27 → 0.3.29
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/{choose-DrXtu_96.js → choose-DT5da6OC.js} +2 -2
- package/dist/chunks/{choose-DrXtu_96.js.map → choose-DT5da6OC.js.map} +1 -1
- package/dist/chunks/{constants-ikG85dT8.js → constants-DowRD9ai.js} +2 -2
- package/dist/chunks/{constants-ikG85dT8.js.map → constants-DowRD9ai.js.map} +1 -1
- package/dist/chunks/{escape-D1HPTUrP.js → escape-DQC5HWqF.js} +2 -2
- package/dist/chunks/{escape-D1HPTUrP.js.map → escape-DQC5HWqF.js.map} +1 -1
- package/dist/chunks/{export-CHd4tQE2.js → export-CVi12U7J.js} +81 -60
- package/dist/chunks/export-CVi12U7J.js.map +1 -0
- package/dist/chunks/{exporter-D23CKNqF.js → exporter-C3Pa2PSd.js} +5 -5
- package/dist/chunks/exporter-C3Pa2PSd.js.map +1 -0
- package/dist/chunks/{exporter-DfWTgrti.js → exporter-CgsO2nSl.js} +4 -4
- package/dist/chunks/{exporter-DfWTgrti.js.map → exporter-CgsO2nSl.js.map} +1 -1
- package/dist/chunks/{exporter-IHv4nkCm.js → exporter-Cy_1da4c.js} +72 -48
- package/dist/chunks/exporter-Cy_1da4c.js.map +1 -0
- package/dist/chunks/{exporter-DhtW6FxK.js → exporter-JubAlNWi.js} +34 -34
- package/dist/chunks/exporter-JubAlNWi.js.map +1 -0
- package/dist/chunks/{importer-CIAzt-wo.js → importer-BA_hZKo7.js} +4 -4
- package/dist/chunks/{importer-CIAzt-wo.js.map → importer-BA_hZKo7.js.map} +1 -1
- package/dist/chunks/{importer-B1wmPQjr.js → importer-CDXlxXlS.js} +35 -9
- package/dist/chunks/importer-CDXlxXlS.js.map +1 -0
- package/dist/chunks/{importer-BVRE--Un.js → importer-DLz2Vb4q.js} +3 -3
- package/dist/chunks/{importer-BVRE--Un.js.map → importer-DLz2Vb4q.js.map} +1 -1
- package/dist/chunks/{importer-B2W_58pz.js → importer-DVxzzibh.js} +4 -4
- package/dist/chunks/{importer-B2W_58pz.js.map → importer-DVxzzibh.js.map} +1 -1
- package/dist/chunks/{importer-BSALvkui.js → importer-Dej72hIF.js} +6 -6
- package/dist/chunks/importer-Dej72hIF.js.map +1 -0
- package/dist/chunks/{importer-z_FL4VMb.js → importer-lLH9gQF_.js} +5 -5
- package/dist/chunks/{importer-z_FL4VMb.js.map → importer-lLH9gQF_.js.map} +1 -1
- package/dist/chunks/{importer-DpEW5zeG.js → importer-q-R-Q98w.js} +4 -4
- package/dist/chunks/{importer-DpEW5zeG.js.map → importer-q-R-Q98w.js.map} +1 -1
- package/dist/chunks/{json-elements-BAmNBZok.js → json-elements-1IUzkRNy.js} +3 -3
- package/dist/chunks/{json-elements-BAmNBZok.js.map → json-elements-1IUzkRNy.js.map} +1 -1
- package/dist/chunks/{ontology-export-Bab4eUA8.js → ontology-export-b0GLNIj-.js} +2 -2
- package/dist/chunks/{ontology-export-Bab4eUA8.js.map → ontology-export-b0GLNIj-.js.map} +1 -1
- package/dist/chunks/{records-CdlvL4RO.js → records-CdyqwXeY.js} +2 -2
- package/dist/chunks/{records-CdlvL4RO.js.map → records-CdyqwXeY.js.map} +1 -1
- package/dist/chunks/{text-DzXjAiTl.js → text-CDgjbkLC.js} +2 -2
- package/dist/chunks/{text-DzXjAiTl.js.map → text-CDgjbkLC.js.map} +1 -1
- package/dist/csv.js +33 -16
- package/dist/csv.js.map +1 -1
- package/dist/cx.js +1 -1
- package/dist/cx2.js +2 -2
- package/dist/cys.js +1 -1
- package/dist/dot.js +1 -1
- package/dist/gexf.js +2 -2
- package/dist/gml.js +18 -9
- package/dist/gml.js.map +1 -1
- package/dist/graph-io.js +26 -26
- package/dist/graph-io.js.map +1 -1
- package/dist/graphml.js +2 -2
- package/dist/json.js +1 -1
- package/dist/neo4j.js +3 -3
- package/dist/obo.js +1 -1
- package/dist/pajek.js +1 -1
- package/dist/src/common/declared-types.d.ts.map +1 -1
- package/dist/src/common/declared-types.js.map +1 -1
- package/dist/src/common/export.d.ts +6 -0
- package/dist/src/common/export.d.ts.map +1 -1
- package/dist/src/common/export.js +62 -28
- package/dist/src/common/export.js.map +1 -1
- package/dist/src/common/zip.js.map +1 -1
- package/dist/src/formats/csv/exporter.d.ts.map +1 -1
- package/dist/src/formats/csv/exporter.js +18 -7
- package/dist/src/formats/csv/exporter.js.map +1 -1
- package/dist/src/formats/csv/importer.d.ts.map +1 -1
- package/dist/src/formats/csv/importer.js +20 -2
- package/dist/src/formats/csv/importer.js.map +1 -1
- package/dist/src/formats/cx2/exporter.d.ts.map +1 -1
- package/dist/src/formats/cx2/exporter.js +84 -33
- package/dist/src/formats/cx2/exporter.js.map +1 -1
- package/dist/src/formats/dot/exporter.js +30 -4
- package/dist/src/formats/dot/exporter.js.map +1 -1
- package/dist/src/formats/dot/importer.js.map +1 -1
- package/dist/src/formats/gml/exporter.d.ts.map +1 -1
- package/dist/src/formats/gml/exporter.js +23 -6
- package/dist/src/formats/gml/exporter.js.map +1 -1
- package/dist/src/formats/obo/syntax.d.ts +4 -0
- package/dist/src/formats/obo/syntax.d.ts.map +1 -1
- package/dist/src/formats/obo/syntax.js +35 -31
- package/dist/src/formats/obo/syntax.js.map +1 -1
- package/dist/src/formats/pajek/importer.js.map +1 -1
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/registry.js.map +1 -1
- package/dist/src/sniff.d.ts.map +1 -1
- package/dist/src/sniff.js.map +1 -1
- package/dist/src/types.d.ts +6 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/xgmml.js +2 -2
- package/package.json +2 -2
- package/src/common/declared-types.ts +1 -10
- package/src/common/export.ts +105 -62
- package/src/common/zip.ts +1 -1
- package/src/formats/csv/exporter.ts +19 -15
- package/src/formats/csv/importer.ts +21 -2
- package/src/formats/cx2/exporter.ts +123 -49
- package/src/formats/dot/exporter.ts +37 -4
- package/src/formats/dot/importer.ts +1 -1
- package/src/formats/gml/exporter.ts +24 -6
- package/src/formats/obo/syntax.ts +35 -31
- package/src/formats/pajek/importer.ts +1 -1
- package/src/registry.ts +9 -10
- package/src/sniff.ts +2 -21
- package/src/types.ts +7 -7
- package/dist/chunks/export-CHd4tQE2.js.map +0 -1
- package/dist/chunks/exporter-D23CKNqF.js.map +0 -1
- package/dist/chunks/exporter-DhtW6FxK.js.map +0 -1
- package/dist/chunks/exporter-IHv4nkCm.js.map +0 -1
- package/dist/chunks/importer-B1wmPQjr.js.map +0 -1
- package/dist/chunks/importer-BSALvkui.js.map +0 -1
package/dist/csv.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { b as plural, bV as DICT_SAMPLE_ROWS, ac as DictHeuristic, R as ROLE_TAKEN_CODE$1, I as ID_MERGED_CODE$1, m as DUPLICATE_EDGE_ID_CODE$1, n as DUPLICATE_NODE_CODE$1, t as MISSING_ID_CODE$1, s as MISSING_ENDPOINT_CODE$1, E as EMPTY_INPUT_CODE$1, al as resolveImportOptions, a8 as ImportReportBuilder, ao as reportSinkOptions, an as reportUnusedOptions, aq as DirectionResolver, ar as IdCoercer, am as throwIfAborted, O as OPTION_IGNORED_CODE, aL as parseWeightText, a0 as uniqueColumnName, ay as RENAMED_CODE, a1 as declareResolved, c as capabilities, L as LOSS, a as checkCapabilities, r as resolveExportOptions, p as pairFolding, bE as countMixedEdges, $ as agree, e as explicitWeights, b$ as otherFormatDialect, bT as joinListText, aG as formatInteger, aF as formatDecimal, aH as canonicalId, M as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, d as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, C as COLUMN_RENAMED_CODE, w as UNKNOWN_ENCODING_CODE, x as ENCODING_FALLBACK_CODE, y as INVALID_ENCODING_CODE, z as INVALID_UTF8_CODE, P as PRECISION_CODE, F as ELEMENT_ISSUE, G as INPUT_ISSUE } from "./chunks/export-
|
|
2
|
-
import { i as inferTextDtype, T as TextCellWriter, p as parseTextCell, W as WIDENING_UNSUPPORTED_CODE } from "./chunks/text-
|
|
1
|
+
import { b as plural, bV as DICT_SAMPLE_ROWS, ac as DictHeuristic, R as ROLE_TAKEN_CODE$1, I as ID_MERGED_CODE$1, m as DUPLICATE_EDGE_ID_CODE$1, n as DUPLICATE_NODE_CODE$1, t as MISSING_ID_CODE$1, s as MISSING_ENDPOINT_CODE$1, E as EMPTY_INPUT_CODE$1, al as resolveImportOptions, a8 as ImportReportBuilder, ao as reportSinkOptions, an as reportUnusedOptions, aq as DirectionResolver, ar as IdCoercer, am as throwIfAborted, O as OPTION_IGNORED_CODE, aL as parseWeightText, a0 as uniqueColumnName, ay as RENAMED_CODE, a1 as declareResolved, c as capabilities, L as LOSS, a as checkCapabilities, r as resolveExportOptions, p as pairFolding, bE as countMixedEdges, $ as agree, e as explicitWeights, b$ as otherFormatDialect, bT as joinListText, aG as formatInteger, aF as formatDecimal, aH as canonicalId, M as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, d as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, C as COLUMN_RENAMED_CODE, w as UNKNOWN_ENCODING_CODE, x as ENCODING_FALLBACK_CODE, y as INVALID_ENCODING_CODE, z as INVALID_UTF8_CODE, P as PRECISION_CODE, F as ELEMENT_ISSUE, G as INPUT_ISSUE } from "./chunks/export-CVi12U7J.js";
|
|
2
|
+
import { i as inferTextDtype, T as TextCellWriter, p as parseTextCell, W as WIDENING_UNSUPPORTED_CODE } from "./chunks/text-CDgjbkLC.js";
|
|
3
3
|
import { GraphFormatError, INVALID_INDEX } from "@graphty/graph-format";
|
|
4
|
-
import { s as stripLeadingComments, a as sniffNewline, b as sniffDelimiter, D as DELIMITER_CANDIDATES, c as checkRecordSyntax, C as CsvRecordReader, d as splitRecords, B as BAD_QUOTE_CODE, U as UNCLOSED_QUOTE_CODE } from "./chunks/records-
|
|
5
|
-
import { o as quoteCsvCell } from "./chunks/escape-
|
|
4
|
+
import { s as stripLeadingComments, a as sniffNewline, b as sniffDelimiter, D as DELIMITER_CANDIDATES, c as checkRecordSyntax, C as CsvRecordReader, d as splitRecords, B as BAD_QUOTE_CODE, U as UNCLOSED_QUOTE_CODE } from "./chunks/records-CdyqwXeY.js";
|
|
5
|
+
import { o as quoteCsvCell } from "./chunks/escape-DQC5HWqF.js";
|
|
6
6
|
import { j as joinText, e as encodeChunks } from "./chunks/writer-DxjgHwSe.js";
|
|
7
7
|
const SOURCE_NAMES = Object.freeze([
|
|
8
8
|
"source",
|
|
@@ -1606,7 +1606,7 @@ function sniff(head) {
|
|
|
1606
1606
|
label = "utf-16be";
|
|
1607
1607
|
}
|
|
1608
1608
|
const body = stripLeadingComments(new TextDecoder(label).decode(head.subarray(0, HEAD_BYTES)), COMMENT_CHARS);
|
|
1609
|
-
if (body.trim().length === 0 || OTHER_FORMATS.some((r) => r.test(body))) {
|
|
1609
|
+
if (body.trim().length === 0 || hasControlCharacter(body) || OTHER_FORMATS.some((r) => r.test(body))) {
|
|
1610
1610
|
return 0;
|
|
1611
1611
|
}
|
|
1612
1612
|
const newline = sniffNewline(body);
|
|
@@ -1628,6 +1628,16 @@ function sniff(head) {
|
|
|
1628
1628
|
}
|
|
1629
1629
|
return looksLikeProse(body, newline, delimiter) ? 0 : 0.3;
|
|
1630
1630
|
}
|
|
1631
|
+
function hasControlCharacter(text) {
|
|
1632
|
+
const last = text.length - 1;
|
|
1633
|
+
for (let i = 0; i <= last; i++) {
|
|
1634
|
+
const c = text.codePointAt(i) ?? 0;
|
|
1635
|
+
if (c < 32 && c !== 9 && c !== 10 && c !== 13 && !(c === 26 && i === last)) {
|
|
1636
|
+
return true;
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
return false;
|
|
1640
|
+
}
|
|
1631
1641
|
const SENTENCE = /[A-Za-z]{2}[.!?](?:\s|$)/;
|
|
1632
1642
|
function looksLikeProse(body, newline, delimiter) {
|
|
1633
1643
|
const lines2 = body.split(newline).filter((l) => l.trim() !== "");
|
|
@@ -1901,15 +1911,18 @@ function cellText(column, row) {
|
|
|
1901
1911
|
}
|
|
1902
1912
|
}
|
|
1903
1913
|
}
|
|
1904
|
-
function nodeTableNote(names, table,
|
|
1914
|
+
function nodeTableNote(names, table, notes) {
|
|
1905
1915
|
const written = names.length;
|
|
1906
1916
|
if (written > 0) {
|
|
1907
1917
|
const shown = names.slice(0, 3).map((n) => JSON.stringify(n)).join(", ") + (written > 3 ? ", ..." : "");
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1918
|
+
notes.push(
|
|
1919
|
+
Object.freeze({
|
|
1920
|
+
code: CSV_LOSS.NODE_TABLE,
|
|
1921
|
+
message: `the ${table === "adjacency" ? "adjacency" : "edge"} table has no room for node attributes: ${written} node column${plural(written)} (${shown}) ${agree(written, "is", "are")} written only by a second export with table: "nodes"`,
|
|
1922
|
+
column: null,
|
|
1923
|
+
count: written,
|
|
1924
|
+
columns: Object.freeze([...names])
|
|
1925
|
+
})
|
|
1913
1926
|
);
|
|
1914
1927
|
}
|
|
1915
1928
|
}
|
|
@@ -1970,7 +1983,7 @@ function planExport(snapshot, options, values) {
|
|
|
1970
1983
|
edgeRows.push(e);
|
|
1971
1984
|
}
|
|
1972
1985
|
}
|
|
1973
|
-
if (csv.dialect.type === null || csv.table === "adjacency") {
|
|
1986
|
+
if (csv.table !== "nodes" && (csv.dialect.type === null || csv.table === "adjacency")) {
|
|
1974
1987
|
const where = csv.table === "adjacency" ? "an adjacency table" : "the generic dialect";
|
|
1975
1988
|
const mixed = countMixedEdges(snapshot);
|
|
1976
1989
|
if (!snapshot.directed) {
|
|
@@ -1996,7 +2009,7 @@ function planExport(snapshot, options, values) {
|
|
|
1996
2009
|
0
|
|
1997
2010
|
);
|
|
1998
2011
|
}
|
|
1999
|
-
if (folding.mutualCount > 0) {
|
|
2012
|
+
if (folding.mutualCount > 0 && csv.table !== "nodes") {
|
|
2000
2013
|
note(
|
|
2001
2014
|
CSV_LOSS.MUTUAL_EXPANDED,
|
|
2002
2015
|
`${folding.mutualCount} mutual pair${plural(folding.mutualCount)} ${agree(folding.mutualCount, "is", "are")} written as two directed rows; the mutual mark is lost`,
|
|
@@ -2067,7 +2080,7 @@ function planExport(snapshot, options, values) {
|
|
|
2067
2080
|
nodeTableNote(
|
|
2068
2081
|
[...nodeLabel === null ? [] : [nodeLabel.meta.name], ...nodeColumns.map((c) => c.column.meta.name)],
|
|
2069
2082
|
csv.table,
|
|
2070
|
-
|
|
2083
|
+
notes
|
|
2071
2084
|
);
|
|
2072
2085
|
}
|
|
2073
2086
|
return {
|
|
@@ -2453,7 +2466,8 @@ function headerlessNotes(plan) {
|
|
|
2453
2466
|
code: CSV_LOSS.HEADERLESS,
|
|
2454
2467
|
message: `without a header the file is read back by position (${csv.table === "nodes" ? "id" : "source, target, weight"}, then unnamed columns), so ${names.length === 1 ? "the column" : "the columns"} ${shown} ${agree(names.length, "reads", "read")} back unnamed or in another column's place; write the header, or for an edge list pass dialect: "generic" and write only source, target and weight`,
|
|
2455
2468
|
column: null,
|
|
2456
|
-
count: names.length
|
|
2469
|
+
count: names.length,
|
|
2470
|
+
columns: Object.freeze([...names])
|
|
2457
2471
|
})
|
|
2458
2472
|
];
|
|
2459
2473
|
}
|
|
@@ -2482,7 +2496,10 @@ function headerlessEdgeColumns(plan) {
|
|
|
2482
2496
|
function check(snapshot, options) {
|
|
2483
2497
|
const plan = planExport(snapshot, options, true);
|
|
2484
2498
|
return Object.freeze([
|
|
2485
|
-
...checkCapabilities(snapshot, CSV_CAPABILITIES, plan.common, {
|
|
2499
|
+
...checkCapabilities(snapshot, CSV_CAPABILITIES, plan.common, {
|
|
2500
|
+
roles: KEPT_ROLES,
|
|
2501
|
+
...plan.csv.table === "nodes" ? { tables: ["node"] } : {}
|
|
2502
|
+
}),
|
|
2486
2503
|
...plan.notes,
|
|
2487
2504
|
...headerlessNotes(plan)
|
|
2488
2505
|
]);
|