@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,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the GEXF importer and exporter share (research note 07 section 2.1, design sections 5.1,
|
|
3
|
+
* 5.5, 5.6 and 5.10): the namespaces of the two supported versions, the fixed names and
|
|
4
|
+
* declarations of the columns derived from XML attributes and viz elements (design section 5.6:
|
|
5
|
+
* XML-attribute-derived columns have fixed names and roles, and a declared attribute that would
|
|
6
|
+
* take one of them is renamed `<name>#<id>`), the shape of a temporal extension table, and the
|
|
7
|
+
* declared-type table of each version for the exporter.
|
|
8
|
+
*/
|
|
9
|
+
import { TIME_TEXT_ROLE, TIME_TEXT_SUFFIX } from "../../common/temporal.js";
|
|
10
|
+
/** The format name. */
|
|
11
|
+
export const GEXF_FORMAT = "gexf";
|
|
12
|
+
/** The namespace URIs of each version. */
|
|
13
|
+
export const GEXF_NAMESPACES = {
|
|
14
|
+
"1.2": { gexf: "http://www.gexf.net/1.2draft", viz: "http://www.gexf.net/1.2draft/viz" },
|
|
15
|
+
"1.3": { gexf: "http://gexf.net/1.3", viz: "http://gexf.net/1.3/viz" },
|
|
16
|
+
};
|
|
17
|
+
/** The GEXF `timeformat` values. */
|
|
18
|
+
export const TIME_FORMATS = new Set(["integer", "double", "date", "dateTime"]);
|
|
19
|
+
/** The GEXF graph `mode` values. */
|
|
20
|
+
export const GRAPH_MODES = new Set(["static", "dynamic", "slice"]);
|
|
21
|
+
/** The GEXF 1.3 `timerepresentation` values. */
|
|
22
|
+
export const TIME_REPRESENTATIONS = new Set(["interval", "timestamp"]);
|
|
23
|
+
/** The `origin.namespace` of viz-derived columns. */
|
|
24
|
+
export const VIZ_NAMESPACE = "viz";
|
|
25
|
+
/** The origin every XML-derived column declares. */
|
|
26
|
+
const XML_ORIGIN = { format: GEXF_FORMAT };
|
|
27
|
+
/** The origin of every viz-derived column. */
|
|
28
|
+
const VIZ_ORIGIN = { format: GEXF_FORMAT, namespace: VIZ_NAMESPACE };
|
|
29
|
+
/**
|
|
30
|
+
* The fixed node column names the importer owns (design section 5.6): a declared attribute with
|
|
31
|
+
* one of these titles is renamed `<title>#<id>` so the XML-derived column keeps its name and role.
|
|
32
|
+
*/
|
|
33
|
+
export const NODE_COLUMNS = Object.freeze({
|
|
34
|
+
label: "label",
|
|
35
|
+
parent: "parent",
|
|
36
|
+
parents: "parents",
|
|
37
|
+
start: "start",
|
|
38
|
+
end: "end",
|
|
39
|
+
timestamp: "timestamp",
|
|
40
|
+
spells: "spells",
|
|
41
|
+
timestamps: "timestamps",
|
|
42
|
+
open: "open",
|
|
43
|
+
position: "position",
|
|
44
|
+
color: "color",
|
|
45
|
+
size: "size",
|
|
46
|
+
shape: "shape",
|
|
47
|
+
shapeUri: "shape.uri",
|
|
48
|
+
});
|
|
49
|
+
/** The fixed edge column names the importer owns. */
|
|
50
|
+
const EDGE_COLUMNS = Object.freeze({
|
|
51
|
+
id: "id",
|
|
52
|
+
label: "label",
|
|
53
|
+
kind: "kind",
|
|
54
|
+
start: "start",
|
|
55
|
+
end: "end",
|
|
56
|
+
timestamp: "timestamp",
|
|
57
|
+
spells: "spells",
|
|
58
|
+
timestamps: "timestamps",
|
|
59
|
+
open: "open",
|
|
60
|
+
color: "color",
|
|
61
|
+
thickness: "thickness",
|
|
62
|
+
shape: "shape",
|
|
63
|
+
});
|
|
64
|
+
/** Every reserved node column name, including the temporal companions. */
|
|
65
|
+
export const RESERVED_NODE_NAMES = new Set([
|
|
66
|
+
...Object.values(NODE_COLUMNS),
|
|
67
|
+
NODE_COLUMNS.start + TIME_TEXT_SUFFIX,
|
|
68
|
+
NODE_COLUMNS.end + TIME_TEXT_SUFFIX,
|
|
69
|
+
NODE_COLUMNS.timestamp + TIME_TEXT_SUFFIX,
|
|
70
|
+
]);
|
|
71
|
+
/** Every reserved edge column name, including the temporal companions. */
|
|
72
|
+
export const RESERVED_EDGE_NAMES = new Set([
|
|
73
|
+
...Object.values(EDGE_COLUMNS),
|
|
74
|
+
EDGE_COLUMNS.start + TIME_TEXT_SUFFIX,
|
|
75
|
+
EDGE_COLUMNS.end + TIME_TEXT_SUFFIX,
|
|
76
|
+
EDGE_COLUMNS.timestamp + TIME_TEXT_SUFFIX,
|
|
77
|
+
]);
|
|
78
|
+
/** The declarations of the XML-derived node columns, keyed as NODE_COLUMNS. */
|
|
79
|
+
export const NODE_DECLS = {
|
|
80
|
+
label: { name: NODE_COLUMNS.label, dtype: "string", role: "label", nullable: true, origin: XML_ORIGIN },
|
|
81
|
+
parent: {
|
|
82
|
+
name: NODE_COLUMNS.parent,
|
|
83
|
+
dtype: "u32",
|
|
84
|
+
role: "parent",
|
|
85
|
+
refersTo: "node",
|
|
86
|
+
nullable: true,
|
|
87
|
+
origin: XML_ORIGIN,
|
|
88
|
+
},
|
|
89
|
+
parents: {
|
|
90
|
+
name: NODE_COLUMNS.parents,
|
|
91
|
+
dtype: "list",
|
|
92
|
+
itemDtype: "u32",
|
|
93
|
+
role: "parents",
|
|
94
|
+
refersTo: "node",
|
|
95
|
+
nullable: true,
|
|
96
|
+
origin: XML_ORIGIN,
|
|
97
|
+
},
|
|
98
|
+
start: { name: NODE_COLUMNS.start, dtype: "f64", role: "start", nullable: true, origin: XML_ORIGIN },
|
|
99
|
+
end: { name: NODE_COLUMNS.end, dtype: "f64", role: "end", nullable: true, origin: XML_ORIGIN },
|
|
100
|
+
timestamp: { name: NODE_COLUMNS.timestamp, dtype: "f64", role: "timestamp", nullable: true, origin: XML_ORIGIN },
|
|
101
|
+
spells: {
|
|
102
|
+
name: NODE_COLUMNS.spells,
|
|
103
|
+
dtype: "list",
|
|
104
|
+
itemDtype: "f64",
|
|
105
|
+
itemComponents: 2,
|
|
106
|
+
role: "spells",
|
|
107
|
+
nullable: true,
|
|
108
|
+
origin: XML_ORIGIN,
|
|
109
|
+
},
|
|
110
|
+
timestamps: {
|
|
111
|
+
name: NODE_COLUMNS.timestamps,
|
|
112
|
+
dtype: "list",
|
|
113
|
+
itemDtype: "f64",
|
|
114
|
+
role: "timestamps",
|
|
115
|
+
nullable: true,
|
|
116
|
+
origin: XML_ORIGIN,
|
|
117
|
+
},
|
|
118
|
+
open: { name: NODE_COLUMNS.open, dtype: "u8", role: "open", nullable: true, origin: XML_ORIGIN },
|
|
119
|
+
position: {
|
|
120
|
+
name: NODE_COLUMNS.position,
|
|
121
|
+
dtype: "f32",
|
|
122
|
+
components: 3,
|
|
123
|
+
role: "position",
|
|
124
|
+
mutable: true,
|
|
125
|
+
nullable: true,
|
|
126
|
+
origin: VIZ_ORIGIN,
|
|
127
|
+
extra: { units: "file" },
|
|
128
|
+
},
|
|
129
|
+
color: {
|
|
130
|
+
name: NODE_COLUMNS.color,
|
|
131
|
+
dtype: "f32",
|
|
132
|
+
components: 4,
|
|
133
|
+
role: "color",
|
|
134
|
+
nullable: true,
|
|
135
|
+
origin: VIZ_ORIGIN,
|
|
136
|
+
},
|
|
137
|
+
size: { name: NODE_COLUMNS.size, dtype: "f32", role: "size", nullable: true, origin: VIZ_ORIGIN },
|
|
138
|
+
shape: { name: NODE_COLUMNS.shape, dtype: "dict", role: "shape", nullable: true, origin: VIZ_ORIGIN },
|
|
139
|
+
shapeUri: { name: NODE_COLUMNS.shapeUri, dtype: "string", nullable: true, origin: VIZ_ORIGIN },
|
|
140
|
+
};
|
|
141
|
+
/** The declarations of the XML-derived edge columns, keyed as EDGE_COLUMNS. */
|
|
142
|
+
export const EDGE_DECLS = {
|
|
143
|
+
id: { name: EDGE_COLUMNS.id, dtype: "string", role: "id", unique: true, nullable: true, origin: XML_ORIGIN },
|
|
144
|
+
label: { name: EDGE_COLUMNS.label, dtype: "string", role: "label", nullable: true, origin: XML_ORIGIN },
|
|
145
|
+
kind: { name: EDGE_COLUMNS.kind, dtype: "dict", role: "kind", nullable: true, origin: XML_ORIGIN },
|
|
146
|
+
start: { name: EDGE_COLUMNS.start, dtype: "f64", role: "start", nullable: true, origin: XML_ORIGIN },
|
|
147
|
+
end: { name: EDGE_COLUMNS.end, dtype: "f64", role: "end", nullable: true, origin: XML_ORIGIN },
|
|
148
|
+
timestamp: { name: EDGE_COLUMNS.timestamp, dtype: "f64", role: "timestamp", nullable: true, origin: XML_ORIGIN },
|
|
149
|
+
spells: {
|
|
150
|
+
name: EDGE_COLUMNS.spells,
|
|
151
|
+
dtype: "list",
|
|
152
|
+
itemDtype: "f64",
|
|
153
|
+
itemComponents: 2,
|
|
154
|
+
role: "spells",
|
|
155
|
+
nullable: true,
|
|
156
|
+
origin: XML_ORIGIN,
|
|
157
|
+
},
|
|
158
|
+
timestamps: {
|
|
159
|
+
name: EDGE_COLUMNS.timestamps,
|
|
160
|
+
dtype: "list",
|
|
161
|
+
itemDtype: "f64",
|
|
162
|
+
role: "timestamps",
|
|
163
|
+
nullable: true,
|
|
164
|
+
origin: XML_ORIGIN,
|
|
165
|
+
},
|
|
166
|
+
open: { name: EDGE_COLUMNS.open, dtype: "u8", role: "open", nullable: true, origin: XML_ORIGIN },
|
|
167
|
+
color: {
|
|
168
|
+
name: EDGE_COLUMNS.color,
|
|
169
|
+
dtype: "f32",
|
|
170
|
+
components: 4,
|
|
171
|
+
role: "color",
|
|
172
|
+
nullable: true,
|
|
173
|
+
origin: VIZ_ORIGIN,
|
|
174
|
+
},
|
|
175
|
+
thickness: { name: EDGE_COLUMNS.thickness, dtype: "f32", role: "thickness", nullable: true, origin: VIZ_ORIGIN },
|
|
176
|
+
shape: { name: EDGE_COLUMNS.shape, dtype: "dict", role: "shape", nullable: true, origin: VIZ_ORIGIN },
|
|
177
|
+
};
|
|
178
|
+
/** The bit of the `open` column marking an open start (design section 5.1). */
|
|
179
|
+
export const OPEN_START = 1;
|
|
180
|
+
/** The bit of the `open` column marking an open end. */
|
|
181
|
+
export const OPEN_END = 2;
|
|
182
|
+
/** The prefix of a temporal extension table's name (design section 5.10). */
|
|
183
|
+
const TEMPORAL_TABLE_PREFIX = "temporal:";
|
|
184
|
+
/** The column names of a temporal extension table (design section 5.10). */
|
|
185
|
+
export const TEMPORAL_COLUMNS = Object.freeze({
|
|
186
|
+
element: "element",
|
|
187
|
+
start: "start",
|
|
188
|
+
end: "end",
|
|
189
|
+
value: "value",
|
|
190
|
+
open: "open",
|
|
191
|
+
startText: `start${TIME_TEXT_SUFFIX}`,
|
|
192
|
+
endText: `end${TIME_TEXT_SUFFIX}`,
|
|
193
|
+
valueText: `value${TIME_TEXT_SUFFIX}`,
|
|
194
|
+
});
|
|
195
|
+
/**
|
|
196
|
+
* The name of the temporal extension table of a dynamic attribute.
|
|
197
|
+
* @param domain - node or edge
|
|
198
|
+
* @param column - the static column's name
|
|
199
|
+
* @returns `temporal:<domain>:<column>`
|
|
200
|
+
*/
|
|
201
|
+
export function temporalTableName(domain, column) {
|
|
202
|
+
return `${TEMPORAL_TABLE_PREFIX}${domain}:${column}`;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Split a temporal table name into its domain and column.
|
|
206
|
+
* @param name - the table name
|
|
207
|
+
* @returns the parts, or null when the name is not a temporal table's
|
|
208
|
+
*/
|
|
209
|
+
export function parseTemporalTableName(name) {
|
|
210
|
+
if (!name.startsWith(TEMPORAL_TABLE_PREFIX)) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
const rest = name.slice(TEMPORAL_TABLE_PREFIX.length);
|
|
214
|
+
const colon = rest.indexOf(":");
|
|
215
|
+
if (colon < 0) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
const domain = rest.slice(0, colon);
|
|
219
|
+
if (domain !== "node" && domain !== "edge") {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
return { domain, column: rest.slice(colon + 1) };
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* The column declarations of a temporal extension table (design section 5.10): the element index,
|
|
226
|
+
* the interval, the value in the attribute's dtype, the interval's text companions, an open-bounds
|
|
227
|
+
* byte and, for a temporal-typed attribute, the value's text companion.
|
|
228
|
+
* @param domain - the domain the element column refers to
|
|
229
|
+
* @param value - the value column's declaration fields (dtype, itemDtype, options...)
|
|
230
|
+
* @param temporalValue - whether the value is itself a temporal type needing a text companion
|
|
231
|
+
* @returns the declarations in table order
|
|
232
|
+
*/
|
|
233
|
+
export function temporalTableDecls(domain, value, temporalValue) {
|
|
234
|
+
const decls = [
|
|
235
|
+
{ name: TEMPORAL_COLUMNS.element, dtype: "u32", refersTo: domain, nullable: false },
|
|
236
|
+
{ name: TEMPORAL_COLUMNS.start, dtype: "f64", role: "start", nullable: true },
|
|
237
|
+
{ name: TEMPORAL_COLUMNS.end, dtype: "f64", role: "end", nullable: true },
|
|
238
|
+
{ name: TEMPORAL_COLUMNS.value, ...value, nullable: true },
|
|
239
|
+
{
|
|
240
|
+
name: TEMPORAL_COLUMNS.startText,
|
|
241
|
+
dtype: "string",
|
|
242
|
+
role: TIME_TEXT_ROLE,
|
|
243
|
+
nullable: true,
|
|
244
|
+
extra: { for: TEMPORAL_COLUMNS.start },
|
|
245
|
+
},
|
|
246
|
+
{ name: TEMPORAL_COLUMNS.endText, dtype: "string", nullable: true, extra: { for: TEMPORAL_COLUMNS.end } },
|
|
247
|
+
{ name: TEMPORAL_COLUMNS.open, dtype: "u8", role: "open", nullable: true },
|
|
248
|
+
];
|
|
249
|
+
if (temporalValue) {
|
|
250
|
+
decls.push({
|
|
251
|
+
name: TEMPORAL_COLUMNS.valueText,
|
|
252
|
+
dtype: "string",
|
|
253
|
+
nullable: true,
|
|
254
|
+
extra: { for: TEMPORAL_COLUMNS.value },
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
return decls;
|
|
258
|
+
}
|
|
259
|
+
/** The scalar type names GEXF 1.2 declares. */
|
|
260
|
+
const TYPES_1_2 = new Set(["integer", "long", "double", "float", "boolean", "string", "anyURI"]);
|
|
261
|
+
/** The scalar type names GEXF 1.3 declares (the list variants are derived). */
|
|
262
|
+
const TYPES_1_3 = new Set([
|
|
263
|
+
...TYPES_1_2,
|
|
264
|
+
"bigdecimal",
|
|
265
|
+
"biginteger",
|
|
266
|
+
"byte",
|
|
267
|
+
"char",
|
|
268
|
+
"short",
|
|
269
|
+
"date",
|
|
270
|
+
"dateTime",
|
|
271
|
+
]);
|
|
272
|
+
/**
|
|
273
|
+
* Whether a declared type text is a scalar type of a version (case-sensitive, as the schema spells
|
|
274
|
+
* them).
|
|
275
|
+
* @param type - the type text
|
|
276
|
+
* @param version - the target version
|
|
277
|
+
* @returns true when the version declares it
|
|
278
|
+
*/
|
|
279
|
+
export function isScalarType(type, version) {
|
|
280
|
+
return (version === "1.2" ? TYPES_1_2 : TYPES_1_3).has(type);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Whether a declared type text is a list type of a version: `liststring` in 1.2, `list<scalar>` in 1.3.
|
|
284
|
+
* @param type - the type text
|
|
285
|
+
* @param version - the target version
|
|
286
|
+
* @returns true when the version declares it
|
|
287
|
+
*/
|
|
288
|
+
export function isListType(type, version) {
|
|
289
|
+
if (version === "1.2") {
|
|
290
|
+
return type === "liststring";
|
|
291
|
+
}
|
|
292
|
+
return type.startsWith("list") && type.length > 4 && isScalarType(type.slice(4), "1.3");
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* The canonical GEXF scalar type of a column dtype (design section 5.1 reversed).
|
|
296
|
+
* @param dtype - a scalar dtype
|
|
297
|
+
* @returns the type text; u32 becomes `long` (its range exceeds `integer`), u8 `integer`, json `string`
|
|
298
|
+
*/
|
|
299
|
+
export function canonicalScalarType(dtype) {
|
|
300
|
+
switch (dtype) {
|
|
301
|
+
case "bool":
|
|
302
|
+
return "boolean";
|
|
303
|
+
case "i32":
|
|
304
|
+
case "u8":
|
|
305
|
+
return "integer";
|
|
306
|
+
case "u32":
|
|
307
|
+
return "long";
|
|
308
|
+
case "f32":
|
|
309
|
+
return "float";
|
|
310
|
+
case "f64":
|
|
311
|
+
return "double";
|
|
312
|
+
case "dict":
|
|
313
|
+
case "string":
|
|
314
|
+
case "json":
|
|
315
|
+
case "list":
|
|
316
|
+
return "string";
|
|
317
|
+
default: {
|
|
318
|
+
const name = dtype;
|
|
319
|
+
return name;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/formats/gexf/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAK5E,uBAAuB;AACvB,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC;AAElC,0CAA0C;AAC1C,MAAM,CAAC,MAAM,eAAe,GAAmF;IAC3G,KAAK,EAAE,EAAE,IAAI,EAAE,8BAA8B,EAAE,GAAG,EAAE,kCAAkC,EAAE;IACxF,KAAK,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,GAAG,EAAE,yBAAyB,EAAE;CACzE,CAAC;AAKF,oCAAoC;AACpC,MAAM,CAAC,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAEpG,oCAAoC;AACpC,MAAM,CAAC,MAAM,WAAW,GAAwB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;AAExF,gDAAgD;AAChD,MAAM,CAAC,MAAM,oBAAoB,GAAwB,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;AAE5F,qDAAqD;AACrD,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AAEnC,oDAAoD;AACpD,MAAM,UAAU,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAE3C,8CAA8C;AAC9C,MAAM,UAAU,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,C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ACpB,OAAO,CAAC,CAAC,CAAC;YACN,MAAM,IAAI,GAAW,KAAK,CAAC;YAC3B,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The GML exporter (design section 8.5, research note 07 sections 2.2 and 9): writes a snapshot in
|
|
3
|
+
* the NetworkX dialect of GML. Node ids must be integers (`idCharset: "integer"`; `sanitizeIds:
|
|
4
|
+
* "mangle"` renumbers the others and keeps the original in a `graphty_originalId` key the importer
|
|
5
|
+
* restores); columns are written per dtype (`int` for the integer dtypes, `real` with a decimal
|
|
6
|
+
* point guaranteed for f32 / f64 so the dtype survives a re-import, quoted strings with `&#NN;`
|
|
7
|
+
* references, repeated keys for lists with the `_networkx_list_start` marker for one-element
|
|
8
|
+
* lists and `"[]"` for empty ones, nested records for json objects); the position role becomes
|
|
9
|
+
* `graphics [ x y z ]` merged with the node's `graphics` json record; graph columns are written
|
|
10
|
+
* inside `graph [ ]` (or at the top level when the importer found them there); `Creator` and
|
|
11
|
+
* `Version` come from the metadata.
|
|
12
|
+
*
|
|
13
|
+
* check() reports, before anything is written, the capability gaps of the common check plus the
|
|
14
|
+
* GML-specific ones: json columns holding numbers (JSON cannot keep the int / real distinction:
|
|
15
|
+
* `W_GML_RECORD_NUMBER_TYPE`), booleans (written 1 / 0) or nulls (omitted), arrays nested in
|
|
16
|
+
* arrays (no GML spelling; export() throws), column names and record keys that are not GML keys
|
|
17
|
+
* or collide with the structural keys (`E_GML_INVALID_KEY` / `E_GML_RESERVED_KEY`, or
|
|
18
|
+
* `W_GML_KEY_MANGLED` under `sanitizeKeys: "mangle"`), and graphics / position overlaps.
|
|
19
|
+
*/
|
|
20
|
+
import { type GraphExporter } from "../../types.js";
|
|
21
|
+
/** The format-specific options of the GML exporter. */
|
|
22
|
+
export interface GmlExportOptions {
|
|
23
|
+
/**
|
|
24
|
+
* The edge key explicit weights are written under; by default the key the GML importer read
|
|
25
|
+
* them from (`meta.weightOrigin.id` when the snapshot came from GML), else `value`.
|
|
26
|
+
*/
|
|
27
|
+
weightKey?: string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* "error" (default): a column name or record key that is not a GML key (`[A-Za-z][0-9A-Za-z_]*`)
|
|
30
|
+
* or collides with a structural key makes export() throw; "mangle": such keys are rewritten
|
|
31
|
+
* (`.` and other characters become `_`, collisions get a `_2` suffix) and check() reports them.
|
|
32
|
+
*/
|
|
33
|
+
sanitizeKeys?: "error" | "mangle" | undefined;
|
|
34
|
+
}
|
|
35
|
+
/** Loss code: a json column holds numbers; JSON cannot keep GML's int / real distinction (design section 8.5). */
|
|
36
|
+
export declare const RECORD_NUMBER_TYPE_CODE = "W_GML_RECORD_NUMBER_TYPE";
|
|
37
|
+
/** Loss code: a json column holds booleans, written as 1 / 0. */
|
|
38
|
+
export declare const RECORD_BOOLEAN_CODE = "W_GML_RECORD_BOOLEAN";
|
|
39
|
+
/** Loss code: a json column holds nulls, which GML cannot write; the key (or the row) is omitted. */
|
|
40
|
+
export declare const RECORD_NULL_CODE = "W_GML_RECORD_NULL";
|
|
41
|
+
/** Loss code: a json column holds an array inside an array, which GML cannot write; export() throws. */
|
|
42
|
+
export declare const NESTED_ARRAY_CODE = "E_GML_NESTED_ARRAY";
|
|
43
|
+
/** Loss code: a json column holds arrays as row values; written as repeated keys, they re-import as a list column. */
|
|
44
|
+
export declare const JSON_ARRAY_CODE = "W_GML_JSON_ARRAY";
|
|
45
|
+
/** Loss code: a column name or record key is not a GML key; export() throws unless sanitizeKeys is "mangle". */
|
|
46
|
+
export declare const INVALID_KEY_CODE = "E_GML_INVALID_KEY";
|
|
47
|
+
/** Loss code: a column name collides with a structural GML key; export() throws unless sanitizeKeys is "mangle". */
|
|
48
|
+
export declare const RESERVED_KEY_CODE = "E_GML_RESERVED_KEY";
|
|
49
|
+
/** Loss code: keys rewritten under sanitizeKeys "mangle". */
|
|
50
|
+
export declare const KEY_MANGLED_CODE = "W_GML_KEY_MANGLED";
|
|
51
|
+
/** Loss code: a position column with more than three components; x, y and z are written. */
|
|
52
|
+
export declare const POSITION_COMPONENTS_CODE = "W_GML_POSITION_COMPONENTS";
|
|
53
|
+
/** Loss code: a node's graphics record has x / y / z keys the position column replaces. */
|
|
54
|
+
export declare const GRAPHICS_OVERRIDDEN_CODE = "W_GML_GRAPHICS_OVERRIDDEN";
|
|
55
|
+
/** Loss code: a node's graphics value is not a record and cannot hold the position; export() throws. */
|
|
56
|
+
export declare const GRAPHICS_CONFLICT_CODE = "E_GML_GRAPHICS_CONFLICT";
|
|
57
|
+
/** The default weight key (design section 8.4: GML weights are read from `value` by default). */
|
|
58
|
+
export declare const DEFAULT_WEIGHT_KEY = "value";
|
|
59
|
+
/**
|
|
60
|
+
* The GML text of a real: the shortest text of the dtype with a decimal point guaranteed
|
|
61
|
+
* (`2.0`, `1.0e-7`), the NetworkX spellings `+INF` / `-INF` / `NAN` for the non-finite values.
|
|
62
|
+
* @param value - the value
|
|
63
|
+
* @param dtype - the dtype the value came from (f32 uses the fround-shortest text)
|
|
64
|
+
* @returns the text
|
|
65
|
+
*/
|
|
66
|
+
export declare function gmlRealText(value: number, dtype?: "f32" | "f64" | "i32" | "u32" | "u8"): string;
|
|
67
|
+
/** The GML exporter plugin. */
|
|
68
|
+
export declare const gmlExporter: GraphExporter<GmlExportOptions>;
|
|
69
|
+
//# sourceMappingURL=exporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exporter.d.ts","sourceRoot":"","sources":["../../../../src/formats/gml/exporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AA0BH,OAAO,EAAqD,KAAK,aAAa,EAAiB,MAAM,gBAAgB,CAAC;AAGtH,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B;;;;OAIG;IACH,YAAY,CAA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