@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,368 @@
1
+ /**
2
+ * Attribute declaration shared by the typed importers (design sections 5.1, 5.5 and 5.6): turn a
3
+ * GEXF `<attribute>`, a GraphML `<key>` or a Neo4j header column into a ColumnDecl with the right
4
+ * dtype, default, options and origin metadata; parse values (scalars and lists) by the declaration;
5
+ * derive the deterministic `<name>#<origin.id>` name when a declared name collides; and the dict
6
+ * heuristic of design section 5.4.
7
+ *
8
+ * Naming rule (design section 5.6): a column's name is the GEXF `title` / GraphML `attr.name`,
9
+ * falling back to the attribute `id` when the title is absent; `origin.id` always keeps the source
10
+ * id and `origin.title` the title when it differs from the resolved name.
11
+ */
12
+ import { GraphFormatError, INVALID_INDEX, } from "@graphty/graph-format";
13
+ import { BAD_DEFAULT_CODE, BAD_OPTIONS_CODE, COLUMN_RENAMED_CODE, PRECISION_CODE, ROLE_TAKEN_CODE, UNKNOWN_ATTR_TYPE_CODE, } from "./codes.js";
14
+ import { mapDeclaredType, parseScalarText, stringSpec, } from "./declared-types.js";
15
+ import { splitListText } from "./lists.js";
16
+ import { parseTemporal, timeTextCompanion } from "./temporal.js";
17
+ /** Issue code: the declared type is not one the format defines; the column is kept as string. */
18
+ export const UNKNOWN_TYPE_CODE = UNKNOWN_ATTR_TYPE_CODE;
19
+ /** Issue code: the column was renamed `<name>#<id>` because the name was taken (design section 5.6). */
20
+ export const RENAMED_CODE = COLUMN_RENAMED_CODE;
21
+ export { BAD_DEFAULT_CODE, BAD_OPTIONS_CODE, PRECISION_CODE, ROLE_TAKEN_CODE };
22
+ /** Rows sampled before the dict heuristic decides (design section 5.4). */
23
+ export const DICT_SAMPLE_ROWS = 1024;
24
+ /**
25
+ * Build the column declaration of a declared attribute.
26
+ * @param input - what the file declares
27
+ * @returns the declaration, the value spec and any warnings to record
28
+ */
29
+ export function declareAttribute(input) {
30
+ const issues = [];
31
+ const listSyntax = input.listSyntax ?? "gexf";
32
+ let spec;
33
+ if (input.type === null) {
34
+ spec = stringSpec(null);
35
+ }
36
+ else {
37
+ const mapped = mapDeclaredType(input.format, input.type, input.long);
38
+ if (mapped === null) {
39
+ spec = stringSpec(input.type);
40
+ issues.push({
41
+ category: "unsupported",
42
+ code: UNKNOWN_TYPE_CODE,
43
+ message: `${input.format} type "${input.type}" is not supported; values kept as text`,
44
+ });
45
+ }
46
+ else {
47
+ spec = mapped;
48
+ }
49
+ }
50
+ const { name, renamed } = resolveName(input);
51
+ if (renamed) {
52
+ issues.push({
53
+ category: "coercion",
54
+ code: RENAMED_CODE,
55
+ message: `attribute "${input.title ?? input.id ?? ""}" renamed to "${name}": the name was taken`,
56
+ });
57
+ }
58
+ const decl = {
59
+ name,
60
+ dtype: spec.dtype,
61
+ nullable: true,
62
+ origin: {
63
+ format: input.format,
64
+ id: input.id,
65
+ title: input.title !== null && input.title !== name ? input.title : null,
66
+ type: input.type,
67
+ namespace: input.namespace ?? null,
68
+ },
69
+ };
70
+ if (spec.list) {
71
+ decl.itemDtype = spec.itemDtype ?? "string";
72
+ }
73
+ if (input.role !== undefined && input.role !== null) {
74
+ decl.role = input.role;
75
+ }
76
+ if (input.dynamic === true) {
77
+ decl.dynamic = true;
78
+ }
79
+ const optionsText = input.optionsText ?? null;
80
+ if (optionsText !== null) {
81
+ try {
82
+ const options = splitListText(optionsText, listSyntax).map((item) => parseItem(item, spec));
83
+ decl.options = options;
84
+ if (spec.dtype === "string" && !spec.list && options.every((o) => typeof o === "string")) {
85
+ decl.dtype = "dict";
86
+ spec = { ...spec, dtype: "dict" };
87
+ }
88
+ }
89
+ catch (err) {
90
+ issues.push({
91
+ category: "validation-error",
92
+ code: BAD_OPTIONS_CODE,
93
+ message: `options "${optionsText}" of attribute "${name}" do not parse as ${spec.declared}: ${messageOf(err)}`,
94
+ });
95
+ }
96
+ }
97
+ const defaultText = input.defaultText ?? null;
98
+ if (defaultText !== null) {
99
+ try {
100
+ decl.default = parseDeclaredValue(defaultText, spec, listSyntax);
101
+ }
102
+ catch (err) {
103
+ issues.push({
104
+ category: "validation-error",
105
+ code: BAD_DEFAULT_CODE,
106
+ message: `default "${defaultText}" of attribute "${name}" does not parse as ${spec.declared}: ${messageOf(err)}`,
107
+ });
108
+ }
109
+ }
110
+ const companion = spec.temporal !== null && !spec.list ? timeTextCompanion(name) : null;
111
+ return { decl, spec, listSyntax, companion, renamed, issues };
112
+ }
113
+ /**
114
+ * Parse a value text by a declaration: a scalar, or a list split by the syntax with each item
115
+ * parsed by the item kind.
116
+ * @param text - the value text
117
+ * @param spec - the declared type
118
+ * @param listSyntax - the list syntax
119
+ * @returns the value to push (a boolean, a number, a string, a JSON value or an array)
120
+ */
121
+ export function parseDeclaredValue(text, spec, listSyntax) {
122
+ if (spec.list) {
123
+ return splitListText(text, listSyntax).map((item) => parseItem(item, spec));
124
+ }
125
+ return parseItem(text, spec);
126
+ }
127
+ /**
128
+ * Parse a temporal value text by a declaration, keeping the source text when its canonical form
129
+ * differs (for the companion column).
130
+ * @param text - the value text
131
+ * @param spec - a scalar temporal spec
132
+ * @returns the value and the text to keep, or null text
133
+ */
134
+ export function parseDeclaredTemporal(text, spec) {
135
+ if (spec.temporal === null || spec.list) {
136
+ throw new GraphFormatError("E_COLUMN_TYPE", `"${spec.declared}" is not a scalar temporal type`, {
137
+ declared: spec.declared,
138
+ });
139
+ }
140
+ return parseTemporal(text.trim(), spec.temporal);
141
+ }
142
+ const INTEGER_TEXT = /^[+-]?[0-9]+$/;
143
+ /**
144
+ * Whether a long value's text lost precision when parsed to f64 (design section 5.1: a value with
145
+ * |v| > 2^53 is stored as the nearest f64 and recorded as a `precision` issue). Decided from the
146
+ * text, since the parsed number alone cannot tell 2^53 from 2^53 + 1.
147
+ * @param spec - the declared type
148
+ * @param text - the value text (trimmed or not)
149
+ * @returns true when the importer should record a `precision` issue
150
+ */
151
+ export function losesPrecision(spec, text) {
152
+ if (!spec.precision) {
153
+ return false;
154
+ }
155
+ const trimmed = text.trim();
156
+ if (!INTEGER_TEXT.test(trimmed)) {
157
+ return false;
158
+ }
159
+ const n = Number(trimmed);
160
+ return !Number.isFinite(n) || BigInt(trimmed) !== BigInt(n);
161
+ }
162
+ /**
163
+ * Declare a column on the sink for one domain.
164
+ * @param sink - the sink
165
+ * @param domain - node or edge
166
+ * @param decl - the declaration
167
+ * @returns the column handle
168
+ */
169
+ export function declareOn(sink, domain, decl) {
170
+ return domain === "node" ? sink.declareNodeColumn(decl) : sink.declareEdgeColumn(decl);
171
+ }
172
+ /**
173
+ * The io rule of design section 5.6 in one place, so every importer agrees: declare a column on
174
+ * the sink and, when the sink already holds the name with another shape (an earlier import, a
175
+ * caller's column), rename it `<name>#<origin.id>` (a counter when the source has no id) and
176
+ * record W_COLUMN_RENAMED (coercion); when the table already holds the role (design section 5.5:
177
+ * at most one column per role), declare without the role and record W_ROLE_TAKEN (coercion). The
178
+ * same shape under the same name returns the existing handle, as the sink does.
179
+ * @param sink - the sink
180
+ * @param domain - node or edge
181
+ * @param decl - the wanted declaration
182
+ * @param report - the report the coercion issues are recorded in
183
+ * @param where - the line and element, when known
184
+ * @returns the handle and the declaration as applied
185
+ */
186
+ export function declareResolved(sink, domain, decl, report, where) {
187
+ let current = decl;
188
+ let renamed = false;
189
+ let roleDropped = false;
190
+ for (;;) {
191
+ try {
192
+ return { handle: declareOn(sink, domain, current), decl: current, renamed, roleDropped };
193
+ }
194
+ catch (err) {
195
+ if (!(err instanceof GraphFormatError)) {
196
+ throw err;
197
+ }
198
+ if (err.code === "E_COLUMN_EXISTS" && !renamed) {
199
+ const taken = takenIn(sink, domain);
200
+ const id = current.origin?.id ?? null;
201
+ const name = uniqueColumnName(current.name, id, taken);
202
+ report.warning("coercion", COLUMN_RENAMED_CODE, `${domain} column "${current.name}" renamed to "${name}": the sink already holds that name with another shape`, { ...where, element: where?.element ?? current.name });
203
+ current = { ...current, name };
204
+ renamed = true;
205
+ continue;
206
+ }
207
+ if (err.code === "E_DUPLICATE_ROLE" && current.role !== undefined && !roleDropped) {
208
+ const holder = typeof err.details.holder === "string" ? err.details.holder : "another column";
209
+ report.warning("coercion", ROLE_TAKEN_CODE, `${domain} column "${current.name}" loses the ${current.role} role: "${holder}" already holds it`, { ...where, element: where?.element ?? current.name });
210
+ const { role: _role, ...withoutRole } = current;
211
+ current = withoutRole;
212
+ roleDropped = true;
213
+ continue;
214
+ }
215
+ throw err;
216
+ }
217
+ }
218
+ }
219
+ /**
220
+ * Declare the companion text column of a temporal column (design section 5.1). A table holds at
221
+ * most one column per role, so when another companion already carries `timeText` this one is
222
+ * declared without the role (reported once per table); exporters find every companion through
223
+ * `extra.for`.
224
+ * @param sink - the sink
225
+ * @param domain - node or edge
226
+ * @param companion - the declaration from declareAttribute()
227
+ * @param report - the report the role loss is recorded in; when omitted the loss is silent
228
+ * @returns the column handle
229
+ */
230
+ export function declareCompanion(sink, domain, companion, report) {
231
+ try {
232
+ return declareOn(sink, domain, companion);
233
+ }
234
+ catch (err) {
235
+ if (err instanceof GraphFormatError && err.code === "E_DUPLICATE_ROLE") {
236
+ report?.warnOnce("coercion", ROLE_TAKEN_CODE, `${domain} column "${companion.name}" is declared without the timeText role: another companion holds it (exporters use extra.for)`, { element: companion.name });
237
+ const { role: _role, ...withoutRole } = companion;
238
+ return declareOn(sink, domain, withoutRole);
239
+ }
240
+ throw err;
241
+ }
242
+ }
243
+ /**
244
+ * Whether a column name is taken in a sink's table, the usual `taken` callback.
245
+ * @param sink - the sink
246
+ * @param domain - node or edge
247
+ * @returns a predicate over column names
248
+ */
249
+ export function takenIn(sink, domain) {
250
+ return (name) => (domain === "node" ? sink.nodeColumn(name) : sink.edgeColumn(name)) !== INVALID_INDEX;
251
+ }
252
+ /**
253
+ * The deterministic name of a declared attribute whose preferred name is taken (design section
254
+ * 5.6): `<name>#<origin.id>`, and `<name>#<origin.id>#2`, `#3`... should that be taken as well.
255
+ * @param name - the preferred name
256
+ * @param id - the source id (the attribute id or key id); null falls back to a counter
257
+ * @param taken - whether a name is already used in the table
258
+ * @returns a free name
259
+ */
260
+ export function uniqueColumnName(name, id, taken) {
261
+ if (!taken(name)) {
262
+ return name;
263
+ }
264
+ const base = id === null ? name : `${name}#${id}`;
265
+ if (id !== null && !taken(base)) {
266
+ return base;
267
+ }
268
+ for (let n = 2;; n++) {
269
+ const candidate = `${base}#${n}`;
270
+ if (!taken(candidate)) {
271
+ return candidate;
272
+ }
273
+ }
274
+ }
275
+ /**
276
+ * The dict heuristic of design section 5.4 for an untyped string column: observe values until the
277
+ * sample is full; the column is a dict when the distinct count stays below half the rows, a string
278
+ * otherwise. The importer buffers the sampled values and declares the column on the decision.
279
+ */
280
+ export class DictHeuristic {
281
+ /**
282
+ * Create a heuristic.
283
+ * @param sampleRows - rows observed before deciding; DICT_SAMPLE_ROWS by default
284
+ */
285
+ constructor(sampleRows = DICT_SAMPLE_ROWS) {
286
+ this.distinct = new Set();
287
+ this.rowsSeen = 0;
288
+ this.sampleRows = sampleRows;
289
+ }
290
+ /**
291
+ * Rows observed so far.
292
+ * @returns the count
293
+ */
294
+ get rows() {
295
+ return this.rowsSeen;
296
+ }
297
+ /**
298
+ * Distinct values observed so far.
299
+ * @returns the count
300
+ */
301
+ get distinctCount() {
302
+ return this.distinct.size;
303
+ }
304
+ /**
305
+ * Whether the sample is full.
306
+ * @returns true once sampleRows values were observed
307
+ */
308
+ get decided() {
309
+ return this.rowsSeen >= this.sampleRows;
310
+ }
311
+ /**
312
+ * Observe one value.
313
+ * @param value - the value text
314
+ * @returns true when this observation completed the sample
315
+ */
316
+ observe(value) {
317
+ this.rowsSeen++;
318
+ if (this.distinct.size < this.rowsSeen) {
319
+ this.distinct.add(value);
320
+ }
321
+ return this.rowsSeen === this.sampleRows;
322
+ }
323
+ /**
324
+ * The dtype the sample suggests: dict when the distinct count is below rows / 2 (and at least
325
+ * one row was seen), string otherwise. Valid before the sample is full (end of input).
326
+ * @returns "dict" or "string"
327
+ */
328
+ decide() {
329
+ return this.rowsSeen > 0 && this.distinct.size * 2 < this.rowsSeen ? "dict" : "string";
330
+ }
331
+ }
332
+ /**
333
+ * The resolved name of a declaration and whether it was renamed.
334
+ * @param input - the declaration input
335
+ * @returns the name and the rename flag; E_COLUMN_TYPE when neither a title nor an id exists
336
+ */
337
+ function resolveName(input) {
338
+ const preferred = input.title !== null && input.title.length > 0 ? input.title : input.id;
339
+ if (preferred === null || preferred.length === 0) {
340
+ throw new GraphFormatError("E_COLUMN_TYPE", "an attribute declaration needs a title or an id", {
341
+ field: "name",
342
+ format: input.format,
343
+ });
344
+ }
345
+ if (input.taken === undefined) {
346
+ return { name: preferred, renamed: false };
347
+ }
348
+ const name = uniqueColumnName(preferred, input.id, input.taken);
349
+ return { name, renamed: name !== preferred };
350
+ }
351
+ /**
352
+ * Parse one scalar value or list item by a spec.
353
+ * @param text - the item text
354
+ * @param spec - the declared type
355
+ * @returns the parsed value
356
+ */
357
+ function parseItem(text, spec) {
358
+ return parseScalarText(text, spec.kind, spec.temporal);
359
+ }
360
+ /**
361
+ * The message of a caught value.
362
+ * @param err - the thrown value
363
+ * @returns the message
364
+ */
365
+ function messageOf(err) {
366
+ return err instanceof Error ? err.message : String(err);
367
+ }
368
+ //# sourceMappingURL=attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../../src/common/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAIH,gBAAgB,EAEhB,aAAa,GAChB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,sBAAsB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAGH,eAAe,EACf,eAAe,EACf,UAAU,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAmB,aAAa,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAsB,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAoErF,iGAAiG;AACjG,MAAM,CAAC,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AACxD,wGAAwG;AACxG,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC;AAE/E,2EAA2E;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAgC;IAC7D,MAAM,MAAM,GAAuB,EAAE,CAAC;IACtC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,MAAM,CAA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CAAC;IACP,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC/C,CAAC;IACD,MAAM,IAAI,GAAG,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAChE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,KAAK,SAAS,EAAE,CAAC;AACjD,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,IAAY,EAAE,IAAsB;IACnD,OAAO,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC3D,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,GAAY;IAC3B,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * The issue and loss codes shared by more than one format (design section 8.6: "a stable code
3
+ * such as E_UNKNOWN_NODE or W_WIDENED"): one constant per condition, aliased by every format's
4
+ * `<FMT>_ISSUE` / `<FMT>_LOSS` table, so a consumer can switch on a condition without knowing the
5
+ * format and two importers never spell the same condition differently. A condition specific to one
6
+ * format keeps that format's own `E_<FMT>_` / `W_<FMT>_` code next to its importer or exporter.
7
+ *
8
+ * Naming scheme: `E_` for an issue recorded with severity "error" (or a loss note whose export()
9
+ * throws), `W_` for a warning; a table key is the code without the severity prefix and without the
10
+ * format prefix.
11
+ */
12
+ /** The element (node, attribute, key, ...) has no id where the format requires one. */
13
+ export declare const MISSING_ID_CODE = "E_MISSING_ID";
14
+ /** An edge has no source or no target. */
15
+ export declare const MISSING_ENDPOINT_CODE = "E_MISSING_ENDPOINT";
16
+ /** A node id declared twice; the second declaration merges into the first. */
17
+ export declare const DUPLICATE_NODE_CODE = "W_DUPLICATE_NODE";
18
+ /** The document declares no graph at all (fatal). */
19
+ export declare const NO_GRAPH_CODE = "E_NO_GRAPH";
20
+ /** A second graph in one document is merged into the first. */
21
+ export declare const MULTIPLE_GRAPHS_CODE = "W_MULTIPLE_GRAPHS";
22
+ /** The input is empty (fatal). */
23
+ export declare const EMPTY_INPUT_CODE = "E_EMPTY_INPUT";
24
+ /** The text grammar of the format is violated (fatal; the message carries the detail). */
25
+ export declare const SYNTAX_CODE = "E_SYNTAX";
26
+ /** The XML is not well-formed (fatal; the message carries the detail and the line). */
27
+ export declare const XML_SYNTAX_CODE = "E_XML_SYNTAX";
28
+ /** An element the format does not define at that place was skipped. */
29
+ export declare const UNKNOWN_ELEMENT_CODE = "W_UNKNOWN_ELEMENT";
30
+ /** Text where the format allows only elements was ignored. */
31
+ export declare const STRAY_TEXT_CODE = "W_STRAY_TEXT";
32
+ /** A `pid` / parent reference names a node the document never declares. */
33
+ export declare const UNKNOWN_PARENT_CODE = "E_UNKNOWN_PARENT";
34
+ /** A hyperedge under the `hyperedges: "error"` policy (fatal). */
35
+ export declare const HYPEREDGE_CODE = "E_HYPEREDGE";
36
+ /** A declaration's key / attribute id is declared twice. */
37
+ export declare const DUPLICATE_KEY_CODE = "E_DUPLICATE_KEY";
38
+ /**
39
+ * A column was renamed `<name>#<origin.id>` because the name was taken in the sink's table
40
+ * (design section 5.6).
41
+ */
42
+ export declare const COLUMN_RENAMED_CODE = "W_COLUMN_RENAMED";
43
+ /** A column's role was dropped because another column of the table already holds it (design section 5.5). */
44
+ export declare const ROLE_TAKEN_CODE = "W_ROLE_TAKEN";
45
+ /** A long value beyond 2^53 was stored as the nearest f64 (design section 5.1). */
46
+ export declare const PRECISION_CODE = "W_PRECISION";
47
+ /** Two distinct id texts became one number under ids "number" (design section 4.1). */
48
+ export declare const ID_MERGED_CODE = "W_ID_MERGED";
49
+ /** A builder-policy option the caller asked for that the sink does not honour (design section 8.4). */
50
+ export declare const SINK_OPTION_CODE = "W_SINK_OPTION";
51
+ /** A common option the format has no use for (or cannot honour) was given a non-default value (design section 8.4). */
52
+ export declare const OPTION_IGNORED_CODE = "W_OPTION_IGNORED";
53
+ /** An invalid UTF-8 sequence in the input (fatal). */
54
+ export declare const INVALID_UTF8_CODE = "E_INVALID_UTF8";
55
+ /** The sink refused the file's direction (locked or non-empty); the file is read as the sink's. */
56
+ export declare const DIRECTION_REFUSED_CODE = "W_DIRECTION_REFUSED";
57
+ /** Edges of the other direction were forced to the policy's direction. */
58
+ export declare const DIRECTION_FORCED_CODE = "W_DIRECTION_FORCED";
59
+ /** A mixed-direction file under onMixedDirection "error" (import), or a mixed snapshot under the same export policy. */
60
+ export declare const MIXED_DIRECTION_CODE = "E_MIXED_DIRECTION";
61
+ /** A `count` / `parse.nodes` hint the sink cannot reserve (ignored). */
62
+ export declare const COUNT_HINT_CODE = "W_COUNT_HINT";
63
+ /** The declared type is not one the format defines; the column is kept as string. */
64
+ export declare const UNKNOWN_ATTR_TYPE_CODE = "W_UNKNOWN_ATTR_TYPE";
65
+ /** The declared default does not parse as the declared type; the column has no default. */
66
+ export declare const BAD_DEFAULT_CODE = "W_BAD_DEFAULT";
67
+ /** A declared option does not parse as the declared type; the options are dropped. */
68
+ export declare const BAD_OPTIONS_CODE = "W_BAD_OPTIONS";
69
+ /** A repeated edge id in a format whose edge ids are unique; the second edge is skipped. */
70
+ export declare const DUPLICATE_EDGE_ID_CODE = "E_DUPLICATE_EDGE_ID";
71
+ /** A role column the format has no slot for is written as a plain attribute (the role is lost). */
72
+ export declare const ROLE_DROPPED_CODE = "W_ROLE_DROPPED";
73
+ /** A parents (multi-parent) column in a format with single containment only. */
74
+ export declare const PARENTS_DROPPED_CODE = "W_PARENTS_DROPPED";
75
+ /** A start / end / timestamp column in a format without temporal support. */
76
+ export declare const TEMPORAL_DROPPED_CODE = "W_TEMPORAL_DROPPED";
77
+ /** A mutual pair is written as two directed edges without the mutual mark. */
78
+ export declare const MUTUAL_EXPANDED_CODE = "W_MUTUAL_EXPANDED";
79
+ /** A mutual pair is written as one undirected edge; the pair reads back undirected, the mark is lost. */
80
+ export declare const MUTUAL_AS_UNDIRECTED_CODE = "W_MUTUAL_AS_UNDIRECTED";
81
+ /** Node ids whose written text reads back as the other type under the importer's id rule. */
82
+ export declare const ID_TEXT_TYPE_CODE = "W_ID_TEXT_TYPE";
83
+ /** Two node ids share one written text; export() throws E_INVALID_ID. */
84
+ export declare const ID_TEXT_COLLISION_CODE = "E_ID_TEXT_COLLISION";
85
+ /** A `<column>.text` companion (design section 5.1) the format cannot carry. */
86
+ export declare const TEMPORAL_TEXT_DROPPED_CODE = "W_TEMPORAL_TEXT_DROPPED";
87
+ /** A plain column named like the importer's weight key reads back as THE weight. */
88
+ export declare const WEIGHT_KEY_CLASH_CODE = "W_WEIGHT_KEY_CLASH";
89
+ /** A role-less column whose written name the importer maps to a role. */
90
+ export declare const ROLE_ASSUMED_CODE = "W_ROLE_ASSUMED";
91
+ /** A role column written into the format's slot reads back under the importer's fixed name. */
92
+ export declare const COLUMN_RENAMED_LOSS_CODE = "W_COLUMN_NAME_CHANGED";
93
+ /** A declared column whose every row is unset is not written by a format without declarations. */
94
+ export declare const EMPTY_COLUMN_DROPPED_CODE = "W_EMPTY_COLUMN_DROPPED";
95
+ /** A string / dict column whose cardinality makes the importer read it back as the other storage class. */
96
+ export declare const STORAGE_CLASS_CODE = "W_STORAGE_CLASS_CHANGED";
97
+ /** An f64 column whose set values are all integral reads back as i32 through an untyped format. */
98
+ export declare const INTEGRAL_F64_CODE = "W_INTEGRAL_F64_AS_I32";
99
+ /** A text cell that reads back as a number or boolean under the 5.1 grammar (its lexical form may change). */
100
+ export declare const TEXT_INFERRED_CODE = "W_TEXT_INFERRED";
101
+ /** A string cell holding a character XML 1.0 forbids; export() throws E_COLUMN_TYPE. */
102
+ export declare const XML_ILLEGAL_CHAR_CODE = "E_XML_ILLEGAL_CHAR";
103
+ /** A dict column without declared options gains one from its dictionary on re-import. */
104
+ export declare const OPTIONS_GAINED_CODE = "W_OPTIONS_GAINED";
105
+ //# sourceMappingURL=codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../../src/common/codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,uFAAuF;AACvF,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C,0CAA0C;AAC1C,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAE1D,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAEtD,qDAAqD;AACrD,eAAO,MAAM,aAAa,eAAe,CAAC;AAE1C,+DAA+D;AAC/D,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AAExD,kCAAkC;AAClC,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAEhD,0FAA0F;AAC1F,eAAO,MAAM,WAAW,aAAa,CAAC;AAEtC,uFAAuF;AACvF,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C,uEAAuE;AACvE,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AAExD,8DAA8D;AAC9D,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAEtD,kEAAkE;AAClE,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAE5C,4DAA4D;AAC5D,eAAO,MAAM,kBAAkB,oBAAoB,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAEtD,6GAA6G;AAC7G,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C,mFAAmF;AACnF,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAE5C,uFAAuF;AACvF,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAE5C,uGAAuG;AACvG,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAEhD,u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AAElE,2GAA2G;AAC3G,eAAO,MAAM,kBAAkB,4BAA4B,CAAC;AAE5D,mGAAmG;AACnG,eAAO,MAAM,iBAAiB,0BAA0B,CAAC;AAEzD,8GAA8G;AAC9G,eAAO,MAAM,kBAAkB,oBAAoB,CAAC;AAEpD,wFAAwF;AACxF,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAE1D,yFAAyF;AACzF,eAAO,MAAM,mBAAmB,qBAAqB,CAAC"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * The issue and loss codes shared by more than one format (design section 8.6: "a stable code
3
+ * such as E_UNKNOWN_NODE or W_WIDENED"): one constant per condition, aliased by every format's
4
+ * `<FMT>_ISSUE` / `<FMT>_LOSS` table, so a consumer can switch on a condition without knowing the
5
+ * format and two importers never spell the same condition differently. A condition specific to one
6
+ * format keeps that format's own `E_<FMT>_` / `W_<FMT>_` code next to its importer or exporter.
7
+ *
8
+ * Naming scheme: `E_` for an issue recorded with severity "error" (or a loss note whose export()
9
+ * throws), `W_` for a warning; a table key is the code without the severity prefix and without the
10
+ * format prefix.
11
+ */
12
+ // ============================================================ importer issues
13
+ /** The element (node, attribute, key, ...) has no id where the format requires one. */
14
+ export const MISSING_ID_CODE = "E_MISSING_ID";
15
+ /** An edge has no source or no target. */
16
+ export const MISSING_ENDPOINT_CODE = "E_MISSING_ENDPOINT";
17
+ /** A node id declared twice; the second declaration merges into the first. */
18
+ export const DUPLICATE_NODE_CODE = "W_DUPLICATE_NODE";
19
+ /** The document declares no graph at all (fatal). */
20
+ export const NO_GRAPH_CODE = "E_NO_GRAPH";
21
+ /** A second graph in one document is merged into the first. */
22
+ export const MULTIPLE_GRAPHS_CODE = "W_MULTIPLE_GRAPHS";
23
+ /** The input is empty (fatal). */
24
+ export const EMPTY_INPUT_CODE = "E_EMPTY_INPUT";
25
+ /** The text grammar of the format is violated (fatal; the message carries the detail). */
26
+ export const SYNTAX_CODE = "E_SYNTAX";
27
+ /** The XML is not well-formed (fatal; the message carries the detail and the line). */
28
+ export const XML_SYNTAX_CODE = "E_XML_SYNTAX";
29
+ /** An element the format does not define at that place was skipped. */
30
+ export const UNKNOWN_ELEMENT_CODE = "W_UNKNOWN_ELEMENT";
31
+ /** Text where the format allows only elements was ignored. */
32
+ export const STRAY_TEXT_CODE = "W_STRAY_TEXT";
33
+ /** A `pid` / parent reference names a node the document never declares. */
34
+ export const UNKNOWN_PARENT_CODE = "E_UNKNOWN_PARENT";
35
+ /** A hyperedge under the `hyperedges: "error"` policy (fatal). */
36
+ export const HYPEREDGE_CODE = "E_HYPEREDGE";
37
+ /** A declaration's key / attribute id is declared twice. */
38
+ export const DUPLICATE_KEY_CODE = "E_DUPLICATE_KEY";
39
+ /**
40
+ * A column was renamed `<name>#<origin.id>` because the name was taken in the sink's table
41
+ * (design section 5.6).
42
+ */
43
+ export const COLUMN_RENAMED_CODE = "W_COLUMN_RENAMED";
44
+ /** A column's role was dropped because another column of the table already holds it (design section 5.5). */
45
+ export const ROLE_TAKEN_CODE = "W_ROLE_TAKEN";
46
+ /** A long value beyond 2^53 was stored as the nearest f64 (design section 5.1). */
47
+ export const PRECISION_CODE = "W_PRECISION";
48
+ /** Two distinct id texts became one number under ids "number" (design section 4.1). */
49
+ export const ID_MERGED_CODE = "W_ID_MERGED";
50
+ /** A builder-policy option the caller asked for that the sink does not honour (design section 8.4). */
51
+ export const SINK_OPTION_CODE = "W_SINK_OPTION";
52
+ /** A common option the format has no use for (or cannot honour) was given a non-default value (design section 8.4). */
53
+ export const OPTION_IGNORED_CODE = "W_OPTION_IGNORED";
54
+ /** An invalid UTF-8 sequence in the input (fatal). */
55
+ export const INVALID_UTF8_CODE = "E_INVALID_UTF8";
56
+ /** The sink refused the file's direction (locked or non-empty); the file is read as the sink's. */
57
+ export const DIRECTION_REFUSED_CODE = "W_DIRECTION_REFUSED";
58
+ /** Edges of the other direction were forced to the policy's direction. */
59
+ export const DIRECTION_FORCED_CODE = "W_DIRECTION_FORCED";
60
+ /** A mixed-direction file under onMixedDirection "error" (import), or a mixed snapshot under the same export policy. */
61
+ export const MIXED_DIRECTION_CODE = "E_MIXED_DIRECTION";
62
+ /** A `count` / `parse.nodes` hint the sink cannot reserve (ignored). */
63
+ export const COUNT_HINT_CODE = "W_COUNT_HINT";
64
+ /** The declared type is not one the format defines; the column is kept as string. */
65
+ export const UNKNOWN_ATTR_TYPE_CODE = "W_UNKNOWN_ATTR_TYPE";
66
+ /** The declared default does not parse as the declared type; the column has no default. */
67
+ export const BAD_DEFAULT_CODE = "W_BAD_DEFAULT";
68
+ /** A declared option does not parse as the declared type; the options are dropped. */
69
+ export const BAD_OPTIONS_CODE = "W_BAD_OPTIONS";
70
+ /** A repeated edge id in a format whose edge ids are unique; the second edge is skipped. */
71
+ export const DUPLICATE_EDGE_ID_CODE = "E_DUPLICATE_EDGE_ID";
72
+ // ============================================================ exporter loss notes
73
+ /** A role column the format has no slot for is written as a plain attribute (the role is lost). */
74
+ export const ROLE_DROPPED_CODE = "W_ROLE_DROPPED";
75
+ /** A parents (multi-parent) column in a format with single containment only. */
76
+ export const PARENTS_DROPPED_CODE = "W_PARENTS_DROPPED";
77
+ /** A start / end / timestamp column in a format without temporal support. */
78
+ export const TEMPORAL_DROPPED_CODE = "W_TEMPORAL_DROPPED";
79
+ /** A mutual pair is written as two directed edges without the mutual mark. */
80
+ export const MUTUAL_EXPANDED_CODE = "W_MUTUAL_EXPANDED";
81
+ /** A mutual pair is written as one undirected edge; the pair reads back undirected, the mark is lost. */
82
+ export const MUTUAL_AS_UNDIRECTED_CODE = "W_MUTUAL_AS_UNDIRECTED";
83
+ /** Node ids whose written text reads back as the other type under the importer's id rule. */
84
+ export const ID_TEXT_TYPE_CODE = "W_ID_TEXT_TYPE";
85
+ /** Two node ids share one written text; export() throws E_INVALID_ID. */
86
+ export const ID_TEXT_COLLISION_CODE = "E_ID_TEXT_COLLISION";
87
+ /** A `<column>.text` companion (design section 5.1) the format cannot carry. */
88
+ export const TEMPORAL_TEXT_DROPPED_CODE = "W_TEMPORAL_TEXT_DROPPED";
89
+ /** A plain column named like the importer's weight key reads back as THE weight. */
90
+ export const WEIGHT_KEY_CLASH_CODE = "W_WEIGHT_KEY_CLASH";
91
+ /** A role-less column whose written name the importer maps to a role. */
92
+ export const ROLE_ASSUMED_CODE = "W_ROLE_ASSUMED";
93
+ /** A role column written into the format's slot reads back under the importer's fixed name. */
94
+ export const COLUMN_RENAMED_LOSS_CODE = "W_COLUMN_NAME_CHANGED";
95
+ /** A declared column whose every row is unset is not written by a format without declarations. */
96
+ export const EMPTY_COLUMN_DROPPED_CODE = "W_EMPTY_COLUMN_DROPPED";
97
+ /** A string / dict column whose cardinality makes the importer read it back as the other storage class. */
98
+ export const STORAGE_CLASS_CODE = "W_STORAGE_CLASS_CHANGED";
99
+ /** An f64 column whose set values are all integral reads back as i32 through an untyped format. */
100
+ export const INTEGRAL_F64_CODE = "W_INTEGRAL_F64_AS_I32";
101
+ /** A text cell that reads back as a number or boolean under the 5.1 grammar (its lexical form may change). */
102
+ export const TEXT_INFERRED_CODE = "W_TEXT_INFERRED";
103
+ /** A string cell holding a character XML 1.0 forbids; export() throws E_COLUMN_TYPE. */
104
+ export const XML_ILLEGAL_CHAR_CODE = "E_XML_ILLEGAL_CHAR";
105
+ /** A dict column without declared options gains one from its dictionary on re-import. */
106
+ export const OPTIONS_GAINED_CODE = "W_OPTIONS_GAINED";
107
+ //# sourceMappingURL=codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codes.js","sourceRoot":"","sources":["../../../src/common/codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,+EAA+E;AAE/E,uFAAuF;AACvF,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC;AAE9C,0CAA0C;AAC1C,MAAM,CAAC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAE1D,8EAA8E;AAC9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAEtD,qDAAqD;AACrD,M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