@graphty/graph-io 0.0.0 → 0.2.0
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,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Option normalisation for importers and exporters (design sections 8.4 and 8.5): every common
|
|
3
|
+
* option resolved to its documented default, enum values checked (E_UNSUPPORTED, the core's
|
|
4
|
+
* convention for an option outside its set), and the per-format defaults (`ids`, `defaultDirected`,
|
|
5
|
+
* `weightFrom`, `addMissingNodes`) supplied by the importer that calls resolveImportOptions().
|
|
6
|
+
*/
|
|
7
|
+
import { type DuplicatePolicy, type GraphSink, type IdCoercion } from "@graphty/graph-format";
|
|
8
|
+
import { type CommonExportOptions, type CommonImportOptions } from "../types.js";
|
|
9
|
+
import { SINK_OPTION_CODE } from "./codes.js";
|
|
10
|
+
import { type ImportReportBuilder } from "./report.js";
|
|
11
|
+
/** The defaults an importer supplies for the options whose default is per format (design section 8.4). */
|
|
12
|
+
export interface ImportFormatDefaults {
|
|
13
|
+
/** "canonical" for text-cell formats, "keep" for JSON. */
|
|
14
|
+
readonly ids: IdCoercion;
|
|
15
|
+
/** The direction assumed when the file declares none. */
|
|
16
|
+
readonly defaultDirected: boolean;
|
|
17
|
+
/** The attribute that becomes the weight ("weight", GML "value"), or null for an unweighted format. */
|
|
18
|
+
readonly weightFrom: string | null;
|
|
19
|
+
/** Whether edges may reference undeclared nodes; true unless the format says otherwise (GEXF: false). */
|
|
20
|
+
readonly addMissingNodes?: boolean | undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* CommonImportOptions with every field present (design section 8.4 defaults applied).
|
|
24
|
+
* Consumed by the per-format importers and exporters under src/formats.
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export interface ResolvedImportOptions {
|
|
28
|
+
/** The id coercion rule. */
|
|
29
|
+
readonly ids: IdCoercion;
|
|
30
|
+
/** Which field becomes the node id. */
|
|
31
|
+
readonly nodeIdFrom: "id" | "label" | "index";
|
|
32
|
+
/** Whether an edge may reference an undeclared node. */
|
|
33
|
+
readonly addMissingNodes: boolean;
|
|
34
|
+
/** The builder's duplicate-edge policy seed. */
|
|
35
|
+
readonly duplicateEdges: DuplicatePolicy;
|
|
36
|
+
/** The builder's self-loop policy seed. */
|
|
37
|
+
readonly selfLoops: "keep" | "drop" | "error";
|
|
38
|
+
/** The mixed-direction policy. */
|
|
39
|
+
readonly onMixedDirection: "expand" | "directed" | "undirected" | "error";
|
|
40
|
+
/** The direction assumed when the file declares none. */
|
|
41
|
+
readonly defaultDirected: boolean;
|
|
42
|
+
/** The weight attribute, or null for unweighted. */
|
|
43
|
+
readonly weightFrom: string | null;
|
|
44
|
+
/** The weight staging precision. */
|
|
45
|
+
readonly weightDtype: "f32" | "f64";
|
|
46
|
+
/** How declared long columns are stored. */
|
|
47
|
+
readonly long: "f64" | "string";
|
|
48
|
+
/** Whether mangled ids are restored. */
|
|
49
|
+
readonly restoreMangledIds: boolean;
|
|
50
|
+
/** The hyperedge policy. */
|
|
51
|
+
readonly hyperedges: "error" | "skip" | "star" | "clique";
|
|
52
|
+
/** Errors tolerated before aborting. */
|
|
53
|
+
readonly errorLimit: number;
|
|
54
|
+
/** The cancellation signal, or null. */
|
|
55
|
+
readonly signal: AbortSignal | null;
|
|
56
|
+
/** The progress callback, or null. */
|
|
57
|
+
readonly onProgress: ((bytesDone: number, bytesTotal?: number) => void) | null;
|
|
58
|
+
}
|
|
59
|
+
/** CommonExportOptions with every field present (design section 8.5 defaults applied). */
|
|
60
|
+
export interface ResolvedExportOptions {
|
|
61
|
+
/** "error" never renames a node; "mangle" rewrites and keeps the original. */
|
|
62
|
+
readonly sanitizeIds: "error" | "mangle";
|
|
63
|
+
/** What a format without mixed-direction support does with a mixed snapshot. */
|
|
64
|
+
readonly onMixedDirection: "error" | "directed" | "undirected";
|
|
65
|
+
}
|
|
66
|
+
/** The default error limit of design section 8.4. */
|
|
67
|
+
export declare const DEFAULT_ERROR_LIMIT = 100;
|
|
68
|
+
export { SINK_OPTION_CODE };
|
|
69
|
+
/**
|
|
70
|
+
* Report every builder-policy option the caller explicitly requested that the sink does not use
|
|
71
|
+
* (design section 8.4 precedence), one `W_SINK_OPTION` warning per option with the option name as
|
|
72
|
+
* the element. Options left undefined are never reported: they are defaults, not requests. On the
|
|
73
|
+
* registry's builder, which is seeded from the same options, nothing is ever reported.
|
|
74
|
+
* @param sink - the sink the importer pushes into
|
|
75
|
+
* @param options - the caller's raw options, possibly undefined
|
|
76
|
+
* @param report - the report to record into
|
|
77
|
+
* @param enforcesMissingNodes - true when the importer applies `addMissingNodes: false` itself (it
|
|
78
|
+
* refuses unknown endpoints before the sink sees them), so that request is honoured on any sink and
|
|
79
|
+
* only `addMissingNodes: true` against a refusing sink is reported
|
|
80
|
+
* @returns the number of warnings recorded
|
|
81
|
+
*/
|
|
82
|
+
export declare function reportSinkOptions(sink: GraphSink, options: CommonImportOptions | undefined, report: ImportReportBuilder, enforcesMissingNodes?: boolean): number;
|
|
83
|
+
/**
|
|
84
|
+
* Report every common option the caller set to a non-default value that the format has no use
|
|
85
|
+
* for (design section 8.4: "the importer reports every option it could not honour"): one
|
|
86
|
+
* `W_OPTION_IGNORED` warning (category `unsupported`) per option, the option name as the element.
|
|
87
|
+
* The builder-policy options are reportSinkOptions()'s and are skipped here.
|
|
88
|
+
* @param options - the caller's raw options, possibly undefined
|
|
89
|
+
* @param report - the report to record into
|
|
90
|
+
* @param used - the common option names the importer reads
|
|
91
|
+
* @returns the number of warnings recorded
|
|
92
|
+
*/
|
|
93
|
+
export declare function reportUnusedOptions(options: CommonImportOptions | undefined, report: ImportReportBuilder, used: ReadonlySet<keyof CommonImportOptions>): number;
|
|
94
|
+
/**
|
|
95
|
+
* Apply the design section 8.4 defaults to an importer's common options and check every enum
|
|
96
|
+
* value. Format-specific options in the same object are ignored here.
|
|
97
|
+
* @param options - the caller's options, possibly undefined
|
|
98
|
+
* @param defaults - the importer's per-format defaults
|
|
99
|
+
* @returns the resolved options; E_UNSUPPORTED for a value outside its set
|
|
100
|
+
*/
|
|
101
|
+
export declare function resolveImportOptions(options: CommonImportOptions | undefined, defaults: ImportFormatDefaults): ResolvedImportOptions;
|
|
102
|
+
/**
|
|
103
|
+
* Apply the design section 8.5 defaults to an exporter's common options and check the enum values.
|
|
104
|
+
* @param options - the caller's options, possibly undefined
|
|
105
|
+
* @returns the resolved options; E_UNSUPPORTED for a value outside its set
|
|
106
|
+
*/
|
|
107
|
+
export declare function resolveExportOptions(options: CommonExportOptions | undefined): ResolvedExportOptions;
|
|
108
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/common/options.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,eAAe,EAAoB,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEhH,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAuB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,0GAA0G;AAC1G,MAAM,WAAW,oBAAoB;IACjC,0DAA0D;IAC1D,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,yDAAyD;IACzD,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,uGAAuG;IACvG,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,yGAAyG;IACzG,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAClD;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IAClC,4BAA4B;IAC5B,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,uCAAuC;IACvC,QAAQ,CAAC,UAAU,EAAE,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC;IAC9C,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mBAAmB,MAAM,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAK5B;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC7B,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,mBAAmB,GAAG,SAAS,EACxC,MAAM,EAAE,mBAAmB,EAC3B,oBAAoB,UAAQ,GAC7B,MAAM,CAuBR;AAkBD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAC/B,OAAO,EAAE,mBAAmB,GAAG,SAAS,EACxC,MAAM,EAAE,mBAAmB,EAC3B,IAAI,EAAE,WAAW,CAAC,MAAM,mBAAmB,CAAC,GAC7C,MAAM,CAsBR;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAChC,OAAO,EAAE,mBAAmB,GAAG,SAAS,EACxC,QAAQ,EAAE,oBAAoB,GAC/B,qBAAqB,CAmBvB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,GAAG,qBAAqB,CAMpG"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Option normalisation for importers and exporters (design sections 8.4 and 8.5): every common
|
|
3
|
+
* option resolved to its documented default, enum values checked (E_UNSUPPORTED, the core's
|
|
4
|
+
* convention for an option outside its set), and the per-format defaults (`ids`, `defaultDirected`,
|
|
5
|
+
* `weightFrom`, `addMissingNodes`) supplied by the importer that calls resolveImportOptions().
|
|
6
|
+
*/
|
|
7
|
+
import { GraphFormatError } from "@graphty/graph-format";
|
|
8
|
+
import { OPTION_IGNORED_CODE, SINK_OPTION_CODE } from "./codes.js";
|
|
9
|
+
const ID_COERCIONS = new Set(["keep", "canonical", "string", "number"]);
|
|
10
|
+
const NODE_ID_SOURCES = new Set(["id", "label", "index"]);
|
|
11
|
+
const DUPLICATE_POLICIES = new Set(["keep", "error", "first", "last", "sum", "min", "max"]);
|
|
12
|
+
const SELF_LOOP_POLICIES = new Set(["keep", "drop", "error"]);
|
|
13
|
+
const IMPORT_MIXED_POLICIES = new Set(["expand", "directed", "undirected", "error"]);
|
|
14
|
+
const EXPORT_MIXED_POLICIES = new Set(["error", "directed", "undirected"]);
|
|
15
|
+
const WEIGHT_DTYPES = new Set(["f32", "f64"]);
|
|
16
|
+
const LONG_MODES = new Set(["f64", "string"]);
|
|
17
|
+
const HYPEREDGE_POLICIES = new Set(["error", "skip", "star", "clique"]);
|
|
18
|
+
const SANITIZE_MODES = new Set(["error", "mangle"]);
|
|
19
|
+
/** The default error limit of design section 8.4. */
|
|
20
|
+
export const DEFAULT_ERROR_LIMIT = 100;
|
|
21
|
+
export { SINK_OPTION_CODE };
|
|
22
|
+
/** The builder-policy options a sink exposes read-only as `sink.options` (design section 8.4). */
|
|
23
|
+
const SINK_OPTION_NAMES = ["addMissingNodes", "duplicateEdges", "selfLoops", "weightDtype"];
|
|
24
|
+
/**
|
|
25
|
+
* Report every builder-policy option the caller explicitly requested that the sink does not use
|
|
26
|
+
* (design section 8.4 precedence), one `W_SINK_OPTION` warning per option with the option name as
|
|
27
|
+
* the element. Options left undefined are never reported: they are defaults, not requests. On the
|
|
28
|
+
* registry's builder, which is seeded from the same options, nothing is ever reported.
|
|
29
|
+
* @param sink - the sink the importer pushes into
|
|
30
|
+
* @param options - the caller's raw options, possibly undefined
|
|
31
|
+
* @param report - the report to record into
|
|
32
|
+
* @param enforcesMissingNodes - true when the importer applies `addMissingNodes: false` itself (it
|
|
33
|
+
* refuses unknown endpoints before the sink sees them), so that request is honoured on any sink and
|
|
34
|
+
* only `addMissingNodes: true` against a refusing sink is reported
|
|
35
|
+
* @returns the number of warnings recorded
|
|
36
|
+
*/
|
|
37
|
+
export function reportSinkOptions(sink, options, report, enforcesMissingNodes = false) {
|
|
38
|
+
if (options === undefined) {
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
let recorded = 0;
|
|
42
|
+
for (const name of SINK_OPTION_NAMES) {
|
|
43
|
+
const wanted = options[name];
|
|
44
|
+
const actual = sink.options[name];
|
|
45
|
+
if (wanted === undefined || wanted === actual) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (name === "addMissingNodes" && enforcesMissingNodes && wanted === false) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
report.warning("coercion", SINK_OPTION_CODE, `option ${name}: ${JSON.stringify(wanted)} requested but the sink uses ${JSON.stringify(actual)}; the sink's setting applies`, { element: name });
|
|
52
|
+
recorded++;
|
|
53
|
+
}
|
|
54
|
+
return recorded;
|
|
55
|
+
}
|
|
56
|
+
/** The common options a format may leave unused; `signal`, `onProgress` and `errorLimit` apply everywhere. */
|
|
57
|
+
const IGNORABLE_OPTION_NAMES = [
|
|
58
|
+
"ids",
|
|
59
|
+
"nodeIdFrom",
|
|
60
|
+
"addMissingNodes",
|
|
61
|
+
"duplicateEdges",
|
|
62
|
+
"selfLoops",
|
|
63
|
+
"onMixedDirection",
|
|
64
|
+
"defaultDirected",
|
|
65
|
+
"weightFrom",
|
|
66
|
+
"weightDtype",
|
|
67
|
+
"long",
|
|
68
|
+
"restoreMangledIds",
|
|
69
|
+
"hyperedges",
|
|
70
|
+
];
|
|
71
|
+
/**
|
|
72
|
+
* Report every common option the caller set to a non-default value that the format has no use
|
|
73
|
+
* for (design section 8.4: "the importer reports every option it could not honour"): one
|
|
74
|
+
* `W_OPTION_IGNORED` warning (category `unsupported`) per option, the option name as the element.
|
|
75
|
+
* The builder-policy options are reportSinkOptions()'s and are skipped here.
|
|
76
|
+
* @param options - the caller's raw options, possibly undefined
|
|
77
|
+
* @param report - the report to record into
|
|
78
|
+
* @param used - the common option names the importer reads
|
|
79
|
+
* @returns the number of warnings recorded
|
|
80
|
+
*/
|
|
81
|
+
export function reportUnusedOptions(options, report, used) {
|
|
82
|
+
if (options === undefined) {
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
let recorded = 0;
|
|
86
|
+
for (const name of IGNORABLE_OPTION_NAMES) {
|
|
87
|
+
if (used.has(name) || SINK_OPTION_NAMES.includes(name)) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const value = options[name];
|
|
91
|
+
if (value === undefined) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
report.warning("unsupported", OPTION_IGNORED_CODE, `option ${name}: ${JSON.stringify(value)} has no effect on the ${report.format} importer`, { element: name });
|
|
95
|
+
recorded++;
|
|
96
|
+
}
|
|
97
|
+
return recorded;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Apply the design section 8.4 defaults to an importer's common options and check every enum
|
|
101
|
+
* value. Format-specific options in the same object are ignored here.
|
|
102
|
+
* @param options - the caller's options, possibly undefined
|
|
103
|
+
* @param defaults - the importer's per-format defaults
|
|
104
|
+
* @returns the resolved options; E_UNSUPPORTED for a value outside its set
|
|
105
|
+
*/
|
|
106
|
+
export function resolveImportOptions(options, defaults) {
|
|
107
|
+
const o = options ?? {};
|
|
108
|
+
return Object.freeze({
|
|
109
|
+
ids: enumOption("ids", o.ids, defaults.ids, ID_COERCIONS),
|
|
110
|
+
nodeIdFrom: enumOption("nodeIdFrom", o.nodeIdFrom, "id", NODE_ID_SOURCES),
|
|
111
|
+
addMissingNodes: booleanOption("addMissingNodes", o.addMissingNodes, defaults.addMissingNodes ?? true),
|
|
112
|
+
duplicateEdges: enumOption("duplicateEdges", o.duplicateEdges, "keep", DUPLICATE_POLICIES),
|
|
113
|
+
selfLoops: enumOption("selfLoops", o.selfLoops, "keep", SELF_LOOP_POLICIES),
|
|
114
|
+
onMixedDirection: enumOption("onMixedDirection", o.onMixedDirection, "expand", IMPORT_MIXED_POLICIES),
|
|
115
|
+
defaultDirected: booleanOption("defaultDirected", o.defaultDirected, defaults.defaultDirected),
|
|
116
|
+
weightFrom: weightFromOption(o.weightFrom, defaults.weightFrom),
|
|
117
|
+
weightDtype: enumOption("weightDtype", o.weightDtype, "f64", WEIGHT_DTYPES),
|
|
118
|
+
long: enumOption("long", o.long, "f64", LONG_MODES),
|
|
119
|
+
restoreMangledIds: booleanOption("restoreMangledIds", o.restoreMangledIds, true),
|
|
120
|
+
hyperedges: enumOption("hyperedges", o.hyperedges, "skip", HYPEREDGE_POLICIES),
|
|
121
|
+
errorLimit: errorLimitOption(o.errorLimit),
|
|
122
|
+
signal: signalOption(o.signal),
|
|
123
|
+
onProgress: progressOption(o.onProgress),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Apply the design section 8.5 defaults to an exporter's common options and check the enum values.
|
|
128
|
+
* @param options - the caller's options, possibly undefined
|
|
129
|
+
* @returns the resolved options; E_UNSUPPORTED for a value outside its set
|
|
130
|
+
*/
|
|
131
|
+
export function resolveExportOptions(options) {
|
|
132
|
+
const o = options ?? {};
|
|
133
|
+
return Object.freeze({
|
|
134
|
+
sanitizeIds: enumOption("sanitizeIds", o.sanitizeIds, "error", SANITIZE_MODES),
|
|
135
|
+
onMixedDirection: enumOption("onMixedDirection", o.onMixedDirection, "error", EXPORT_MIXED_POLICIES),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Resolve one enum-valued option.
|
|
140
|
+
* @param name - the option name, for the error
|
|
141
|
+
* @param value - the caller's value
|
|
142
|
+
* @param fallback - the default
|
|
143
|
+
* @param allowed - the accepted values
|
|
144
|
+
* @returns the value or the default; E_UNSUPPORTED when outside the set
|
|
145
|
+
*/
|
|
146
|
+
function enumOption(name, value, fallback, allowed) {
|
|
147
|
+
if (value === undefined) {
|
|
148
|
+
return fallback;
|
|
149
|
+
}
|
|
150
|
+
if (typeof value !== "string" || !allowed.has(value)) {
|
|
151
|
+
throw new GraphFormatError("E_UNSUPPORTED", `option ${name}: ${describe(value)} is not one of ${list(allowed)}`, {
|
|
152
|
+
option: name,
|
|
153
|
+
found: value,
|
|
154
|
+
supported: [...allowed],
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Resolve one boolean option.
|
|
161
|
+
* @param name - the option name, for the error
|
|
162
|
+
* @param value - the caller's value
|
|
163
|
+
* @param fallback - the default
|
|
164
|
+
* @returns the value or the default; E_UNSUPPORTED when not a boolean
|
|
165
|
+
*/
|
|
166
|
+
function booleanOption(name, value, fallback) {
|
|
167
|
+
if (value === undefined) {
|
|
168
|
+
return fallback;
|
|
169
|
+
}
|
|
170
|
+
if (typeof value !== "boolean") {
|
|
171
|
+
throw new GraphFormatError("E_UNSUPPORTED", `option ${name}: ${describe(value)} is not a boolean`, {
|
|
172
|
+
option: name,
|
|
173
|
+
found: value,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Resolve the weightFrom option: a non-empty attribute name, null for unweighted, or the format default.
|
|
180
|
+
* @param value - the caller's value
|
|
181
|
+
* @param fallback - the format default
|
|
182
|
+
* @returns the resolved value; E_UNSUPPORTED for anything else
|
|
183
|
+
*/
|
|
184
|
+
function weightFromOption(value, fallback) {
|
|
185
|
+
if (value === undefined) {
|
|
186
|
+
return fallback;
|
|
187
|
+
}
|
|
188
|
+
if (value === null || (typeof value === "string" && value.length > 0)) {
|
|
189
|
+
return value;
|
|
190
|
+
}
|
|
191
|
+
throw new GraphFormatError("E_UNSUPPORTED", `option weightFrom: ${describe(value)} is not an attribute name or null`, { option: "weightFrom", found: value });
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Resolve the error limit: a non-negative integer or Infinity.
|
|
195
|
+
* @param value - the caller's value
|
|
196
|
+
* @returns the limit or the default
|
|
197
|
+
*/
|
|
198
|
+
function errorLimitOption(value) {
|
|
199
|
+
if (value === undefined) {
|
|
200
|
+
return DEFAULT_ERROR_LIMIT;
|
|
201
|
+
}
|
|
202
|
+
if (typeof value === "number" && value >= 0 && (Number.isInteger(value) || value === Infinity)) {
|
|
203
|
+
return value;
|
|
204
|
+
}
|
|
205
|
+
throw new GraphFormatError("E_UNSUPPORTED", `option errorLimit: ${describe(value)} is not a non-negative integer or Infinity`, { option: "errorLimit", found: value });
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Resolve the signal option by duck type, so a signal from another realm is accepted.
|
|
209
|
+
* @param value - the caller's value
|
|
210
|
+
* @returns the signal or null
|
|
211
|
+
*/
|
|
212
|
+
function signalOption(value) {
|
|
213
|
+
if (value === undefined || value === null) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
if (typeof value === "object" && typeof value.aborted === "boolean") {
|
|
217
|
+
return value;
|
|
218
|
+
}
|
|
219
|
+
throw new GraphFormatError("E_UNSUPPORTED", `option signal: ${describe(value)} is not an AbortSignal`, {
|
|
220
|
+
option: "signal",
|
|
221
|
+
found: typeof value,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Resolve the progress callback option.
|
|
226
|
+
* @param value - the caller's value
|
|
227
|
+
* @returns the callback or null
|
|
228
|
+
*/
|
|
229
|
+
function progressOption(value) {
|
|
230
|
+
if (value === undefined || value === null) {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
if (typeof value === "function") {
|
|
234
|
+
return value;
|
|
235
|
+
}
|
|
236
|
+
throw new GraphFormatError("E_UNSUPPORTED", `option onProgress: ${describe(value)} is not a function`, {
|
|
237
|
+
option: "onProgress",
|
|
238
|
+
found: typeof value,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* A short description of an option value for an error message.
|
|
243
|
+
* @param value - the value
|
|
244
|
+
* @returns the JSON text of a primitive, or the type name otherwise
|
|
245
|
+
*/
|
|
246
|
+
function describe(value) {
|
|
247
|
+
switch (typeof value) {
|
|
248
|
+
case "string":
|
|
249
|
+
return JSON.stringify(value);
|
|
250
|
+
case "number":
|
|
251
|
+
case "boolean":
|
|
252
|
+
return String(value);
|
|
253
|
+
default:
|
|
254
|
+
return value === null ? "null" : typeof value;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* The accepted values of an enum option, for an error message.
|
|
259
|
+
* @param allowed - the set
|
|
260
|
+
* @returns the quoted values joined by commas
|
|
261
|
+
*/
|
|
262
|
+
function list(allowed) {
|
|
263
|
+
return [...allowed].map((v) => JSON.stringify(v)).join(", ");
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/common/options.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAwB,gBAAgB,EAAmC,MAAM,uBAAuB,CAAC;AAGhH,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AA6DnE,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC7F,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAC/E,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AACjH,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACnF,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;AAC1G,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC;AAChG,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC,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;IACtC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ImportReport builder shared by every importer (design section 8.6): issues by category and
|
|
3
|
+
* severity, the element counts, loss notes, the error limit with truncation, and the ImportError
|
|
4
|
+
* that carries the partial report when the importer aborts.
|
|
5
|
+
*
|
|
6
|
+
* Layering (design section 8.6): the builder throws on the first hard error; the importer catches
|
|
7
|
+
* per element, records an ImportIssue through this class, skips the element and continues until the
|
|
8
|
+
* error limit, then aborts with E_IMPORT. `recordError()` is that catch: it turns a thrown
|
|
9
|
+
* GraphFormatError into an issue with the category its code implies and re-throws everything else
|
|
10
|
+
* (an ImportError, an abort reason, a programming error) unchanged.
|
|
11
|
+
*/
|
|
12
|
+
import { ImportError, type ImportIssue, type ImportReport, type IssueCategory, type LossNote } from "../types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Where an issue was found: the 1-based line and the element (id or attribute name) when known.
|
|
15
|
+
* Consumed by the per-format importers and exporters under src/formats.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export interface IssueLocation {
|
|
19
|
+
/** The 1-based source line, when known. */
|
|
20
|
+
readonly line?: number | null | undefined;
|
|
21
|
+
/** The element the issue is about, when known. */
|
|
22
|
+
readonly element?: string | null | undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The mutable element counters of a report in progress; importers increment them directly in hot loops.
|
|
26
|
+
* Consumed by the per-format importers and exporters under src/formats.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export interface MutableCounts {
|
|
30
|
+
/** Nodes pushed. */
|
|
31
|
+
nodes: number;
|
|
32
|
+
/** Logical edges pushed (both halves of an expanded edge count). */
|
|
33
|
+
edges: number;
|
|
34
|
+
/** Nodes skipped after an error. */
|
|
35
|
+
skippedNodes: number;
|
|
36
|
+
/** Edges skipped after an error. */
|
|
37
|
+
skippedEdges: number;
|
|
38
|
+
/** Source edges expanded into two logical edges (design section 3.6). */
|
|
39
|
+
expandedMixed: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The code a report used to give a thrown value that was not a GraphFormatError. Since audit round
|
|
43
|
+
* 1 such a value (a TypeError, a RangeError: a bug in an importer or a sink, never a defect of the
|
|
44
|
+
* input) propagates out of import() untouched, so no importer records this code any more; the
|
|
45
|
+
* constant stays for consumers that switch on the codes of earlier reports.
|
|
46
|
+
*/
|
|
47
|
+
export declare const PARSE_ERROR_CODE = "E_PARSE";
|
|
48
|
+
/**
|
|
49
|
+
* Accumulates an ImportReport while an importer runs. Errors count toward the error limit; the
|
|
50
|
+
* error that takes the count beyond the limit is still recorded, `truncated` is set, and an
|
|
51
|
+
* ImportError carrying the report so far is thrown (design section 8.4: "beyond it the importer
|
|
52
|
+
* aborts with E_IMPORT"). Warnings never abort.
|
|
53
|
+
*/
|
|
54
|
+
export declare class ImportReportBuilder {
|
|
55
|
+
/** The importer's format name. */
|
|
56
|
+
readonly format: string;
|
|
57
|
+
/** The error limit the report was created with. */
|
|
58
|
+
readonly errorLimit: number;
|
|
59
|
+
/** The element counters; importers increment them directly. */
|
|
60
|
+
readonly counts: MutableCounts;
|
|
61
|
+
private readonly issueList;
|
|
62
|
+
private readonly lossList;
|
|
63
|
+
private readonly onceCodes;
|
|
64
|
+
private errors;
|
|
65
|
+
private warnings;
|
|
66
|
+
private truncatedFlag;
|
|
67
|
+
private readonly startedAt;
|
|
68
|
+
/**
|
|
69
|
+
* Create a builder for one import call.
|
|
70
|
+
* @param format - the importer's format name
|
|
71
|
+
* @param errorLimit - errors tolerated before the import aborts; Infinity for no limit
|
|
72
|
+
*/
|
|
73
|
+
constructor(format: string, errorLimit: number);
|
|
74
|
+
/**
|
|
75
|
+
* Issues recorded so far, in order.
|
|
76
|
+
* @returns the live list (not copied; finish() copies)
|
|
77
|
+
*/
|
|
78
|
+
get issues(): readonly ImportIssue[];
|
|
79
|
+
/**
|
|
80
|
+
* Issues with severity "error".
|
|
81
|
+
* @returns the count
|
|
82
|
+
*/
|
|
83
|
+
get errorCount(): number;
|
|
84
|
+
/**
|
|
85
|
+
* Issues with severity "warning".
|
|
86
|
+
* @returns the count
|
|
87
|
+
*/
|
|
88
|
+
get warningCount(): number;
|
|
89
|
+
/**
|
|
90
|
+
* Whether the error limit was exceeded.
|
|
91
|
+
* @returns true once an error beyond the limit was recorded
|
|
92
|
+
*/
|
|
93
|
+
get truncated(): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Loss notes recorded so far.
|
|
96
|
+
* @returns the live list
|
|
97
|
+
*/
|
|
98
|
+
get lossy(): readonly LossNote[];
|
|
99
|
+
/**
|
|
100
|
+
* Record an error. When the count goes beyond the error limit the report is marked truncated
|
|
101
|
+
* and an ImportError carrying it is thrown; the importer does not catch that.
|
|
102
|
+
* @param category - the issue category
|
|
103
|
+
* @param code - a stable code such as "E_UNKNOWN_NODE"
|
|
104
|
+
* @param message - a plain-ASCII message
|
|
105
|
+
* @param where - the line and element, when known
|
|
106
|
+
* @returns the recorded issue
|
|
107
|
+
*/
|
|
108
|
+
error(category: IssueCategory, code: string, message: string, where?: IssueLocation): ImportIssue;
|
|
109
|
+
/**
|
|
110
|
+
* Record a warning; warnings never count toward the limit.
|
|
111
|
+
* @param category - the issue category
|
|
112
|
+
* @param code - a stable code such as "W_WIDENED"
|
|
113
|
+
* @param message - a plain-ASCII message
|
|
114
|
+
* @param where - the line and element, when known
|
|
115
|
+
* @returns the recorded issue
|
|
116
|
+
*/
|
|
117
|
+
warning(category: IssueCategory, code: string, message: string, where?: IssueLocation): ImportIssue;
|
|
118
|
+
/**
|
|
119
|
+
* Record a warning the first time its key is seen and ignore later repeats, for conditions
|
|
120
|
+
* that would otherwise produce one warning per row.
|
|
121
|
+
* @param category - the issue category
|
|
122
|
+
* @param code - the stable code
|
|
123
|
+
* @param message - a plain-ASCII message
|
|
124
|
+
* @param where - the line and element, when known
|
|
125
|
+
* @param key - what repeats are deduplicated on; the code itself by default (pass `code:column`
|
|
126
|
+
* to warn once per column)
|
|
127
|
+
* @returns the recorded issue, or null when the key was already recorded
|
|
128
|
+
*/
|
|
129
|
+
warnOnce(category: IssueCategory, code: string, message: string, where?: IssueLocation, key?: string): ImportIssue | null;
|
|
130
|
+
/**
|
|
131
|
+
* Record something the importer could not represent.
|
|
132
|
+
* @param code - a stable code
|
|
133
|
+
* @param message - a plain-ASCII message
|
|
134
|
+
* @param column - the affected column, or null
|
|
135
|
+
* @param count - the affected count, or null
|
|
136
|
+
* @returns the recorded note
|
|
137
|
+
*/
|
|
138
|
+
loss(code: string, message: string, column?: string | null, count?: number | null): LossNote;
|
|
139
|
+
/**
|
|
140
|
+
* The per-element catch of design section 8.6: record a thrown GraphFormatError as an error
|
|
141
|
+
* issue with its code and the category the code implies. Anything else is re-thrown unchanged:
|
|
142
|
+
* an ImportError (the import already aborted), an abort reason, and any other thrown value (a
|
|
143
|
+
* TypeError or RangeError is a programming error in the importer or the sink, never a defect of
|
|
144
|
+
* the input, so it must surface as an exception rather than as an issue blamed on the file).
|
|
145
|
+
* @param err - the thrown value
|
|
146
|
+
* @param where - the line and element, when known
|
|
147
|
+
* @returns the recorded issue
|
|
148
|
+
*/
|
|
149
|
+
recordError(err: unknown, where?: IssueLocation): ImportIssue;
|
|
150
|
+
/**
|
|
151
|
+
* Build the ImportError that aborts the import, carrying the report so far. The caller throws
|
|
152
|
+
* it; this method only constructs it so it can be used in expression position.
|
|
153
|
+
* @param message - a plain-ASCII message
|
|
154
|
+
* @param details - optional machine-readable context
|
|
155
|
+
* @returns the error to throw
|
|
156
|
+
*/
|
|
157
|
+
abort(message: string, details?: Readonly<Record<string, unknown>>): ImportError;
|
|
158
|
+
/**
|
|
159
|
+
* Record a fatal parse error and abort: the issue is recorded (even beyond the error limit)
|
|
160
|
+
* and an ImportError carrying the report is thrown.
|
|
161
|
+
* @param code - a stable code such as "E_INVALID_UTF8"
|
|
162
|
+
* @param message - a plain-ASCII message
|
|
163
|
+
* @param where - the line and element, when known
|
|
164
|
+
* @param details - optional machine-readable context for the ImportError
|
|
165
|
+
*/
|
|
166
|
+
fail(code: string, message: string, where?: IssueLocation, details?: Readonly<Record<string, unknown>>): never;
|
|
167
|
+
/**
|
|
168
|
+
* The report as it stands: a frozen snapshot with the parse duration so far. Can be called more
|
|
169
|
+
* than once; each call reflects everything recorded up to that point.
|
|
170
|
+
* @returns the report
|
|
171
|
+
*/
|
|
172
|
+
finish(): ImportReport;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Whether a thrown value is an abort reason (the DOMException or Error named "AbortError" that
|
|
176
|
+
* AbortSignal.reason holds), which an importer must let through untouched.
|
|
177
|
+
* @param err - the thrown value
|
|
178
|
+
* @returns true for an AbortError
|
|
179
|
+
*/
|
|
180
|
+
export declare function isAbortError(err: unknown): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* The message of a thrown value: an Error's message, a string as is, anything else described by type.
|
|
183
|
+
* @param err - the thrown value
|
|
184
|
+
* @returns a plain message
|
|
185
|
+
*/
|
|
186
|
+
export declare function messageOf(err: unknown): string;
|
|
187
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/common/report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAElH;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC1B,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C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