@graphty/graph-io 0.3.46 → 0.3.48

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 (460) hide show
  1. package/dist/chunks/{approximations-wWjCRzKj.js → approximations-C2riR4NT.js} +2 -2
  2. package/dist/chunks/{approximations-wWjCRzKj.js.map → approximations-C2riR4NT.js.map} +1 -1
  3. package/dist/chunks/{block-DiGq58c3.js → block-Cu22ewuS.js} +92 -21
  4. package/dist/chunks/block-Cu22ewuS.js.map +1 -0
  5. package/dist/chunks/{choose--jM0yYCo.js → choose-Cdx6Enl2.js} +3 -3
  6. package/dist/chunks/{choose--jM0yYCo.js.map → choose-Cdx6Enl2.js.map} +1 -1
  7. package/dist/chunks/codes-CV_Bhcyi.js +153 -0
  8. package/dist/chunks/codes-CV_Bhcyi.js.map +1 -0
  9. package/dist/chunks/{constants-BKwqelYD.js → constants-D0LqcsLJ.js} +2 -2
  10. package/dist/chunks/{constants-BKwqelYD.js.map → constants-D0LqcsLJ.js.map} +1 -1
  11. package/dist/chunks/context-cgmmOxZ2.js +663 -0
  12. package/dist/chunks/context-cgmmOxZ2.js.map +1 -0
  13. package/dist/chunks/credentials-BiQsnMTb.js +347 -0
  14. package/dist/chunks/credentials-BiQsnMTb.js.map +1 -0
  15. package/dist/chunks/cx-export-BEeF6ymo.js +259 -0
  16. package/dist/chunks/cx-export-BEeF6ymo.js.map +1 -0
  17. package/dist/chunks/descriptor-BJ-W0Jd-.js +137 -0
  18. package/dist/chunks/descriptor-BJ-W0Jd-.js.map +1 -0
  19. package/dist/chunks/descriptor-C-YDhtsn.js +48 -0
  20. package/dist/chunks/descriptor-C-YDhtsn.js.map +1 -0
  21. package/dist/chunks/{emit-CwU8cUmG.js → emit-CD8xnY8s.js} +70 -10
  22. package/dist/chunks/emit-CD8xnY8s.js.map +1 -0
  23. package/dist/chunks/{escape-CgzxiYPg.js → escape-DH2Egt-l.js} +12 -12
  24. package/dist/chunks/{escape-CgzxiYPg.js.map → escape-DH2Egt-l.js.map} +1 -1
  25. package/dist/chunks/{export-BvqAXCKh.js → export-CZ7VRm4I.js} +53 -1443
  26. package/dist/chunks/export-CZ7VRm4I.js.map +1 -0
  27. package/dist/chunks/{exporter-DndFlGSa.js → exporter-BIdaoIgh.js} +7 -6
  28. package/dist/chunks/{exporter-DndFlGSa.js.map → exporter-BIdaoIgh.js.map} +1 -1
  29. package/dist/chunks/{exporter-CJgfhF-l.js → exporter-ChjL5fmP.js} +8 -7
  30. package/dist/chunks/{exporter-CJgfhF-l.js.map → exporter-ChjL5fmP.js.map} +1 -1
  31. package/dist/chunks/{exporter--Mk9gXCJ.js → exporter-Dcw7Ldtq.js} +6 -4
  32. package/dist/chunks/{exporter--Mk9gXCJ.js.map → exporter-Dcw7Ldtq.js.map} +1 -1
  33. package/dist/chunks/exporter-DtVU80Fa.js +1008 -0
  34. package/dist/chunks/exporter-DtVU80Fa.js.map +1 -0
  35. package/dist/chunks/{exporter-CrDWIyiq.js → exporter-bxxjOrDZ.js} +11 -9
  36. package/dist/chunks/{exporter-CrDWIyiq.js.map → exporter-bxxjOrDZ.js.map} +1 -1
  37. package/dist/chunks/format-BMS-1Nxb.js +64 -0
  38. package/dist/chunks/format-BMS-1Nxb.js.map +1 -0
  39. package/dist/chunks/{generic-Dq1ntt9q.js → generic-CP6YD34u.js} +4 -4
  40. package/dist/chunks/{generic-Dq1ntt9q.js.map → generic-CP6YD34u.js.map} +1 -1
  41. package/dist/chunks/{importer-DiZRmOQG.js → importer-B87_fmVx.js} +13 -17
  42. package/dist/chunks/importer-B87_fmVx.js.map +1 -0
  43. package/dist/chunks/{importer-BSvfrX_h.js → importer-Bji2MeWr.js} +18 -1014
  44. package/dist/chunks/importer-Bji2MeWr.js.map +1 -0
  45. package/dist/chunks/{importer-COTK9Tsl.js → importer-CB_zV5_L.js} +14 -11
  46. package/dist/chunks/importer-CB_zV5_L.js.map +1 -0
  47. package/dist/chunks/{importer-e6LGpqHB.js → importer-CVT-JyDE.js} +12 -9
  48. package/dist/chunks/importer-CVT-JyDE.js.map +1 -0
  49. package/dist/chunks/{importer-yh_aBCU6.js → importer-Cyy6UseH.js} +7 -6
  50. package/dist/chunks/{importer-yh_aBCU6.js.map → importer-Cyy6UseH.js.map} +1 -1
  51. package/dist/chunks/{importer-iFYPEKaJ.js → importer-DPZDN40-.js} +14 -10
  52. package/dist/chunks/{importer-iFYPEKaJ.js.map → importer-DPZDN40-.js.map} +1 -1
  53. package/dist/chunks/{importer-CMmeMWlC.js → importer-e3huMZbm.js} +8 -260
  54. package/dist/chunks/importer-e3huMZbm.js.map +1 -0
  55. package/dist/chunks/input-Ccg9I22A.js +1397 -0
  56. package/dist/chunks/input-Ccg9I22A.js.map +1 -0
  57. package/dist/chunks/{json-elements-DJZRZ6jd.js → json-elements-By172SVq.js} +4 -4
  58. package/dist/chunks/{json-elements-DJZRZ6jd.js.map → json-elements-By172SVq.js.map} +1 -1
  59. package/dist/chunks/{lexicon-CT69Kd87.js → lexicon-u2SI5xcx.js} +19 -5
  60. package/dist/chunks/lexicon-u2SI5xcx.js.map +1 -0
  61. package/dist/chunks/{ontology-export-G4MqRdux.js → ontology-export-BwgMyuF0.js} +4 -3
  62. package/dist/chunks/{ontology-export-G4MqRdux.js.map → ontology-export-BwgMyuF0.js.map} +1 -1
  63. package/dist/chunks/{records-CiaWZrFH.js → records-Cgvxz-Vx.js} +2 -2
  64. package/dist/chunks/{records-CiaWZrFH.js.map → records-Cgvxz-Vx.js.map} +1 -1
  65. package/dist/chunks/{format-BpQBx8MZ.js → report-CgdsL9Hb.js} +72 -129
  66. package/dist/chunks/report-CgdsL9Hb.js.map +1 -0
  67. package/dist/chunks/sigv4-LkAzsLAu.js +247 -0
  68. package/dist/chunks/sigv4-LkAzsLAu.js.map +1 -0
  69. package/dist/chunks/{styles-BQnsga7p.js → styles-CaABMoO1.js} +76 -43
  70. package/dist/chunks/styles-CaABMoO1.js.map +1 -0
  71. package/dist/chunks/{styles-D3fRphrO.js → styles-P_gmFAOi.js} +101 -21
  72. package/dist/chunks/styles-P_gmFAOi.js.map +1 -0
  73. package/dist/chunks/{styles-yed-BF5x3_Y5.js → styles-yed-Cs1nmrjn.js} +60 -20
  74. package/dist/chunks/styles-yed-Cs1nmrjn.js.map +1 -0
  75. package/dist/chunks/{text-CzJNFOS9.js → text-BuKQVMz2.js} +2 -2
  76. package/dist/chunks/{text-CzJNFOS9.js.map → text-BuKQVMz2.js.map} +1 -1
  77. package/dist/chunks/{writer-DMKvthQE.js → writer-DvHTl36J.js} +5 -4
  78. package/dist/chunks/writer-DvHTl36J.js.map +1 -0
  79. package/dist/csv.js +7 -5
  80. package/dist/csv.js.map +1 -1
  81. package/dist/cx.js +5 -4
  82. package/dist/cx.js.map +1 -1
  83. package/dist/cx2.js +2 -2
  84. package/dist/cys.js +1 -1
  85. package/dist/dot.js +2 -2
  86. package/dist/gexf.js +7 -5
  87. package/dist/gexf.js.map +1 -1
  88. package/dist/gml.js +16 -13
  89. package/dist/gml.js.map +1 -1
  90. package/dist/graph-io.js +1181 -224
  91. package/dist/graph-io.js.map +1 -1
  92. package/dist/graphml.js +3 -3
  93. package/dist/json.js +1 -1
  94. package/dist/neo4j.js +6 -4
  95. package/dist/neo4j.js.map +1 -1
  96. package/dist/obo.js +1 -1
  97. package/dist/pajek.js +1 -1
  98. package/dist/sources-cypher.d.ts +1 -0
  99. package/dist/sources-cypher.js +1236 -0
  100. package/dist/sources-cypher.js.map +1 -0
  101. package/dist/sources-ndex.d.ts +1 -0
  102. package/dist/sources-ndex.js +278 -0
  103. package/dist/sources-ndex.js.map +1 -0
  104. package/dist/sources-rest.d.ts +1 -0
  105. package/dist/sources-rest.js +1367 -0
  106. package/dist/sources-rest.js.map +1 -0
  107. package/dist/src/common/report.d.ts +6 -3
  108. package/dist/src/common/report.d.ts.map +1 -1
  109. package/dist/src/common/report.js +15 -9
  110. package/dist/src/common/report.js.map +1 -1
  111. package/dist/src/formats/cx/styles.d.ts.map +1 -1
  112. package/dist/src/formats/cx/styles.js +1 -0
  113. package/dist/src/formats/cx/styles.js.map +1 -1
  114. package/dist/src/formats/dot/styles.d.ts.map +1 -1
  115. package/dist/src/formats/dot/styles.js +3 -1
  116. package/dist/src/formats/dot/styles.js.map +1 -1
  117. package/dist/src/formats/gexf/styles.d.ts +29 -12
  118. package/dist/src/formats/gexf/styles.d.ts.map +1 -1
  119. package/dist/src/formats/gexf/styles.js +160 -31
  120. package/dist/src/formats/gexf/styles.js.map +1 -1
  121. package/dist/src/formats/gml/styles.d.ts.map +1 -1
  122. package/dist/src/formats/gml/styles.js +5 -4
  123. package/dist/src/formats/gml/styles.js.map +1 -1
  124. package/dist/src/formats/graphml/styles-plain.d.ts.map +1 -1
  125. package/dist/src/formats/graphml/styles-plain.js +3 -3
  126. package/dist/src/formats/graphml/styles-plain.js.map +1 -1
  127. package/dist/src/formats/graphml/styles-yed.d.ts.map +1 -1
  128. package/dist/src/formats/graphml/styles-yed.js +89 -19
  129. package/dist/src/formats/graphml/styles-yed.js.map +1 -1
  130. package/dist/src/formats/pajek/styles.d.ts.map +1 -1
  131. package/dist/src/formats/pajek/styles.js +1 -0
  132. package/dist/src/formats/pajek/styles.js.map +1 -1
  133. package/dist/src/formats/xgmml/styles.d.ts.map +1 -1
  134. package/dist/src/formats/xgmml/styles.js +1 -0
  135. package/dist/src/formats/xgmml/styles.js.map +1 -1
  136. package/dist/src/index.d.ts +8 -1
  137. package/dist/src/index.d.ts.map +1 -1
  138. package/dist/src/index.js +9 -1
  139. package/dist/src/index.js.map +1 -1
  140. package/dist/src/registry.d.ts +173 -1
  141. package/dist/src/registry.d.ts.map +1 -1
  142. package/dist/src/registry.js +196 -1
  143. package/dist/src/registry.js.map +1 -1
  144. package/dist/src/sources/builtins.d.ts +11 -0
  145. package/dist/src/sources/builtins.d.ts.map +1 -0
  146. package/dist/src/sources/builtins.js +47 -0
  147. package/dist/src/sources/builtins.js.map +1 -0
  148. package/dist/src/sources/codes.d.ts +230 -0
  149. package/dist/src/sources/codes.d.ts.map +1 -0
  150. package/dist/src/sources/codes.js +58 -0
  151. package/dist/src/sources/codes.js.map +1 -0
  152. package/dist/src/sources/context.d.ts +112 -0
  153. package/dist/src/sources/context.d.ts.map +1 -0
  154. package/dist/src/sources/context.js +739 -0
  155. package/dist/src/sources/context.js.map +1 -0
  156. package/dist/src/sources/credentials.d.ts +179 -0
  157. package/dist/src/sources/credentials.d.ts.map +1 -0
  158. package/dist/src/sources/credentials.js +301 -0
  159. package/dist/src/sources/credentials.js.map +1 -0
  160. package/dist/src/sources/cypher/descriptor.d.ts +21 -0
  161. package/dist/src/sources/cypher/descriptor.d.ts.map +1 -0
  162. package/dist/src/sources/cypher/descriptor.js +119 -0
  163. package/dist/src/sources/cypher/descriptor.js.map +1 -0
  164. package/dist/src/sources/cypher/flatten.d.ts +72 -0
  165. package/dist/src/sources/cypher/flatten.d.ts.map +1 -0
  166. package/dist/src/sources/cypher/flatten.js +279 -0
  167. package/dist/src/sources/cypher/flatten.js.map +1 -0
  168. package/dist/src/sources/cypher/index.d.ts +33 -0
  169. package/dist/src/sources/cypher/index.d.ts.map +1 -0
  170. package/dist/src/sources/cypher/index.js +405 -0
  171. package/dist/src/sources/cypher/index.js.map +1 -0
  172. package/dist/src/sources/cypher/params.d.ts +40 -0
  173. package/dist/src/sources/cypher/params.d.ts.map +1 -0
  174. package/dist/src/sources/cypher/params.js +6 -0
  175. package/dist/src/sources/cypher/params.js.map +1 -0
  176. package/dist/src/sources/cypher/profiles.d.ts +44 -0
  177. package/dist/src/sources/cypher/profiles.d.ts.map +1 -0
  178. package/dist/src/sources/cypher/profiles.js +61 -0
  179. package/dist/src/sources/cypher/profiles.js.map +1 -0
  180. package/dist/src/sources/cypher/query-builder.d.ts +106 -0
  181. package/dist/src/sources/cypher/query-builder.d.ts.map +1 -0
  182. package/dist/src/sources/cypher/query-builder.js +236 -0
  183. package/dist/src/sources/cypher/query-builder.js.map +1 -0
  184. package/dist/src/sources/cypher/transports/bolt.d.ts +21 -0
  185. package/dist/src/sources/cypher/transports/bolt.d.ts.map +1 -0
  186. package/dist/src/sources/cypher/transports/bolt.js +185 -0
  187. package/dist/src/sources/cypher/transports/bolt.js.map +1 -0
  188. package/dist/src/sources/cypher/transports/neptune-analytics.d.ts +15 -0
  189. package/dist/src/sources/cypher/transports/neptune-analytics.d.ts.map +1 -0
  190. package/dist/src/sources/cypher/transports/neptune-analytics.js +38 -0
  191. package/dist/src/sources/cypher/transports/neptune-analytics.js.map +1 -0
  192. package/dist/src/sources/cypher/transports/neptune-https.d.ts +31 -0
  193. package/dist/src/sources/cypher/transports/neptune-https.d.ts.map +1 -0
  194. package/dist/src/sources/cypher/transports/neptune-https.js +104 -0
  195. package/dist/src/sources/cypher/transports/neptune-https.js.map +1 -0
  196. package/dist/src/sources/cypher/transports/query-api.d.ts +14 -0
  197. package/dist/src/sources/cypher/transports/query-api.d.ts.map +1 -0
  198. package/dist/src/sources/cypher/transports/query-api.js +80 -0
  199. package/dist/src/sources/cypher/transports/query-api.js.map +1 -0
  200. package/dist/src/sources/cypher/transports/transport.d.ts +78 -0
  201. package/dist/src/sources/cypher/transports/transport.d.ts.map +1 -0
  202. package/dist/src/sources/cypher/transports/transport.js +77 -0
  203. package/dist/src/sources/cypher/transports/transport.js.map +1 -0
  204. package/dist/src/sources/cypher/types-map.d.ts +91 -0
  205. package/dist/src/sources/cypher/types-map.d.ts.map +1 -0
  206. package/dist/src/sources/cypher/types-map.js +306 -0
  207. package/dist/src/sources/cypher/types-map.js.map +1 -0
  208. package/dist/src/sources/define.d.ts +47 -0
  209. package/dist/src/sources/define.d.ts.map +1 -0
  210. package/dist/src/sources/define.js +173 -0
  211. package/dist/src/sources/define.js.map +1 -0
  212. package/dist/src/sources/fail.d.ts +33 -0
  213. package/dist/src/sources/fail.d.ts.map +1 -0
  214. package/dist/src/sources/fail.js +49 -0
  215. package/dist/src/sources/fail.js.map +1 -0
  216. package/dist/src/sources/ids.d.ts +64 -0
  217. package/dist/src/sources/ids.d.ts.map +1 -0
  218. package/dist/src/sources/ids.js +64 -0
  219. package/dist/src/sources/ids.js.map +1 -0
  220. package/dist/src/sources/ndex/client.d.ts +31 -0
  221. package/dist/src/sources/ndex/client.d.ts.map +1 -0
  222. package/dist/src/sources/ndex/client.js +90 -0
  223. package/dist/src/sources/ndex/client.js.map +1 -0
  224. package/dist/src/sources/ndex/descriptor.d.ts +10 -0
  225. package/dist/src/sources/ndex/descriptor.d.ts.map +1 -0
  226. package/dist/src/sources/ndex/descriptor.js +55 -0
  227. package/dist/src/sources/ndex/descriptor.js.map +1 -0
  228. package/dist/src/sources/ndex/expand.d.ts +20 -0
  229. package/dist/src/sources/ndex/expand.d.ts.map +1 -0
  230. package/dist/src/sources/ndex/expand.js +87 -0
  231. package/dist/src/sources/ndex/expand.js.map +1 -0
  232. package/dist/src/sources/ndex/index.d.ts +25 -0
  233. package/dist/src/sources/ndex/index.d.ts.map +1 -0
  234. package/dist/src/sources/ndex/index.js +191 -0
  235. package/dist/src/sources/ndex/index.js.map +1 -0
  236. package/dist/src/sources/ndex/params.d.ts +17 -0
  237. package/dist/src/sources/ndex/params.d.ts.map +1 -0
  238. package/dist/src/sources/ndex/params.js +6 -0
  239. package/dist/src/sources/ndex/params.js.map +1 -0
  240. package/dist/src/sources/ndex/share-url.d.ts +40 -0
  241. package/dist/src/sources/ndex/share-url.d.ts.map +1 -0
  242. package/dist/src/sources/ndex/share-url.js +64 -0
  243. package/dist/src/sources/ndex/share-url.js.map +1 -0
  244. package/dist/src/sources/params.d.ts +28 -0
  245. package/dist/src/sources/params.d.ts.map +1 -0
  246. package/dist/src/sources/params.js +6 -0
  247. package/dist/src/sources/params.js.map +1 -0
  248. package/dist/src/sources/registry.d.ts +118 -0
  249. package/dist/src/sources/registry.d.ts.map +1 -0
  250. package/dist/src/sources/registry.js +193 -0
  251. package/dist/src/sources/registry.js.map +1 -0
  252. package/dist/src/sources/rest/descriptor.d.ts +16 -0
  253. package/dist/src/sources/rest/descriptor.d.ts.map +1 -0
  254. package/dist/src/sources/rest/descriptor.js +71 -0
  255. package/dist/src/sources/rest/descriptor.js.map +1 -0
  256. package/dist/src/sources/rest/index.d.ts +14 -0
  257. package/dist/src/sources/rest/index.d.ts.map +1 -0
  258. package/dist/src/sources/rest/index.js +13 -0
  259. package/dist/src/sources/rest/index.js.map +1 -0
  260. package/dist/src/sources/rest/mapping.d.ts +30 -0
  261. package/dist/src/sources/rest/mapping.d.ts.map +1 -0
  262. package/dist/src/sources/rest/mapping.js +362 -0
  263. package/dist/src/sources/rest/mapping.js.map +1 -0
  264. package/dist/src/sources/rest/openalex.d.ts +27 -0
  265. package/dist/src/sources/rest/openalex.d.ts.map +1 -0
  266. package/dist/src/sources/rest/openalex.js +269 -0
  267. package/dist/src/sources/rest/openalex.js.map +1 -0
  268. package/dist/src/sources/rest/paging.d.ts +53 -0
  269. package/dist/src/sources/rest/paging.d.ts.map +1 -0
  270. package/dist/src/sources/rest/paging.js +138 -0
  271. package/dist/src/sources/rest/paging.js.map +1 -0
  272. package/dist/src/sources/rest/params.d.ts +216 -0
  273. package/dist/src/sources/rest/params.d.ts.map +1 -0
  274. package/dist/src/sources/rest/params.js +7 -0
  275. package/dist/src/sources/rest/params.js.map +1 -0
  276. package/dist/src/sources/rest/records.d.ts +41 -0
  277. package/dist/src/sources/rest/records.d.ts.map +1 -0
  278. package/dist/src/sources/rest/records.js +240 -0
  279. package/dist/src/sources/rest/records.js.map +1 -0
  280. package/dist/src/sources/rest/samples/deps-dev.d.ts +10 -0
  281. package/dist/src/sources/rest/samples/deps-dev.d.ts.map +1 -0
  282. package/dist/src/sources/rest/samples/deps-dev.js +47 -0
  283. package/dist/src/sources/rest/samples/deps-dev.js.map +1 -0
  284. package/dist/src/sources/rest/samples/string.d.ts +9 -0
  285. package/dist/src/sources/rest/samples/string.d.ts.map +1 -0
  286. package/dist/src/sources/rest/samples/string.js +42 -0
  287. package/dist/src/sources/rest/samples/string.js.map +1 -0
  288. package/dist/src/sources/rest/selectors.d.ts +41 -0
  289. package/dist/src/sources/rest/selectors.d.ts.map +1 -0
  290. package/dist/src/sources/rest/selectors.js +81 -0
  291. package/dist/src/sources/rest/selectors.js.map +1 -0
  292. package/dist/src/sources/rest/source.d.ts +67 -0
  293. package/dist/src/sources/rest/source.d.ts.map +1 -0
  294. package/dist/src/sources/rest/source.js +635 -0
  295. package/dist/src/sources/rest/source.js.map +1 -0
  296. package/dist/src/sources/rest/templates.d.ts +38 -0
  297. package/dist/src/sources/rest/templates.d.ts.map +1 -0
  298. package/dist/src/sources/rest/templates.js +125 -0
  299. package/dist/src/sources/rest/templates.js.map +1 -0
  300. package/dist/src/sources/run.d.ts +93 -0
  301. package/dist/src/sources/run.d.ts.map +1 -0
  302. package/dist/src/sources/run.js +673 -0
  303. package/dist/src/sources/run.js.map +1 -0
  304. package/dist/src/sources/sha256.d.ts +12 -0
  305. package/dist/src/sources/sha256.d.ts.map +1 -0
  306. package/dist/src/sources/sha256.js +95 -0
  307. package/dist/src/sources/sha256.js.map +1 -0
  308. package/dist/src/sources/sigv4.d.ts +24 -0
  309. package/dist/src/sources/sigv4.d.ts.map +1 -0
  310. package/dist/src/sources/sigv4.js +182 -0
  311. package/dist/src/sources/sigv4.js.map +1 -0
  312. package/dist/src/sources/testing.d.ts +96 -0
  313. package/dist/src/sources/testing.d.ts.map +1 -0
  314. package/dist/src/sources/testing.js +138 -0
  315. package/dist/src/sources/testing.js.map +1 -0
  316. package/dist/src/sources/types.d.ts +665 -0
  317. package/dist/src/sources/types.d.ts.map +1 -0
  318. package/dist/src/sources/types.js +10 -0
  319. package/dist/src/sources/types.js.map +1 -0
  320. package/dist/src/styles/canon/enums.d.ts.map +1 -1
  321. package/dist/src/styles/canon/enums.js +1 -0
  322. package/dist/src/styles/canon/enums.js.map +1 -1
  323. package/dist/src/styles/cyjs/cascade.d.ts.map +1 -1
  324. package/dist/src/styles/cyjs/cascade.js +68 -2
  325. package/dist/src/styles/cyjs/cascade.js.map +1 -1
  326. package/dist/src/styles/cyjs/defaults-table.d.ts.map +1 -1
  327. package/dist/src/styles/cyjs/defaults-table.js +2 -0
  328. package/dist/src/styles/cyjs/defaults-table.js.map +1 -1
  329. package/dist/src/styles/cyjs/emit.d.ts.map +1 -1
  330. package/dist/src/styles/cyjs/emit.js +18 -7
  331. package/dist/src/styles/cyjs/emit.js.map +1 -1
  332. package/dist/src/styles/cyjs/mappers.d.ts +4 -1
  333. package/dist/src/styles/cyjs/mappers.d.ts.map +1 -1
  334. package/dist/src/styles/cyjs/mappers.js +2 -0
  335. package/dist/src/styles/cyjs/mappers.js.map +1 -1
  336. package/dist/src/styles/cytoscape/emit.d.ts.map +1 -1
  337. package/dist/src/styles/cytoscape/emit.js +59 -7
  338. package/dist/src/styles/cytoscape/emit.js.map +1 -1
  339. package/dist/src/styles/cytoscape/lexicon.d.ts +6 -0
  340. package/dist/src/styles/cytoscape/lexicon.d.ts.map +1 -1
  341. package/dist/src/styles/cytoscape/lexicon.js +26 -2
  342. package/dist/src/styles/cytoscape/lexicon.js.map +1 -1
  343. package/dist/src/styles/cytoscape/resolve.d.ts +4 -1
  344. package/dist/src/styles/cytoscape/resolve.d.ts.map +1 -1
  345. package/dist/src/styles/cytoscape/resolve.js +10 -6
  346. package/dist/src/styles/cytoscape/resolve.js.map +1 -1
  347. package/dist/src/styles/cytoscape/translate.d.ts.map +1 -1
  348. package/dist/src/styles/cytoscape/translate.js +10 -10
  349. package/dist/src/styles/cytoscape/translate.js.map +1 -1
  350. package/dist/src/styles/defaults.d.ts +30 -0
  351. package/dist/src/styles/defaults.d.ts.map +1 -1
  352. package/dist/src/styles/defaults.js +45 -4
  353. package/dist/src/styles/defaults.js.map +1 -1
  354. package/dist/src/styles/io/block.d.ts.map +1 -1
  355. package/dist/src/styles/io/block.js +9 -0
  356. package/dist/src/styles/io/block.js.map +1 -1
  357. package/dist/src/styles/io/writer.d.ts.map +1 -1
  358. package/dist/src/styles/io/writer.js +7 -3
  359. package/dist/src/styles/io/writer.js.map +1 -1
  360. package/dist/src/styles/plan/resolve.d.ts +2 -1
  361. package/dist/src/styles/plan/resolve.d.ts.map +1 -1
  362. package/dist/src/styles/plan/resolve.js +13 -2
  363. package/dist/src/styles/plan/resolve.js.map +1 -1
  364. package/dist/src/styles/types.d.ts +19 -2
  365. package/dist/src/styles/types.d.ts.map +1 -1
  366. package/dist/src/styles/vocabulary.d.ts.map +1 -1
  367. package/dist/src/styles/vocabulary.js +15 -1
  368. package/dist/src/styles/vocabulary.js.map +1 -1
  369. package/dist/src/types.d.ts +19 -5
  370. package/dist/src/types.d.ts.map +1 -1
  371. package/dist/src/types.js.map +1 -1
  372. package/dist/styles.js +11 -11
  373. package/dist/xgmml.js +3 -3
  374. package/docs/samples/people.json +6 -0
  375. package/package.json +29 -4
  376. package/src/common/report.ts +27 -7
  377. package/src/formats/cx/styles.ts +1 -0
  378. package/src/formats/dot/styles.ts +3 -1
  379. package/src/formats/gexf/styles.ts +185 -37
  380. package/src/formats/gml/styles.ts +5 -4
  381. package/src/formats/graphml/styles-plain.ts +3 -9
  382. package/src/formats/graphml/styles-yed.ts +93 -20
  383. package/src/formats/pajek/styles.ts +1 -0
  384. package/src/formats/xgmml/styles.ts +1 -0
  385. package/src/index.ts +90 -0
  386. package/src/registry.ts +326 -1
  387. package/src/sources/builtins.ts +56 -0
  388. package/src/sources/codes.ts +235 -0
  389. package/src/sources/context.ts +893 -0
  390. package/src/sources/credentials.ts +409 -0
  391. package/src/sources/cypher/descriptor.ts +125 -0
  392. package/src/sources/cypher/flatten.ts +323 -0
  393. package/src/sources/cypher/index.ts +498 -0
  394. package/src/sources/cypher/params.ts +41 -0
  395. package/src/sources/cypher/profiles.ts +78 -0
  396. package/src/sources/cypher/query-builder.ts +294 -0
  397. package/src/sources/cypher/transports/bolt.ts +228 -0
  398. package/src/sources/cypher/transports/neptune-analytics.ts +41 -0
  399. package/src/sources/cypher/transports/neptune-https.ts +122 -0
  400. package/src/sources/cypher/transports/query-api.ts +100 -0
  401. package/src/sources/cypher/transports/transport.ts +139 -0
  402. package/src/sources/cypher/types-map.ts +418 -0
  403. package/src/sources/define.ts +195 -0
  404. package/src/sources/fail.ts +70 -0
  405. package/src/sources/ids.ts +74 -0
  406. package/src/sources/ndex/client.ts +102 -0
  407. package/src/sources/ndex/descriptor.ts +64 -0
  408. package/src/sources/ndex/expand.ts +100 -0
  409. package/src/sources/ndex/index.ts +235 -0
  410. package/src/sources/ndex/params.ts +17 -0
  411. package/src/sources/ndex/share-url.ts +84 -0
  412. package/src/sources/params.ts +29 -0
  413. package/src/sources/registry.ts +325 -0
  414. package/src/sources/rest/descriptor.ts +74 -0
  415. package/src/sources/rest/index.ts +22 -0
  416. package/src/sources/rest/mapping.ts +401 -0
  417. package/src/sources/rest/openalex.ts +288 -0
  418. package/src/sources/rest/paging.ts +180 -0
  419. package/src/sources/rest/params.ts +243 -0
  420. package/src/sources/rest/records.ts +289 -0
  421. package/src/sources/rest/samples/deps-dev.ts +49 -0
  422. package/src/sources/rest/samples/string.ts +44 -0
  423. package/src/sources/rest/selectors.ts +91 -0
  424. package/src/sources/rest/source.ts +760 -0
  425. package/src/sources/rest/templates.ts +151 -0
  426. package/src/sources/run.ts +793 -0
  427. package/src/sources/sha256.ts +99 -0
  428. package/src/sources/sigv4.ts +207 -0
  429. package/src/sources/testing.ts +210 -0
  430. package/src/sources/types.ts +741 -0
  431. package/src/styles/canon/enums.ts +1 -0
  432. package/src/styles/cyjs/cascade.ts +81 -2
  433. package/src/styles/cyjs/defaults-table.ts +2 -0
  434. package/src/styles/cyjs/emit.ts +18 -7
  435. package/src/styles/cyjs/mappers.ts +6 -1
  436. package/src/styles/cytoscape/emit.ts +61 -7
  437. package/src/styles/cytoscape/lexicon.ts +28 -2
  438. package/src/styles/cytoscape/resolve.ts +22 -6
  439. package/src/styles/cytoscape/translate.ts +11 -11
  440. package/src/styles/defaults.ts +93 -4
  441. package/src/styles/io/block.ts +10 -0
  442. package/src/styles/io/writer.ts +8 -3
  443. package/src/styles/plan/resolve.ts +14 -2
  444. package/src/styles/types.ts +28 -2
  445. package/src/styles/vocabulary.ts +15 -1
  446. package/src/types.ts +19 -5
  447. package/dist/chunks/block-DiGq58c3.js.map +0 -1
  448. package/dist/chunks/emit-CwU8cUmG.js.map +0 -1
  449. package/dist/chunks/export-BvqAXCKh.js.map +0 -1
  450. package/dist/chunks/format-BpQBx8MZ.js.map +0 -1
  451. package/dist/chunks/importer-BSvfrX_h.js.map +0 -1
  452. package/dist/chunks/importer-CMmeMWlC.js.map +0 -1
  453. package/dist/chunks/importer-COTK9Tsl.js.map +0 -1
  454. package/dist/chunks/importer-DiZRmOQG.js.map +0 -1
  455. package/dist/chunks/importer-e6LGpqHB.js.map +0 -1
  456. package/dist/chunks/lexicon-CT69Kd87.js.map +0 -1
  457. package/dist/chunks/styles-BQnsga7p.js.map +0 -1
  458. package/dist/chunks/styles-D3fRphrO.js.map +0 -1
  459. package/dist/chunks/styles-yed-BF5x3_Y5.js.map +0 -1
  460. package/dist/chunks/writer-DMKvthQE.js.map +0 -1
