@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.
Files changed (339) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +250 -28
  3. package/dist/chunks/children-CL3Cy0ez.js +238 -0
  4. package/dist/chunks/children-CL3Cy0ez.js.map +1 -0
  5. package/dist/chunks/escape-DyI8JofU.js +938 -0
  6. package/dist/chunks/escape-DyI8JofU.js.map +1 -0
  7. package/dist/chunks/importer-CQnJuWJw.js +2987 -0
  8. package/dist/chunks/importer-CQnJuWJw.js.map +1 -0
  9. package/dist/chunks/importer-CpCpfbxr.js +2015 -0
  10. package/dist/chunks/importer-CpCpfbxr.js.map +1 -0
  11. package/dist/chunks/importer-DbnGYr3_.js +2342 -0
  12. package/dist/chunks/importer-DbnGYr3_.js.map +1 -0
  13. package/dist/chunks/importer-GozH8DkN.js +3050 -0
  14. package/dist/chunks/importer-GozH8DkN.js.map +1 -0
  15. package/dist/chunks/records-CGpxszm1.js +605 -0
  16. package/dist/chunks/records-CGpxszm1.js.map +1 -0
  17. package/dist/chunks/text-CajMdVFy.js +189 -0
  18. package/dist/chunks/text-CajMdVFy.js.map +1 -0
  19. package/dist/chunks/writer-DxSKC7TL.js +2842 -0
  20. package/dist/chunks/writer-DxSKC7TL.js.map +1 -0
  21. package/dist/csv.d.ts +1 -0
  22. package/dist/csv.js +1702 -0
  23. package/dist/csv.js.map +1 -0
  24. package/dist/dot.d.ts +1 -0
  25. package/dist/dot.js +8 -0
  26. package/dist/dot.js.map +1 -0
  27. package/dist/gexf.d.ts +1 -0
  28. package/dist/gexf.js +3466 -0
  29. package/dist/gexf.js.map +1 -0
  30. package/dist/gml.d.ts +1 -0
  31. package/dist/gml.js +2647 -0
  32. package/dist/gml.js.map +1 -0
  33. package/dist/graph-io.d.ts +1 -0
  34. package/dist/graph-io.js +790 -0
  35. package/dist/graph-io.js.map +1 -0
  36. package/dist/graphml.d.ts +1 -0
  37. package/dist/graphml.js +8 -0
  38. package/dist/graphml.js.map +1 -0
  39. package/dist/json.d.ts +1 -0
  40. package/dist/json.js +11 -0
  41. package/dist/json.js.map +1 -0
  42. package/dist/neo4j.d.ts +1 -0
  43. package/dist/neo4j.js +2046 -0
  44. package/dist/neo4j.js.map +1 -0
  45. package/dist/pajek.d.ts +1 -0
  46. package/dist/pajek.js +8 -0
  47. package/dist/pajek.js.map +1 -0
  48. package/dist/src/children.d.ts +134 -0
  49. package/dist/src/children.d.ts.map +1 -0
  50. package/dist/src/children.js +274 -0
  51. package/dist/src/children.js.map +1 -0
  52. package/dist/src/common/attributes.d.ts +229 -0
  53. package/dist/src/common/attributes.d.ts.map +1 -0
  54. package/dist/src/common/attributes.js +368 -0
  55. package/dist/src/common/attributes.js.map +1 -0
  56. package/dist/src/common/codes.d.ts +105 -0
  57. package/dist/src/common/codes.d.ts.map +1 -0
  58. package/dist/src/common/codes.js +107 -0
  59. package/dist/src/common/codes.js.map +1 -0
  60. package/dist/src/common/declared-types.d.ts +84 -0
  61. package/dist/src/common/declared-types.d.ts.map +1 -0
  62. package/dist/src/common/declared-types.js +326 -0
  63. package/dist/src/common/declared-types.js.map +1 -0
  64. package/dist/src/common/direction.d.ts +206 -0
  65. package/dist/src/common/direction.d.ts.map +1 -0
  66. package/dist/src/common/direction.js +370 -0
  67. package/dist/src/common/direction.js.map +1 -0
  68. package/dist/src/common/escape.d.ts +92 -0
  69. package/dist/src/common/escape.d.ts.map +1 -0
  70. package/dist/src/common/escape.js +212 -0
  71. package/dist/src/common/escape.js.map +1 -0
  72. package/dist/src/common/export.d.ts +249 -0
  73. package/dist/src/common/export.d.ts.map +1 -0
  74. package/dist/src/common/export.js +594 -0
  75. package/dist/src/common/export.js.map +1 -0
  76. package/dist/src/common/format.d.ts +59 -0
  77. package/dist/src/common/format.d.ts.map +1 -0
  78. package/dist/src/common/format.js +106 -0
  79. package/dist/src/common/format.js.map +1 -0
  80. package/dist/src/common/ids.d.ts +83 -0
  81. package/dist/src/common/ids.d.ts.map +1 -0
  82. package/dist/src/common/ids.js +158 -0
  83. package/dist/src/common/ids.js.map +1 -0
  84. package/dist/src/common/input.d.ts +100 -0
  85. package/dist/src/common/input.d.ts.map +1 -0
  86. package/dist/src/common/input.js +335 -0
  87. package/dist/src/common/input.js.map +1 -0
  88. package/dist/src/common/lists.d.ts +34 -0
  89. package/dist/src/common/lists.d.ts.map +1 -0
  90. package/dist/src/common/lists.js +185 -0
  91. package/dist/src/common/lists.js.map +1 -0
  92. package/dist/src/common/options.d.ts +108 -0
  93. package/dist/src/common/options.d.ts.map +1 -0
  94. package/dist/src/common/options.js +265 -0
  95. package/dist/src/common/options.js.map +1 -0
  96. package/dist/src/common/report.d.ts +187 -0
  97. package/dist/src/common/report.d.ts.map +1 -0
  98. package/dist/src/common/report.js +274 -0
  99. package/dist/src/common/report.js.map +1 -0
  100. package/dist/src/common/temporal.d.ts +71 -0
  101. package/dist/src/common/temporal.d.ts.map +1 -0
  102. package/dist/src/common/temporal.js +266 -0
  103. package/dist/src/common/temporal.js.map +1 -0
  104. package/dist/src/common/text.d.ts +104 -0
  105. package/dist/src/common/text.d.ts.map +1 -0
  106. package/dist/src/common/text.js +255 -0
  107. package/dist/src/common/text.js.map +1 -0
  108. package/dist/src/common/weights.d.ts +77 -0
  109. package/dist/src/common/weights.d.ts.map +1 -0
  110. package/dist/src/common/weights.js +156 -0
  111. package/dist/src/common/weights.js.map +1 -0
  112. package/dist/src/common/writer.d.ts +51 -0
  113. package/dist/src/common/writer.d.ts.map +1 -0
  114. package/dist/src/common/writer.js +108 -0
  115. package/dist/src/common/writer.js.map +1 -0
  116. package/dist/src/common/xml.d.ts +245 -0
  117. package/dist/src/common/xml.d.ts.map +1 -0
  118. package/dist/src/common/xml.js +942 -0
  119. package/dist/src/common/xml.js.map +1 -0
  120. package/dist/src/formats/csv/exporter.d.ts +70 -0
  121. package/dist/src/formats/csv/exporter.d.ts.map +1 -0
  122. package/dist/src/formats/csv/exporter.js +682 -0
  123. package/dist/src/formats/csv/exporter.js.map +1 -0
  124. package/dist/src/formats/csv/header.d.ts +66 -0
  125. package/dist/src/formats/csv/header.d.ts.map +1 -0
  126. package/dist/src/formats/csv/header.js +152 -0
  127. package/dist/src/formats/csv/header.js.map +1 -0
  128. package/dist/src/formats/csv/importer.d.ts +82 -0
  129. package/dist/src/formats/csv/importer.d.ts.map +1 -0
  130. package/dist/src/formats/csv/importer.js +849 -0
  131. package/dist/src/formats/csv/importer.js.map +1 -0
  132. package/dist/src/formats/csv/index.d.ts +60 -0
  133. package/dist/src/formats/csv/index.d.ts.map +1 -0
  134. package/dist/src/formats/csv/index.js +63 -0
  135. package/dist/src/formats/csv/index.js.map +1 -0
  136. package/dist/src/formats/csv/records.d.ts +188 -0
  137. package/dist/src/formats/csv/records.d.ts.map +1 -0
  138. package/dist/src/formats/csv/records.js +702 -0
  139. package/dist/src/formats/csv/records.js.map +1 -0
  140. package/dist/src/formats/csv/values.d.ts +105 -0
  141. package/dist/src/formats/csv/values.d.ts.map +1 -0
  142. package/dist/src/formats/csv/values.js +192 -0
  143. package/dist/src/formats/csv/values.js.map +1 -0
  144. package/dist/src/formats/dot/exporter.d.ts +52 -0
  145. package/dist/src/formats/dot/exporter.d.ts.map +1 -0
  146. package/dist/src/formats/dot/exporter.js +836 -0
  147. package/dist/src/formats/dot/exporter.js.map +1 -0
  148. package/dist/src/formats/dot/importer.d.ts +102 -0
  149. package/dist/src/formats/dot/importer.d.ts.map +1 -0
  150. package/dist/src/formats/dot/importer.js +1291 -0
  151. package/dist/src/formats/dot/importer.js.map +1 -0
  152. package/dist/src/formats/dot/index.d.ts +7 -0
  153. package/dist/src/formats/dot/index.d.ts.map +1 -0
  154. package/dist/src/formats/dot/index.js +7 -0
  155. package/dist/src/formats/dot/index.js.map +1 -0
  156. package/dist/src/formats/dot/names.d.ts +29 -0
  157. package/dist/src/formats/dot/names.d.ts.map +1 -0
  158. package/dist/src/formats/dot/names.js +28 -0
  159. package/dist/src/formats/dot/names.js.map +1 -0
  160. package/dist/src/formats/dot/tokenizer.d.ts +114 -0
  161. package/dist/src/formats/dot/tokenizer.d.ts.map +1 -0
  162. package/dist/src/formats/dot/tokenizer.js +341 -0
  163. package/dist/src/formats/dot/tokenizer.js.map +1 -0
  164. package/dist/src/formats/gexf/exporter.d.ts +56 -0
  165. package/dist/src/formats/gexf/exporter.d.ts.map +1 -0
  166. package/dist/src/formats/gexf/exporter.js +1395 -0
  167. package/dist/src/formats/gexf/exporter.js.map +1 -0
  168. package/dist/src/formats/gexf/importer.d.ts +73 -0
  169. package/dist/src/formats/gexf/importer.d.ts.map +1 -0
  170. package/dist/src/formats/gexf/importer.js +1880 -0
  171. package/dist/src/formats/gexf/importer.js.map +1 -0
  172. package/dist/src/formats/gexf/index.d.ts +96 -0
  173. package/dist/src/formats/gexf/index.d.ts.map +1 -0
  174. package/dist/src/formats/gexf/index.js +97 -0
  175. package/dist/src/formats/gexf/index.js.map +1 -0
  176. package/dist/src/formats/gexf/schema.d.ts +135 -0
  177. package/dist/src/formats/gexf/schema.d.ts.map +1 -0
  178. package/dist/src/formats/gexf/schema.js +323 -0
  179. package/dist/src/formats/gexf/schema.js.map +1 -0
  180. package/dist/src/formats/gml/exporter.d.ts +69 -0
  181. package/dist/src/formats/gml/exporter.d.ts.map +1 -0
  182. package/dist/src/formats/gml/exporter.js +1093 -0
  183. package/dist/src/formats/gml/exporter.js.map +1 -0
  184. package/dist/src/formats/gml/importer.d.ts +66 -0
  185. package/dist/src/formats/gml/importer.d.ts.map +1 -0
  186. package/dist/src/formats/gml/importer.js +1331 -0
  187. package/dist/src/formats/gml/importer.js.map +1 -0
  188. package/dist/src/formats/gml/index.d.ts +85 -0
  189. package/dist/src/formats/gml/index.d.ts.map +1 -0
  190. package/dist/src/formats/gml/index.js +88 -0
  191. package/dist/src/formats/gml/index.js.map +1 -0
  192. package/dist/src/formats/gml/syntax.d.ts +186 -0
  193. package/dist/src/formats/gml/syntax.d.ts.map +1 -0
  194. package/dist/src/formats/gml/syntax.js +467 -0
  195. package/dist/src/formats/gml/syntax.js.map +1 -0
  196. package/dist/src/formats/graphml/constants.d.ts +169 -0
  197. package/dist/src/formats/graphml/constants.d.ts.map +1 -0
  198. package/dist/src/formats/graphml/constants.js +165 -0
  199. package/dist/src/formats/graphml/constants.js.map +1 -0
  200. package/dist/src/formats/graphml/exporter.d.ts +34 -0
  201. package/dist/src/formats/graphml/exporter.d.ts.map +1 -0
  202. package/dist/src/formats/graphml/exporter.js +1176 -0
  203. package/dist/src/formats/graphml/exporter.js.map +1 -0
  204. package/dist/src/formats/graphml/importer.d.ts +31 -0
  205. package/dist/src/formats/graphml/importer.d.ts.map +1 -0
  206. package/dist/src/formats/graphml/importer.js +1607 -0
  207. package/dist/src/formats/graphml/importer.js.map +1 -0
  208. package/dist/src/formats/graphml/index.d.ts +8 -0
  209. package/dist/src/formats/graphml/index.d.ts.map +1 -0
  210. package/dist/src/formats/graphml/index.js +8 -0
  211. package/dist/src/formats/graphml/index.js.map +1 -0
  212. package/dist/src/formats/graphml/tree.d.ts +72 -0
  213. package/dist/src/formats/graphml/tree.d.ts.map +1 -0
  214. package/dist/src/formats/graphml/tree.js +290 -0
  215. package/dist/src/formats/graphml/tree.js.map +1 -0
  216. package/dist/src/formats/json/dialect.d.ts +125 -0
  217. package/dist/src/formats/json/dialect.d.ts.map +1 -0
  218. package/dist/src/formats/json/dialect.js +262 -0
  219. package/dist/src/formats/json/dialect.js.map +1 -0
  220. package/dist/src/formats/json/exporter.d.ts +89 -0
  221. package/dist/src/formats/json/exporter.d.ts.map +1 -0
  222. package/dist/src/formats/json/exporter.js +1358 -0
  223. package/dist/src/formats/json/exporter.js.map +1 -0
  224. package/dist/src/formats/json/importer.d.ts +108 -0
  225. package/dist/src/formats/json/importer.d.ts.map +1 -0
  226. package/dist/src/formats/json/importer.js +1838 -0
  227. package/dist/src/formats/json/importer.js.map +1 -0
  228. package/dist/src/formats/json/index.d.ts +8 -0
  229. package/dist/src/formats/json/index.d.ts.map +1 -0
  230. package/dist/src/formats/json/index.js +8 -0
  231. package/dist/src/formats/json/index.js.map +1 -0
  232. package/dist/src/formats/neo4j/exporter.d.ts +68 -0
  233. package/dist/src/formats/neo4j/exporter.d.ts.map +1 -0
  234. package/dist/src/formats/neo4j/exporter.js +1055 -0
  235. package/dist/src/formats/neo4j/exporter.js.map +1 -0
  236. package/dist/src/formats/neo4j/header.d.ts +52 -0
  237. package/dist/src/formats/neo4j/header.d.ts.map +1 -0
  238. package/dist/src/formats/neo4j/header.js +131 -0
  239. package/dist/src/formats/neo4j/header.js.map +1 -0
  240. package/dist/src/formats/neo4j/importer.d.ts +73 -0
  241. package/dist/src/formats/neo4j/importer.d.ts.map +1 -0
  242. package/dist/src/formats/neo4j/importer.js +932 -0
  243. package/dist/src/formats/neo4j/importer.js.map +1 -0
  244. package/dist/src/formats/neo4j/index.d.ts +79 -0
  245. package/dist/src/formats/neo4j/index.d.ts.map +1 -0
  246. package/dist/src/formats/neo4j/index.js +83 -0
  247. package/dist/src/formats/neo4j/index.js.map +1 -0
  248. package/dist/src/formats/pajek/exporter.d.ts +58 -0
  249. package/dist/src/formats/pajek/exporter.d.ts.map +1 -0
  250. package/dist/src/formats/pajek/exporter.js +825 -0
  251. package/dist/src/formats/pajek/exporter.js.map +1 -0
  252. package/dist/src/formats/pajek/importer.d.ts +88 -0
  253. package/dist/src/formats/pajek/importer.d.ts.map +1 -0
  254. package/dist/src/formats/pajek/importer.js +1047 -0
  255. package/dist/src/formats/pajek/importer.js.map +1 -0
  256. package/dist/src/formats/pajek/index.d.ts +7 -0
  257. package/dist/src/formats/pajek/index.d.ts.map +1 -0
  258. package/dist/src/formats/pajek/index.js +7 -0
  259. package/dist/src/formats/pajek/index.js.map +1 -0
  260. package/dist/src/formats/pajek/syntax.d.ts +112 -0
  261. package/dist/src/formats/pajek/syntax.d.ts.map +1 -0
  262. package/dist/src/formats/pajek/syntax.js +269 -0
  263. package/dist/src/formats/pajek/syntax.js.map +1 -0
  264. package/dist/src/index.d.ts +35 -0
  265. package/dist/src/index.d.ts.map +1 -0
  266. package/dist/src/index.js +39 -0
  267. package/dist/src/index.js.map +1 -0
  268. package/dist/src/registry.d.ts +207 -0
  269. package/dist/src/registry.d.ts.map +1 -0
  270. package/dist/src/registry.js +481 -0
  271. package/dist/src/registry.js.map +1 -0
  272. package/dist/src/sniff.d.ts +104 -0
  273. package/dist/src/sniff.d.ts.map +1 -0
  274. package/dist/src/sniff.js +357 -0
  275. package/dist/src/sniff.js.map +1 -0
  276. package/dist/src/types.d.ts +238 -0
  277. package/dist/src/types.d.ts.map +1 -0
  278. package/dist/src/types.js +29 -0
  279. package/dist/src/types.js.map +1 -0
  280. package/dist/tsconfig.build.tsbuildinfo +1 -0
  281. package/package.json +122 -7
  282. package/src/children.ts +335 -0
  283. package/src/common/attributes.ts +520 -0
  284. package/src/common/codes.ts +153 -0
  285. package/src/common/declared-types.ts +374 -0
  286. package/src/common/direction.ts +518 -0
  287. package/src/common/escape.ts +231 -0
  288. package/src/common/export.ts +817 -0
  289. package/src/common/format.ts +111 -0
  290. package/src/common/ids.ts +176 -0
  291. package/src/common/input.ts +378 -0
  292. package/src/common/lists.ts +196 -0
  293. package/src/common/options.ts +377 -0
  294. package/src/common/report.ts +352 -0
  295. package/src/common/temporal.ts +302 -0
  296. package/src/common/text.ts +294 -0
  297. package/src/common/weights.ts +202 -0
  298. package/src/common/writer.ts +123 -0
  299. package/src/common/xml.ts +1053 -0
  300. package/src/formats/csv/exporter.ts +894 -0
  301. package/src/formats/csv/header.ts +172 -0
  302. package/src/formats/csv/importer.ts +1104 -0
  303. package/src/formats/csv/index.ts +88 -0
  304. package/src/formats/csv/records.ts +813 -0
  305. package/src/formats/csv/values.ts +224 -0
  306. package/src/formats/dot/exporter.ts +1014 -0
  307. package/src/formats/dot/importer.ts +1549 -0
  308. package/src/formats/dot/index.ts +7 -0
  309. package/src/formats/dot/names.ts +40 -0
  310. package/src/formats/dot/tokenizer.ts +384 -0
  311. package/src/formats/gexf/exporter.ts +1696 -0
  312. package/src/formats/gexf/importer.ts +2333 -0
  313. package/src/formats/gexf/index.ts +142 -0
  314. package/src/formats/gexf/schema.ts +361 -0
  315. package/src/formats/gml/exporter.ts +1404 -0
  316. package/src/formats/gml/importer.ts +1591 -0
  317. package/src/formats/gml/index.ts +128 -0
  318. package/src/formats/gml/syntax.ts +545 -0
  319. package/src/formats/graphml/constants.ts +225 -0
  320. package/src/formats/graphml/exporter.ts +1458 -0
  321. package/src/formats/graphml/importer.ts +2027 -0
  322. package/src/formats/graphml/index.ts +8 -0
  323. package/src/formats/graphml/tree.ts +318 -0
  324. package/src/formats/json/dialect.ts +317 -0
  325. package/src/formats/json/exporter.ts +1616 -0
  326. package/src/formats/json/importer.ts +2271 -0
  327. package/src/formats/json/index.ts +8 -0
  328. package/src/formats/neo4j/exporter.ts +1287 -0
  329. package/src/formats/neo4j/header.ts +156 -0
  330. package/src/formats/neo4j/importer.ts +1220 -0
  331. package/src/formats/neo4j/index.ts +116 -0
  332. package/src/formats/pajek/exporter.ts +1000 -0
  333. package/src/formats/pajek/importer.ts +1311 -0
  334. package/src/formats/pajek/index.ts +7 -0
  335. package/src/formats/pajek/syntax.ts +307 -0
  336. package/src/index.ts +244 -0
  337. package/src/registry.ts +617 -0
  338. package/src/sniff.ts +397 -0
  339. package/src/types.ts +262 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialect.d.ts","sourceRoot":"","sources":["../../../../src/formats/json/dialect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,qDAAqD;AACrD,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,IAAI,GAAG,KAAK,GAAG,WAAW,GAAG,YAAY,GAAG,KAAK,CAAC;AAE1F,4DA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EAAE,MAAM,GAAG,OAAO,CAEtF;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAsClE;AAeD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,aAAa,CAoB1D;AAED,2GAA2G;AAC3G,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAO1E,CAAC;AAuEH;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,GAAG,kBAAkB,CAE5E;AAED,2FAA2F;AAC3F,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,CASrD,CAAC;AAEH,wFAAwF;AACxF,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,MAAM,CAAqD,CAAC;AAEhH;;;;GAIG;AACH,eAAO,MAAM,MAAM;IACf,qGAAqG;;IAErG,qFAAqF;;EAEvF,CAAC;AAEH,gGAAgG;AAChG,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAA6C,CAAC;AAEjG,0EAA0E;AAC1E,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAA2C,CAAC;AAE/F,8FAA8F;AAC9F,eAAO,MAAM,eAAe,aAAa,CAAC;AAE1C,wFAAwF;AACxF,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC,kFAAkF;AAClF,eAAO,MAAM,aAAa,WAAW,CAAC"}
