@graphty/graph-io 0.3.38 → 0.3.40
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-CsO24U-5.js → choose-CS3fvGT1.js} +2 -2
- package/dist/chunks/{choose-CsO24U-5.js.map → choose-CS3fvGT1.js.map} +1 -1
- package/dist/chunks/{constants-BPRiVyBu.js → constants-DqKZT6cH.js} +2 -2
- package/dist/chunks/{constants-BPRiVyBu.js.map → constants-DqKZT6cH.js.map} +1 -1
- package/dist/chunks/{escape-BRcyzD77.js → escape-BJRLd3vJ.js} +4 -3
- package/dist/chunks/escape-BJRLd3vJ.js.map +1 -0
- package/dist/chunks/{export-CTUlibzr.js → export-B-aVCwyG.js} +103 -92
- package/dist/chunks/export-B-aVCwyG.js.map +1 -0
- package/dist/chunks/{exporter-Bf5tZA0X.js → exporter-6ocL_9x_.js} +6 -5
- package/dist/chunks/exporter-6ocL_9x_.js.map +1 -0
- package/dist/chunks/{exporter-Bn4jdYfd.js → exporter-BVXnV9-9.js} +43 -30
- package/dist/chunks/exporter-BVXnV9-9.js.map +1 -0
- package/dist/chunks/{exporter-D-qQuRcG.js → exporter-Bcp-l4Bo.js} +6 -6
- package/dist/chunks/exporter-Bcp-l4Bo.js.map +1 -0
- package/dist/chunks/{exporter-F0vT919P.js → exporter-SFYkDzD0.js} +5 -4
- package/dist/chunks/exporter-SFYkDzD0.js.map +1 -0
- package/dist/chunks/{importer-Bgb9sgZZ.js → importer-AjwOJrn2.js} +6 -8
- package/dist/chunks/importer-AjwOJrn2.js.map +1 -0
- package/dist/chunks/{importer-BuzbaFFY.js → importer-BJlGAOht.js} +28 -13
- package/dist/chunks/importer-BJlGAOht.js.map +1 -0
- package/dist/chunks/{importer-DqMtyYLX.js → importer-BpuS3J8C.js} +12 -14
- package/dist/chunks/importer-BpuS3J8C.js.map +1 -0
- package/dist/chunks/{importer-CEuUmyPe.js → importer-CPqnIY8m.js} +6 -6
- package/dist/chunks/{importer-CEuUmyPe.js.map → importer-CPqnIY8m.js.map} +1 -1
- package/dist/chunks/{importer-yWUPR_nU.js → importer-DEp_fYjf.js} +30 -12
- package/dist/chunks/importer-DEp_fYjf.js.map +1 -0
- package/dist/chunks/{importer-CNMQnHDd.js → importer-D_srHyj6.js} +112 -62
- package/dist/chunks/importer-D_srHyj6.js.map +1 -0
- package/dist/chunks/{importer-oIUx9u_g.js → importer-DcKB97kW.js} +40 -18
- package/dist/chunks/importer-DcKB97kW.js.map +1 -0
- package/dist/chunks/{json-elements-AkglPS3m.js → json-elements-DpO6AXIc.js} +7 -5
- package/dist/chunks/{json-elements-AkglPS3m.js.map → json-elements-DpO6AXIc.js.map} +1 -1
- package/dist/chunks/{ontology-export-DDoG3egY.js → ontology-export-50L9DOV4.js} +2 -2
- package/dist/chunks/{ontology-export-DDoG3egY.js.map → ontology-export-50L9DOV4.js.map} +1 -1
- package/dist/chunks/{records-ChmWZGuz.js → records-r3SFHz11.js} +137 -96
- package/dist/chunks/records-r3SFHz11.js.map +1 -0
- package/dist/chunks/{text-Btw3sBe_.js → text-Bjfa1xYL.js} +2 -2
- package/dist/chunks/{text-Btw3sBe_.js.map → text-Bjfa1xYL.js.map} +1 -1
- package/dist/csv.js +4 -4
- 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 +6 -4
- package/dist/gexf.js.map +1 -1
- package/dist/gml.js +8 -6
- package/dist/gml.js.map +1 -1
- package/dist/graph-io.js +26 -26
- 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/direction.js +1 -1
- package/dist/src/common/direction.js.map +1 -1
- package/dist/src/common/export.d.ts.map +1 -1
- package/dist/src/common/export.js +136 -71
- package/dist/src/common/export.js.map +1 -1
- package/dist/src/common/input.js +1 -1
- package/dist/src/common/input.js.map +1 -1
- package/dist/src/common/json-elements.d.ts.map +1 -1
- package/dist/src/common/json-elements.js +4 -2
- package/dist/src/common/json-elements.js.map +1 -1
- package/dist/src/common/xml.d.ts.map +1 -1
- package/dist/src/common/xml.js +2 -1
- package/dist/src/common/xml.js.map +1 -1
- package/dist/src/formats/csv/records.d.ts.map +1 -1
- package/dist/src/formats/csv/records.js +138 -100
- package/dist/src/formats/csv/records.js.map +1 -1
- package/dist/src/formats/cx/importer.d.ts.map +1 -1
- package/dist/src/formats/cx/importer.js +108 -53
- package/dist/src/formats/cx/importer.js.map +1 -1
- package/dist/src/formats/cx2/exporter.d.ts.map +1 -1
- package/dist/src/formats/cx2/exporter.js +2 -1
- package/dist/src/formats/cx2/exporter.js.map +1 -1
- package/dist/src/formats/cx2/importer.d.ts.map +1 -1
- package/dist/src/formats/cx2/importer.js +28 -6
- package/dist/src/formats/cx2/importer.js.map +1 -1
- package/dist/src/formats/dot/importer.d.ts +6 -0
- package/dist/src/formats/dot/importer.d.ts.map +1 -1
- package/dist/src/formats/dot/importer.js +11 -6
- package/dist/src/formats/dot/importer.js.map +1 -1
- package/dist/src/formats/dot/names.d.ts +5 -0
- package/dist/src/formats/dot/names.d.ts.map +1 -1
- package/dist/src/formats/dot/names.js +5 -0
- package/dist/src/formats/dot/names.js.map +1 -1
- package/dist/src/formats/dot/tokenizer.js +9 -9
- package/dist/src/formats/dot/tokenizer.js.map +1 -1
- package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
- package/dist/src/formats/gexf/exporter.js +4 -2
- package/dist/src/formats/gexf/exporter.js.map +1 -1
- package/dist/src/formats/gml/importer.d.ts +6 -0
- package/dist/src/formats/gml/importer.d.ts.map +1 -1
- package/dist/src/formats/gml/importer.js +6 -3
- package/dist/src/formats/gml/importer.js.map +1 -1
- package/dist/src/formats/graphml/exporter.d.ts.map +1 -1
- package/dist/src/formats/graphml/exporter.js +2 -1
- package/dist/src/formats/graphml/exporter.js.map +1 -1
- package/dist/src/formats/graphml/importer.d.ts.map +1 -1
- package/dist/src/formats/graphml/importer.js +5 -6
- package/dist/src/formats/graphml/importer.js.map +1 -1
- package/dist/src/formats/obo/importer.d.ts.map +1 -1
- package/dist/src/formats/obo/importer.js +2 -1
- package/dist/src/formats/obo/importer.js.map +1 -1
- package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
- package/dist/src/formats/pajek/exporter.js +4 -5
- package/dist/src/formats/pajek/exporter.js.map +1 -1
- package/dist/src/formats/xgmml/emit.d.ts +6 -0
- package/dist/src/formats/xgmml/emit.d.ts.map +1 -1
- package/dist/src/formats/xgmml/emit.js +33 -10
- package/dist/src/formats/xgmml/emit.js.map +1 -1
- package/dist/src/formats/xgmml/exporter.d.ts.map +1 -1
- package/dist/src/formats/xgmml/exporter.js +54 -22
- package/dist/src/formats/xgmml/exporter.js.map +1 -1
- package/dist/src/sniff.js +1 -1
- package/dist/src/sniff.js.map +1 -1
- package/dist/xgmml.js +2 -2
- package/package.json +2 -2
- package/src/common/direction.ts +1 -1
- package/src/common/export.ts +190 -97
- package/src/common/input.ts +1 -1
- package/src/common/json-elements.ts +4 -2
- package/src/common/xml.ts +2 -1
- package/src/formats/csv/records.ts +143 -99
- package/src/formats/cx/importer.ts +140 -58
- package/src/formats/cx2/exporter.ts +2 -1
- package/src/formats/cx2/importer.ts +34 -10
- package/src/formats/dot/importer.ts +35 -4
- package/src/formats/dot/names.ts +6 -0
- package/src/formats/dot/tokenizer.ts +9 -9
- package/src/formats/gexf/exporter.ts +4 -2
- package/src/formats/gml/importer.ts +14 -3
- package/src/formats/graphml/exporter.ts +2 -3
- package/src/formats/graphml/importer.ts +5 -6
- package/src/formats/obo/importer.ts +2 -1
- package/src/formats/pajek/exporter.ts +6 -4
- package/src/formats/xgmml/emit.ts +34 -10
- package/src/formats/xgmml/exporter.ts +63 -23
- package/src/sniff.ts +1 -1
- package/dist/chunks/escape-BRcyzD77.js.map +0 -1
- package/dist/chunks/export-CTUlibzr.js.map +0 -1
- package/dist/chunks/exporter-Bf5tZA0X.js.map +0 -1
- package/dist/chunks/exporter-Bn4jdYfd.js.map +0 -1
- package/dist/chunks/exporter-D-qQuRcG.js.map +0 -1
- package/dist/chunks/exporter-F0vT919P.js.map +0 -1
- package/dist/chunks/importer-Bgb9sgZZ.js.map +0 -1
- package/dist/chunks/importer-BuzbaFFY.js.map +0 -1
- package/dist/chunks/importer-CNMQnHDd.js.map +0 -1
- package/dist/chunks/importer-DqMtyYLX.js.map +0 -1
- package/dist/chunks/importer-oIUx9u_g.js.map +0 -1
- package/dist/chunks/importer-yWUPR_nU.js.map +0 -1
- package/dist/chunks/records-ChmWZGuz.js.map +0 -1
|
@@ -592,9 +592,10 @@ function checkNumberVerification(value, count, report, line) {
|
|
|
592
592
|
const raw = isRecord(value) ? value.longNumber : undefined;
|
|
593
593
|
const digits = raw instanceof ExactInteger ? raw.digits : String(raw);
|
|
594
594
|
if (count > 1 || !NUMBER_VERIFICATION_VALUES.has(digits)) {
|
|
595
|
+
const held = raw === undefined ? null : digits;
|
|
595
596
|
report.warning("validation-error", CX_ISSUE.NUMBER_VERIFICATION, count > 1
|
|
596
597
|
? "a second numberVerification element; ignored"
|
|
597
|
-
: `numberVerification holds ${shown(
|
|
598
|
+
: `numberVerification holds ${shown(held)}, not 281474976710655`, { line, element: "numberVerification" });
|
|
598
599
|
}
|
|
599
600
|
}
|
|
600
601
|
/**
|
|
@@ -752,7 +753,8 @@ async function readDocument(input, report, options) {
|
|
|
752
753
|
break;
|
|
753
754
|
}
|
|
754
755
|
countMember(event.block, null);
|
|
755
|
-
|
|
756
|
+
const what = keys.length > 1 ? `an object with ${keys.length} keys (${keys.join(", ")})` : shown(value);
|
|
757
|
+
report.error("parse-error", BAD_ASPECT_BLOCK_CODE, `a member of the document is ${what}, not a one-key aspect fragment; skipped`, { line: event.line, element: keys[0] ?? null });
|
|
756
758
|
break;
|
|
757
759
|
}
|
|
758
760
|
case "block":
|
|
@@ -1048,6 +1050,14 @@ function layoutViews(doc) {
|
|
|
1048
1050
|
function memberCount(members, total) {
|
|
1049
1051
|
return members === null ? total : members.size;
|
|
1050
1052
|
}
|
|
1053
|
+
/**
|
|
1054
|
+
* A visual property value as text: a string as it is, anything else as JSON.
|
|
1055
|
+
* @param raw - the value
|
|
1056
|
+
* @returns its text
|
|
1057
|
+
*/
|
|
1058
|
+
function visualText(raw) {
|
|
1059
|
+
return typeof raw === "string" ? raw : JSON.stringify(raw);
|
|
1060
|
+
}
|
|
1051
1061
|
/** Reads one graph of a collected document into a sink. */
|
|
1052
1062
|
class CxReader {
|
|
1053
1063
|
/**
|
|
@@ -2215,57 +2225,87 @@ class CxReader {
|
|
|
2215
2225
|
* applied.
|
|
2216
2226
|
*/
|
|
2217
2227
|
readVisualProperties() {
|
|
2218
|
-
const entries = aspect(this.doc, "cyVisualProperties");
|
|
2219
2228
|
// Cytoscape's table-cell styles: a visual property aspect graph-io keeps but does not read
|
|
2220
2229
|
const tableStyles = TABLE_STYLE_ASPECTS.reduce((n, name) => n + (this.doc.kept.get(name)?.length ?? 0), 0);
|
|
2221
2230
|
// the graph's own view (its first): the one its positions come from; the others stay in meta.extra.cx
|
|
2222
2231
|
const views = new Set(this.plan.views.slice(0, 1));
|
|
2223
|
-
const
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
if (view !== null && views.size > 0 && !views.has(view)) {
|
|
2234
|
-
continue;
|
|
2232
|
+
const visual = {
|
|
2233
|
+
columns: { node: new Map(), edge: new Map() },
|
|
2234
|
+
network: new Map(),
|
|
2235
|
+
defaults: 0,
|
|
2236
|
+
mappings: 0,
|
|
2237
|
+
dependencies: 0,
|
|
2238
|
+
};
|
|
2239
|
+
for (const { value } of aspect(this.doc, "cyVisualProperties")) {
|
|
2240
|
+
if (isRecord(value)) {
|
|
2241
|
+
this.collectVisualEntry(value, views, visual);
|
|
2235
2242
|
}
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2243
|
+
}
|
|
2244
|
+
this.writeBypassColumns(visual.columns);
|
|
2245
|
+
this.writeBypassNetwork(visual.network);
|
|
2246
|
+
this.reportStyleRules(visual, tableStyles);
|
|
2247
|
+
}
|
|
2248
|
+
/**
|
|
2249
|
+
* File one cyVisualProperties element of this graph's view into the collection: per-element and
|
|
2250
|
+
* network values by property, defaults, mappings and dependencies counted.
|
|
2251
|
+
* @param value - the element
|
|
2252
|
+
* @param views - the views read (empty: every view)
|
|
2253
|
+
* @param visual - the collection to add to
|
|
2254
|
+
*/
|
|
2255
|
+
collectVisualEntry(value, views, visual) {
|
|
2256
|
+
const view = value.view === undefined || value.view === null ? null : refId(value.view);
|
|
2257
|
+
if (view !== null && views.size > 0 && !views.has(view)) {
|
|
2258
|
+
return;
|
|
2259
|
+
}
|
|
2260
|
+
const properties = isRecord(value.properties) ? value.properties : {};
|
|
2261
|
+
visual.mappings += isRecord(value.mappings) ? Object.keys(value.mappings).length : 0;
|
|
2262
|
+
visual.dependencies += isRecord(value.dependencies) ? Object.keys(value.dependencies).length : 0;
|
|
2263
|
+
switch (value.properties_of) {
|
|
2264
|
+
case "nodes":
|
|
2265
|
+
this.collectElementProperties("node", value.applies_to, properties, visual.columns);
|
|
2266
|
+
break;
|
|
2267
|
+
case "edges":
|
|
2268
|
+
this.collectElementProperties("edge", value.applies_to, properties, visual.columns);
|
|
2269
|
+
break;
|
|
2270
|
+
case "network":
|
|
2271
|
+
for (const [property, raw] of Object.entries(properties)) {
|
|
2272
|
+
visual.network.set(property, visualText(raw));
|
|
2258
2273
|
}
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2274
|
+
break;
|
|
2275
|
+
default:
|
|
2276
|
+
visual.defaults += Object.keys(properties).length;
|
|
2277
|
+
break;
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
/**
|
|
2281
|
+
* File the visual values of one node or edge under its row; an element not in this graph is
|
|
2282
|
+
* skipped, and reported dangling when it is in no graph of the file.
|
|
2283
|
+
* @param domain - node or edge
|
|
2284
|
+
* @param appliesTo - the element's applies_to
|
|
2285
|
+
* @param properties - its visual properties
|
|
2286
|
+
* @param columns - the per-property cells to add to
|
|
2287
|
+
*/
|
|
2288
|
+
collectElementProperties(domain, appliesTo, properties, columns) {
|
|
2289
|
+
const target = refId(appliesTo);
|
|
2290
|
+
const rows = domain === "node" ? this.nodeRows : this.edgeRows;
|
|
2291
|
+
const row = target === null ? undefined : rows.get(target);
|
|
2292
|
+
if (row === undefined) {
|
|
2293
|
+
if (target === null || !(domain === "node" ? this.rootNodes : this.rootEdges).has(target)) {
|
|
2294
|
+
this.dangle(`${domain} visual property entry`);
|
|
2267
2295
|
}
|
|
2296
|
+
return;
|
|
2268
2297
|
}
|
|
2298
|
+
for (const [property, raw] of Object.entries(properties)) {
|
|
2299
|
+
const list = columns[domain].get(property) ?? [];
|
|
2300
|
+
list.push([row, visualText(raw)]);
|
|
2301
|
+
columns[domain].set(property, list);
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
/**
|
|
2305
|
+
* Write the collected per-element visual values as string columns in the cx.bypass namespace.
|
|
2306
|
+
* @param columns - the per-property cells of each domain
|
|
2307
|
+
*/
|
|
2308
|
+
writeBypassColumns(columns) {
|
|
2269
2309
|
for (const domain of ["node", "edge"]) {
|
|
2270
2310
|
for (const [property, cells] of columns[domain]) {
|
|
2271
2311
|
const handle = declareFresh(this.sink, domain, {
|
|
@@ -2284,6 +2324,12 @@ class CxReader {
|
|
|
2284
2324
|
}
|
|
2285
2325
|
}
|
|
2286
2326
|
}
|
|
2327
|
+
}
|
|
2328
|
+
/**
|
|
2329
|
+
* Write the network visual values as graph values in the cx.bypass namespace.
|
|
2330
|
+
* @param network - the value of each property
|
|
2331
|
+
*/
|
|
2332
|
+
writeBypassNetwork(network) {
|
|
2287
2333
|
for (const [property, text] of network) {
|
|
2288
2334
|
try {
|
|
2289
2335
|
this.sink.setGraphValue(property, text, {
|
|
@@ -2295,15 +2341,24 @@ class CxReader {
|
|
|
2295
2341
|
this.report.recordError(err, { element: property });
|
|
2296
2342
|
}
|
|
2297
2343
|
}
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2344
|
+
}
|
|
2345
|
+
/**
|
|
2346
|
+
* Warn that the style rules (defaults, mappings, dependencies, table styles) are kept, not applied.
|
|
2347
|
+
* @param visual - the counted rules
|
|
2348
|
+
* @param tableStyles - the number of table style elements
|
|
2349
|
+
*/
|
|
2350
|
+
reportStyleRules(visual, tableStyles) {
|
|
2351
|
+
const { defaults, mappings, dependencies } = visual;
|
|
2352
|
+
if (defaults + mappings + dependencies + tableStyles === 0) {
|
|
2353
|
+
return;
|
|
2354
|
+
}
|
|
2355
|
+
const parts = [
|
|
2356
|
+
`cyVisualProperties: ${defaults} default${plural(defaults)}, ${mappings} mapping${plural(mappings)}, ${dependencies} dependenc(ies)`,
|
|
2357
|
+
];
|
|
2358
|
+
if (tableStyles > 0) {
|
|
2359
|
+
parts.push(`${tableStyles} table style element${plural(tableStyles)}`);
|
|
2306
2360
|
}
|
|
2361
|
+
this.report.warning("unsupported", STYLES_NOT_IMPORTED_CODE, `the file's style rules are not applied (${parts.join("; ")}); they are kept in meta.extra.cx`, { element: "cyVisualProperties" });
|
|
2307
2362
|
}
|
|
2308
2363
|
/**
|
|
2309
2364
|
* Read the provenance aspects: citations and supports as extension tables cx:citations and
|