@graphty/graph-io 0.0.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +250 -28
- package/dist/chunks/children-CL3Cy0ez.js +238 -0
- package/dist/chunks/children-CL3Cy0ez.js.map +1 -0
- package/dist/chunks/escape-DyI8JofU.js +938 -0
- package/dist/chunks/escape-DyI8JofU.js.map +1 -0
- package/dist/chunks/importer-CQnJuWJw.js +2987 -0
- package/dist/chunks/importer-CQnJuWJw.js.map +1 -0
- package/dist/chunks/importer-CpCpfbxr.js +2015 -0
- package/dist/chunks/importer-CpCpfbxr.js.map +1 -0
- package/dist/chunks/importer-DbnGYr3_.js +2342 -0
- package/dist/chunks/importer-DbnGYr3_.js.map +1 -0
- package/dist/chunks/importer-GozH8DkN.js +3050 -0
- package/dist/chunks/importer-GozH8DkN.js.map +1 -0
- package/dist/chunks/records-CGpxszm1.js +605 -0
- package/dist/chunks/records-CGpxszm1.js.map +1 -0
- package/dist/chunks/text-CajMdVFy.js +189 -0
- package/dist/chunks/text-CajMdVFy.js.map +1 -0
- package/dist/chunks/writer-DxSKC7TL.js +2842 -0
- package/dist/chunks/writer-DxSKC7TL.js.map +1 -0
- package/dist/csv.d.ts +1 -0
- package/dist/csv.js +1702 -0
- package/dist/csv.js.map +1 -0
- package/dist/dot.d.ts +1 -0
- package/dist/dot.js +8 -0
- package/dist/dot.js.map +1 -0
- package/dist/gexf.d.ts +1 -0
- package/dist/gexf.js +3466 -0
- package/dist/gexf.js.map +1 -0
- package/dist/gml.d.ts +1 -0
- package/dist/gml.js +2647 -0
- package/dist/gml.js.map +1 -0
- package/dist/graph-io.d.ts +1 -0
- package/dist/graph-io.js +790 -0
- package/dist/graph-io.js.map +1 -0
- package/dist/graphml.d.ts +1 -0
- package/dist/graphml.js +8 -0
- package/dist/graphml.js.map +1 -0
- package/dist/json.d.ts +1 -0
- package/dist/json.js +11 -0
- package/dist/json.js.map +1 -0
- package/dist/neo4j.d.ts +1 -0
- package/dist/neo4j.js +2046 -0
- package/dist/neo4j.js.map +1 -0
- package/dist/pajek.d.ts +1 -0
- package/dist/pajek.js +8 -0
- package/dist/pajek.js.map +1 -0
- package/dist/src/children.d.ts +134 -0
- package/dist/src/children.d.ts.map +1 -0
- package/dist/src/children.js +274 -0
- package/dist/src/children.js.map +1 -0
- package/dist/src/common/attributes.d.ts +229 -0
- package/dist/src/common/attributes.d.ts.map +1 -0
- package/dist/src/common/attributes.js +368 -0
- package/dist/src/common/attributes.js.map +1 -0
- package/dist/src/common/codes.d.ts +105 -0
- package/dist/src/common/codes.d.ts.map +1 -0
- package/dist/src/common/codes.js +107 -0
- package/dist/src/common/codes.js.map +1 -0
- package/dist/src/common/declared-types.d.ts +84 -0
- package/dist/src/common/declared-types.d.ts.map +1 -0
- package/dist/src/common/declared-types.js +326 -0
- package/dist/src/common/declared-types.js.map +1 -0
- package/dist/src/common/direction.d.ts +206 -0
- package/dist/src/common/direction.d.ts.map +1 -0
- package/dist/src/common/direction.js +370 -0
- package/dist/src/common/direction.js.map +1 -0
- package/dist/src/common/escape.d.ts +92 -0
- package/dist/src/common/escape.d.ts.map +1 -0
- package/dist/src/common/escape.js +212 -0
- package/dist/src/common/escape.js.map +1 -0
- package/dist/src/common/export.d.ts +249 -0
- package/dist/src/common/export.d.ts.map +1 -0
- package/dist/src/common/export.js +594 -0
- package/dist/src/common/export.js.map +1 -0
- package/dist/src/common/format.d.ts +59 -0
- package/dist/src/common/format.d.ts.map +1 -0
- package/dist/src/common/format.js +106 -0
- package/dist/src/common/format.js.map +1 -0
- package/dist/src/common/ids.d.ts +83 -0
- package/dist/src/common/ids.d.ts.map +1 -0
- package/dist/src/common/ids.js +158 -0
- package/dist/src/common/ids.js.map +1 -0
- package/dist/src/common/input.d.ts +100 -0
- package/dist/src/common/input.d.ts.map +1 -0
- package/dist/src/common/input.js +335 -0
- package/dist/src/common/input.js.map +1 -0
- package/dist/src/common/lists.d.ts +34 -0
- package/dist/src/common/lists.d.ts.map +1 -0
- package/dist/src/common/lists.js +185 -0
- package/dist/src/common/lists.js.map +1 -0
- package/dist/src/common/options.d.ts +108 -0
- package/dist/src/common/options.d.ts.map +1 -0
- package/dist/src/common/options.js +265 -0
- package/dist/src/common/options.js.map +1 -0
- package/dist/src/common/report.d.ts +187 -0
- package/dist/src/common/report.d.ts.map +1 -0
- package/dist/src/common/report.js +274 -0
- package/dist/src/common/report.js.map +1 -0
- package/dist/src/common/temporal.d.ts +71 -0
- package/dist/src/common/temporal.d.ts.map +1 -0
- package/dist/src/common/temporal.js +266 -0
- package/dist/src/common/temporal.js.map +1 -0
- package/dist/src/common/text.d.ts +104 -0
- package/dist/src/common/text.d.ts.map +1 -0
- package/dist/src/common/text.js +255 -0
- package/dist/src/common/text.js.map +1 -0
- package/dist/src/common/weights.d.ts +77 -0
- package/dist/src/common/weights.d.ts.map +1 -0
- package/dist/src/common/weights.js +156 -0
- package/dist/src/common/weights.js.map +1 -0
- package/dist/src/common/writer.d.ts +51 -0
- package/dist/src/common/writer.d.ts.map +1 -0
- package/dist/src/common/writer.js +108 -0
- package/dist/src/common/writer.js.map +1 -0
- package/dist/src/common/xml.d.ts +245 -0
- package/dist/src/common/xml.d.ts.map +1 -0
- package/dist/src/common/xml.js +942 -0
- package/dist/src/common/xml.js.map +1 -0
- package/dist/src/formats/csv/exporter.d.ts +70 -0
- package/dist/src/formats/csv/exporter.d.ts.map +1 -0
- package/dist/src/formats/csv/exporter.js +682 -0
- package/dist/src/formats/csv/exporter.js.map +1 -0
- package/dist/src/formats/csv/header.d.ts +66 -0
- package/dist/src/formats/csv/header.d.ts.map +1 -0
- package/dist/src/formats/csv/header.js +152 -0
- package/dist/src/formats/csv/header.js.map +1 -0
- package/dist/src/formats/csv/importer.d.ts +82 -0
- package/dist/src/formats/csv/importer.d.ts.map +1 -0
- package/dist/src/formats/csv/importer.js +849 -0
- package/dist/src/formats/csv/importer.js.map +1 -0
- package/dist/src/formats/csv/index.d.ts +60 -0
- package/dist/src/formats/csv/index.d.ts.map +1 -0
- package/dist/src/formats/csv/index.js +63 -0
- package/dist/src/formats/csv/index.js.map +1 -0
- package/dist/src/formats/csv/records.d.ts +188 -0
- package/dist/src/formats/csv/records.d.ts.map +1 -0
- package/dist/src/formats/csv/records.js +702 -0
- package/dist/src/formats/csv/records.js.map +1 -0
- package/dist/src/formats/csv/values.d.ts +105 -0
- package/dist/src/formats/csv/values.d.ts.map +1 -0
- package/dist/src/formats/csv/values.js +192 -0
- package/dist/src/formats/csv/values.js.map +1 -0
- package/dist/src/formats/dot/exporter.d.ts +52 -0
- package/dist/src/formats/dot/exporter.d.ts.map +1 -0
- package/dist/src/formats/dot/exporter.js +836 -0
- package/dist/src/formats/dot/exporter.js.map +1 -0
- package/dist/src/formats/dot/importer.d.ts +102 -0
- package/dist/src/formats/dot/importer.d.ts.map +1 -0
- package/dist/src/formats/dot/importer.js +1291 -0
- package/dist/src/formats/dot/importer.js.map +1 -0
- package/dist/src/formats/dot/index.d.ts +7 -0
- package/dist/src/formats/dot/index.d.ts.map +1 -0
- package/dist/src/formats/dot/index.js +7 -0
- package/dist/src/formats/dot/index.js.map +1 -0
- package/dist/src/formats/dot/names.d.ts +29 -0
- package/dist/src/formats/dot/names.d.ts.map +1 -0
- package/dist/src/formats/dot/names.js +28 -0
- package/dist/src/formats/dot/names.js.map +1 -0
- package/dist/src/formats/dot/tokenizer.d.ts +114 -0
- package/dist/src/formats/dot/tokenizer.d.ts.map +1 -0
- package/dist/src/formats/dot/tokenizer.js +341 -0
- package/dist/src/formats/dot/tokenizer.js.map +1 -0
- package/dist/src/formats/gexf/exporter.d.ts +56 -0
- package/dist/src/formats/gexf/exporter.d.ts.map +1 -0
- package/dist/src/formats/gexf/exporter.js +1395 -0
- package/dist/src/formats/gexf/exporter.js.map +1 -0
- package/dist/src/formats/gexf/importer.d.ts +73 -0
- package/dist/src/formats/gexf/importer.d.ts.map +1 -0
- package/dist/src/formats/gexf/importer.js +1880 -0
- package/dist/src/formats/gexf/importer.js.map +1 -0
- package/dist/src/formats/gexf/index.d.ts +96 -0
- package/dist/src/formats/gexf/index.d.ts.map +1 -0
- package/dist/src/formats/gexf/index.js +97 -0
- package/dist/src/formats/gexf/index.js.map +1 -0
- package/dist/src/formats/gexf/schema.d.ts +135 -0
- package/dist/src/formats/gexf/schema.d.ts.map +1 -0
- package/dist/src/formats/gexf/schema.js +323 -0
- package/dist/src/formats/gexf/schema.js.map +1 -0
- package/dist/src/formats/gml/exporter.d.ts +69 -0
- package/dist/src/formats/gml/exporter.d.ts.map +1 -0
- package/dist/src/formats/gml/exporter.js +1093 -0
- package/dist/src/formats/gml/exporter.js.map +1 -0
- package/dist/src/formats/gml/importer.d.ts +66 -0
- package/dist/src/formats/gml/importer.d.ts.map +1 -0
- package/dist/src/formats/gml/importer.js +1331 -0
- package/dist/src/formats/gml/importer.js.map +1 -0
- package/dist/src/formats/gml/index.d.ts +85 -0
- package/dist/src/formats/gml/index.d.ts.map +1 -0
- package/dist/src/formats/gml/index.js +88 -0
- package/dist/src/formats/gml/index.js.map +1 -0
- package/dist/src/formats/gml/syntax.d.ts +186 -0
- package/dist/src/formats/gml/syntax.d.ts.map +1 -0
- package/dist/src/formats/gml/syntax.js +467 -0
- package/dist/src/formats/gml/syntax.js.map +1 -0
- package/dist/src/formats/graphml/constants.d.ts +169 -0
- package/dist/src/formats/graphml/constants.d.ts.map +1 -0
- package/dist/src/formats/graphml/constants.js +165 -0
- package/dist/src/formats/graphml/constants.js.map +1 -0
- package/dist/src/formats/graphml/exporter.d.ts +34 -0
- package/dist/src/formats/graphml/exporter.d.ts.map +1 -0
- package/dist/src/formats/graphml/exporter.js +1176 -0
- package/dist/src/formats/graphml/exporter.js.map +1 -0
- package/dist/src/formats/graphml/importer.d.ts +31 -0
- package/dist/src/formats/graphml/importer.d.ts.map +1 -0
- package/dist/src/formats/graphml/importer.js +1607 -0
- package/dist/src/formats/graphml/importer.js.map +1 -0
- package/dist/src/formats/graphml/index.d.ts +8 -0
- package/dist/src/formats/graphml/index.d.ts.map +1 -0
- package/dist/src/formats/graphml/index.js +8 -0
- package/dist/src/formats/graphml/index.js.map +1 -0
- package/dist/src/formats/graphml/tree.d.ts +72 -0
- package/dist/src/formats/graphml/tree.d.ts.map +1 -0
- package/dist/src/formats/graphml/tree.js +290 -0
- package/dist/src/formats/graphml/tree.js.map +1 -0
- package/dist/src/formats/json/dialect.d.ts +125 -0
- package/dist/src/formats/json/dialect.d.ts.map +1 -0
- package/dist/src/formats/json/dialect.js +262 -0
- package/dist/src/formats/json/dialect.js.map +1 -0
- package/dist/src/formats/json/exporter.d.ts +89 -0
- package/dist/src/formats/json/exporter.d.ts.map +1 -0
- package/dist/src/formats/json/exporter.js +1358 -0
- package/dist/src/formats/json/exporter.js.map +1 -0
- package/dist/src/formats/json/importer.d.ts +108 -0
- package/dist/src/formats/json/importer.d.ts.map +1 -0
- package/dist/src/formats/json/importer.js +1838 -0
- package/dist/src/formats/json/importer.js.map +1 -0
- package/dist/src/formats/json/index.d.ts +8 -0
- package/dist/src/formats/json/index.d.ts.map +1 -0
- package/dist/src/formats/json/index.js +8 -0
- package/dist/src/formats/json/index.js.map +1 -0
- package/dist/src/formats/neo4j/exporter.d.ts +68 -0
- package/dist/src/formats/neo4j/exporter.d.ts.map +1 -0
- package/dist/src/formats/neo4j/exporter.js +1055 -0
- package/dist/src/formats/neo4j/exporter.js.map +1 -0
- package/dist/src/formats/neo4j/header.d.ts +52 -0
- package/dist/src/formats/neo4j/header.d.ts.map +1 -0
- package/dist/src/formats/neo4j/header.js +131 -0
- package/dist/src/formats/neo4j/header.js.map +1 -0
- package/dist/src/formats/neo4j/importer.d.ts +73 -0
- package/dist/src/formats/neo4j/importer.d.ts.map +1 -0
- package/dist/src/formats/neo4j/importer.js +932 -0
- package/dist/src/formats/neo4j/importer.js.map +1 -0
- package/dist/src/formats/neo4j/index.d.ts +79 -0
- package/dist/src/formats/neo4j/index.d.ts.map +1 -0
- package/dist/src/formats/neo4j/index.js +83 -0
- package/dist/src/formats/neo4j/index.js.map +1 -0
- package/dist/src/formats/pajek/exporter.d.ts +58 -0
- package/dist/src/formats/pajek/exporter.d.ts.map +1 -0
- package/dist/src/formats/pajek/exporter.js +825 -0
- package/dist/src/formats/pajek/exporter.js.map +1 -0
- package/dist/src/formats/pajek/importer.d.ts +88 -0
- package/dist/src/formats/pajek/importer.d.ts.map +1 -0
- package/dist/src/formats/pajek/importer.js +1047 -0
- package/dist/src/formats/pajek/importer.js.map +1 -0
- package/dist/src/formats/pajek/index.d.ts +7 -0
- package/dist/src/formats/pajek/index.d.ts.map +1 -0
- package/dist/src/formats/pajek/index.js +7 -0
- package/dist/src/formats/pajek/index.js.map +1 -0
- package/dist/src/formats/pajek/syntax.d.ts +112 -0
- package/dist/src/formats/pajek/syntax.d.ts.map +1 -0
- package/dist/src/formats/pajek/syntax.js +269 -0
- package/dist/src/formats/pajek/syntax.js.map +1 -0
- package/dist/src/index.d.ts +35 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +39 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/registry.d.ts +207 -0
- package/dist/src/registry.d.ts.map +1 -0
- package/dist/src/registry.js +481 -0
- package/dist/src/registry.js.map +1 -0
- package/dist/src/sniff.d.ts +104 -0
- package/dist/src/sniff.d.ts.map +1 -0
- package/dist/src/sniff.js +357 -0
- package/dist/src/sniff.js.map +1 -0
- package/dist/src/types.d.ts +238 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +29 -0
- package/dist/src/types.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +122 -7
- package/src/children.ts +335 -0
- package/src/common/attributes.ts +520 -0
- package/src/common/codes.ts +153 -0
- package/src/common/declared-types.ts +374 -0
- package/src/common/direction.ts +518 -0
- package/src/common/escape.ts +231 -0
- package/src/common/export.ts +817 -0
- package/src/common/format.ts +111 -0
- package/src/common/ids.ts +176 -0
- package/src/common/input.ts +378 -0
- package/src/common/lists.ts +196 -0
- package/src/common/options.ts +377 -0
- package/src/common/report.ts +352 -0
- package/src/common/temporal.ts +302 -0
- package/src/common/text.ts +294 -0
- package/src/common/weights.ts +202 -0
- package/src/common/writer.ts +123 -0
- package/src/common/xml.ts +1053 -0
- package/src/formats/csv/exporter.ts +894 -0
- package/src/formats/csv/header.ts +172 -0
- package/src/formats/csv/importer.ts +1104 -0
- package/src/formats/csv/index.ts +88 -0
- package/src/formats/csv/records.ts +813 -0
- package/src/formats/csv/values.ts +224 -0
- package/src/formats/dot/exporter.ts +1014 -0
- package/src/formats/dot/importer.ts +1549 -0
- package/src/formats/dot/index.ts +7 -0
- package/src/formats/dot/names.ts +40 -0
- package/src/formats/dot/tokenizer.ts +384 -0
- package/src/formats/gexf/exporter.ts +1696 -0
- package/src/formats/gexf/importer.ts +2333 -0
- package/src/formats/gexf/index.ts +142 -0
- package/src/formats/gexf/schema.ts +361 -0
- package/src/formats/gml/exporter.ts +1404 -0
- package/src/formats/gml/importer.ts +1591 -0
- package/src/formats/gml/index.ts +128 -0
- package/src/formats/gml/syntax.ts +545 -0
- package/src/formats/graphml/constants.ts +225 -0
- package/src/formats/graphml/exporter.ts +1458 -0
- package/src/formats/graphml/importer.ts +2027 -0
- package/src/formats/graphml/index.ts +8 -0
- package/src/formats/graphml/tree.ts +318 -0
- package/src/formats/json/dialect.ts +317 -0
- package/src/formats/json/exporter.ts +1616 -0
- package/src/formats/json/importer.ts +2271 -0
- package/src/formats/json/index.ts +8 -0
- package/src/formats/neo4j/exporter.ts +1287 -0
- package/src/formats/neo4j/header.ts +156 -0
- package/src/formats/neo4j/importer.ts +1220 -0
- package/src/formats/neo4j/index.ts +116 -0
- package/src/formats/pajek/exporter.ts +1000 -0
- package/src/formats/pajek/importer.ts +1311 -0
- package/src/formats/pajek/index.ts +7 -0
- package/src/formats/pajek/syntax.ts +307 -0
- package/src/index.ts +244 -0
- package/src/registry.ts +617 -0
- package/src/sniff.ts +397 -0
- package/src/types.ts +262 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The importer / exporter registry (design sections 8.2 and 8.4): the eight built-in formats
|
|
3
|
+
* registered by name, `sniff()` over them, and the two conveniences for callers who do not own a
|
|
4
|
+
* sink: `importGraph()` sniffs the format, creates a builder seeded from the common options
|
|
5
|
+
* (`directed: true` as a placeholder; the importer sets the real value), imports and freezes;
|
|
6
|
+
* `exportGraph()` looks the exporter up by name. A caller who owns a builder uses the importer
|
|
7
|
+
* objects directly (the subpath exports) and this module never touches their sink.
|
|
8
|
+
*/
|
|
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 GraphExporter, type GraphImporter, type ImportInput, type ImportReport, type LossNote } from "./types.js";
|
|
12
|
+
/** The issue code of an input whose format no registered importer recognises. */
|
|
13
|
+
export declare const UNKNOWN_FORMAT_CODE = "E_UNKNOWN_FORMAT";
|
|
14
|
+
/** The builder options importGraph() accepts beyond the ones the common import options seed. */
|
|
15
|
+
export type BuilderSeed = Omit<GraphBuilderOptions, "directed" | "addMissingNodes" | "duplicateEdges" | "selfLoops" | "weightDtype">;
|
|
16
|
+
/**
|
|
17
|
+
* The options of importGraph(): the common import options (which also seed the registry's
|
|
18
|
+
* builder, design section 8.4), the format choice and the hints sniffing uses, the builder and
|
|
19
|
+
* freeze options, and any format-specific option (`delimiter`, `dialect`, ...) passed through to
|
|
20
|
+
* the importer unchanged.
|
|
21
|
+
*/
|
|
22
|
+
export interface ImportGraphOptions extends CommonImportOptions {
|
|
23
|
+
/** The format name, or "auto" (default) to sniff it from the filename, MIME type and content. */
|
|
24
|
+
readonly format?: string | undefined;
|
|
25
|
+
/** The file name or path the input came from, a hint for sniffing. */
|
|
26
|
+
readonly filename?: string | null | undefined;
|
|
27
|
+
/** The MIME type the input was served as, a hint for sniffing. */
|
|
28
|
+
readonly mimeType?: string | null | undefined;
|
|
29
|
+
/** Builder options the common options do not cover (`weighted`, `expectedNodes`, ...). */
|
|
30
|
+
readonly builder?: BuilderSeed | undefined;
|
|
31
|
+
/** Options of the freeze that follows the import. */
|
|
32
|
+
readonly freeze?: FreezeOptions | undefined;
|
|
33
|
+
/** Format-specific options, passed to the importer as they are. */
|
|
34
|
+
readonly [formatOption: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
/** What importGraph() returns (design section 8.4). */
|
|
37
|
+
export interface ImportGraphResult {
|
|
38
|
+
/** The format the input was read as. */
|
|
39
|
+
readonly format: string;
|
|
40
|
+
/** The sniff that chose the importer, or null when the caller named the format. */
|
|
41
|
+
readonly sniff: SniffResult | null;
|
|
42
|
+
/** The frozen snapshot. */
|
|
43
|
+
readonly snapshot: GraphSnapshot;
|
|
44
|
+
/** The importer's report. */
|
|
45
|
+
readonly report: ImportReport;
|
|
46
|
+
/** The freeze report (design section 6.6). */
|
|
47
|
+
readonly freeze: FreezeReport;
|
|
48
|
+
}
|
|
49
|
+
/** The options of exportGraph(): the common export options plus any format-specific option, passed through. */
|
|
50
|
+
export interface ExportGraphOptions extends CommonExportOptions {
|
|
51
|
+
/** Format-specific options, passed to the exporter as they are. */
|
|
52
|
+
readonly [formatOption: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A registry of importers and exporters by format name. Registration order is the tie-break
|
|
56
|
+
* order of sniffing (design section 8.2); the default registry lists the built-in formats in the
|
|
57
|
+
* order of GRAPH_FORMATS.
|
|
58
|
+
*/
|
|
59
|
+
export declare class FormatRegistry {
|
|
60
|
+
private readonly importerMap;
|
|
61
|
+
private readonly exporterMap;
|
|
62
|
+
/**
|
|
63
|
+
* Register an importer under its format name, replacing one of the same name in place (the
|
|
64
|
+
* original registration order is kept).
|
|
65
|
+
* @param importer - the importer
|
|
66
|
+
* @returns this registry, for chaining
|
|
67
|
+
*/
|
|
68
|
+
registerImporter(importer: GraphImporter): this;
|
|
69
|
+
/**
|
|
70
|
+
* Register an exporter under its format name, replacing one of the same name.
|
|
71
|
+
* @param exporter - the exporter
|
|
72
|
+
* @returns this registry, for chaining
|
|
73
|
+
*/
|
|
74
|
+
registerExporter(exporter: GraphExporter): this;
|
|
75
|
+
/**
|
|
76
|
+
* The importer of a format.
|
|
77
|
+
* @param format - the format name
|
|
78
|
+
* @returns the importer; E_UNSUPPORTED when none is registered
|
|
79
|
+
*/
|
|
80
|
+
importer(format: string): GraphImporter;
|
|
81
|
+
/**
|
|
82
|
+
* The exporter of a format.
|
|
83
|
+
* @param format - the format name
|
|
84
|
+
* @returns the exporter; E_UNSUPPORTED when none is registered
|
|
85
|
+
*/
|
|
86
|
+
exporter(format: string): GraphExporter;
|
|
87
|
+
/**
|
|
88
|
+
* Whether an importer is registered for a format.
|
|
89
|
+
* @param format - the format name
|
|
90
|
+
* @returns true when importer(format) would succeed
|
|
91
|
+
*/
|
|
92
|
+
hasImporter(format: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Whether an exporter is registered for a format.
|
|
95
|
+
* @param format - the format name
|
|
96
|
+
* @returns true when exporter(format) would succeed
|
|
97
|
+
*/
|
|
98
|
+
hasExporter(format: string): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Every registered importer, in registration order.
|
|
101
|
+
* @returns the importers
|
|
102
|
+
*/
|
|
103
|
+
importers(): readonly GraphImporter[];
|
|
104
|
+
/**
|
|
105
|
+
* Every registered exporter, in registration order.
|
|
106
|
+
* @returns the exporters
|
|
107
|
+
*/
|
|
108
|
+
exporters(): readonly GraphExporter[];
|
|
109
|
+
/**
|
|
110
|
+
* The names of every format with an importer or an exporter, importers' order first.
|
|
111
|
+
* @returns the format names, each once
|
|
112
|
+
*/
|
|
113
|
+
formats(): readonly string[];
|
|
114
|
+
/**
|
|
115
|
+
* Rank the registered importers for an input (design section 8.2; the successor of
|
|
116
|
+
* graphty-element's detectFormat()).
|
|
117
|
+
* @param hints - the filename, MIME type and / or head of the input
|
|
118
|
+
* @returns the candidates, best first; empty when nothing matches
|
|
119
|
+
*/
|
|
120
|
+
sniffAll(hints: SniffHints): readonly SniffResult[];
|
|
121
|
+
/**
|
|
122
|
+
* The best importer for an input, or null when no registered importer claims it.
|
|
123
|
+
* @param hints - the filename, MIME type and / or head of the input
|
|
124
|
+
* @returns the best candidate, or null
|
|
125
|
+
*/
|
|
126
|
+
sniff(hints: SniffHints): SniffResult | null;
|
|
127
|
+
/**
|
|
128
|
+
* Read an input into a fresh builder and freeze it (design section 8.4: for callers who do not
|
|
129
|
+
* own a sink). The format is the one named in the options, else sniffed from the filename,
|
|
130
|
+
* the MIME type and the first bytes of the content; the builder is seeded from the common
|
|
131
|
+
* options with `directed: true` as a placeholder that the importer overrides from the file.
|
|
132
|
+
* @param input - the text, bytes, stream or chunks to read
|
|
133
|
+
* @param options - the format, hints, common and format-specific import options
|
|
134
|
+
* @returns the snapshot, the import report and the freeze report
|
|
135
|
+
*/
|
|
136
|
+
importGraph(input: ImportInput, options?: ImportGraphOptions): Promise<ImportGraphResult>;
|
|
137
|
+
/**
|
|
138
|
+
* Write a snapshot in a format, as UTF-8 chunks (design section 8.5).
|
|
139
|
+
* @param snapshot - the snapshot
|
|
140
|
+
* @param format - the format name
|
|
141
|
+
* @param options - the exporter's common and format-specific options
|
|
142
|
+
* @returns the encoded chunks
|
|
143
|
+
*/
|
|
144
|
+
exportGraph(snapshot: GraphSnapshot, format: string, options?: ExportGraphOptions): AsyncIterable<Uint8Array>;
|
|
145
|
+
/**
|
|
146
|
+
* Write a snapshot in a format, as one string.
|
|
147
|
+
* @param snapshot - the snapshot
|
|
148
|
+
* @param format - the format name
|
|
149
|
+
* @param options - the exporter's common and format-specific options
|
|
150
|
+
* @returns the whole document
|
|
151
|
+
*/
|
|
152
|
+
exportGraphToString(snapshot: GraphSnapshot, format: string, options?: ExportGraphOptions): Promise<string>;
|
|
153
|
+
/**
|
|
154
|
+
* What exporting a snapshot in a format would lose, without writing anything.
|
|
155
|
+
* @param snapshot - the snapshot
|
|
156
|
+
* @param format - the format name
|
|
157
|
+
* @param options - the exporter's common and format-specific options
|
|
158
|
+
* @returns the loss notes, empty when the export is exact
|
|
159
|
+
*/
|
|
160
|
+
checkExport(snapshot: GraphSnapshot, format: string, options?: ExportGraphOptions): readonly LossNote[];
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* A registry holding the eight built-in importers and exporters in the order of GRAPH_FORMATS.
|
|
164
|
+
* @returns a new registry
|
|
165
|
+
*/
|
|
166
|
+
export declare function createRegistry(): FormatRegistry;
|
|
167
|
+
/** The default registry: every built-in format. */
|
|
168
|
+
export declare const registry: FormatRegistry;
|
|
169
|
+
/**
|
|
170
|
+
* Read an input into a fresh builder and freeze it, through the default registry (design section
|
|
171
|
+
* 8.4: `importGraph(input, { format?, ...options })`).
|
|
172
|
+
* @param input - the text, bytes, stream or chunks to read
|
|
173
|
+
* @param options - the format, hints, common and format-specific import options
|
|
174
|
+
* @returns the snapshot, the import report and the freeze report
|
|
175
|
+
*/
|
|
176
|
+
export declare function importGraph(input: ImportInput, options?: ImportGraphOptions): Promise<ImportGraphResult>;
|
|
177
|
+
/**
|
|
178
|
+
* Write a snapshot in a format through the default registry, as UTF-8 chunks.
|
|
179
|
+
* @param snapshot - the snapshot
|
|
180
|
+
* @param format - the format name
|
|
181
|
+
* @param options - the exporter's common and format-specific options
|
|
182
|
+
* @returns the encoded chunks
|
|
183
|
+
*/
|
|
184
|
+
export declare function exportGraph(snapshot: GraphSnapshot, format: string, options?: ExportGraphOptions): AsyncIterable<Uint8Array>;
|
|
185
|
+
/**
|
|
186
|
+
* Write a snapshot in a format through the default registry, as one string.
|
|
187
|
+
* @param snapshot - the snapshot
|
|
188
|
+
* @param format - the format name
|
|
189
|
+
* @param options - the exporter's common and format-specific options
|
|
190
|
+
* @returns the whole document
|
|
191
|
+
*/
|
|
192
|
+
export declare function exportGraphToString(snapshot: GraphSnapshot, format: string, options?: ExportGraphOptions): Promise<string>;
|
|
193
|
+
/**
|
|
194
|
+
* What exporting a snapshot in a format would lose, through the default registry.
|
|
195
|
+
* @param snapshot - the snapshot
|
|
196
|
+
* @param format - the format name
|
|
197
|
+
* @param options - the exporter's common and format-specific options
|
|
198
|
+
* @returns the loss notes, empty when the export is exact
|
|
199
|
+
*/
|
|
200
|
+
export declare function checkExport(snapshot: GraphSnapshot, format: string, options?: ExportGraphOptions): readonly LossNote[];
|
|
201
|
+
/**
|
|
202
|
+
* Sniff an input's format through the default registry.
|
|
203
|
+
* @param hints - the filename, MIME type and / or head of the input
|
|
204
|
+
* @returns the best candidate, or null when no built-in importer claims it
|
|
205
|
+
*/
|
|
206
|
+
export declare function sniff(hints: SniffHints): SniffResult | null;
|
|
207
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACH,KAAK,aAAa,EAClB,KAAK,YAAY,EAEjB,KAAK,mBAAmB,EAExB,KAAK,aAAa,EACrB,MAAM,uBAAuB,CAAC;AAY/B,OAAO,EAAiC,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9F,OAAO,EACH,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,QAAQ,EAChB,MAAM,YAAY,CAAC;AAEpB,iFAAiF;AACjF,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAEtD,gGAAgG;AAChG,MAAM,MAAM,WAAW,GAAG,IAAI,CAC1B,mBAAmB,EACnB,UAAU,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,WAAW,GAAG,aAAa,CAClF,CAAC;AAEF;;;;;GAKG;AACH,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