@@ -0,0 +1,262 @@
1
+ /**
2
+ * What the JSON importer and exporter share (design sections 8.2 and 8.5): the dialect names, the
3
+ * reserved `meta.extra.json` shape record the importer writes and the exporter reads back, the
4
+ * per-dialect capability tables, the fixed key sets of each dialect and the small JSON value
5
+ * helpers both sides use.
6
+ *
7
+ * Dialects: NetworkX node-link (`nodes` + `links` / `edges`, graph-level `directed` / `multigraph`
8
+ * / `graph`), the d3 lineage of the same shape (`links`, `name` ids, integer index endpoints),
9
+ * JSON Graph Format v2 (`graph.nodes` keyed by id, per-edge `directed`, hyperedges), Cytoscape.js
10
+ * elements (`data.id` / `data.source` / `data.target`, `position`, `classes`, `data.parent`),
11
+ * graphology serialisation (`key` / `attributes`, `undirected` edges, `options.type` / `multi`) and
12
+ * vis.js (`from` / `to`).
13
+ */
14
+ import { capabilities } from "../../common/export.js";
15
+ /** Every dialect name, for option checking and messages. */
16
+ export const JSON_DIALECTS = Object.freeze([
17
+ "node-link",
18
+ "d3",
19
+ "jgf",
20
+ "cytoscape",
21
+ "graphology",
22
+ "vis",
23
+ ]);
24
+ /** The key under `meta.extra` that holds the shape record (design section 8.5). */
25
+ export const META_KEY = "json";
26
+ /**
27
+ * Whether a value is a plain JSON object (not null, not an array).
28
+ * @param value - any value
29
+ * @returns true for an object that is not an array
30
+ */
31
+ export function isJsonObject(value) {
32
+ return typeof value === "object" && value !== null && !Array.isArray(value);
33
+ }
34
+ /**
35
+ * Whether a record has an own property; JSON.parse output is checked with hasOwnProperty so a key
36
+ * named "constructor" or "__proto__" is never read from the prototype.
37
+ * @param record - the record
38
+ * @param key - the key
39
+ * @returns true when the key is an own property
40
+ */
41
+ export function hasKey(record, key) {
42
+ return Object.prototype.hasOwnProperty.call(record, key);
43
+ }
44
+ /**
45
+ * Whether a text names a dialect.
46
+ * @param value - any value
47
+ * @returns true for one of JSON_DIALECTS
48
+ */
49
+ export function isJsonDialect(value) {
50
+ return typeof value === "string" && JSON_DIALECTS.includes(value);
51
+ }
52
+ /**
53
+ * The dialect of a parsed JSON document, by the shape rules of design section 8.2 (Cytoscape:
54
+ * `elements` or a top-level array of `{ data }` elements; JGF: `graph.nodes` / `graph.edges` or
55
+ * `graphs[]`; graphology: `options.type` / `options.multi`, `key` nodes without `id`, edges with
56
+ * `undirected` or an `attributes` record; vis: edges with `from` / `to`; d3: `links` without
57
+ * `directed` / `multigraph` / `graph`; else node-link). Pure: the importer wraps it with its issue
58
+ * codes, the registry's sniff() uses it on a head that parses as a whole document.
59
+ * @param root - the parsed document
60
+ * @returns the dialect, or null when the document is not a graph document in any dialect
61
+ */
62
+ export function sniffJsonDialect(root) {
63
+ if (Array.isArray(root)) {
64
+ const first = firstJsonObject(root);
65
+ return root.length === 0 || (first !== null && isJsonObject(first.data)) ? "cytoscape" : null;
66
+ }
67
+ if (!isJsonObject(root)) {
68
+ return null;
69
+ }
70
+ if (hasKey(root, "elements")) {
71
+ return "cytoscape";
72
+ }
73
+ if (isJsonObject(root.graph) && (hasKey(root.graph, "nodes") || hasKey(root.graph, "edges"))) {
74
+ return "jgf";
75
+ }
76
+ if (Array.isArray(root.graphs)) {
77
+ return "jgf";
78
+ }
79
+ if (!hasKey(root, "nodes") && !hasKey(root, "edges") && !hasKey(root, "links")) {
80
+ return null;
81
+ }
82
+ const firstNode = firstJsonObject(root.nodes);
83
+ const firstEdge = firstJsonObject(hasKey(root, "edges") ? root.edges : root.links);
84
+ if (isJsonObject(root.options) && (hasKey(root.options, "type") || hasKey(root.options, "multi"))) {
85
+ return "graphology";
86
+ }
87
+ if (firstNode !== null && hasKey(firstNode, "key") && !hasKey(firstNode, "id")) {
88
+ return "graphology";
89
+ }
90
+ if (firstEdge !== null && !hasKey(firstEdge, "from")) {
91
+ if (hasKey(firstEdge, "undirected") || isJsonObject(firstEdge.attributes)) {
92
+ return "graphology";
93
+ }
94
+ }
95
+ if (firstEdge !== null && hasKey(firstEdge, "from") && hasKey(firstEdge, "to") && !hasKey(firstEdge, "source")) {
96
+ return "vis";
97
+ }
98
+ const bare = !hasKey(root, "directed") && !hasKey(root, "multigraph") && !hasKey(root, "graph");
99
+ return bare && hasKey(root, "links") ? "d3" : "node-link";
100
+ }
101
+ /**
102
+ * The first object of an array, or null.
103
+ * @param value - maybe an array
104
+ * @returns the first element that is an object
105
+ */
106
+ function firstJsonObject(value) {
107
+ if (!Array.isArray(value)) {
108
+ return null;
109
+ }
110
+ const found = value.find((item) => isJsonObject(item));
111
+ return isJsonObject(found) ? found : null;
112
+ }
113
+ /**
114
+ * The shape record of a snapshot's metadata, or an empty record when the snapshot did not come
115
+ * from the JSON importer.
116
+ * @param meta - the snapshot's metadata
117
+ * @returns the fields found under `meta.extra.json`, each only when it has the expected type
118
+ */
119
+ export function shapeMetaOf(meta) {
120
+ const raw = meta.extra[META_KEY];
121
+ if (!isJsonObject(raw)) {
122
+ return {};
123
+ }
124
+ const text = (key) => (typeof raw[key] === "string" ? raw[key] : undefined);
125
+ const flag = (key) => (typeof raw[key] === "boolean" ? raw[key] : undefined);
126
+ const { nodeIdKey } = raw;
127
+ return {
128
+ dialect: isJsonDialect(raw.dialect) ? raw.dialect : undefined,
129
+ edgesKey: text("edgesKey"),
130
+ nodeIdKey: nodeIdKey === null || typeof nodeIdKey === "string" ? nodeIdKey : undefined,
131
+ indexLinks: flag("indexLinks"),
132
+ sourceKey: text("sourceKey"),
133
+ targetKey: text("targetKey"),
134
+ id: text("id"),
135
+ type: text("type"),
136
+ allowSelfLoops: flag("allowSelfLoops"),
137
+ cytoscape: isJsonObject(raw.cytoscape) ? raw.cytoscape : undefined,
138
+ };
139
+ }
140
+ /** The direction a dialect assumes when the file declares none (design section 8.4, `defaultDirected`). */
141
+ export const DIALECT_DEFAULT_DIRECTED = Object.freeze({
142
+ "node-link": false,
143
+ d3: false,
144
+ jgf: true,
145
+ cytoscape: true,
146
+ graphology: true,
147
+ vis: false,
148
+ });
149
+ /**
150
+ * The dtypes a JSON dialect keeps as declared: JSON declares no types, so a value reads back as
151
+ * what the importer's inference gives it (design section 5.1: integral numbers i32, other numbers
152
+ * f64, booleans, strings). f32 values re-read as f64 differ from the f32 ones, u32 / u8 come back
153
+ * i32, dict comes back string, a multi-component or list value comes back json.
154
+ */
155
+ const JSON_DTYPES = Object.freeze(["f64", "i32", "bool", "string"]);
156
+ const COMMON = {
157
+ multiEdges: true,
158
+ selfLoops: true,
159
+ idCharset: "any",
160
+ dtypes: JSON_DTYPES,
161
+ components: false,
162
+ lists: false,
163
+ json: true,
164
+ defaults: false,
165
+ options: false,
166
+ temporal: "none",
167
+ positions: false,
168
+ viz: false,
169
+ };
170
+ const TABLES = Object.freeze({
171
+ "node-link": capabilities({
172
+ ...COMMON,
173
+ mixedDirection: false,
174
+ edgeIds: "none",
175
+ hierarchy: false,
176
+ graphAttributes: true,
177
+ }),
178
+ d3: capabilities({
179
+ ...COMMON,
180
+ mixedDirection: false,
181
+ edgeIds: "none",
182
+ hierarchy: false,
183
+ graphAttributes: false,
184
+ }),
185
+ jgf: capabilities({
186
+ ...COMMON,
187
+ mixedDirection: true,
188
+ edgeIds: "optional",
189
+ hierarchy: false,
190
+ graphAttributes: true,
191
+ }),
192
+ cytoscape: capabilities({
193
+ ...COMMON,
194
+ positions: true,
195
+ mixedDirection: false,
196
+ edgeIds: "required",
197
+ hierarchy: true,
198
+ graphAttributes: true,
199
+ }),
200
+ graphology: capabilities({
201
+ ...COMMON,
202
+ mixedDirection: true,
203
+ edgeIds: "optional",
204
+ hierarchy: false,
205
+ graphAttributes: true,
206
+ }),
207
+ vis: capabilities({
208
+ ...COMMON,
209
+ mixedDirection: false,
210
+ edgeIds: "optional",
211
+ hierarchy: false,
212
+ graphAttributes: false,
213
+ }),
214
+ });
215
+ /**
216
+ * What one dialect can express (design section 8.5): positions and visual columns are written as
217
+ * plain attributes (an array for a multi-component column) and read back without their role,
218
+ * except Cytoscape's `position` object; containment only as the Cytoscape `data.parent`; mixed
219
+ * direction only where the dialect carries a per-edge flag (JGF `directed`, graphology
220
+ * `undirected`); edge ids where the dialect has a slot (not node-link / d3); nothing temporal;
221
+ * graph attributes everywhere but d3 (the bare shape) and vis.
222
+ * @param dialect - the dialect
223
+ * @returns its frozen capability table
224
+ */
225
+ export function dialectCapabilities(dialect) {
226
+ return TABLES[dialect];
227
+ }
228
+ /** The Cytoscape element-level keys (everything else on an element lives under `data`). */
229
+ export const CYTOSCAPE_ELEMENT_KEYS = new Set([
230
+ "selected",
231
+ "selectable",
232
+ "locked",
233
+ "grabbable",
234
+ "pannable",
235
+ "removed",
236
+ "scratch",
237
+ "renderedPosition",
238
+ ]);
239
+ /** The Cytoscape element keys the importer maps structurally rather than to columns. */
240
+ export const CYTOSCAPE_STRUCTURAL_KEYS = new Set(["data", "group", "position", "classes"]);
241
+ /**
242
+ * The suffix the importer appends to a column name that collides with a structural column or a
243
+ * reserved key of its dialect (design section 5.6 names collisions deterministically); the exporter
244
+ * strips it when the value goes back to the level the suffix names.
245
+ */
246
+ export const SUFFIX = Object.freeze({
247
+ /** A Cytoscape `data` key or a JGF / graphology attribute that collides with a structural column. */
248
+ data: "#data",
249
+ /** An element-level key the dialect does not define (Cytoscape, JGF, graphology). */
250
+ element: "#element",
251
+ });
252
+ /** The default source keys of a node-link edge record, tried in order (as fromRecords does). */
253
+ export const NODE_LINK_SOURCE_KEYS = Object.freeze(["source", "src", "from"]);
254
+ /** The default target keys of a node-link edge record, tried in order. */
255
+ export const NODE_LINK_TARGET_KEYS = Object.freeze(["target", "dst", "to"]);
256
+ /** The name of the position column every JSON dialect writes / reads (design section 5.2). */
257
+ export const POSITION_COLUMN = "position";
258
+ /** The name of the Cytoscape classes column (a list of strings with role "classes"). */
259
+ export const CLASSES_COLUMN = "classes";
260
+ /** The name of the Cytoscape parent column (u32 refersTo node, role "parent"). */
261
+ export const PARENT_COLUMN = "parent";
262
+ //# sourceMappingURL=dialect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialect.js","sourceRoot":"","sources":["../../../../src/formats/json/dialect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAMtD,4DAA4D;AAC5D,MAAM,CAAC,MAAM,aAAa,GAA2B,MAAM,CAAC,MAAM,CAAC;IAC/D,WAAW;IACX,IAAI;IACJ,KAAK;IACL,WAAW;IACX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,kFAAkF;AAClF,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CAAC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * The JSON exporter (design section 8.5): one GraphExporter with a `dialect` option writing
3
+ * NetworkX node-link (the default), d3 (`links`, optional index endpoints), JSON Graph Format v2,
4
+ * Cytoscape.js elements, graphology serialisation or vis.js. The dialect defaults to the one the
5
+ * importer recorded under `meta.extra.json` so a JSON file re-exported as JSON keeps its shape,
6
+ * and to node-link for a snapshot from any other source.
7
+ *
8
+ * check() runs the generic capability pre-flight against the dialect's table and appends the
9
+ * dialect-specific notes (non-finite numbers written as null, JGF id stringification / collisions
10
+ * / node order, direction dropped by Cytoscape and vis, mutual pairs expanded, reserved key
11
+ * collisions, positions written as plain attributes, a Cytoscape `parents` column) before anything
12
+ * is written; the same column plan drives write(), so the notes and the output agree.
13
+ *
14
+ * Every column without a structural slot in the dialect is written as a plain attribute under its
15
+ * column name; an f32 value is written as the shortest decimal that round-trips through
16
+ * Math.fround (design section 3.7); a multi-component value is an array; a list is an array; a json
17
+ * value is its JSON text; an unset row writes no key (design section 5.3). Non-finite numbers,
18
+ * which JSON cannot carry, become null and are reported.
19
+ */
20
+ import { type ExportCapabilities, type GraphExporter } from "../../types.js";
21
+ import { type JsonDialect } from "./dialect.js";
22
+ /** The format-specific options of the JSON exporter. */
23
+ export interface JsonExportOptions {
24
+ /** The dialect to write; default: the dialect the importer recorded, else "node-link". */
25
+ dialect?: JsonDialect | undefined;
26
+ /** Spaces per indentation level; 0 (default) writes compact JSON. */
27
+ indent?: number | undefined;
28
+ /** node-link / d3: the key of the edge array; default: the recorded key, else "edges" (d3: "links"). */
29
+ edgesKey?: string | undefined;
30
+ /** node-link / d3 / vis: the node id key; default: the recorded key, else "id". */
31
+ nodeIdKey?: string | undefined;
32
+ /** node-link / d3: write endpoints as node array positions; default: the recorded flag, else false. */
33
+ indexLinks?: boolean | undefined;
34
+ /** node-link / d3 / vis: the source key; default: the recorded key, else "source" (vis: "from"). */
35
+ sourceKey?: string | undefined;
36
+ /** node-link / d3 / vis: the target key; default: the recorded key, else "target" (vis: "to"). */
37
+ targetKey?: string | undefined;
38
+ /** The key the weight is written under; default: the key the JSON importer read it from, else "weight". */
39
+ weightKey?: string | undefined;
40
+ }
41
+ /**
42
+ * The LossNote codes of the JSON exporter's check(): the dialect-specific ones and, aliased, the
43
+ * shared ones it records (`LOSS` holds the rest of the generic pre-flight's codes). A key is the
44
+ * code without its severity prefix.
45
+ */
46
+ export declare const JSON_LOSS: Readonly<{
47
+ /** Non-finite numbers (columns, weights) are written as null. */
48
+ NONFINITE_AS_NULL: "W_NONFINITE_AS_NULL";
49
+ /** Cytoscape, vis and d3 carry no direction; the file re-imports with the dialect's default direction. */
50
+ DIRECTION_DROPPED: "W_DIRECTION_DROPPED";
51
+ /** GEXF mutual pairs are written as two directed edges. */
52
+ MUTUAL_EXPANDED: "W_MUTUAL_EXPANDED";
53
+ /** JGF keys its nodes by string; numeric ids re-import as text unless ids: "canonical". */
54
+ NUMERIC_IDS_STRINGIFIED: "W_NUMERIC_IDS_STRINGIFIED";
55
+ /** JGF: two ids have the same text; export() throws E_INVALID_ID. */
56
+ ID_TEXT_COLLISION: "E_ID_TEXT_COLLISION";
57
+ /** JGF: integer-like id keys are enumerated first and ascending by JSON parsers; node order changes on re-import. */
58
+ NODE_ORDER: "W_NODE_ORDER";
59
+ /** A column named like a reserved key of the dialect (id, source, target, ...) is skipped. */
60
+ RESERVED_KEY: "W_RESERVED_KEY";
61
+ /** A plain edge column named like the weight key reads back as THE weight (or is skipped when weights are written). */
62
+ WEIGHT_KEY_CLASH: "W_WEIGHT_KEY_CLASH";
63
+ /** A position column without a slot (every dialect but Cytoscape) is a plain array attribute; the role is lost. */
64
+ POSITIONS_DROPPED: "W_POSITIONS_DROPPED";
65
+ /** Cytoscape positions are 2D; non-zero z values are dropped. */
66
+ POSITION_Z_DROPPED: "W_POSITION_Z_DROPPED";
67
+ /** Cytoscape has a single parent; a `parents` list column cannot be written. */
68
+ PARENTS_DROPPED: "W_PARENTS_DROPPED";
69
+ /** node-link / d3 have no edge id slot; the id column is written as a plain attribute. */
70
+ EDGE_IDS_DROPPED: "W_EDGE_IDS_DROPPED";
71
+ /** An f64 column of integral values reads back as i32 (JSON declares no types). */
72
+ INTEGRAL_F64_AS_I32: "W_INTEGRAL_F64_AS_I32";
73
+ /** A role column the dialect has no slot for is a plain attribute; the role is lost. */
74
+ ROLE_DROPPED: "W_ROLE_DROPPED";
75
+ /** A column without a set cell is not written (JSON declares no columns). */
76
+ EMPTY_COLUMN_DROPPED: "W_EMPTY_COLUMN_DROPPED";
77
+ }>;
78
+ /**
79
+ * The JSON exporter plugin (design section 8.5). `capabilities` is the node-link table (the
80
+ * default dialect); check() applies the table of the dialect actually selected.
81
+ */
82
+ export declare const jsonExporter: GraphExporter<JsonExportOptions>;
83
+ /**
84
+ * The capability table of one dialect, for callers that pick a dialect before check().
85
+ * @param dialect - the dialect
86
+ * @returns the frozen table
87
+ */
88
+ export declare function jsonCapabilities(dialect: JsonDialect): ExportCapabilities;
89
+ //# sourceMappingURL=exporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exporter.d.ts","sourceRoot":"","sources":["../../../../src/formats/json/exporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAUH,OAAO,EAA4B,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAiB,MAAM,gBAAgB,CAAC;AACtH,OAAO,EAMH,KAAK,WAAW,EAInB,MAAM,cAAc,CAAC;AAEtB,wDAAwD;AACxD,MAAM,WAAW,iBAAiB;IAC9B,0FAA0F;IAC1F,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAClC,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,wGAAwG;IACxG,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,mFAAmF;IACnF,SAAS,CAAC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