@graphty/graph-io 0.3.25 → 0.3.27
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 +49 -414
- package/dist/chunks/children-CL3Cy0ez.js.map +1 -1
- package/dist/chunks/choose-DrXtu_96.js +56 -0
- package/dist/chunks/choose-DrXtu_96.js.map +1 -0
- package/dist/chunks/constants-ikG85dT8.js +231 -0
- package/dist/chunks/constants-ikG85dT8.js.map +1 -0
- package/dist/chunks/{escape-B-tkk_Cl.js → escape-D1HPTUrP.js} +390 -99
- package/dist/chunks/escape-D1HPTUrP.js.map +1 -0
- package/dist/chunks/export-CHd4tQE2.js +4333 -0
- package/dist/chunks/export-CHd4tQE2.js.map +1 -0
- package/dist/chunks/{importer-eUREhBGj.js → exporter-D23CKNqF.js} +4969 -3201
- package/dist/chunks/exporter-D23CKNqF.js.map +1 -0
- package/dist/chunks/{exporter-DIeGJXAZ.js → exporter-DfWTgrti.js} +23 -21
- package/dist/chunks/exporter-DfWTgrti.js.map +1 -0
- package/dist/chunks/exporter-DhtW6FxK.js +3465 -0
- package/dist/chunks/exporter-DhtW6FxK.js.map +1 -0
- package/dist/chunks/{exporter-BGrsWamJ.js → exporter-IHv4nkCm.js} +38 -229
- package/dist/chunks/exporter-IHv4nkCm.js.map +1 -0
- package/dist/chunks/{importer-BWY2FFc5.js → importer-B1wmPQjr.js} +255 -77
- package/dist/chunks/importer-B1wmPQjr.js.map +1 -0
- package/dist/chunks/{importer-D_e7e7LX.js → importer-B2W_58pz.js} +399 -146
- package/dist/chunks/importer-B2W_58pz.js.map +1 -0
- package/dist/chunks/importer-BSALvkui.js +2811 -0
- package/dist/chunks/importer-BSALvkui.js.map +1 -0
- package/dist/chunks/{importer-vi3bSdtw.js → importer-BVRE--Un.js} +510 -77
- package/dist/chunks/importer-BVRE--Un.js.map +1 -0
- package/dist/chunks/{importer-DET1tg6s.js → importer-CIAzt-wo.js} +1689 -312
- package/dist/chunks/importer-CIAzt-wo.js.map +1 -0
- package/dist/chunks/{importer-DIrbbnAf.js → importer-DpEW5zeG.js} +585 -226
- package/dist/chunks/importer-DpEW5zeG.js.map +1 -0
- package/dist/chunks/{importer-zGLo8Dg_.js → importer-z_FL4VMb.js} +488 -161
- package/dist/chunks/importer-z_FL4VMb.js.map +1 -0
- package/dist/chunks/json-elements-BAmNBZok.js +1225 -0
- package/dist/chunks/json-elements-BAmNBZok.js.map +1 -0
- package/dist/chunks/ontology-export-Bab4eUA8.js +357 -0
- package/dist/chunks/ontology-export-Bab4eUA8.js.map +1 -0
- package/dist/chunks/{records-dbRkxwaq.js → records-CdlvL4RO.js} +298 -114
- package/dist/chunks/records-CdlvL4RO.js.map +1 -0
- package/dist/chunks/{text-Dr0Ifpag.js → text-DzXjAiTl.js} +29 -11
- package/dist/chunks/text-DzXjAiTl.js.map +1 -0
- package/dist/chunks/{writer-C7flM-Ih.js → writer-DxjgHwSe.js} +19 -1
- package/dist/chunks/writer-DxjgHwSe.js.map +1 -0
- package/dist/csv.js +952 -262
- package/dist/csv.js.map +1 -1
- package/dist/cx.js +6 -3
- package/dist/cx2.js +2 -2
- package/dist/cys.js +6 -3
- package/dist/dot.js +1 -1
- package/dist/gexf.js +554 -122
- package/dist/gexf.js.map +1 -1
- package/dist/gml.js +344 -87
- package/dist/gml.js.map +1 -1
- package/dist/graph-io.js +1105 -213
- package/dist/graph-io.js.map +1 -1
- package/dist/graphml.js +3 -2
- package/dist/graphml.js.map +1 -1
- package/dist/json.js +3 -2
- package/dist/neo4j.js +565 -158
- package/dist/neo4j.js.map +1 -1
- package/dist/obo.js +6 -3
- package/dist/pajek.js +1 -1
- package/dist/src/children.d.ts +18 -6
- package/dist/src/children.d.ts.map +1 -1
- package/dist/src/children.js +6 -3
- package/dist/src/children.js.map +1 -1
- package/dist/src/common/attributes.d.ts +29 -11
- package/dist/src/common/attributes.d.ts.map +1 -1
- package/dist/src/common/attributes.js +25 -7
- package/dist/src/common/attributes.js.map +1 -1
- package/dist/src/common/cell-budget.d.ts +9 -2
- package/dist/src/common/cell-budget.d.ts.map +1 -1
- package/dist/src/common/cell-budget.js +11 -3
- package/dist/src/common/cell-budget.js.map +1 -1
- package/dist/src/common/choose.d.ts +19 -0
- package/dist/src/common/choose.d.ts.map +1 -0
- package/dist/src/common/choose.js +72 -0
- package/dist/src/common/choose.js.map +1 -0
- package/dist/src/common/codes.d.ts +456 -66
- package/dist/src/common/codes.d.ts.map +1 -1
- package/dist/src/common/codes.js +458 -66
- package/dist/src/common/codes.js.map +1 -1
- package/dist/src/common/compare.d.ts +81 -0
- package/dist/src/common/compare.d.ts.map +1 -0
- package/dist/src/common/compare.js +394 -0
- package/dist/src/common/compare.js.map +1 -0
- package/dist/src/common/cx-export.d.ts +123 -0
- package/dist/src/common/cx-export.d.ts.map +1 -0
- package/dist/src/common/cx-export.js +334 -0
- package/dist/src/common/cx-export.js.map +1 -0
- package/dist/src/common/declared-types.d.ts +22 -2
- package/dist/src/common/declared-types.d.ts.map +1 -1
- package/dist/src/common/declared-types.js +21 -3
- package/dist/src/common/declared-types.js.map +1 -1
- package/dist/src/common/direction.d.ts +74 -50
- package/dist/src/common/direction.d.ts.map +1 -1
- package/dist/src/common/direction.js +47 -27
- package/dist/src/common/direction.js.map +1 -1
- package/dist/src/common/escape.d.ts +21 -9
- package/dist/src/common/escape.d.ts.map +1 -1
- package/dist/src/common/escape.js +39 -22
- package/dist/src/common/escape.js.map +1 -1
- package/dist/src/common/export.d.ts +144 -32
- package/dist/src/common/export.d.ts.map +1 -1
- package/dist/src/common/export.js +216 -42
- package/dist/src/common/export.js.map +1 -1
- package/dist/src/common/format.d.ts +23 -1
- package/dist/src/common/format.d.ts.map +1 -1
- package/dist/src/common/format.js +26 -1
- package/dist/src/common/format.js.map +1 -1
- package/dist/src/common/ids.d.ts +9 -2
- package/dist/src/common/ids.d.ts.map +1 -1
- package/dist/src/common/ids.js +6 -2
- package/dist/src/common/ids.js.map +1 -1
- package/dist/src/common/input.d.ts +122 -28
- package/dist/src/common/input.d.ts.map +1 -1
- package/dist/src/common/input.js +890 -124
- package/dist/src/common/input.js.map +1 -1
- package/dist/src/common/json-elements.d.ts +144 -20
- package/dist/src/common/json-elements.d.ts.map +1 -1
- package/dist/src/common/json-elements.js +869 -189
- package/dist/src/common/json-elements.js.map +1 -1
- package/dist/src/common/line-format.d.ts +90 -0
- package/dist/src/common/line-format.d.ts.map +1 -0
- package/dist/src/common/line-format.js +185 -0
- package/dist/src/common/line-format.js.map +1 -0
- package/dist/src/common/lists.d.ts +6 -1
- package/dist/src/common/lists.d.ts.map +1 -1
- package/dist/src/common/lists.js +3 -1
- package/dist/src/common/lists.js.map +1 -1
- package/dist/src/common/ontology-export.d.ts +167 -0
- package/dist/src/common/ontology-export.d.ts.map +1 -0
- package/dist/src/common/ontology-export.js +359 -0
- package/dist/src/common/ontology-export.js.map +1 -0
- package/dist/src/common/ontology.d.ts +25 -3
- package/dist/src/common/ontology.d.ts.map +1 -1
- package/dist/src/common/ontology.js +30 -9
- package/dist/src/common/ontology.js.map +1 -1
- package/dist/src/common/options.d.ts +62 -12
- package/dist/src/common/options.d.ts.map +1 -1
- package/dist/src/common/options.js +89 -11
- package/dist/src/common/options.js.map +1 -1
- package/dist/src/common/plural.d.ts +31 -0
- package/dist/src/common/plural.d.ts.map +1 -0
- package/dist/src/common/plural.js +46 -0
- package/dist/src/common/plural.js.map +1 -0
- package/dist/src/common/report.d.ts +72 -14
- package/dist/src/common/report.d.ts.map +1 -1
- package/dist/src/common/report.js +146 -22
- package/dist/src/common/report.js.map +1 -1
- package/dist/src/common/temporal.d.ts +22 -5
- package/dist/src/common/temporal.d.ts.map +1 -1
- package/dist/src/common/temporal.js +13 -2
- package/dist/src/common/temporal.js.map +1 -1
- package/dist/src/common/text.d.ts +39 -23
- package/dist/src/common/text.d.ts.map +1 -1
- package/dist/src/common/text.js +51 -21
- package/dist/src/common/text.js.map +1 -1
- package/dist/src/common/weights.d.ts +37 -4
- package/dist/src/common/weights.d.ts.map +1 -1
- package/dist/src/common/weights.js +61 -2
- package/dist/src/common/weights.js.map +1 -1
- package/dist/src/common/writer.d.ts +19 -3
- package/dist/src/common/writer.d.ts.map +1 -1
- package/dist/src/common/writer.js +30 -2
- package/dist/src/common/writer.js.map +1 -1
- package/dist/src/common/xml.d.ts +125 -9
- package/dist/src/common/xml.d.ts.map +1 -1
- package/dist/src/common/xml.js +402 -85
- package/dist/src/common/xml.js.map +1 -1
- package/dist/src/common/zip.d.ts +44 -4
- package/dist/src/common/zip.d.ts.map +1 -1
- package/dist/src/common/zip.js +134 -5
- package/dist/src/common/zip.js.map +1 -1
- package/dist/src/formats/csv/exporter.d.ts +80 -24
- package/dist/src/formats/csv/exporter.d.ts.map +1 -1
- package/dist/src/formats/csv/exporter.js +146 -33
- package/dist/src/formats/csv/exporter.js.map +1 -1
- package/dist/src/formats/csv/header.d.ts +38 -9
- package/dist/src/formats/csv/header.d.ts.map +1 -1
- package/dist/src/formats/csv/header.js +46 -10
- package/dist/src/formats/csv/header.js.map +1 -1
- package/dist/src/formats/csv/importer.d.ts +187 -37
- package/dist/src/formats/csv/importer.d.ts.map +1 -1
- package/dist/src/formats/csv/importer.js +835 -204
- package/dist/src/formats/csv/importer.js.map +1 -1
- package/dist/src/formats/csv/index.d.ts +100 -19
- package/dist/src/formats/csv/index.d.ts.map +1 -1
- package/dist/src/formats/csv/index.js +94 -21
- package/dist/src/formats/csv/index.js.map +1 -1
- package/dist/src/formats/csv/records.d.ts +95 -10
- package/dist/src/formats/csv/records.d.ts.map +1 -1
- package/dist/src/formats/csv/records.js +333 -122
- package/dist/src/formats/csv/records.js.map +1 -1
- package/dist/src/formats/csv/values.d.ts +1 -0
- package/dist/src/formats/csv/values.d.ts.map +1 -1
- package/dist/src/formats/csv/values.js +1 -0
- package/dist/src/formats/csv/values.js.map +1 -1
- package/dist/src/formats/cx/exporter.d.ts +102 -0
- package/dist/src/formats/cx/exporter.d.ts.map +1 -0
- package/dist/src/formats/cx/exporter.js +1217 -0
- package/dist/src/formats/cx/exporter.js.map +1 -0
- package/dist/src/formats/cx/importer.d.ts +79 -32
- package/dist/src/formats/cx/importer.d.ts.map +1 -1
- package/dist/src/formats/cx/importer.js +682 -287
- package/dist/src/formats/cx/importer.js.map +1 -1
- package/dist/src/formats/cx/index.d.ts +4 -3
- package/dist/src/formats/cx/index.d.ts.map +1 -1
- package/dist/src/formats/cx/index.js +4 -3
- package/dist/src/formats/cx/index.js.map +1 -1
- package/dist/src/formats/cx2/exporter.d.ts +29 -11
- package/dist/src/formats/cx2/exporter.d.ts.map +1 -1
- package/dist/src/formats/cx2/exporter.js +39 -268
- package/dist/src/formats/cx2/exporter.js.map +1 -1
- package/dist/src/formats/cx2/importer.d.ts +78 -28
- package/dist/src/formats/cx2/importer.d.ts.map +1 -1
- package/dist/src/formats/cx2/importer.js +227 -80
- package/dist/src/formats/cx2/importer.js.map +1 -1
- package/dist/src/formats/cx2/index.d.ts +2 -1
- package/dist/src/formats/cx2/index.d.ts.map +1 -1
- package/dist/src/formats/cx2/index.js +2 -1
- package/dist/src/formats/cx2/index.js.map +1 -1
- package/dist/src/formats/cys/constants.d.ts +66 -17
- package/dist/src/formats/cys/constants.d.ts.map +1 -1
- package/dist/src/formats/cys/constants.js +59 -18
- package/dist/src/formats/cys/constants.js.map +1 -1
- package/dist/src/formats/cys/exporter.d.ts +118 -0
- package/dist/src/formats/cys/exporter.d.ts.map +1 -0
- package/dist/src/formats/cys/exporter.js +1072 -0
- package/dist/src/formats/cys/exporter.js.map +1 -0
- package/dist/src/formats/cys/importer.d.ts +22 -8
- package/dist/src/formats/cys/importer.d.ts.map +1 -1
- package/dist/src/formats/cys/importer.js +510 -149
- package/dist/src/formats/cys/importer.js.map +1 -1
- package/dist/src/formats/cys/index.d.ts +4 -2
- package/dist/src/formats/cys/index.d.ts.map +1 -1
- package/dist/src/formats/cys/index.js +4 -2
- package/dist/src/formats/cys/index.js.map +1 -1
- package/dist/src/formats/cys/session.d.ts +46 -7
- package/dist/src/formats/cys/session.d.ts.map +1 -1
- package/dist/src/formats/cys/session.js +101 -27
- package/dist/src/formats/cys/session.js.map +1 -1
- package/dist/src/formats/cys/tables.d.ts +9 -2
- package/dist/src/formats/cys/tables.d.ts.map +1 -1
- package/dist/src/formats/cys/tables.js +29 -7
- package/dist/src/formats/cys/tables.js.map +1 -1
- package/dist/src/formats/dot/exporter.d.ts +42 -14
- package/dist/src/formats/dot/exporter.d.ts.map +1 -1
- package/dist/src/formats/dot/exporter.js +56 -29
- package/dist/src/formats/dot/exporter.js.map +1 -1
- package/dist/src/formats/dot/importer.d.ts +91 -29
- package/dist/src/formats/dot/importer.d.ts.map +1 -1
- package/dist/src/formats/dot/importer.js +190 -39
- package/dist/src/formats/dot/importer.js.map +1 -1
- package/dist/src/formats/dot/index.d.ts +2 -1
- package/dist/src/formats/dot/index.d.ts.map +1 -1
- package/dist/src/formats/dot/index.js +2 -1
- package/dist/src/formats/dot/index.js.map +1 -1
- package/dist/src/formats/dot/names.d.ts +44 -11
- package/dist/src/formats/dot/names.d.ts.map +1 -1
- package/dist/src/formats/dot/names.js +44 -11
- package/dist/src/formats/dot/names.js.map +1 -1
- package/dist/src/formats/dot/tokenizer.d.ts +9 -2
- package/dist/src/formats/dot/tokenizer.d.ts.map +1 -1
- package/dist/src/formats/dot/tokenizer.js +20 -5
- package/dist/src/formats/dot/tokenizer.js.map +1 -1
- package/dist/src/formats/gexf/exporter.d.ts +46 -15
- package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
- package/dist/src/formats/gexf/exporter.js +45 -15
- package/dist/src/formats/gexf/exporter.js.map +1 -1
- package/dist/src/formats/gexf/importer.d.ts +87 -23
- package/dist/src/formats/gexf/importer.d.ts.map +1 -1
- package/dist/src/formats/gexf/importer.js +471 -90
- package/dist/src/formats/gexf/importer.js.map +1 -1
- package/dist/src/formats/gexf/index.d.ts +84 -21
- package/dist/src/formats/gexf/index.d.ts.map +1 -1
- package/dist/src/formats/gexf/index.js +80 -23
- package/dist/src/formats/gexf/index.js.map +1 -1
- package/dist/src/formats/gexf/schema.d.ts +67 -15
- package/dist/src/formats/gexf/schema.d.ts.map +1 -1
- package/dist/src/formats/gexf/schema.js +59 -13
- package/dist/src/formats/gexf/schema.js.map +1 -1
- package/dist/src/formats/gml/exporter.d.ts +69 -21
- package/dist/src/formats/gml/exporter.d.ts.map +1 -1
- package/dist/src/formats/gml/exporter.js +74 -29
- package/dist/src/formats/gml/exporter.js.map +1 -1
- package/dist/src/formats/gml/importer.d.ts +116 -25
- package/dist/src/formats/gml/importer.d.ts.map +1 -1
- package/dist/src/formats/gml/importer.js +290 -61
- package/dist/src/formats/gml/importer.js.map +1 -1
- package/dist/src/formats/gml/index.d.ts +87 -24
- package/dist/src/formats/gml/index.d.ts.map +1 -1
- package/dist/src/formats/gml/index.js +79 -26
- package/dist/src/formats/gml/index.js.map +1 -1
- package/dist/src/formats/gml/syntax.d.ts +67 -18
- package/dist/src/formats/gml/syntax.d.ts.map +1 -1
- package/dist/src/formats/gml/syntax.js +110 -28
- package/dist/src/formats/gml/syntax.js.map +1 -1
- package/dist/src/formats/graphml/constants.d.ts +174 -44
- package/dist/src/formats/graphml/constants.d.ts.map +1 -1
- package/dist/src/formats/graphml/constants.js +165 -44
- package/dist/src/formats/graphml/constants.js.map +1 -1
- package/dist/src/formats/graphml/exporter.d.ts +17 -9
- package/dist/src/formats/graphml/exporter.d.ts.map +1 -1
- package/dist/src/formats/graphml/exporter.js +33 -12
- package/dist/src/formats/graphml/exporter.js.map +1 -1
- package/dist/src/formats/graphml/importer.d.ts +19 -7
- package/dist/src/formats/graphml/importer.d.ts.map +1 -1
- package/dist/src/formats/graphml/importer.js +466 -39
- package/dist/src/formats/graphml/importer.js.map +1 -1
- package/dist/src/formats/graphml/index.d.ts +2 -1
- package/dist/src/formats/graphml/index.d.ts.map +1 -1
- package/dist/src/formats/graphml/index.js +2 -1
- package/dist/src/formats/graphml/index.js.map +1 -1
- package/dist/src/formats/graphml/tree.d.ts +6 -2
- package/dist/src/formats/graphml/tree.d.ts.map +1 -1
- package/dist/src/formats/graphml/tree.js +6 -2
- package/dist/src/formats/graphml/tree.js.map +1 -1
- package/dist/src/formats/graphml/yfiles.d.ts +8 -3
- package/dist/src/formats/graphml/yfiles.d.ts.map +1 -1
- package/dist/src/formats/graphml/yfiles.js +36 -15
- package/dist/src/formats/graphml/yfiles.js.map +1 -1
- package/dist/src/formats/json/dialect.d.ts +88 -24
- package/dist/src/formats/json/dialect.d.ts.map +1 -1
- package/dist/src/formats/json/dialect.js +109 -19
- package/dist/src/formats/json/dialect.js.map +1 -1
- package/dist/src/formats/json/exporter.d.ts +134 -22
- package/dist/src/formats/json/exporter.d.ts.map +1 -1
- package/dist/src/formats/json/exporter.js +135 -54
- package/dist/src/formats/json/exporter.js.map +1 -1
- package/dist/src/formats/json/importer.d.ts +173 -52
- package/dist/src/formats/json/importer.d.ts.map +1 -1
- package/dist/src/formats/json/importer.js +899 -220
- package/dist/src/formats/json/importer.js.map +1 -1
- package/dist/src/formats/json/index.d.ts +3 -2
- package/dist/src/formats/json/index.d.ts.map +1 -1
- package/dist/src/formats/json/index.js +3 -2
- package/dist/src/formats/json/index.js.map +1 -1
- package/dist/src/formats/json/obographs-export.d.ts +68 -0
- package/dist/src/formats/json/obographs-export.d.ts.map +1 -0
- package/dist/src/formats/json/obographs-export.js +941 -0
- package/dist/src/formats/json/obographs-export.js.map +1 -0
- package/dist/src/formats/json/obographs.d.ts +26 -0
- package/dist/src/formats/json/obographs.d.ts.map +1 -1
- package/dist/src/formats/json/obographs.js +297 -80
- package/dist/src/formats/json/obographs.js.map +1 -1
- package/dist/src/formats/neo4j/exporter.d.ts +109 -21
- package/dist/src/formats/neo4j/exporter.d.ts.map +1 -1
- package/dist/src/formats/neo4j/exporter.js +239 -86
- package/dist/src/formats/neo4j/exporter.js.map +1 -1
- package/dist/src/formats/neo4j/header.d.ts +17 -4
- package/dist/src/formats/neo4j/header.d.ts.map +1 -1
- package/dist/src/formats/neo4j/header.js +36 -4
- package/dist/src/formats/neo4j/header.js.map +1 -1
- package/dist/src/formats/neo4j/importer.d.ts +107 -27
- package/dist/src/formats/neo4j/importer.d.ts.map +1 -1
- package/dist/src/formats/neo4j/importer.js +415 -63
- package/dist/src/formats/neo4j/importer.js.map +1 -1
- package/dist/src/formats/neo4j/index.d.ts +73 -23
- package/dist/src/formats/neo4j/index.d.ts.map +1 -1
- package/dist/src/formats/neo4j/index.js +65 -25
- package/dist/src/formats/neo4j/index.js.map +1 -1
- package/dist/src/formats/obo/exporter.d.ts +150 -0
- package/dist/src/formats/obo/exporter.d.ts.map +1 -0
- package/dist/src/formats/obo/exporter.js +1736 -0
- package/dist/src/formats/obo/exporter.js.map +1 -0
- package/dist/src/formats/obo/importer.d.ts +95 -19
- package/dist/src/formats/obo/importer.d.ts.map +1 -1
- package/dist/src/formats/obo/importer.js +475 -104
- package/dist/src/formats/obo/importer.js.map +1 -1
- package/dist/src/formats/obo/index.d.ts +6 -3
- package/dist/src/formats/obo/index.d.ts.map +1 -1
- package/dist/src/formats/obo/index.js +6 -3
- package/dist/src/formats/obo/index.js.map +1 -1
- package/dist/src/formats/obo/syntax.d.ts +108 -4
- package/dist/src/formats/obo/syntax.d.ts.map +1 -1
- package/dist/src/formats/obo/syntax.js +211 -34
- package/dist/src/formats/obo/syntax.js.map +1 -1
- package/dist/src/formats/pajek/exporter.d.ts +54 -16
- package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
- package/dist/src/formats/pajek/exporter.js +67 -35
- package/dist/src/formats/pajek/exporter.js.map +1 -1
- package/dist/src/formats/pajek/importer.d.ts +84 -22
- package/dist/src/formats/pajek/importer.d.ts.map +1 -1
- package/dist/src/formats/pajek/importer.js +303 -83
- package/dist/src/formats/pajek/importer.js.map +1 -1
- package/dist/src/formats/pajek/index.d.ts +2 -1
- package/dist/src/formats/pajek/index.d.ts.map +1 -1
- package/dist/src/formats/pajek/index.js +2 -1
- package/dist/src/formats/pajek/index.js.map +1 -1
- package/dist/src/formats/pajek/syntax.d.ts +77 -14
- package/dist/src/formats/pajek/syntax.d.ts.map +1 -1
- package/dist/src/formats/pajek/syntax.js +186 -54
- package/dist/src/formats/pajek/syntax.js.map +1 -1
- package/dist/src/formats/xgmml/columns.d.ts +1 -0
- package/dist/src/formats/xgmml/columns.d.ts.map +1 -1
- package/dist/src/formats/xgmml/columns.js +4 -0
- package/dist/src/formats/xgmml/columns.js.map +1 -1
- package/dist/src/formats/xgmml/constants.d.ts +186 -56
- package/dist/src/formats/xgmml/constants.d.ts.map +1 -1
- package/dist/src/formats/xgmml/constants.js +181 -57
- package/dist/src/formats/xgmml/constants.js.map +1 -1
- package/dist/src/formats/xgmml/document.d.ts +65 -11
- package/dist/src/formats/xgmml/document.d.ts.map +1 -1
- package/dist/src/formats/xgmml/document.js +157 -28
- package/dist/src/formats/xgmml/document.js.map +1 -1
- package/dist/src/formats/xgmml/emit.d.ts +61 -3
- package/dist/src/formats/xgmml/emit.d.ts.map +1 -1
- package/dist/src/formats/xgmml/emit.js +129 -26
- package/dist/src/formats/xgmml/emit.js.map +1 -1
- package/dist/src/formats/xgmml/exporter.d.ts +13 -6
- package/dist/src/formats/xgmml/exporter.d.ts.map +1 -1
- package/dist/src/formats/xgmml/exporter.js +21 -22
- package/dist/src/formats/xgmml/exporter.js.map +1 -1
- package/dist/src/formats/xgmml/importer.d.ts +33 -12
- package/dist/src/formats/xgmml/importer.d.ts.map +1 -1
- package/dist/src/formats/xgmml/importer.js +35 -72
- package/dist/src/formats/xgmml/importer.js.map +1 -1
- package/dist/src/formats/xgmml/index.d.ts +1 -0
- package/dist/src/formats/xgmml/index.d.ts.map +1 -1
- package/dist/src/formats/xgmml/index.js +1 -0
- package/dist/src/formats/xgmml/index.js.map +1 -1
- package/dist/src/formats/xgmml/values.d.ts +8 -1
- package/dist/src/formats/xgmml/values.d.ts.map +1 -1
- package/dist/src/formats/xgmml/values.js +8 -3
- package/dist/src/formats/xgmml/values.js.map +1 -1
- package/dist/src/index.d.ts +23 -18
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +28 -16
- package/dist/src/index.js.map +1 -1
- package/dist/src/registry.d.ts +478 -92
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/registry.js +807 -88
- package/dist/src/registry.js.map +1 -1
- package/dist/src/sniff.d.ts +61 -19
- package/dist/src/sniff.d.ts.map +1 -1
- package/dist/src/sniff.js +121 -29
- package/dist/src/sniff.js.map +1 -1
- package/dist/src/types.d.ts +362 -112
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +28 -7
- package/dist/src/types.js.map +1 -1
- package/dist/xgmml.js +2 -2
- package/docs/samples/README.md +25 -0
- package/docs/samples/got-edges.csv +353 -0
- package/docs/samples/got-network.graphml +1384 -0
- package/docs/samples/got-nodes.csv +108 -0
- package/docs/samples/got.cx +930 -0
- package/docs/samples/got.cx2 +465 -0
- package/docs/samples/got.gexf +471 -0
- package/docs/samples/got.gml +2650 -0
- package/docs/samples/got.json +2546 -0
- package/docs/samples/got.net +461 -0
- package/docs/samples/movies-nodes.csv +9 -0
- package/docs/samples/movies-rels.csv +8 -0
- package/docs/samples/networks.cys +0 -0
- package/docs/samples/proteins.xgmml +9 -0
- package/docs/samples/teams.gv +24 -0
- package/docs/samples/vehicles.obo +25 -0
- package/package.json +9 -4
- package/src/children.ts +18 -6
- package/src/common/attributes.ts +29 -11
- package/src/common/cell-budget.ts +11 -3
- package/src/common/choose.ts +89 -0
- package/src/common/codes.ts +490 -66
- package/src/common/compare.ts +472 -0
- package/src/common/cx-export.ts +432 -0
- package/src/common/declared-types.ts +40 -6
- package/src/common/direction.ts +78 -51
- package/src/common/escape.ts +39 -22
- package/src/common/export.ts +284 -47
- package/src/common/format.ts +30 -1
- package/src/common/ids.ts +14 -3
- package/src/common/input.ts +1057 -134
- package/src/common/json-elements.ts +1035 -199
- package/src/common/line-format.ts +249 -0
- package/src/common/lists.ts +7 -2
- package/src/common/ontology-export.ts +461 -0
- package/src/common/ontology.ts +31 -9
- package/src/common/options.ts +110 -15
- package/src/common/plural.ts +49 -0
- package/src/common/report.ts +168 -25
- package/src/common/temporal.ts +22 -5
- package/src/common/text.ts +62 -23
- package/src/common/weights.ts +74 -4
- package/src/common/writer.ts +37 -3
- package/src/common/xml.ts +479 -90
- package/src/common/zip.ts +169 -7
- package/src/formats/csv/exporter.ts +202 -47
- package/src/formats/csv/header.ts +50 -11
- package/src/formats/csv/importer.ts +1133 -245
- package/src/formats/csv/index.ts +106 -19
- package/src/formats/csv/records.ts +396 -122
- package/src/formats/csv/values.ts +1 -0
- package/src/formats/cx/exporter.ts +1483 -0
- package/src/formats/cx/importer.ts +890 -302
- package/src/formats/cx/index.ts +4 -3
- package/src/formats/cx2/exporter.ts +62 -339
- package/src/formats/cx2/importer.ts +318 -87
- package/src/formats/cx2/index.ts +2 -1
- package/src/formats/cys/constants.ts +62 -17
- package/src/formats/cys/exporter.ts +1368 -0
- package/src/formats/cys/importer.ts +659 -157
- package/src/formats/cys/index.ts +4 -2
- package/src/formats/cys/session.ts +142 -34
- package/src/formats/cys/tables.ts +47 -9
- package/src/formats/dot/exporter.ts +83 -37
- package/src/formats/dot/importer.ts +248 -54
- package/src/formats/dot/index.ts +2 -1
- package/src/formats/dot/names.ts +44 -11
- package/src/formats/dot/tokenizer.ts +25 -6
- package/src/formats/gexf/exporter.ts +57 -18
- package/src/formats/gexf/importer.ts +636 -105
- package/src/formats/gexf/index.ts +90 -21
- package/src/formats/gexf/schema.ts +67 -15
- package/src/formats/gml/exporter.ts +90 -36
- package/src/formats/gml/importer.ts +388 -67
- package/src/formats/gml/index.ts +85 -24
- package/src/formats/gml/syntax.ts +113 -28
- package/src/formats/graphml/constants.ts +178 -44
- package/src/formats/graphml/exporter.ts +52 -18
- package/src/formats/graphml/importer.ts +640 -60
- package/src/formats/graphml/index.ts +2 -1
- package/src/formats/graphml/tree.ts +6 -2
- package/src/formats/graphml/yfiles.ts +37 -15
- package/src/formats/json/dialect.ts +128 -29
- package/src/formats/json/exporter.ts +205 -68
- package/src/formats/json/importer.ts +1163 -253
- package/src/formats/json/index.ts +3 -1
- package/src/formats/json/obographs-export.ts +1197 -0
- package/src/formats/json/obographs.ts +353 -92
- package/src/formats/neo4j/exporter.ts +321 -102
- package/src/formats/neo4j/header.ts +44 -6
- package/src/formats/neo4j/importer.ts +512 -73
- package/src/formats/neo4j/index.ts +75 -23
- package/src/formats/obo/exporter.ts +2210 -0
- package/src/formats/obo/importer.ts +622 -109
- package/src/formats/obo/index.ts +6 -3
- package/src/formats/obo/syntax.ts +232 -37
- package/src/formats/pajek/exporter.ts +90 -42
- package/src/formats/pajek/importer.ts +407 -93
- package/src/formats/pajek/index.ts +2 -1
- package/src/formats/pajek/syntax.ts +216 -55
- package/src/formats/xgmml/columns.ts +10 -0
- package/src/formats/xgmml/constants.ts +183 -56
- package/src/formats/xgmml/document.ts +212 -34
- package/src/formats/xgmml/emit.ts +175 -34
- package/src/formats/xgmml/exporter.ts +36 -28
- package/src/formats/xgmml/importer.ts +64 -86
- package/src/formats/xgmml/index.ts +1 -0
- package/src/formats/xgmml/values.ts +12 -4
- package/src/index.ts +81 -11
- package/src/registry.ts +1121 -135
- package/src/sniff.ts +163 -32
- package/src/types.ts +385 -114
- package/dist/chunks/escape-B-tkk_Cl.js.map +0 -1
- package/dist/chunks/export-Bh60Dv-n.js +0 -582
- package/dist/chunks/export-Bh60Dv-n.js.map +0 -1
- package/dist/chunks/exporter-BGrsWamJ.js.map +0 -1
- package/dist/chunks/exporter-DIeGJXAZ.js.map +0 -1
- package/dist/chunks/importer-BWY2FFc5.js.map +0 -1
- package/dist/chunks/importer-DD-xv9_Y.js +0 -1471
- package/dist/chunks/importer-DD-xv9_Y.js.map +0 -1
- package/dist/chunks/importer-DET1tg6s.js.map +0 -1
- package/dist/chunks/importer-DEcKhsmQ.js +0 -1614
- package/dist/chunks/importer-DEcKhsmQ.js.map +0 -1
- package/dist/chunks/importer-DIrbbnAf.js.map +0 -1
- package/dist/chunks/importer-D_e7e7LX.js.map +0 -1
- package/dist/chunks/importer-eUREhBGj.js.map +0 -1
- package/dist/chunks/importer-vi3bSdtw.js.map +0 -1
- package/dist/chunks/importer-zGLo8Dg_.js.map +0 -1
- package/dist/chunks/json-elements-DDS8N2Dd.js +0 -779
- package/dist/chunks/json-elements-DDS8N2Dd.js.map +0 -1
- package/dist/chunks/ontology-BnrJ4I98.js +0 -113
- package/dist/chunks/ontology-BnrJ4I98.js.map +0 -1
- package/dist/chunks/records-dbRkxwaq.js.map +0 -1
- package/dist/chunks/report-B1z4WT9e.js +0 -2372
- package/dist/chunks/report-B1z4WT9e.js.map +0 -1
- package/dist/chunks/text-Dr0Ifpag.js.map +0 -1
- package/dist/chunks/weights-Dzba96G3.js +0 -176
- package/dist/chunks/weights-Dzba96G3.js.map +0 -1
- package/dist/chunks/writer-C7flM-Ih.js.map +0 -1
package/dist/src/registry.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The importer / exporter registry
|
|
2
|
+
* The importer / exporter registry: the built-in formats
|
|
3
3
|
* registered by name, `sniff()` over them, and the two conveniences for callers who do not own a
|
|
4
4
|
* sink: `importGraph()` sniffs the format, creates a builder seeded from the common options
|
|
5
5
|
* (`directed: true` as a placeholder; the importer sets the real value), imports and freezes;
|
|
@@ -7,62 +7,183 @@
|
|
|
7
7
|
* objects directly (the subpath exports) and this module never touches their sink.
|
|
8
8
|
*/
|
|
9
9
|
import { type FreezeOptions, type FreezeReport, type GraphBuilderOptions, type GraphSnapshot } from "@graphty/graph-format";
|
|
10
|
-
import { type SniffHints, type SniffResult } from "./sniff.js";
|
|
11
|
-
import { type CommonExportOptions, type CommonImportOptions, type GraphChoiceOptions, type GraphExporter, type GraphImporter, type GraphListing, type ImportInput, type ImportReport, type LossNote } from "./types.js";
|
|
12
|
-
/**
|
|
10
|
+
import { type FormatName, type SniffHints, type SniffResult } from "./sniff.js";
|
|
11
|
+
import { type CommonExportOptions, type CommonImportOptions, type ExportCapabilities, type GraphChoiceOptions, type GraphExporter, type GraphImporter, type GraphListing, type ImportInput, type ImportReport, type LossNote } from "./types.js";
|
|
12
|
+
/**
|
|
13
|
+
* The input is in no format graph-io can read (or none of the formats you registered, for your own FormatRegistry).
|
|
14
|
+
* Pass `format` when you know what the file is.
|
|
15
|
+
* @category Issue and loss codes
|
|
16
|
+
*/
|
|
13
17
|
export declare const UNKNOWN_FORMAT_CODE = "E_UNKNOWN_FORMAT";
|
|
14
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Registered importer whose sniff() threw while the format was being chosen; that importer was treated as not
|
|
20
|
+
* recognizing the input (a defect in that importer).
|
|
21
|
+
* @category Issue and loss codes
|
|
22
|
+
*/
|
|
23
|
+
export declare const SNIFF_FAILED_CODE = "W_SNIFF_FAILED";
|
|
24
|
+
/**
|
|
25
|
+
* The `builder` option of importGraph(): settings for building the graph that the common import
|
|
26
|
+
* options do not cover. `weighted`: "auto" (the default) gives the graph weights when any edge has
|
|
27
|
+
* one, true always does (every weight 1 when the file has none), false never does. `expectedNodes`
|
|
28
|
+
* and `expectedEdges`: how many nodes and edges to make room for up front, which saves time on a
|
|
29
|
+
* large file whose size you know.
|
|
30
|
+
* @category Loading
|
|
31
|
+
*/
|
|
15
32
|
export type BuilderSeed = Omit<GraphBuilderOptions, "directed" | "addMissingNodes" | "duplicateEdges" | "selfLoops" | "weightDtype">;
|
|
16
33
|
/**
|
|
17
|
-
* The options of importGraph()
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
34
|
+
* The options of importGraph(), importAllGraphs(), listGraphs() and loadFromFile(): the common
|
|
35
|
+
* import options, the format and the hints used to detect it, the graph to read from a file that
|
|
36
|
+
* holds several, and any format-specific option (`delimiter`, `dialect`, ...), which reaches the
|
|
37
|
+
* importer unchanged.
|
|
38
|
+
* @category Loading
|
|
22
39
|
*/
|
|
23
40
|
export interface ImportGraphOptions extends CommonImportOptions, GraphChoiceOptions {
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
41
|
+
/**
|
|
42
|
+
* The format to read the input as ("graphml", "csv", ...; `listFormats()` names them all), or
|
|
43
|
+
* "auto" to work it out from `filename`, `mimeType` and the first bytes of the input. Name it to
|
|
44
|
+
* be strict: detection reads a file graph-io cannot place as the closest format it recognizes.
|
|
45
|
+
* @defaultValue "auto"
|
|
46
|
+
*/
|
|
47
|
+
readonly format?: FormatName | "auto" | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* The file name or full path the input came from; only its extension is used, as a format hint.
|
|
50
|
+
* loadFromUrl() takes it from the URL and loadFromFile() from a File's name when you do not pass
|
|
51
|
+
* it.
|
|
52
|
+
*/
|
|
27
53
|
readonly filename?: string | null | undefined;
|
|
28
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* The MIME type the input was served as, a format hint. loadFromUrl() takes it from the
|
|
56
|
+
* response's Content-Type and loadFromFile() from the Blob's `type` when you do not pass it.
|
|
57
|
+
*/
|
|
29
58
|
readonly mimeType?: string | null | undefined;
|
|
30
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Settings for building the graph: `weighted` ("auto", true or false: whether the graph gets
|
|
61
|
+
* weights), `expectedNodes` and `expectedEdges` (room to make up front for a large file). Most
|
|
62
|
+
* programs never set it.
|
|
63
|
+
*/
|
|
31
64
|
readonly builder?: BuilderSeed | undefined;
|
|
32
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Settings for the last step of an import, which turns what was read into the snapshot:
|
|
67
|
+
* `label` (a name for debugging, read back as `snapshot.label`), `prepare` (views of the graph
|
|
68
|
+
* to compute up front, such as `["reverse"]`), `checksum` (record checksums, which
|
|
69
|
+
* `snapshot.validate({ checksum: true })` compares later to catch changed memory) and `profile` (record how long each step took, in `result.freeze.timings`). Most
|
|
70
|
+
* programs never set it.
|
|
71
|
+
*/
|
|
33
72
|
readonly freeze?: FreezeOptions | undefined;
|
|
34
73
|
/**
|
|
35
|
-
* The most attribute slots that hold no value the import may allocate before it stops with
|
|
36
|
-
* E_TOO_MANY_EMPTY_CELLS. Every attribute is a column with one slot per node (or edge), so a file
|
|
74
|
+
* The most attribute slots that hold no value the import may allocate before it stops with an
|
|
75
|
+
* ImportError whose `issue.code` is E_TOO_MANY_EMPTY_CELLS. Every attribute is a column with one slot per node (or edge), so a file
|
|
37
76
|
* whose nodes each have a differently named attribute would otherwise need nodes x attributes
|
|
38
|
-
* memory.
|
|
77
|
+
* memory. Infinity turns the check off. Files whose elements mostly share their attributes are
|
|
78
|
+
* never stopped.
|
|
79
|
+
* @defaultValue 16777216
|
|
39
80
|
*/
|
|
40
81
|
readonly maxEmptyCells?: number | undefined;
|
|
41
82
|
/** Format-specific options, passed to the importer as they are. */
|
|
42
83
|
readonly [formatOption: string]: unknown;
|
|
43
84
|
}
|
|
44
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* What importGraph(), loadFromUrl() and loadFromFile() return.
|
|
87
|
+
* @category Loading
|
|
88
|
+
*/
|
|
45
89
|
export interface ImportGraphResult {
|
|
46
|
-
/** The format the input was read as. */
|
|
90
|
+
/** The format the input was read as ("graphml", ...). */
|
|
47
91
|
readonly format: string;
|
|
48
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* How the format was detected (the candidate's `confidence` and what matched), or null when you
|
|
94
|
+
* named the format. Most callers can ignore it. For the JSON dialect that was read, call
|
|
95
|
+
* `jsonShapeOf(snapshot)` from `@graphty/graph-io/json`.
|
|
96
|
+
*/
|
|
49
97
|
readonly sniff: SniffResult | null;
|
|
50
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* The graph. `snapshot.nodeCount`, `snapshot.edgeCount`, attribute tables and so on come from
|
|
100
|
+
* the `@graphty/graph-format` package.
|
|
101
|
+
*/
|
|
51
102
|
readonly snapshot: GraphSnapshot;
|
|
52
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* What happened during the import. `errorCount` counts skipped elements (see `errorLimit`,
|
|
105
|
+
* default 100); `warningCount` counts elements that were kept but changed; `issues` lists both;
|
|
106
|
+
* `counts.skippedNodes` / `counts.skippedEdges` say how much is missing from `snapshot`.
|
|
107
|
+
*/
|
|
53
108
|
readonly report: ImportReport;
|
|
54
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* What the last step of the import did to the graph: `mergedEdges` (parallel edges merged by
|
|
111
|
+
* `duplicateEdges`), `droppedSelfLoops` (removed by `selfLoops: "drop"`), and `timings` when you
|
|
112
|
+
* passed `freeze: { profile: true }`. Both counts are also reported as warnings, so most callers
|
|
113
|
+
* can ignore it. It is not enumerable, so `console.log(result)` and `{ ...result }` leave it out.
|
|
114
|
+
*/
|
|
55
115
|
readonly freeze: FreezeReport;
|
|
56
116
|
}
|
|
57
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Options for loadFromUrl(): everything importGraph() accepts, plus the fetch request settings.
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* await loadFromUrl("/api/graph.csv", { request: { headers: { Authorization: token } }, delimiter: ";" });
|
|
122
|
+
* ```
|
|
123
|
+
* @category Loading
|
|
124
|
+
*/
|
|
125
|
+
export interface LoadFromUrlOptions extends ImportGraphOptions {
|
|
126
|
+
/**
|
|
127
|
+
* Passed to fetch() as its second argument: headers, credentials, mode and so on. If you set
|
|
128
|
+
* `signal` in the import options and not here, the same signal also cancels the download.
|
|
129
|
+
*/
|
|
130
|
+
readonly request?: RequestInit | undefined;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Options for downloadGraph(): the export options plus the name of the saved file.
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* await downloadGraph(snapshot, "graphml", { filename: "network.graphml" });
|
|
137
|
+
* ```
|
|
138
|
+
* @category Saving
|
|
139
|
+
*/
|
|
140
|
+
export interface DownloadGraphOptions extends ExportGraphOptions {
|
|
141
|
+
/**
|
|
142
|
+
* The file name the browser saves as. The default is "graph" plus the first entry of the
|
|
143
|
+
* format's `extensions` ("graph.graphml"), or "graph.<format>" when it lists none.
|
|
144
|
+
* @defaultValue "graph" plus the format's extension
|
|
145
|
+
*/
|
|
146
|
+
readonly filename?: string | undefined;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* One format the registry can read, write or both.
|
|
150
|
+
* @category Formats and detection
|
|
151
|
+
*/
|
|
152
|
+
export interface FormatInfo {
|
|
153
|
+
/** The name you pass as `format`: "graphml", "gexf", "csv", "pajek", ... */
|
|
154
|
+
readonly format: string;
|
|
155
|
+
/**
|
|
156
|
+
* File extensions with the leading dot, most common first (".graphml", ".net"). Empty only for a
|
|
157
|
+
* custom format that declares none.
|
|
158
|
+
*/
|
|
159
|
+
readonly extensions: readonly string[];
|
|
160
|
+
/** MIME types, most specific first. Empty when the format declares none. */
|
|
161
|
+
readonly mimeTypes: readonly string[];
|
|
162
|
+
/** Whether loadFromUrl(), loadFromFile() and importGraph() can read it. */
|
|
163
|
+
readonly canImport: boolean;
|
|
164
|
+
/** Whether the export functions can write it. */
|
|
165
|
+
readonly canExport: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* What the format can store exactly, or null when it cannot be written. The fields are
|
|
168
|
+
* mixedDirection, multiEdges, selfLoops, edgeIds, idCharset, dtypes, components, lists, json,
|
|
169
|
+
* defaults, options, hierarchy, temporal, graphAttributes, positions and viz (each documented on
|
|
170
|
+
* ExportCapabilities). checkExport() tells you where a particular graph goes beyond this.
|
|
171
|
+
*/
|
|
172
|
+
readonly capabilities: ExportCapabilities | null;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The options of exportGraph(): the common export options plus any format-specific option, passed through.
|
|
176
|
+
* @category Saving
|
|
177
|
+
*/
|
|
58
178
|
export interface ExportGraphOptions extends CommonExportOptions {
|
|
59
179
|
/** Format-specific options, passed to the exporter as they are. */
|
|
60
180
|
readonly [formatOption: string]: unknown;
|
|
61
181
|
}
|
|
62
182
|
/**
|
|
63
183
|
* A registry of importers and exporters by format name. Registration order is the tie-break
|
|
64
|
-
* order of sniffing
|
|
184
|
+
* order of sniffing; the default registry lists the built-in formats in the
|
|
65
185
|
* order of GRAPH_FORMATS.
|
|
186
|
+
* @category Formats and detection
|
|
66
187
|
*/
|
|
67
188
|
export declare class FormatRegistry {
|
|
68
189
|
private readonly importerMap;
|
|
@@ -85,25 +206,25 @@ export declare class FormatRegistry {
|
|
|
85
206
|
* @param format - the format name
|
|
86
207
|
* @returns the importer; E_UNSUPPORTED when none is registered
|
|
87
208
|
*/
|
|
88
|
-
importer(format:
|
|
209
|
+
importer(format: FormatName): GraphImporter;
|
|
89
210
|
/**
|
|
90
211
|
* The exporter of a format.
|
|
91
212
|
* @param format - the format name
|
|
92
213
|
* @returns the exporter; E_UNSUPPORTED when none is registered
|
|
93
214
|
*/
|
|
94
|
-
exporter(format:
|
|
215
|
+
exporter(format: FormatName): GraphExporter;
|
|
95
216
|
/**
|
|
96
217
|
* Whether an importer is registered for a format.
|
|
97
218
|
* @param format - the format name
|
|
98
219
|
* @returns true when importer(format) would succeed
|
|
99
220
|
*/
|
|
100
|
-
hasImporter(format:
|
|
221
|
+
hasImporter(format: FormatName): boolean;
|
|
101
222
|
/**
|
|
102
223
|
* Whether an exporter is registered for a format.
|
|
103
224
|
* @param format - the format name
|
|
104
225
|
* @returns true when exporter(format) would succeed
|
|
105
226
|
*/
|
|
106
|
-
hasExporter(format:
|
|
227
|
+
hasExporter(format: FormatName): boolean;
|
|
107
228
|
/**
|
|
108
229
|
* Every registered importer, in registration order.
|
|
109
230
|
* @returns the importers
|
|
@@ -120,10 +241,10 @@ export declare class FormatRegistry {
|
|
|
120
241
|
*/
|
|
121
242
|
formats(): readonly string[];
|
|
122
243
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* @param hints -
|
|
126
|
-
* @returns the candidates, best first; empty when
|
|
244
|
+
* Every format that could be the input, best first, from the same hints as sniff(): use it to
|
|
245
|
+
* offer the user a choice when the best guess is not certain.
|
|
246
|
+
* @param hints - `{ filename, mimeType, head }`, any of them
|
|
247
|
+
* @returns the candidates, best first; empty when no format claims the input
|
|
127
248
|
*/
|
|
128
249
|
sniffAll(hints: SniffHints): readonly SniffResult[];
|
|
129
250
|
/**
|
|
@@ -133,27 +254,46 @@ export declare class FormatRegistry {
|
|
|
133
254
|
*/
|
|
134
255
|
sniff(hints: SniffHints): SniffResult | null;
|
|
135
256
|
/**
|
|
136
|
-
* Read
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* An input holding several graphs yields the first, with a warning naming how many were
|
|
141
|
-
* skipped; importAllGraphs() returns every one.
|
|
257
|
+
* Read a graph from a string, bytes or a stream. The format is the one you name in `format`,
|
|
258
|
+
* else it is detected from `filename`, `mimeType` and the first bytes of the content. From an
|
|
259
|
+
* input that holds several graphs, it reads the one `graphIndex` or `graphName` chooses, else
|
|
260
|
+
* the first, with a W_MULTIPLE_GRAPHS warning; importAllGraphs() returns every one.
|
|
142
261
|
* @param input - the text, bytes, stream or chunks to read
|
|
143
262
|
* @param options - the format, hints, common and format-specific import options
|
|
144
|
-
* @returns the snapshot, the
|
|
263
|
+
* @returns the graph (`snapshot`), the format it was read as, and the import report
|
|
145
264
|
*/
|
|
146
|
-
importGraph(input: ImportInput, options?: ImportGraphOptions): Promise<ImportGraphResult>;
|
|
265
|
+
importGraph(input: ImportInput, options?: ImportGraphOptions | CommonImportOptions): Promise<ImportGraphResult>;
|
|
266
|
+
/**
|
|
267
|
+
* Fetch a graph file from a URL and load it; see the top-level loadFromUrl() for the full
|
|
268
|
+
* description.
|
|
269
|
+
* @param url - an absolute URL, or in a browser one relative to the page
|
|
270
|
+
* @param options - import options, plus `request` for fetch
|
|
271
|
+
* @returns the graph, the format it was read as, and the import report
|
|
272
|
+
*/
|
|
273
|
+
loadFromUrl(url: string | URL, options?: LoadFromUrlOptions | CommonImportOptions): Promise<ImportGraphResult>;
|
|
274
|
+
/**
|
|
275
|
+
* Load a graph from a File or Blob; see the top-level loadFromFile() for the full description.
|
|
276
|
+
* @param file - the File or Blob to read
|
|
277
|
+
* @param options - the same options as importGraph()
|
|
278
|
+
* @returns the graph, the format it was read as, and the import report
|
|
279
|
+
*/
|
|
280
|
+
loadFromFile(file: Blob, options?: ImportGraphOptions | CommonImportOptions): Promise<ImportGraphResult>;
|
|
147
281
|
/**
|
|
148
282
|
* Read every graph of an input (a DOT file with several graphs, a Pajek project with several
|
|
149
|
-
* networks, a JGF document with a `graphs` array), each
|
|
150
|
-
*
|
|
151
|
-
* entry. Options, sniffing and the builder seed are those of importGraph().
|
|
283
|
+
* networks, a JGF document with a `graphs` array), each as its own snapshot. A format that holds
|
|
284
|
+
* one graph per file gives one result. Options and detection are those of importGraph().
|
|
152
285
|
* @param input - the text, bytes, stream or chunks to read
|
|
153
286
|
* @param options - the format, hints, common and format-specific import options
|
|
154
287
|
* @returns one result per graph, in document order
|
|
155
288
|
*/
|
|
156
|
-
importAllGraphs(input: ImportInput, options?: ImportGraphOptions): Promise<ImportGraphResult[]>;
|
|
289
|
+
importAllGraphs(input: ImportInput, options?: ImportGraphOptions | CommonImportOptions): Promise<ImportGraphResult[]>;
|
|
290
|
+
/**
|
|
291
|
+
* Read every graph of an input with the chosen importer.
|
|
292
|
+
* @param chosen - the importer and the input to hand it
|
|
293
|
+
* @param options - the importGraph options
|
|
294
|
+
* @returns one result per graph, in document order
|
|
295
|
+
*/
|
|
296
|
+
private readAll;
|
|
157
297
|
/**
|
|
158
298
|
* The graphs of an input that can hold several, without importing them (a Cytoscape session's
|
|
159
299
|
* networks, a JGF `graphs` array), so a caller can offer a choice and then pass `graphIndex`
|
|
@@ -163,22 +303,31 @@ export declare class FormatRegistry {
|
|
|
163
303
|
* @returns one listing per graph, in document order; null when the format's importer does not
|
|
164
304
|
* list its graphs (importGraph() then reads the first)
|
|
165
305
|
*/
|
|
166
|
-
listGraphs(input: ImportInput, options?: ImportGraphOptions): Promise<readonly GraphListing[] | null>;
|
|
306
|
+
listGraphs(input: ImportInput, options?: ImportGraphOptions | CommonImportOptions): Promise<readonly GraphListing[] | null>;
|
|
167
307
|
/**
|
|
168
308
|
* The importer for an input: the named format, or the sniffed one.
|
|
169
|
-
* @param
|
|
309
|
+
* @param rawInput - the input as the caller passed it
|
|
170
310
|
* @param options - the importGraph options
|
|
171
311
|
* @returns the importer, the sniff, and the input to read (replayed for a stream)
|
|
172
312
|
*/
|
|
173
313
|
private choose;
|
|
174
314
|
/**
|
|
175
|
-
*
|
|
315
|
+
* Refuse an input no importer recognizes: empty, or not in a known graph format.
|
|
316
|
+
* @param failures - the report the error is recorded in
|
|
317
|
+
* @param head - the head, as sniffed
|
|
318
|
+
* @param foreign - what known non-graph file the head is, or null
|
|
319
|
+
* @param options - the importGraph options
|
|
320
|
+
* @returns never: always throws
|
|
321
|
+
*/
|
|
322
|
+
private refuseUndetected;
|
|
323
|
+
/**
|
|
324
|
+
* Write a snapshot in a format, as UTF-8 chunks.
|
|
176
325
|
* @param snapshot - the snapshot
|
|
177
326
|
* @param format - the format name
|
|
178
327
|
* @param options - the exporter's common and format-specific options
|
|
179
328
|
* @returns the encoded chunks
|
|
180
329
|
*/
|
|
181
|
-
exportGraph(snapshot: GraphSnapshot, format:
|
|
330
|
+
exportGraph(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): AsyncIterable<Uint8Array>;
|
|
182
331
|
/**
|
|
183
332
|
* Write a snapshot in a format, as one string.
|
|
184
333
|
* @param snapshot - the snapshot
|
|
@@ -186,7 +335,25 @@ export declare class FormatRegistry {
|
|
|
186
335
|
* @param options - the exporter's common and format-specific options
|
|
187
336
|
* @returns the whole document
|
|
188
337
|
*/
|
|
189
|
-
exportGraphToString(snapshot: GraphSnapshot, format:
|
|
338
|
+
exportGraphToString(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): Promise<string>;
|
|
339
|
+
/**
|
|
340
|
+
* Write a snapshot in a format as one buffer of UTF-8 bytes; see the top-level
|
|
341
|
+
* exportGraphToBytes().
|
|
342
|
+
* @param snapshot - the graph to write
|
|
343
|
+
* @param format - a format name where `canExport` is true
|
|
344
|
+
* @param options - sanitizeIds, onMixedDirection and the format's own options
|
|
345
|
+
* @returns the encoded file
|
|
346
|
+
*/
|
|
347
|
+
exportGraphToBytes(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): Promise<Uint8Array>;
|
|
348
|
+
/**
|
|
349
|
+
* Write a snapshot in a format as a Blob typed with the format's first MIME type; see the
|
|
350
|
+
* top-level exportGraphToBlob().
|
|
351
|
+
* @param snapshot - the graph to write
|
|
352
|
+
* @param format - a format name where `canExport` is true
|
|
353
|
+
* @param options - sanitizeIds, onMixedDirection and the format's own options
|
|
354
|
+
* @returns the file as a Blob
|
|
355
|
+
*/
|
|
356
|
+
exportGraphToBlob(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): Promise<Blob>;
|
|
190
357
|
/**
|
|
191
358
|
* What exporting a snapshot in a format would lose, without writing anything.
|
|
192
359
|
* @param snapshot - the snapshot
|
|
@@ -194,65 +361,284 @@ export declare class FormatRegistry {
|
|
|
194
361
|
* @param options - the exporter's common and format-specific options
|
|
195
362
|
* @returns the loss notes, empty when the export is exact
|
|
196
363
|
*/
|
|
197
|
-
checkExport(snapshot: GraphSnapshot, format:
|
|
364
|
+
checkExport(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): readonly LossNote[];
|
|
365
|
+
/**
|
|
366
|
+
* The option names no registered format and no load or save function takes (misspellings), or none while a
|
|
367
|
+
* registered format does not list its options.
|
|
368
|
+
* @param options - the caller's options
|
|
369
|
+
* @returns the unknown names
|
|
370
|
+
*/
|
|
371
|
+
private unknownOptions;
|
|
372
|
+
/**
|
|
373
|
+
* Browser only: write a graph in a format and have the browser save it as a file; see the
|
|
374
|
+
* top-level downloadGraph(). Use this method on a registry from createRegistry() to download
|
|
375
|
+
* without bundling every built-in format.
|
|
376
|
+
* @param snapshot - the graph to write
|
|
377
|
+
* @param format - a format name from listFormats() where `canExport` is true
|
|
378
|
+
* @param options - the export options, plus `filename`
|
|
379
|
+
* @returns resolves once the download has been handed to the browser
|
|
380
|
+
*/
|
|
381
|
+
downloadGraph(snapshot: GraphSnapshot, format: FormatName, options?: DownloadGraphOptions | CommonExportOptions): Promise<void>;
|
|
382
|
+
/**
|
|
383
|
+
* Every format this registry can read or write, in registration order; see the top-level
|
|
384
|
+
* listFormats().
|
|
385
|
+
* @returns one entry per format
|
|
386
|
+
*/
|
|
387
|
+
listFormats(): readonly FormatInfo[];
|
|
198
388
|
}
|
|
199
389
|
/**
|
|
200
|
-
* A registry holding
|
|
390
|
+
* A new registry holding every built-in importer and exporter, in the order of GRAPH_FORMATS.
|
|
201
391
|
* @returns a new registry
|
|
392
|
+
* @category Formats and detection
|
|
202
393
|
*/
|
|
203
394
|
export declare function createRegistry(): FormatRegistry;
|
|
204
|
-
/**
|
|
395
|
+
/**
|
|
396
|
+
* The default registry: every built-in format.
|
|
397
|
+
* @category Formats and detection
|
|
398
|
+
*/
|
|
205
399
|
export declare const registry: FormatRegistry;
|
|
206
400
|
/**
|
|
207
|
-
* Read
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
401
|
+
* Read a graph from a string, bytes or a stream. The format is the one you name in `format`, else
|
|
402
|
+
* it is detected from `filename`, `mimeType` and the first bytes; an input that matches no format
|
|
403
|
+
* fails with E_UNKNOWN_FORMAT. From a file that holds several graphs it reads the one `graphIndex`
|
|
404
|
+
* or `graphName` chooses, else the first, with a W_MULTIPLE_GRAPHS warning. For a File or Blob use
|
|
405
|
+
* loadFromFile(), for a URL loadFromUrl().
|
|
406
|
+
* @param input - the whole text, the bytes (a Uint8Array or a Node Buffer), a ReadableStream of
|
|
407
|
+
* bytes, or an async iterable of text or byte chunks (a Node read stream)
|
|
408
|
+
* @param options - the format, format hints, the options every importer takes and the format's own
|
|
409
|
+
* options
|
|
410
|
+
* @returns the graph (`snapshot`), the format it was read as, and the import report
|
|
411
|
+
* @throws ImportError when the input could not be read; `err.issue?.code` says why
|
|
412
|
+
* @throws GraphFormatError with code E_UNSUPPORTED for a `format` no importer is registered for, or
|
|
413
|
+
* an option value that is not allowed (`err.details.option` names it)
|
|
414
|
+
* @throws the signal's reason when `signal` aborts
|
|
415
|
+
* @category Loading
|
|
416
|
+
*/
|
|
417
|
+
export declare function importGraph(input: ImportInput, options?: ImportGraphOptions | CommonImportOptions): Promise<ImportGraphResult>;
|
|
418
|
+
/**
|
|
419
|
+
* Read every graph of a file that can hold several (DOT, GML, a Pajek project, a JSON Graph Format
|
|
420
|
+
* or OBO Graphs document, CX, XGMML, a Cytoscape session). A format that holds one graph per file
|
|
421
|
+
* gives one result. Options and errors are the same as importGraph()'s.
|
|
422
|
+
* @param input - the text, bytes or stream to read
|
|
423
|
+
* @param options - the same options as importGraph()
|
|
424
|
+
* @returns one result per graph, in file order
|
|
425
|
+
* @category Loading
|
|
426
|
+
*/
|
|
427
|
+
export declare function importAllGraphs(input: ImportInput, options?: ImportGraphOptions | CommonImportOptions): Promise<ImportGraphResult[]>;
|
|
428
|
+
/**
|
|
429
|
+
* List the graphs of a file without reading them: each one's `index`, `name`, and node and edge
|
|
430
|
+
* counts when the file states them. Pass the index or name to importGraph() as `graphIndex` or
|
|
431
|
+
* `graphName`. The counts come from the file and can differ from what an import reads, for example
|
|
432
|
+
* when the import adds edges the listing does not count. JSON, CX, XGMML and Cytoscape sessions can
|
|
433
|
+
* list their graphs; for DOT, GML and Pajek it returns null, and importAllGraphs() is the way to see
|
|
434
|
+
* them.
|
|
435
|
+
* @param input - the text, bytes or stream to read
|
|
436
|
+
* @param options - the same options as importGraph()
|
|
437
|
+
* @returns one listing per graph, in file order; null when the format cannot list its graphs
|
|
438
|
+
* @category Loading
|
|
439
|
+
*/
|
|
440
|
+
export declare function listGraphs(input: ImportInput, options?: ImportGraphOptions | CommonImportOptions): Promise<readonly GraphListing[] | null>;
|
|
441
|
+
/**
|
|
442
|
+
* Write a graph in a format as a stream of UTF-8 byte chunks, for a graph too large to hold as one
|
|
443
|
+
* file in memory. In Node, pipe it to a file with `pipeline(exportGraph(...), createWriteStream(path))`.
|
|
444
|
+
* Options and errors are the same as exportGraphToBytes()'s.
|
|
445
|
+
* @param snapshot - the graph to write
|
|
446
|
+
* @param format - a format name from listFormats() where `canExport` is true
|
|
447
|
+
* @param options - sanitizeIds, onMixedDirection and the format's own options
|
|
448
|
+
* @returns the file's bytes, chunk by chunk
|
|
449
|
+
* @category Saving
|
|
450
|
+
*/
|
|
451
|
+
export declare function exportGraph(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): AsyncIterable<Uint8Array>;
|
|
452
|
+
/**
|
|
453
|
+
* Write a graph in a format and return the file as one string. A binary format (a Cytoscape
|
|
454
|
+
* session) cannot be a string and fails with E_UNSUPPORTED; use exportGraphToBytes() for it. Options
|
|
455
|
+
* and errors are the same as exportGraphToBytes()'s.
|
|
456
|
+
* @param snapshot - the graph to write
|
|
457
|
+
* @param format - a format name from listFormats() where `canExport` is true
|
|
458
|
+
* @param options - sanitizeIds, onMixedDirection and the format's own options
|
|
459
|
+
* @returns the whole file
|
|
460
|
+
* @category Saving
|
|
461
|
+
*/
|
|
462
|
+
export declare function exportGraphToString(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): Promise<string>;
|
|
463
|
+
/**
|
|
464
|
+
* What saving a graph in a format would lose, without writing anything. Pass the same options you
|
|
465
|
+
* will pass to the save. Each note has a stable `code`: "E_" means the save would throw, "W_" means
|
|
466
|
+
* the file is written but that part does not read back the same. An empty array means the file
|
|
467
|
+
* reads back as the same graph. Runs synchronously.
|
|
468
|
+
* @param snapshot - the graph to check
|
|
469
|
+
* @param format - a format name from listFormats() where `canExport` is true
|
|
470
|
+
* @param options - the options you will save with
|
|
471
|
+
* @returns the loss notes, empty when the save is exact
|
|
472
|
+
* @throws GraphFormatError with code E_UNSUPPORTED when no exporter is registered for `format`, or
|
|
473
|
+
* when an option value is not allowed (`err.details.option` names it)
|
|
474
|
+
* @category Saving
|
|
475
|
+
*/
|
|
476
|
+
export declare function checkExport(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): readonly LossNote[];
|
|
477
|
+
/**
|
|
478
|
+
* Fetch a graph file from a URL and load it. The file is streamed into the importer as it
|
|
479
|
+
* downloads, so a large file is not held in memory twice. When you do not name a `format`, it is
|
|
480
|
+
* worked out from the URL's file name, the response's Content-Type and the first bytes of the
|
|
481
|
+
* file. Your own `filename` or `mimeType` option takes the place of the hint from the URL or the
|
|
482
|
+
* response. Every other option goes to importGraph() unchanged, including format-specific ones
|
|
483
|
+
* such as `delimiter` or `dialect`, and `graphIndex` / `graphName` for files that hold several
|
|
484
|
+
* graphs. The result is the same as importGraph()'s. A successful load can still have skipped
|
|
485
|
+
* elements; check `report.errorCount` and `report.warningCount`, or pass `errorLimit: 0` to make
|
|
486
|
+
* the first error fatal. Works wherever fetch exists: browsers, Node 18 and later, Deno, Bun and
|
|
487
|
+
* workers.
|
|
488
|
+
* @param url - an absolute URL, or in a browser one relative to the page
|
|
489
|
+
* @param options - import options, plus `request` for fetch
|
|
490
|
+
* @returns the graph, the format it was read as, and the import report
|
|
491
|
+
* @throws ImportError when the file could not be loaded; `err.issue?.code` is "E_FETCH" for a
|
|
492
|
+
* network failure, a CORS refusal or a status outside 200-299 (`err.details.url`,
|
|
493
|
+
* `err.details.status` -- null for a network failure -- and `err.details.cause`, fetch's own
|
|
494
|
+
* error), "E_UNKNOWN_FORMAT" when no format recognizes the file (pass `format`), or the code of
|
|
495
|
+
* the parse error
|
|
496
|
+
* @throws GraphFormatError with code E_UNSUPPORTED when `format` names no registered importer
|
|
497
|
+
* @throws the signal's reason when `signal` aborts
|
|
498
|
+
* @example
|
|
499
|
+
* ```ts
|
|
500
|
+
* import { GraphFormatError, loadFromUrl } from "@graphty/graph-io";
|
|
501
|
+
*
|
|
502
|
+
* try {
|
|
503
|
+
* const { snapshot, format } = await loadFromUrl("https://example.com/data/karate.gml");
|
|
504
|
+
* console.log(`${format}: ${snapshot.nodeCount} nodes, ${snapshot.edgeCount} edges`);
|
|
505
|
+
* } catch (err) {
|
|
506
|
+
* if (err instanceof GraphFormatError) {
|
|
507
|
+
* console.error(err.message);
|
|
508
|
+
* } else {
|
|
509
|
+
* throw err;
|
|
510
|
+
* }
|
|
511
|
+
* }
|
|
512
|
+
* ```
|
|
513
|
+
* @category Loading
|
|
212
514
|
*/
|
|
213
|
-
export declare function
|
|
515
|
+
export declare function loadFromUrl(url: string | URL, options?: LoadFromUrlOptions | CommonImportOptions): Promise<ImportGraphResult>;
|
|
214
516
|
/**
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
517
|
+
* Load a graph from a File or Blob: a file the user picked in an `<input type="file">`, a file
|
|
518
|
+
* dropped on the page, a Blob you built, or in Node a Blob from `fs.openAsBlob(path)`. The content
|
|
519
|
+
* is streamed into the importer. A File's `name` and the Blob's `type` are used as format hints
|
|
520
|
+
* unless you pass `filename` or `mimeType` yourself. Options, result and errors are the same as
|
|
521
|
+
* loadFromUrl()'s, without E_FETCH.
|
|
522
|
+
* @param file - the File or Blob to read
|
|
523
|
+
* @param options - the same options as importGraph()
|
|
524
|
+
* @returns the graph, the format it was read as, and the import report
|
|
525
|
+
* @throws ImportError when the file could not be loaded (`err.issue?.code` E_UNKNOWN_FORMAT or a parse error)
|
|
526
|
+
* @throws GraphFormatError with code E_UNSUPPORTED when `format` names no registered importer
|
|
527
|
+
* @throws the signal's reason when `signal` aborts
|
|
528
|
+
* @example
|
|
529
|
+
* ```ts
|
|
530
|
+
* input.addEventListener("change", async () => {
|
|
531
|
+
* const file = input.files?.[0];
|
|
532
|
+
* if (file) {
|
|
533
|
+
* const { snapshot, report } = await loadFromFile(file);
|
|
534
|
+
* console.log(`${snapshot.nodeCount} nodes, ${report.errorCount} skipped`);
|
|
535
|
+
* }
|
|
536
|
+
* });
|
|
537
|
+
* ```
|
|
538
|
+
* @category Loading
|
|
219
539
|
*/
|
|
220
|
-
export declare function
|
|
540
|
+
export declare function loadFromFile(file: Blob, options?: ImportGraphOptions | CommonImportOptions): Promise<ImportGraphResult>;
|
|
221
541
|
/**
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
542
|
+
* Write a graph in a format and return the whole file as UTF-8 bytes, ready for fs.writeFile, a
|
|
543
|
+
* fetch body or a zip entry. Prefer this over exportGraphToString() when the result goes to a file
|
|
544
|
+
* or the network. To stream a very large graph, use exportGraph(). To find out beforehand what the
|
|
545
|
+
* file will not keep, call checkExport() with the same format and the same options object: every
|
|
546
|
+
* "E_" note it returns makes this call throw, and every "W_" note describes a loss this call
|
|
547
|
+
* accepts. Most "E_" notes go away with `sanitizeIds: "mangle"` (rewrite ids the format cannot
|
|
548
|
+
* hold) or `onMixedDirection: "directed"` / `"undirected"`. The format's own options (the CSV
|
|
549
|
+
* `table` and `dialect`, the GEXF `version`, ...) go in the same object.
|
|
550
|
+
* @param snapshot - the graph to write
|
|
551
|
+
* @param format - a format name from listFormats() where `canExport` is true
|
|
552
|
+
* @param options - sanitizeIds, onMixedDirection and the format's own options
|
|
553
|
+
* @returns the encoded file
|
|
554
|
+
* @throws GraphFormatError with code E_UNSUPPORTED when no exporter is registered for `format`
|
|
555
|
+
* @throws GraphFormatError when the graph cannot be written in this format under these options
|
|
556
|
+
* (checkExport() returns an "E_" note for the same call). The thrown code names the kind of
|
|
557
|
+
* failure rather than the note: E_INVALID_ID for ids (the E_ID_CHARSET and E_ID_TEXT_COLLISION
|
|
558
|
+
* notes), E_DIRECTED for direction (E_MIXED_DIRECTION), and E_COLUMN_TYPE or E_UNSUPPORTED for a
|
|
559
|
+
* value the format cannot write; each note's entry on the codes page says which
|
|
560
|
+
* @throws GraphFormatError with code E_UNSUPPORTED for an option value that is not allowed
|
|
561
|
+
* (`err.details.option` names it)
|
|
562
|
+
* @example
|
|
563
|
+
* ```ts
|
|
564
|
+
* import { writeFile } from "node:fs/promises";
|
|
565
|
+
*
|
|
566
|
+
* await writeFile("out.gexf", await exportGraphToBytes(snapshot, "gexf"));
|
|
567
|
+
* ```
|
|
568
|
+
* @category Saving
|
|
226
569
|
*/
|
|
227
|
-
export declare function
|
|
570
|
+
export declare function exportGraphToBytes(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): Promise<Uint8Array>;
|
|
228
571
|
/**
|
|
229
|
-
* Write a
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
572
|
+
* Write a graph in a format and return it as a Blob, for uploading with fetch or FormData or for
|
|
573
|
+
* offering as a download. The Blob's `type` is the first entry of the format's `mimeTypes` in
|
|
574
|
+
* listFormats(), or application/octet-stream when the format lists none. The exporter's chunks
|
|
575
|
+
* are kept as they are and never joined into one string. Options and errors are the same as
|
|
576
|
+
* exportGraphToBytes().
|
|
577
|
+
* @param snapshot - the graph to write
|
|
578
|
+
* @param format - a format name from listFormats() where `canExport` is true
|
|
579
|
+
* @param options - sanitizeIds, onMixedDirection and the format's own options
|
|
580
|
+
* @returns the file as a Blob
|
|
581
|
+
* @throws the same errors as exportGraphToBytes()
|
|
582
|
+
* @example
|
|
583
|
+
* ```ts
|
|
584
|
+
* const body = new FormData();
|
|
585
|
+
* body.append("file", await exportGraphToBlob(snapshot, "graphml"), "graph.graphml");
|
|
586
|
+
* await fetch("/api/graphs", { method: "POST", body });
|
|
587
|
+
* ```
|
|
588
|
+
* @category Saving
|
|
234
589
|
*/
|
|
235
|
-
export declare function
|
|
590
|
+
export declare function exportGraphToBlob(snapshot: GraphSnapshot, format: FormatName, options?: ExportGraphOptions | CommonExportOptions): Promise<Blob>;
|
|
236
591
|
/**
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
592
|
+
* Browser only: write a graph in a format and have the browser save it as a file, the same as
|
|
593
|
+
* clicking a download link. Call it from a click handler; awaiting other work first is fine. The
|
|
594
|
+
* promise resolves once the file has been handed to the browser. There is no way to learn
|
|
595
|
+
* whether the user then canceled the save. Calling it where there is no `document` (Node, a
|
|
596
|
+
* worker) throws instead of silently doing nothing; importing it is safe everywhere. Formats you
|
|
597
|
+
* registered with `registry.registerExporter()` can be downloaded too.
|
|
598
|
+
* @param snapshot - the graph to write
|
|
599
|
+
* @param format - a format name from listFormats() where `canExport` is true
|
|
600
|
+
* @param options - the export options, plus `filename`
|
|
601
|
+
* @returns resolves once the download has been handed to the browser
|
|
602
|
+
* @throws GraphFormatError with code E_UNSUPPORTED when called without a DOM `document`
|
|
603
|
+
* @throws the same errors as exportGraphToBytes()
|
|
604
|
+
* @example
|
|
605
|
+
* ```ts
|
|
606
|
+
* saveButton.addEventListener("click", () => {
|
|
607
|
+
* void downloadGraph(snapshot, "graphml", { filename: "network.graphml" });
|
|
608
|
+
* });
|
|
609
|
+
* ```
|
|
610
|
+
* @category Saving
|
|
242
611
|
*/
|
|
243
|
-
export declare function
|
|
612
|
+
export declare function downloadGraph(snapshot: GraphSnapshot, format: FormatName, options?: DownloadGraphOptions | CommonExportOptions): Promise<void>;
|
|
244
613
|
/**
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
614
|
+
* Every format the default registry can read or write, including any you registered yourself:
|
|
615
|
+
* the built-in formats in the order of GRAPH_FORMATS (the order format detection prefers them),
|
|
616
|
+
* then yours in registration order. Use it to fill a "Save as" menu (the entries with
|
|
617
|
+
* `canExport`), a file input's `accept` attribute (the `extensions` of the entries with
|
|
618
|
+
* `canImport`), or to pick the output format from a file name.
|
|
619
|
+
* @returns one entry per format
|
|
620
|
+
* @example
|
|
621
|
+
* ```ts
|
|
622
|
+
* input.accept = listFormats().filter((f) => f.canImport).flatMap((f) => f.extensions).join(",");
|
|
623
|
+
* const target = listFormats().find((f) => f.canExport && f.extensions.includes(extensionOf(path) ?? ""));
|
|
624
|
+
* ```
|
|
625
|
+
* @category Formats and detection
|
|
250
626
|
*/
|
|
251
|
-
export declare function
|
|
627
|
+
export declare function listFormats(): readonly FormatInfo[];
|
|
252
628
|
/**
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
629
|
+
* Detect a file's format without reading it, from what you know about it: a `filename` (only the
|
|
630
|
+
* extension counts), a `mimeType`, and `head`, the file's first bytes or characters (up to
|
|
631
|
+
* SNIFF_HEAD_BYTES; pass `bytes.subarray(0, SNIFF_HEAD_BYTES)`). It uses every format of the default
|
|
632
|
+
* registry, including the ones you registered. For every candidate, best first, call
|
|
633
|
+
* `registry.sniffAll(hints)`.
|
|
634
|
+
* @param hints - `{ filename, mimeType, head }`, any of them
|
|
635
|
+
* @returns the best candidate (`format`, `confidence` and what matched), or null when no format
|
|
636
|
+
* claims the input
|
|
637
|
+
* @example
|
|
638
|
+
* ```ts
|
|
639
|
+
* sniff({ filename: "graph.xml", head: "<?xml version=\"1.0\"?><gexf" })?.format; // "gexf"
|
|
640
|
+
* ```
|
|
641
|
+
* @category Formats and detection
|
|
256
642
|
*/
|
|
257
643
|
export declare function sniff(hints: SniffHints): SniffResult | null;
|
|
258
644
|
//# sourceMappingURL=registry.d.ts.map
|