@@ -0,0 +1,235 @@
1
+ /**
2
+ * `@graphty/graph-io/sources/ndex`: the NDEx source (design section 12.1). Experimental.
3
+ *
4
+ * - load: the network's summary first (counts, download size, modification time), checked against
5
+ * the caps before a byte of the network is read; then the CX2 (or CX) download, streamed into
6
+ * the CX2 (or CX) importer.
7
+ * - probe: the summary. list: NDEx's v2 network search. validate: the summary's modificationTime.
8
+ * - expand: NDEx's neighborhood query (`expand.ts`).
9
+ *
10
+ * Errors are classified by status; a body is read only from a 401, 403 or 404 (NDEx's own
11
+ * `errorCode`, passed through as `serverCode`), so a 500 with a Java stack trace never reaches a
12
+ * report.
13
+ * @module @graphty/graph-io/sources/ndex
14
+ */
15
+
16
+ import { defineSource } from "../define.js";
17
+ import { failOn } from "../fail.js";
18
+ import { NDEX_SOURCE_ID } from "../ids.js";
19
+ import {
20
+ type GraphSource,
21
+ type SourceContext,
22
+ type SourceFreshness,
23
+ type SourceListing,
24
+ type SourceListQuery,
25
+ type SourceProbe,
26
+ type SourceValidators,
27
+ } from "../types.js";
28
+ import { checkedUuid, checkEndpoint, ndexFetch } from "./client.js";
29
+ import { NDEX_DESCRIPTOR } from "./descriptor.js";
30
+ import { expandNdex } from "./expand.js";
31
+ import { type NdexParams } from "./params.js";
32
+
33
+ export { NDEX_DESCRIPTOR } from "./descriptor.js";
34
+ export { type NdexParams } from "./params.js";
35
+ export { type NdexShareLink, parseShareUrl } from "./share-url.js";
36
+
37
+ /** The fields of a network summary this source reads. */
38
+ interface NdexSummary {
39
+ readonly nodeCount?: number;
40
+ readonly edgeCount?: number;
41
+ readonly cxFileSize?: number;
42
+ readonly cx2FileSize?: number;
43
+ readonly modificationTime?: number;
44
+ readonly creationTime?: number;
45
+ readonly visibility?: string;
46
+ readonly properties?: Readonly<Record<string, { readonly v?: unknown } | undefined>>;
47
+ }
48
+
49
+ /** One network of a v2 search answer. */
50
+ interface NdexSearchHit {
51
+ readonly externalId?: string;
52
+ readonly name?: string;
53
+ readonly nodeCount?: number;
54
+ readonly edgeCount?: number;
55
+ readonly modificationTime?: number;
56
+ }
57
+
58
+ /**
59
+ * Read a network's summary.
60
+ * @param uuid - the checked UUID
61
+ * @param ctx - the context
62
+ * @returns the summary and the bytes it took
63
+ */
64
+ async function readSummary(uuid: string, ctx: SourceContext): Promise<{ summary: NdexSummary; bytes: number }> {
65
+ const response = await ndexFetch(ctx, `v3/networks/${uuid}/summary`, uuid, {
66
+ headers: { Accept: "application/json" },
67
+ });
68
+ const text = await response.text();
69
+ try {
70
+ return { summary: JSON.parse(text) as NdexSummary, bytes: new TextEncoder().encode(text).byteLength };
71
+ } catch {
72
+ return failOn(ctx.report, "E_SOURCE_RESPONSE", "the NDEx summary is not JSON", {
73
+ expected: "json",
74
+ contentType: response.headers.get("content-type"),
75
+ });
76
+ }
77
+ }
78
+
79
+ /**
80
+ * An NDEx time (epoch milliseconds) as an ISO string.
81
+ * @param ms - the time
82
+ * @returns the ISO string, or undefined
83
+ */
84
+ function iso(ms: number | undefined): string | undefined {
85
+ return typeof ms === "number" && Number.isFinite(ms) ? new Date(ms).toISOString() : undefined;
86
+ }
87
+
88
+ /**
89
+ * The download size the summary gives for a format.
90
+ * @param summary - the summary
91
+ * @param format - "cx2" or "cx"
92
+ * @returns the size in bytes, or undefined
93
+ */
94
+ function sizeOf(summary: NdexSummary, format: string): number | undefined {
95
+ return format === "cx" ? summary.cxFileSize : summary.cx2FileSize;
96
+ }
97
+
98
+ /**
99
+ * Stop the load before its first byte when the summary says a cap would cut it: a network file cut
100
+ * short is not a graph, so this is E_SOURCE_LIMIT under either `onLimit`.
101
+ * @param summary - the summary
102
+ * @param format - the download format
103
+ * @param ctx - the context
104
+ */
105
+ function checkCaps(summary: NdexSummary, format: string, ctx: SourceContext): void {
106
+ const caps: [string, number | undefined, number | undefined][] = [
107
+ ["maxNodes", summary.nodeCount, ctx.limits.maxNodes],
108
+ ["maxEdges", summary.edgeCount, ctx.limits.maxEdges],
109
+ ["maxBytes", sizeOf(summary, format), ctx.limits.maxBytes],
110
+ ];
111
+ for (const [limit, value, cap] of caps) {
112
+ if (value !== undefined && cap !== undefined && value > cap) {
113
+ failOn(ctx.report, "E_SOURCE_LIMIT", `the network's ${limit} of ${String(value)} is over the cap`, {
114
+ limit,
115
+ value,
116
+ });
117
+ }
118
+ }
119
+ }
120
+
121
+ /**
122
+ * The graph facts a summary adds: when it changed, and who may use it.
123
+ * @param summary - the summary
124
+ * @returns the facts
125
+ */
126
+ function metaOf(summary: NdexSummary): Record<string, string> {
127
+ const meta: Record<string, string> = {};
128
+ const modified = iso(summary.modificationTime);
129
+ if (modified !== undefined) {
130
+ meta.modified = modified;
131
+ }
132
+ if (typeof summary.visibility === "string") {
133
+ meta.visibility = summary.visibility;
134
+ }
135
+ for (const key of ["rights", "rightsHolder"]) {
136
+ const value = summary.properties?.[key]?.v;
137
+ if (typeof value === "string") {
138
+ meta[key] = value;
139
+ }
140
+ }
141
+ return meta;
142
+ }
143
+
144
+ /**
145
+ * The validators of a summary.
146
+ * @param summary - the summary
147
+ * @returns `{ modified }` when NDEx gave a modification time
148
+ */
149
+ function validatorsOf(summary: NdexSummary): SourceValidators {
150
+ const modified = iso(summary.modificationTime);
151
+ return modified === undefined ? {} : { modified };
152
+ }
153
+
154
+ /**
155
+ * The NDEx source. Experimental.
156
+ * @category Network sources
157
+ */
158
+ export const ndexSource: GraphSource<NdexParams> = defineSource<NdexParams>({
159
+ id: NDEX_SOURCE_ID,
160
+ descriptor: NDEX_DESCRIPTOR,
161
+ async file(params, ctx) {
162
+ const uuid = checkedUuid(params.uuid, ctx);
163
+ const format = params.format ?? "cx2";
164
+ const { summary, bytes } = await readSummary(uuid, ctx);
165
+ checkCaps(summary, format, ctx);
166
+ const size = sizeOf(summary, format);
167
+ // progress counts every byte read, the summary's included
168
+ ctx.progress(bytes, size === undefined ? undefined : bytes + size, "bytes");
169
+ // records the validators in report.source; the file path keeps them
170
+ ctx.finish({ validators: validatorsOf(summary) });
171
+ const path = format === "cx" ? `v2/network/${uuid}` : `v3/networks/${uuid}`;
172
+ const body = await ndexFetch(ctx, path, uuid);
173
+ return { body, format, meta: metaOf(summary) };
174
+ },
175
+ async probe(params, ctx): Promise<SourceProbe> {
176
+ const uuid = checkedUuid(params.uuid, ctx);
177
+ const { summary } = await readSummary(uuid, ctx);
178
+ return {
179
+ ok: true,
180
+ counts: {
181
+ nodes: summary.nodeCount,
182
+ edges: summary.edgeCount,
183
+ bytes: sizeOf(summary, params.format ?? "cx2"),
184
+ },
185
+ };
186
+ },
187
+ async list(query: SourceListQuery<NdexParams>, ctx): Promise<SourceListing> {
188
+ checkEndpoint(ctx);
189
+ const start = Number(query.cursor?.start ?? 0);
190
+ const size = query.size ?? 25;
191
+ const body = await ctx.fetchJson<{ networks?: unknown; numFound?: unknown }>(
192
+ `v2/search/network?start=${String(start)}&size=${String(size)}`,
193
+ {
194
+ method: "POST",
195
+ idempotent: true,
196
+ headers: { "Content-Type": "application/json" },
197
+ body: JSON.stringify({ searchString: query.search ?? "" }),
198
+ },
199
+ );
200
+ const networks = Array.isArray(body.networks)
201
+ ? (body.networks as readonly NdexSearchHit[])
202
+ : failOn(ctx.report, "E_SOURCE_RESPONSE", "the NDEx search answer has no networks", {
203
+ expected: "ndex-search",
204
+ contentType: "application/json",
205
+ });
206
+ const { numFound } = body;
207
+ const items = networks.flatMap((n) =>
208
+ typeof n.externalId === "string"
209
+ ? [
210
+ {
211
+ params: { uuid: n.externalId },
212
+ name: n.name ?? n.externalId,
213
+ nodeCount: n.nodeCount,
214
+ edgeCount: n.edgeCount,
215
+ modified: iso(n.modificationTime),
216
+ },
217
+ ]
218
+ : [],
219
+ );
220
+ const total = typeof numFound === "number" ? numFound : undefined;
221
+ const more = total === undefined ? networks.length === size : start + networks.length < total;
222
+ return { items, next: more && networks.length > 0 ? { start: start + networks.length } : null, total };
223
+ },
224
+ async validate(params, seen, ctx): Promise<SourceFreshness> {
225
+ const uuid = checkedUuid(params.uuid, ctx);
226
+ const validators = validatorsOf((await readSummary(uuid, ctx)).summary);
227
+ if (seen.modified === undefined || validators.modified === undefined) {
228
+ return { status: "unverifiable", validators };
229
+ }
230
+ return seen.modified === validators.modified
231
+ ? { status: "current", via: "modified", validators }
232
+ : { status: "changed", via: "modified", changedAt: validators.modified, validators };
233
+ },
234
+ expand: expandNdex,
235
+ });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The parameters of the NDEx source (design section 12.1). Experimental. The NDEx work may add
3
+ * optional fields only.
4
+ */
5
+
6
+ /**
7
+ * What to load from NDEx. Experimental.
8
+ * @category Network sources
9
+ */
10
+ export interface NdexParams {
11
+ /** The network's UUID ("86719f5b-1439-11f0-9806-005056ae3c32"). */
12
+ readonly uuid: string;
13
+ /** The download format. @defaultValue "cx2" */
14
+ readonly format?: "cx2" | "cx" | undefined;
15
+ /** The node attribute that identifies a node across NDEx's two id spaces (for expand): "name", "represents". */
16
+ readonly idAttribute?: string | undefined;
17
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * NDEx share links: a network's page or API URL, possibly carrying a link-share access key.
3
+ */
4
+
5
+ import { credentials } from "../credentials.js";
6
+ import { failAlone } from "../fail.js";
7
+ import { NDEX_SOURCE_ID } from "../ids.js";
8
+ import { type Credential } from "../types.js";
9
+ import { ACCESS_KEY_QUERY } from "./client.js";
10
+
11
+ /** A network UUID anywhere in a URL's path or hash. */
12
+ const UUID_IN_URL = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
13
+
14
+ /**
15
+ * What a share link says: the network, the NDEx server, and the access key as a credential.
16
+ * Experimental.
17
+ * @category Network sources
18
+ */
19
+ export interface NdexShareLink {
20
+ /** The params to load the network with. */
21
+ readonly params: {
22
+ /** The network's NDEx id. */
23
+ readonly uuid: string;
24
+ };
25
+ /** The NDEx server the link points at ("https://www.ndexbio.org/"). */
26
+ readonly endpoint: string;
27
+ /** The link's access key, sent only to that server; absent when the link has none. */
28
+ readonly credential?: Credential | undefined;
29
+ }
30
+
31
+ /**
32
+ * Read an NDEx share link (`https://www.ndexbio.org/viewer/networks/<uuid>?accesskey=<key>`, the
33
+ * older `#/network/<uuid>` form, or an API URL). The access key leaves the URL and becomes a
34
+ * credential bound to the link's server, so it is never logged or stored with the params.
35
+ * Rejects with `E_SOURCE_PARAM` (`name: "url"`): `reason: "format"` when the text is not a URL
36
+ * naming a network, `"credentials-in-url"` when it carries a user name or password. Experimental.
37
+ * @param url - the link
38
+ * @returns the params, endpoint and credential to load it with
39
+ * @example
40
+ * ```ts
41
+ * const link = parseShareUrl(sharedUrl);
42
+ * const { snapshot } = await loadFromSource("ndex", link.params, {
43
+ * endpoint: link.endpoint,
44
+ * credential: link.credential,
45
+ * });
46
+ * ```
47
+ * @category Network sources
48
+ */
49
+ export function parseShareUrl(url: string | URL): NdexShareLink {
50
+ let parsed: URL;
51
+ try {
52
+ parsed = new URL(url);
53
+ } catch {
54
+ return refuse("format");
55
+ }
56
+ if (parsed.username !== "" || parsed.password !== "") {
57
+ return refuse("credentials-in-url");
58
+ }
59
+ // the older viewer keeps the network and its key in the hash
60
+ const hash = new URL(parsed.hash.replace(/^#/, ""), "https://hash.invalid/");
61
+ const uuid = UUID_IN_URL.exec(`${parsed.pathname} ${hash.pathname}`)?.[0];
62
+ if (uuid === undefined || (parsed.protocol !== "https:" && parsed.protocol !== "http:")) {
63
+ return refuse("format");
64
+ }
65
+ // the bare host redirects to www without CORS headers, so a page cannot follow it
66
+ const host = parsed.host.toLowerCase() === "ndexbio.org" ? "www.ndexbio.org" : parsed.host;
67
+ const endpoint = `${parsed.protocol}//${host}/`;
68
+ const key = parsed.searchParams.get(ACCESS_KEY_QUERY) ?? hash.searchParams.get(ACCESS_KEY_QUERY);
69
+ const params = { uuid: uuid.toLowerCase() };
70
+ if (key === null || key === "") {
71
+ return { params, endpoint };
72
+ }
73
+ const credential = credentials.apiKey({ query: ACCESS_KEY_QUERY }, key, { origins: [new URL(endpoint).origin] });
74
+ return { params, endpoint, credential };
75
+ }
76
+
77
+ /**
78
+ * Reject a share link.
79
+ * @param reason - why
80
+ * @returns never
81
+ */
82
+ function refuse(reason: "format" | "credentials-in-url"): never {
83
+ return failAlone("E_SOURCE_PARAM", "not an NDEx share link", { name: "url", reason }, `source:${NDEX_SOURCE_ID}`);
84
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `SourceParamsMap`: the params type of every built-in source by id, so `loadFromSource("ndex", ...)`
3
+ * type-checks its params. A consumer adds its own source by declaration merging.
4
+ */
5
+
6
+ import { type CypherParams } from "./cypher/params.js";
7
+ import { type NdexParams } from "./ndex/params.js";
8
+ import { type OpenAlexParams, type RestParams } from "./rest/params.js";
9
+
10
+ /**
11
+ * Parameter types by source id; extend it by declaration merging:
12
+ * `declare module "@graphty/graph-io" { interface SourceParamsMap { people: { team: string } } }`.
13
+ * Experimental.
14
+ * @category Network sources
15
+ */
16
+ export interface SourceParamsMap {
17
+ /** NDEx. */
18
+ ndex: NdexParams;
19
+ /** Any openCypher server. */
20
+ cypher: CypherParams;
21
+ /** Neo4j. */
22
+ neo4j: CypherParams;
23
+ /** Amazon Neptune. */
24
+ neptune: CypherParams;
25
+ /** A REST API through a mapping. */
26
+ rest: RestParams;
27
+ /** OpenAlex. */
28
+ openalex: OpenAlexParams;
29
+ }
@@ -0,0 +1,325 @@
1
+ /**
2
+ * The source registry (design section 3): sources by id, in their own name space beside the
3
+ * formats. Lazy sources are registered by descriptor and load their code on first use, so listing
4
+ * sources loads none. A FormatRegistry holds one, so one object holds formats and sources.
5
+ */
6
+
7
+ import { type GraphBuilder, type GraphSink } from "@graphty/graph-format";
8
+
9
+ import { type FormatRegistry, type ImportGraphResult } from "../registry.js";
10
+ import { type ImportReport } from "../types.js";
11
+ import { checkLazySource, checkSource } from "./define.js";
12
+ import { failAlone } from "./fail.js";
13
+ import { runIntoSink, runMethod, sourceFormat, stopAtLimit, withSource, wrapCursor, wrapSink } from "./run.js";
14
+ import {
15
+ type ExpandRequest,
16
+ type GraphSource,
17
+ type LazySource,
18
+ type LoadFromSourceOptions,
19
+ type SourceDescriptor,
20
+ type SourceFreshness,
21
+ type SourceInfo,
22
+ type SourceListing,
23
+ type SourceListQuery,
24
+ type SourceProbe,
25
+ type SourceValidators,
26
+ } from "./types.js";
27
+
28
+ /** A registered source: loaded, or a lazy one with its descriptor. */
29
+ interface Entry {
30
+ /** The descriptor known without loading. */
31
+ readonly descriptor: SourceDescriptor;
32
+ /** The lazy registration, if any. */
33
+ readonly lazy: LazySource | null;
34
+ /** The loaded source. */
35
+ source: GraphSource<never> | null;
36
+ /** The load in flight. */
37
+ loading: Promise<GraphSource<never>> | null;
38
+ }
39
+
40
+ /**
41
+ * Whether a registration is a lazy source rather than a source.
42
+ * @param value - the registration
43
+ * @returns true for a LazySource
44
+ */
45
+ function isLazy(value: GraphSource<never> | LazySource): value is LazySource {
46
+ const v = value as { load?: unknown; records?: unknown; file?: unknown; import?: unknown };
47
+ return typeof v.load === "function" && v.records === undefined && v.file === undefined && v.import === undefined;
48
+ }
49
+
50
+ /** What a SourceRegistry borrows from its FormatRegistry: building and freezing a graph. */
51
+ interface SourceBuilding {
52
+ /**
53
+ * A builder seeded from the load options.
54
+ * @param options - the options
55
+ * @param format - the report format name
56
+ * @returns the builder
57
+ */
58
+ readonly newBuilder: (options: LoadFromSourceOptions, format: string) => GraphBuilder;
59
+ /**
60
+ * Freeze a filled builder into a load result.
61
+ * @param format - the result's format
62
+ * @param builder - the builder
63
+ * @param report - the report
64
+ * @param options - the options
65
+ * @returns the result
66
+ */
67
+ readonly freeze: (
68
+ format: string,
69
+ builder: GraphBuilder,
70
+ report: ImportReport,
71
+ options: LoadFromSourceOptions,
72
+ ) => ImportGraphResult;
73
+ }
74
+
75
+ /**
76
+ * The sources of one FormatRegistry. Experimental.
77
+ * @category Network sources
78
+ */
79
+ export class SourceRegistry {
80
+ private readonly entries = new Map<string, Entry>();
81
+
82
+ /**
83
+ * Create one for a format registry, whose importers read `file` sources.
84
+ * @param formats - the format registry
85
+ * @param building - how it builds and freezes graphs
86
+ */
87
+ constructor(
88
+ private readonly formats: FormatRegistry,
89
+ private readonly building: SourceBuilding,
90
+ ) {}
91
+
92
+ /**
93
+ * Register a source or a lazy source. A malformed one, or an id already taken, throws an
94
+ * ImportError with E_SOURCE_INVALID.
95
+ * @param source - the source
96
+ */
97
+ register(source: GraphSource<never> | LazySource): void {
98
+ if (isLazy(source)) {
99
+ checkLazySource(source);
100
+ } else {
101
+ checkSource(source);
102
+ }
103
+ if (this.entries.has(source.id)) {
104
+ failAlone("E_SOURCE_INVALID", `a source with id ${source.id} is already registered`, {
105
+ id: source.id,
106
+ reason: "duplicate",
107
+ });
108
+ }
109
+ const lazy = isLazy(source) ? source : null;
110
+ this.entries.set(source.id, {
111
+ descriptor: source.descriptor ?? { plainName: source.id, params: [] },
112
+ lazy,
113
+ source: lazy === null ? (source as GraphSource<never>) : null,
114
+ loading: null,
115
+ });
116
+ }
117
+
118
+ /**
119
+ * Whether a source id is registered.
120
+ * @param id - the id
121
+ * @returns true when registered
122
+ */
123
+ has(id: string): boolean {
124
+ return this.entries.has(id);
125
+ }
126
+
127
+ /**
128
+ * Every registered source, without loading any code.
129
+ * @returns one entry per source, in registration order
130
+ */
131
+ list(): readonly SourceInfo[] {
132
+ return Object.freeze(
133
+ [...this.entries].map(([id, e]) =>
134
+ Object.freeze({ id, descriptor: e.descriptor, loaded: e.source !== null }),
135
+ ),
136
+ );
137
+ }
138
+
139
+ /**
140
+ * A source by id, loading a lazy one; a source object passes through after its checks.
141
+ * @param source - the id or the source
142
+ * @returns the loaded source
143
+ */
144
+ async resolve(source: string | GraphSource<never>): Promise<GraphSource<never>> {
145
+ if (typeof source !== "string") {
146
+ checkSource(source);
147
+ return source;
148
+ }
149
+ const entry = this.entries.get(source);
150
+ if (entry === undefined) {
151
+ return failAlone(
152
+ "E_SOURCE_UNKNOWN",
153
+ `no source has id ${JSON.stringify(source)}`,
154
+ { id: source, known: [...this.entries.keys()] },
155
+ sourceFormat(source),
156
+ );
157
+ }
158
+ if (entry.source !== null) {
159
+ return entry.source;
160
+ }
161
+ const lazy = entry.lazy as LazySource;
162
+ entry.loading ??= lazy.load().then(
163
+ (loaded) => {
164
+ if (loaded.id !== lazy.id) {
165
+ failAlone("E_SOURCE_INVALID", `lazy source ${lazy.id} loaded a source with id ${loaded.id}`, {
166
+ id: lazy.id,
167
+ reason: "lazy",
168
+ });
169
+ }
170
+ checkSource(loaded, lazy.descriptor);
171
+ entry.source = loaded.descriptor === undefined ? { ...loaded, descriptor: lazy.descriptor } : loaded;
172
+ return entry.source;
173
+ },
174
+ (err: unknown) => {
175
+ entry.loading = null;
176
+ throw err;
177
+ },
178
+ );
179
+ return entry.loading;
180
+ }
181
+
182
+ /**
183
+ * Load a graph from a source.
184
+ * @param source - the id or the source
185
+ * @param params - its params
186
+ * @param options - endpoint, credential, cursor, caps and the import options
187
+ * @returns the graph and the report
188
+ */
189
+ async load(
190
+ source: string | GraphSource<never>,
191
+ params: Readonly<Record<string, unknown>>,
192
+ options: LoadFromSourceOptions = {},
193
+ ): Promise<ImportGraphResult> {
194
+ const resolved = await this.resolve(source);
195
+ const builder = this.building.newBuilder(options, sourceFormat(resolved.id));
196
+ const { report, format } = await runIntoSink(resolved, params, builder, options, this.formats);
197
+ return this.building.freeze(format, builder, report, options);
198
+ }
199
+
200
+ /**
201
+ * Load from a source into a sink you own.
202
+ * @param source - the id or the source
203
+ * @param params - its params
204
+ * @param sink - where to write
205
+ * @param options - the options
206
+ * @returns the report
207
+ */
208
+ async import(
209
+ source: string | GraphSource<never>,
210
+ params: Readonly<Record<string, unknown>>,
211
+ sink: GraphSink,
212
+ options: LoadFromSourceOptions = {},
213
+ ): Promise<ImportReport> {
214
+ const resolved = await this.resolve(source);
215
+ return (await runIntoSink(resolved, params, sink, options, this.formats)).report;
216
+ }
217
+
218
+ /**
219
+ * Fetch the neighborhood of some nodes: a snapshot of only what was fetched.
220
+ * @param source - the id or the source
221
+ * @param request - the seeds and how far to go
222
+ * @param options - the options
223
+ * @returns the fetched part and the report
224
+ */
225
+ async expand(
226
+ source: string | GraphSource<never>,
227
+ request: ExpandRequest<Readonly<Record<string, unknown>>>,
228
+ options: LoadFromSourceOptions = {},
229
+ ): Promise<ImportGraphResult> {
230
+ const resolved = await this.resolve(source);
231
+ const builder: GraphBuilder = this.building.newBuilder(options, sourceFormat(resolved.id));
232
+ const report = await runMethod(resolved, "expand", request.params, options, async (prepared) => {
233
+ const sink = wrapSink(builder, prepared, options.idPrefix);
234
+ const run = resolved.expand?.({ ...request, params: prepared.params } as never, sink, prepared.created.ctx);
235
+ const out = await stopAtLimit(run as Promise<ImportReport>, prepared);
236
+ return withSource(
237
+ out,
238
+ prepared,
239
+ wrapCursor(prepared.created.state.finish?.next, resolved.descriptor?.version ?? 1),
240
+ );
241
+ });
242
+ return this.building.freeze(sourceFormat(resolved.id), builder, report, options);
243
+ }
244
+
245
+ /**
246
+ * Check params and credential without loading.
247
+ * @param source - the id or the source
248
+ * @param params - its params
249
+ * @param options - the options
250
+ * @returns what the service said
251
+ */
252
+ async probe(
253
+ source: string | GraphSource<never>,
254
+ params: Readonly<Record<string, unknown>>,
255
+ options: LoadFromSourceOptions = {},
256
+ ): Promise<SourceProbe> {
257
+ const resolved = await this.resolve(source);
258
+ return runMethod(
259
+ resolved,
260
+ "probe",
261
+ params,
262
+ options,
263
+ (prepared) => resolved.probe?.(prepared.params as never, prepared.created.ctx) as Promise<SourceProbe>,
264
+ );
265
+ }
266
+
267
+ /**
268
+ * Search what a source holds.
269
+ * @param source - the id or the source
270
+ * @param query - the search
271
+ * @param options - the options
272
+ * @returns one page of results
273
+ */
274
+ async search(
275
+ source: string | GraphSource<never>,
276
+ query: SourceListQuery<Readonly<Record<string, unknown>>>,
277
+ options: LoadFromSourceOptions = {},
278
+ ): Promise<SourceListing> {
279
+ const resolved = await this.resolve(source);
280
+ // a search narrows by some params, so required ones are not checked
281
+ const partial: SourceDescriptor | undefined =
282
+ resolved.descriptor === undefined
283
+ ? undefined
284
+ : {
285
+ ...resolved.descriptor,
286
+ params: resolved.descriptor.params.map((p) => ({ ...p, required: false })),
287
+ };
288
+ return runMethod(
289
+ { ...resolved, descriptor: partial },
290
+ "list",
291
+ query.params,
292
+ options,
293
+ (prepared) =>
294
+ resolved.list?.(
295
+ { ...query, params: prepared.params } as never,
296
+ prepared.created.ctx,
297
+ ) as Promise<SourceListing>,
298
+ );
299
+ }
300
+
301
+ /**
302
+ * Tell whether data loaded earlier changed.
303
+ * @param source - the id or the source
304
+ * @param params - the params it was loaded with
305
+ * @param seen - the validators recorded then
306
+ * @param options - the options
307
+ * @returns whether it changed
308
+ */
309
+ async validate(
310
+ source: string | GraphSource<never>,
311
+ params: Readonly<Record<string, unknown>>,
312
+ seen: SourceValidators,
313
+ options: LoadFromSourceOptions = {},
314
+ ): Promise<SourceFreshness> {
315
+ const resolved = await this.resolve(source);
316
+ return runMethod(
317
+ resolved,
318
+ "validate",
319
+ params,
320
+ options,
321
+ (prepared) =>
322
+ resolved.validate?.(prepared.params as never, seen, prepared.created.ctx) as Promise<SourceFreshness>,
323
+ );
324
+ }
325
+ }