@nshiab/simple-data-analysis-core 2.0.8 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (513) hide show
  1. package/esm/class/SDAError.d.ts +6 -6
  2. package/esm/class/SDAError.js +6 -6
  3. package/esm/class/Simple.d.ts +9 -9
  4. package/esm/class/Simple.js +9 -9
  5. package/esm/class/SimpleDB.d.ts +80 -76
  6. package/esm/class/SimpleDB.d.ts.map +1 -1
  7. package/esm/class/SimpleDB.js +80 -76
  8. package/esm/class/SimpleTable.d.ts +2805 -1077
  9. package/esm/class/SimpleTable.d.ts.map +1 -1
  10. package/esm/class/SimpleTable.js +2777 -1077
  11. package/esm/helpers/appendColumnBatches.d.ts +3 -0
  12. package/esm/helpers/appendColumnBatches.d.ts.map +1 -0
  13. package/esm/helpers/appendColumnBatches.js +21 -0
  14. package/esm/helpers/buildApproximateMutualReachabilityMst.d.ts +45 -0
  15. package/esm/helpers/buildApproximateMutualReachabilityMst.d.ts.map +1 -0
  16. package/esm/helpers/buildApproximateMutualReachabilityMst.js +212 -0
  17. package/esm/helpers/buildChronologicalGraphComponentsSql.d.ts +14 -0
  18. package/esm/helpers/buildChronologicalGraphComponentsSql.d.ts.map +1 -0
  19. package/esm/helpers/buildChronologicalGraphComponentsSql.js +167 -0
  20. package/esm/helpers/buildExactMutualReachabilityMst.d.ts +28 -0
  21. package/esm/helpers/buildExactMutualReachabilityMst.d.ts.map +1 -0
  22. package/esm/helpers/buildExactMutualReachabilityMst.js +97 -0
  23. package/esm/helpers/buildGraphTemporalCostStateSql.d.ts +12 -0
  24. package/esm/helpers/buildGraphTemporalCostStateSql.d.ts.map +1 -0
  25. package/esm/helpers/buildGraphTemporalCostStateSql.js +86 -0
  26. package/esm/helpers/buildGraphTemporalReachabilitySql.d.ts +13 -0
  27. package/esm/helpers/buildGraphTemporalReachabilitySql.d.ts.map +1 -0
  28. package/esm/helpers/buildGraphTemporalReachabilitySql.js +70 -0
  29. package/esm/helpers/buildSparseMutualReachabilityMst.d.ts +10 -0
  30. package/esm/helpers/buildSparseMutualReachabilityMst.d.ts.map +1 -0
  31. package/esm/helpers/buildSparseMutualReachabilityMst.js +47 -0
  32. package/esm/helpers/buildUmapGraph.d.ts +21 -0
  33. package/esm/helpers/buildUmapGraph.d.ts.map +1 -0
  34. package/esm/helpers/buildUmapGraph.js +61 -0
  35. package/esm/helpers/buildVectorNeighbors.d.ts +45 -0
  36. package/esm/helpers/buildVectorNeighbors.d.ts.map +1 -0
  37. package/esm/helpers/buildVectorNeighbors.js +170 -0
  38. package/esm/helpers/buildWeakGraphComponentsSql.d.ts +3 -0
  39. package/esm/helpers/buildWeakGraphComponentsSql.d.ts.map +1 -0
  40. package/esm/helpers/buildWeakGraphComponentsSql.js +32 -0
  41. package/esm/helpers/cacheDatabase.d.ts.map +1 -1
  42. package/esm/helpers/cacheDatabase.js +2 -1
  43. package/esm/helpers/camelCase.d.ts +7 -5
  44. package/esm/helpers/camelCase.d.ts.map +1 -1
  45. package/esm/helpers/camelCase.js +7 -5
  46. package/esm/helpers/capitalize.d.ts +6 -4
  47. package/esm/helpers/capitalize.d.ts.map +1 -1
  48. package/esm/helpers/capitalize.js +6 -4
  49. package/esm/helpers/clusterHdbscan.d.ts +18 -0
  50. package/esm/helpers/clusterHdbscan.d.ts.map +1 -0
  51. package/esm/helpers/clusterHdbscan.js +342 -0
  52. package/esm/helpers/computeCovariance.d.ts +16 -0
  53. package/esm/helpers/computeCovariance.d.ts.map +1 -0
  54. package/esm/helpers/computeCovariance.js +99 -0
  55. package/esm/helpers/computeMahalanobisDistances.d.ts +14 -0
  56. package/esm/helpers/computeMahalanobisDistances.d.ts.map +1 -0
  57. package/esm/helpers/computeMahalanobisDistances.js +87 -0
  58. package/esm/helpers/createDirectory.d.ts +4 -3
  59. package/esm/helpers/createDirectory.d.ts.map +1 -1
  60. package/esm/helpers/createDirectory.js +4 -3
  61. package/esm/helpers/dataToArrays.d.ts +6 -4
  62. package/esm/helpers/dataToArrays.d.ts.map +1 -1
  63. package/esm/helpers/dataToArrays.js +6 -4
  64. package/esm/helpers/extractTypes.d.ts +1 -1
  65. package/esm/helpers/extractTypes.js +4 -9
  66. package/esm/helpers/factorCovariance.d.ts +17 -0
  67. package/esm/helpers/factorCovariance.d.ts.map +1 -0
  68. package/esm/helpers/factorCovariance.js +189 -0
  69. package/esm/helpers/findGeoColumn.d.ts +6 -4
  70. package/esm/helpers/findGeoColumn.d.ts.map +1 -1
  71. package/esm/helpers/findGeoColumn.js +6 -4
  72. package/esm/helpers/findGeoColumnFromSchema.d.ts +8 -5
  73. package/esm/helpers/findGeoColumnFromSchema.d.ts.map +1 -1
  74. package/esm/helpers/findGeoColumnFromSchema.js +8 -5
  75. package/esm/helpers/fitUmapCurve.d.ts +2 -0
  76. package/esm/helpers/fitUmapCurve.d.ts.map +1 -0
  77. package/esm/helpers/fitUmapCurve.js +66 -0
  78. package/esm/helpers/formatDate.d.ts +12 -6
  79. package/esm/helpers/formatDate.d.ts.map +1 -1
  80. package/esm/helpers/formatDate.js +12 -6
  81. package/esm/helpers/formatMissingTables.d.ts +8 -5
  82. package/esm/helpers/formatMissingTables.d.ts.map +1 -1
  83. package/esm/helpers/formatMissingTables.js +8 -5
  84. package/esm/helpers/formatNumber.d.ts +19 -10
  85. package/esm/helpers/formatNumber.d.ts.map +1 -1
  86. package/esm/helpers/formatNumber.js +32 -17
  87. package/esm/helpers/getGraphEdgeIdColumn.d.ts +9 -0
  88. package/esm/helpers/getGraphEdgeIdColumn.d.ts.map +1 -0
  89. package/esm/helpers/getGraphEdgeIdColumn.js +25 -0
  90. package/esm/helpers/getGraphEndpointColumns.d.ts +11 -0
  91. package/esm/helpers/getGraphEndpointColumns.d.ts.map +1 -0
  92. package/esm/helpers/getGraphEndpointColumns.js +160 -0
  93. package/esm/helpers/getGraphWeightColumn.d.ts +10 -0
  94. package/esm/helpers/getGraphWeightColumn.d.ts.map +1 -0
  95. package/esm/helpers/getGraphWeightColumn.js +40 -0
  96. package/esm/helpers/graphRouteResultSchema.d.ts +4 -0
  97. package/esm/helpers/graphRouteResultSchema.d.ts.map +1 -0
  98. package/esm/helpers/graphRouteResultSchema.js +12 -0
  99. package/esm/helpers/graphRouteResultSelect.d.ts +4 -0
  100. package/esm/helpers/graphRouteResultSelect.d.ts.map +1 -0
  101. package/esm/helpers/graphRouteResultSelect.js +22 -0
  102. package/esm/helpers/hasGeometryColumn.d.ts +4 -3
  103. package/esm/helpers/hasGeometryColumn.d.ts.map +1 -1
  104. package/esm/helpers/hasGeometryColumn.js +4 -3
  105. package/esm/helpers/initialUmapCoordinates.d.ts +2 -0
  106. package/esm/helpers/initialUmapCoordinates.d.ts.map +1 -0
  107. package/esm/helpers/initialUmapCoordinates.js +5 -0
  108. package/esm/helpers/inspectGraphConnectivity.d.ts +10 -0
  109. package/esm/helpers/inspectGraphConnectivity.d.ts.map +1 -0
  110. package/esm/helpers/inspectGraphConnectivity.js +55 -0
  111. package/esm/helpers/mergeOptions.d.ts +24 -13
  112. package/esm/helpers/mergeOptions.d.ts.map +1 -1
  113. package/esm/helpers/mergeOptions.js +24 -13
  114. package/esm/helpers/optimizeUmapLayout.d.ts +7 -0
  115. package/esm/helpers/optimizeUmapLayout.d.ts.map +1 -0
  116. package/esm/helpers/optimizeUmapLayout.js +93 -0
  117. package/esm/helpers/parseValue.d.ts +6 -4
  118. package/esm/helpers/parseValue.d.ts.map +1 -1
  119. package/esm/helpers/parseValue.js +6 -4
  120. package/esm/helpers/prepareGraphRouteSql.d.ts +31 -0
  121. package/esm/helpers/prepareGraphRouteSql.d.ts.map +1 -0
  122. package/esm/helpers/prepareGraphRouteSql.js +86 -0
  123. package/esm/helpers/prepareGraphStarts.d.ts +9 -0
  124. package/esm/helpers/prepareGraphStarts.d.ts.map +1 -0
  125. package/esm/helpers/prepareGraphStarts.js +68 -0
  126. package/esm/helpers/prepareGraphTemporalSql.d.ts +28 -0
  127. package/esm/helpers/prepareGraphTemporalSql.d.ts.map +1 -0
  128. package/esm/helpers/prepareGraphTemporalSql.js +154 -0
  129. package/esm/helpers/prepareGraphTraversal.d.ts +19 -0
  130. package/esm/helpers/prepareGraphTraversal.d.ts.map +1 -0
  131. package/esm/helpers/prepareGraphTraversal.js +79 -0
  132. package/esm/helpers/prepareNumericFeatures.d.ts +41 -0
  133. package/esm/helpers/prepareNumericFeatures.d.ts.map +1 -0
  134. package/esm/helpers/prepareNumericFeatures.js +210 -0
  135. package/esm/helpers/prepareUmapLayoutOptions.d.ts +14 -0
  136. package/esm/helpers/prepareUmapLayoutOptions.d.ts.map +1 -0
  137. package/esm/helpers/prepareUmapLayoutOptions.js +23 -0
  138. package/esm/helpers/prettyDuration.d.ts +14 -8
  139. package/esm/helpers/prettyDuration.d.ts.map +1 -1
  140. package/esm/helpers/prettyDuration.js +14 -8
  141. package/esm/helpers/printTable.d.ts +18 -13
  142. package/esm/helpers/printTable.d.ts.map +1 -1
  143. package/esm/helpers/printTable.js +18 -13
  144. package/esm/helpers/publishPreparedColumns.d.ts +37 -0
  145. package/esm/helpers/publishPreparedColumns.d.ts.map +1 -0
  146. package/esm/helpers/publishPreparedColumns.js +113 -0
  147. package/esm/helpers/queryDB.d.ts +24 -13
  148. package/esm/helpers/queryDB.d.ts.map +1 -1
  149. package/esm/helpers/queryDB.js +24 -13
  150. package/esm/helpers/queueAsyncBarrier.d.ts +12 -7
  151. package/esm/helpers/queueAsyncBarrier.d.ts.map +1 -1
  152. package/esm/helpers/queueAsyncBarrier.js +12 -7
  153. package/esm/helpers/queueGraphResult.d.ts +18 -0
  154. package/esm/helpers/queueGraphResult.d.ts.map +1 -0
  155. package/esm/helpers/queueGraphResult.js +39 -0
  156. package/esm/helpers/quoteIdentifier.d.ts +4 -3
  157. package/esm/helpers/quoteIdentifier.d.ts.map +1 -1
  158. package/esm/helpers/quoteIdentifier.js +4 -3
  159. package/esm/helpers/quoteQualifiedIdentifier.d.ts +6 -4
  160. package/esm/helpers/quoteQualifiedIdentifier.d.ts.map +1 -1
  161. package/esm/helpers/quoteQualifiedIdentifier.js +6 -4
  162. package/esm/helpers/readScalarNumber.d.ts +3 -0
  163. package/esm/helpers/readScalarNumber.d.ts.map +1 -0
  164. package/esm/helpers/readScalarNumber.js +4 -0
  165. package/esm/helpers/runQuery.d.ts.map +1 -1
  166. package/esm/helpers/runQuery.js +17 -3
  167. package/esm/helpers/selectFuzzyReplacements.d.ts +11 -0
  168. package/esm/helpers/selectFuzzyReplacements.d.ts.map +1 -0
  169. package/esm/helpers/selectFuzzyReplacements.js +124 -0
  170. package/esm/helpers/stabilizeCosineVectors.d.ts +14 -0
  171. package/esm/helpers/stabilizeCosineVectors.d.ts.map +1 -0
  172. package/esm/helpers/stabilizeCosineVectors.js +34 -0
  173. package/esm/helpers/stringToArray.d.ts +4 -3
  174. package/esm/helpers/stringToArray.d.ts.map +1 -1
  175. package/esm/helpers/stringToArray.js +4 -3
  176. package/esm/helpers/umapRandom.d.ts +2 -0
  177. package/esm/helpers/umapRandom.d.ts.map +1 -0
  178. package/esm/helpers/umapRandom.js +10 -0
  179. package/esm/helpers/updateColumnsWithJS.d.ts +12 -6
  180. package/esm/helpers/updateColumnsWithJS.d.ts.map +1 -1
  181. package/esm/helpers/updateColumnsWithJS.js +12 -6
  182. package/esm/helpers/validateGraphRouteResultSchema.d.ts +4 -0
  183. package/esm/helpers/validateGraphRouteResultSchema.d.ts.map +1 -0
  184. package/esm/helpers/validateGraphRouteResultSchema.js +13 -0
  185. package/esm/helpers/validateGraphTemporalEvents.d.ts +7 -0
  186. package/esm/helpers/validateGraphTemporalEvents.d.ts.map +1 -0
  187. package/esm/helpers/validateGraphTemporalEvents.js +47 -0
  188. package/esm/helpers/validateNumericalAnalysis.d.ts +10 -6
  189. package/esm/helpers/validateNumericalAnalysis.d.ts.map +1 -1
  190. package/esm/helpers/validateNumericalAnalysis.js +10 -6
  191. package/esm/helpers/validateVectorRowIds.d.ts +4 -0
  192. package/esm/helpers/validateVectorRowIds.d.ts.map +1 -0
  193. package/esm/helpers/validateVectorRowIds.js +16 -0
  194. package/esm/helpers/vectorDistanceExpression.d.ts +6 -0
  195. package/esm/helpers/vectorDistanceExpression.d.ts.map +1 -0
  196. package/esm/helpers/vectorDistanceExpression.js +11 -0
  197. package/esm/helpers/wrapString.d.ts +10 -7
  198. package/esm/helpers/wrapString.d.ts.map +1 -1
  199. package/esm/helpers/wrapString.js +10 -7
  200. package/esm/methods/addId.d.ts +5 -0
  201. package/esm/methods/addId.d.ts.map +1 -0
  202. package/esm/methods/addId.js +38 -0
  203. package/esm/methods/cache.js +1 -1
  204. package/esm/methods/commonNeighbors.d.ts +10 -0
  205. package/esm/methods/commonNeighbors.d.ts.map +1 -0
  206. package/esm/methods/commonNeighbors.js +101 -0
  207. package/esm/methods/connectedComponents.d.ts +9 -0
  208. package/esm/methods/connectedComponents.d.ts.map +1 -0
  209. package/esm/methods/connectedComponents.js +147 -0
  210. package/esm/methods/degree.d.ts +9 -0
  211. package/esm/methods/degree.d.ts.map +1 -0
  212. package/esm/methods/degree.js +135 -0
  213. package/esm/methods/distances.d.ts +12 -0
  214. package/esm/methods/distances.d.ts.map +1 -0
  215. package/esm/methods/distances.js +164 -0
  216. package/esm/methods/findCycles.d.ts +12 -0
  217. package/esm/methods/findCycles.d.ts.map +1 -0
  218. package/esm/methods/findCycles.js +330 -0
  219. package/esm/methods/fuzzyClean.d.ts.map +1 -1
  220. package/esm/methods/fuzzyClean.js +17 -136
  221. package/esm/methods/fuzzyJoin.js +70 -16
  222. package/esm/methods/getTypes.d.ts +1 -1
  223. package/esm/methods/hdbscan.d.ts +5 -0
  224. package/esm/methods/hdbscan.d.ts.map +1 -0
  225. package/esm/methods/hdbscan.js +208 -0
  226. package/esm/methods/loadArray.d.ts.map +1 -1
  227. package/esm/methods/loadArray.js +3 -20
  228. package/esm/methods/mahalanobis.d.ts +5 -0
  229. package/esm/methods/mahalanobis.d.ts.map +1 -0
  230. package/esm/methods/mahalanobis.js +92 -0
  231. package/esm/methods/neighbors.d.ts +9 -0
  232. package/esm/methods/neighbors.d.ts.map +1 -0
  233. package/esm/methods/neighbors.js +81 -0
  234. package/esm/methods/normalizeVector.d.ts +5 -0
  235. package/esm/methods/normalizeVector.d.ts.map +1 -0
  236. package/esm/methods/normalizeVector.js +132 -0
  237. package/esm/methods/paths.d.ts +12 -0
  238. package/esm/methods/paths.d.ts.map +1 -0
  239. package/esm/methods/paths.js +287 -0
  240. package/esm/methods/reachable.d.ts +11 -0
  241. package/esm/methods/reachable.d.ts.map +1 -0
  242. package/esm/methods/reachable.js +131 -0
  243. package/esm/methods/rowToVector.d.ts +5 -0
  244. package/esm/methods/rowToVector.d.ts.map +1 -0
  245. package/esm/methods/rowToVector.js +77 -0
  246. package/esm/methods/shortestPath.d.ts +12 -0
  247. package/esm/methods/shortestPath.d.ts.map +1 -0
  248. package/esm/methods/shortestPath.js +337 -0
  249. package/esm/methods/topologicalSort.d.ts +7 -0
  250. package/esm/methods/topologicalSort.d.ts.map +1 -0
  251. package/esm/methods/topologicalSort.js +164 -0
  252. package/esm/methods/umap.d.ts +5 -0
  253. package/esm/methods/umap.d.ts.map +1 -0
  254. package/esm/methods/umap.js +156 -0
  255. package/esm/methods/updateWithJS.js +9 -21
  256. package/llm.md +2170 -128
  257. package/llms.txt +1 -1
  258. package/package.json +1 -1
  259. package/script/class/SDAError.d.ts +6 -6
  260. package/script/class/SDAError.js +6 -6
  261. package/script/class/Simple.d.ts +9 -9
  262. package/script/class/Simple.js +9 -9
  263. package/script/class/SimpleDB.d.ts +80 -76
  264. package/script/class/SimpleDB.d.ts.map +1 -1
  265. package/script/class/SimpleDB.js +80 -76
  266. package/script/class/SimpleTable.d.ts +2805 -1077
  267. package/script/class/SimpleTable.d.ts.map +1 -1
  268. package/script/class/SimpleTable.js +2777 -1077
  269. package/script/helpers/appendColumnBatches.d.ts +3 -0
  270. package/script/helpers/appendColumnBatches.d.ts.map +1 -0
  271. package/script/helpers/appendColumnBatches.js +24 -0
  272. package/script/helpers/buildApproximateMutualReachabilityMst.d.ts +45 -0
  273. package/script/helpers/buildApproximateMutualReachabilityMst.d.ts.map +1 -0
  274. package/script/helpers/buildApproximateMutualReachabilityMst.js +219 -0
  275. package/script/helpers/buildChronologicalGraphComponentsSql.d.ts +14 -0
  276. package/script/helpers/buildChronologicalGraphComponentsSql.d.ts.map +1 -0
  277. package/script/helpers/buildChronologicalGraphComponentsSql.js +174 -0
  278. package/script/helpers/buildExactMutualReachabilityMst.d.ts +28 -0
  279. package/script/helpers/buildExactMutualReachabilityMst.d.ts.map +1 -0
  280. package/script/helpers/buildExactMutualReachabilityMst.js +103 -0
  281. package/script/helpers/buildGraphTemporalCostStateSql.d.ts +12 -0
  282. package/script/helpers/buildGraphTemporalCostStateSql.d.ts.map +1 -0
  283. package/script/helpers/buildGraphTemporalCostStateSql.js +92 -0
  284. package/script/helpers/buildGraphTemporalReachabilitySql.d.ts +13 -0
  285. package/script/helpers/buildGraphTemporalReachabilitySql.d.ts.map +1 -0
  286. package/script/helpers/buildGraphTemporalReachabilitySql.js +76 -0
  287. package/script/helpers/buildSparseMutualReachabilityMst.d.ts +10 -0
  288. package/script/helpers/buildSparseMutualReachabilityMst.d.ts.map +1 -0
  289. package/script/helpers/buildSparseMutualReachabilityMst.js +50 -0
  290. package/script/helpers/buildUmapGraph.d.ts +21 -0
  291. package/script/helpers/buildUmapGraph.d.ts.map +1 -0
  292. package/script/helpers/buildUmapGraph.js +67 -0
  293. package/script/helpers/buildVectorNeighbors.d.ts +45 -0
  294. package/script/helpers/buildVectorNeighbors.d.ts.map +1 -0
  295. package/script/helpers/buildVectorNeighbors.js +176 -0
  296. package/script/helpers/buildWeakGraphComponentsSql.d.ts +3 -0
  297. package/script/helpers/buildWeakGraphComponentsSql.d.ts.map +1 -0
  298. package/script/helpers/buildWeakGraphComponentsSql.js +38 -0
  299. package/script/helpers/cacheDatabase.d.ts.map +1 -1
  300. package/script/helpers/cacheDatabase.js +2 -1
  301. package/script/helpers/camelCase.d.ts +7 -5
  302. package/script/helpers/camelCase.d.ts.map +1 -1
  303. package/script/helpers/camelCase.js +7 -5
  304. package/script/helpers/capitalize.d.ts +6 -4
  305. package/script/helpers/capitalize.d.ts.map +1 -1
  306. package/script/helpers/capitalize.js +6 -4
  307. package/script/helpers/clusterHdbscan.d.ts +18 -0
  308. package/script/helpers/clusterHdbscan.d.ts.map +1 -0
  309. package/script/helpers/clusterHdbscan.js +346 -0
  310. package/script/helpers/computeCovariance.d.ts +16 -0
  311. package/script/helpers/computeCovariance.d.ts.map +1 -0
  312. package/script/helpers/computeCovariance.js +105 -0
  313. package/script/helpers/computeMahalanobisDistances.d.ts +14 -0
  314. package/script/helpers/computeMahalanobisDistances.d.ts.map +1 -0
  315. package/script/helpers/computeMahalanobisDistances.js +93 -0
  316. package/script/helpers/createDirectory.d.ts +4 -3
  317. package/script/helpers/createDirectory.d.ts.map +1 -1
  318. package/script/helpers/createDirectory.js +4 -3
  319. package/script/helpers/dataToArrays.d.ts +6 -4
  320. package/script/helpers/dataToArrays.d.ts.map +1 -1
  321. package/script/helpers/dataToArrays.js +6 -4
  322. package/script/helpers/extractTypes.d.ts +1 -1
  323. package/script/helpers/extractTypes.js +4 -9
  324. package/script/helpers/factorCovariance.d.ts +17 -0
  325. package/script/helpers/factorCovariance.d.ts.map +1 -0
  326. package/script/helpers/factorCovariance.js +194 -0
  327. package/script/helpers/findGeoColumn.d.ts +6 -4
  328. package/script/helpers/findGeoColumn.d.ts.map +1 -1
  329. package/script/helpers/findGeoColumn.js +6 -4
  330. package/script/helpers/findGeoColumnFromSchema.d.ts +8 -5
  331. package/script/helpers/findGeoColumnFromSchema.d.ts.map +1 -1
  332. package/script/helpers/findGeoColumnFromSchema.js +8 -5
  333. package/script/helpers/fitUmapCurve.d.ts +2 -0
  334. package/script/helpers/fitUmapCurve.d.ts.map +1 -0
  335. package/script/helpers/fitUmapCurve.js +69 -0
  336. package/script/helpers/formatDate.d.ts +12 -6
  337. package/script/helpers/formatDate.d.ts.map +1 -1
  338. package/script/helpers/formatDate.js +12 -6
  339. package/script/helpers/formatMissingTables.d.ts +8 -5
  340. package/script/helpers/formatMissingTables.d.ts.map +1 -1
  341. package/script/helpers/formatMissingTables.js +8 -5
  342. package/script/helpers/formatNumber.d.ts +19 -10
  343. package/script/helpers/formatNumber.d.ts.map +1 -1
  344. package/script/helpers/formatNumber.js +32 -17
  345. package/script/helpers/getGraphEdgeIdColumn.d.ts +9 -0
  346. package/script/helpers/getGraphEdgeIdColumn.d.ts.map +1 -0
  347. package/script/helpers/getGraphEdgeIdColumn.js +31 -0
  348. package/script/helpers/getGraphEndpointColumns.d.ts +11 -0
  349. package/script/helpers/getGraphEndpointColumns.d.ts.map +1 -0
  350. package/script/helpers/getGraphEndpointColumns.js +166 -0
  351. package/script/helpers/getGraphWeightColumn.d.ts +10 -0
  352. package/script/helpers/getGraphWeightColumn.d.ts.map +1 -0
  353. package/script/helpers/getGraphWeightColumn.js +46 -0
  354. package/script/helpers/graphRouteResultSchema.d.ts +4 -0
  355. package/script/helpers/graphRouteResultSchema.d.ts.map +1 -0
  356. package/script/helpers/graphRouteResultSchema.js +18 -0
  357. package/script/helpers/graphRouteResultSelect.d.ts +4 -0
  358. package/script/helpers/graphRouteResultSelect.d.ts.map +1 -0
  359. package/script/helpers/graphRouteResultSelect.js +28 -0
  360. package/script/helpers/hasGeometryColumn.d.ts +4 -3
  361. package/script/helpers/hasGeometryColumn.d.ts.map +1 -1
  362. package/script/helpers/hasGeometryColumn.js +4 -3
  363. package/script/helpers/initialUmapCoordinates.d.ts +2 -0
  364. package/script/helpers/initialUmapCoordinates.d.ts.map +1 -0
  365. package/script/helpers/initialUmapCoordinates.js +11 -0
  366. package/script/helpers/inspectGraphConnectivity.d.ts +10 -0
  367. package/script/helpers/inspectGraphConnectivity.d.ts.map +1 -0
  368. package/script/helpers/inspectGraphConnectivity.js +58 -0
  369. package/script/helpers/mergeOptions.d.ts +24 -13
  370. package/script/helpers/mergeOptions.d.ts.map +1 -1
  371. package/script/helpers/mergeOptions.js +24 -13
  372. package/script/helpers/optimizeUmapLayout.d.ts +7 -0
  373. package/script/helpers/optimizeUmapLayout.d.ts.map +1 -0
  374. package/script/helpers/optimizeUmapLayout.js +99 -0
  375. package/script/helpers/parseValue.d.ts +6 -4
  376. package/script/helpers/parseValue.d.ts.map +1 -1
  377. package/script/helpers/parseValue.js +6 -4
  378. package/script/helpers/prepareGraphRouteSql.d.ts +31 -0
  379. package/script/helpers/prepareGraphRouteSql.d.ts.map +1 -0
  380. package/script/helpers/prepareGraphRouteSql.js +127 -0
  381. package/script/helpers/prepareGraphStarts.d.ts +9 -0
  382. package/script/helpers/prepareGraphStarts.d.ts.map +1 -0
  383. package/script/helpers/prepareGraphStarts.js +71 -0
  384. package/script/helpers/prepareGraphTemporalSql.d.ts +28 -0
  385. package/script/helpers/prepareGraphTemporalSql.d.ts.map +1 -0
  386. package/script/helpers/prepareGraphTemporalSql.js +161 -0
  387. package/script/helpers/prepareGraphTraversal.d.ts +19 -0
  388. package/script/helpers/prepareGraphTraversal.d.ts.map +1 -0
  389. package/script/helpers/prepareGraphTraversal.js +87 -0
  390. package/script/helpers/prepareNumericFeatures.d.ts +41 -0
  391. package/script/helpers/prepareNumericFeatures.d.ts.map +1 -0
  392. package/script/helpers/prepareNumericFeatures.js +217 -0
  393. package/script/helpers/prepareUmapLayoutOptions.d.ts +14 -0
  394. package/script/helpers/prepareUmapLayoutOptions.d.ts.map +1 -0
  395. package/script/helpers/prepareUmapLayoutOptions.js +29 -0
  396. package/script/helpers/prettyDuration.d.ts +14 -8
  397. package/script/helpers/prettyDuration.d.ts.map +1 -1
  398. package/script/helpers/prettyDuration.js +14 -8
  399. package/script/helpers/printTable.d.ts +18 -13
  400. package/script/helpers/printTable.d.ts.map +1 -1
  401. package/script/helpers/printTable.js +18 -13
  402. package/script/helpers/publishPreparedColumns.d.ts +37 -0
  403. package/script/helpers/publishPreparedColumns.d.ts.map +1 -0
  404. package/script/helpers/publishPreparedColumns.js +119 -0
  405. package/script/helpers/queryDB.d.ts +24 -13
  406. package/script/helpers/queryDB.d.ts.map +1 -1
  407. package/script/helpers/queryDB.js +24 -13
  408. package/script/helpers/queueAsyncBarrier.d.ts +12 -7
  409. package/script/helpers/queueAsyncBarrier.d.ts.map +1 -1
  410. package/script/helpers/queueAsyncBarrier.js +12 -7
  411. package/script/helpers/queueGraphResult.d.ts +18 -0
  412. package/script/helpers/queueGraphResult.d.ts.map +1 -0
  413. package/script/helpers/queueGraphResult.js +45 -0
  414. package/script/helpers/quoteIdentifier.d.ts +4 -3
  415. package/script/helpers/quoteIdentifier.d.ts.map +1 -1
  416. package/script/helpers/quoteIdentifier.js +4 -3
  417. package/script/helpers/quoteQualifiedIdentifier.d.ts +6 -4
  418. package/script/helpers/quoteQualifiedIdentifier.d.ts.map +1 -1
  419. package/script/helpers/quoteQualifiedIdentifier.js +6 -4
  420. package/script/helpers/readScalarNumber.d.ts +3 -0
  421. package/script/helpers/readScalarNumber.d.ts.map +1 -0
  422. package/script/helpers/readScalarNumber.js +7 -0
  423. package/script/helpers/runQuery.d.ts.map +1 -1
  424. package/script/helpers/runQuery.js +17 -3
  425. package/script/helpers/selectFuzzyReplacements.d.ts +11 -0
  426. package/script/helpers/selectFuzzyReplacements.d.ts.map +1 -0
  427. package/script/helpers/selectFuzzyReplacements.js +127 -0
  428. package/script/helpers/stabilizeCosineVectors.d.ts +14 -0
  429. package/script/helpers/stabilizeCosineVectors.d.ts.map +1 -0
  430. package/script/helpers/stabilizeCosineVectors.js +40 -0
  431. package/script/helpers/stringToArray.d.ts +4 -3
  432. package/script/helpers/stringToArray.d.ts.map +1 -1
  433. package/script/helpers/stringToArray.js +4 -3
  434. package/script/helpers/umapRandom.d.ts +2 -0
  435. package/script/helpers/umapRandom.d.ts.map +1 -0
  436. package/script/helpers/umapRandom.js +13 -0
  437. package/script/helpers/updateColumnsWithJS.d.ts +12 -6
  438. package/script/helpers/updateColumnsWithJS.d.ts.map +1 -1
  439. package/script/helpers/updateColumnsWithJS.js +12 -6
  440. package/script/helpers/validateGraphRouteResultSchema.d.ts +4 -0
  441. package/script/helpers/validateGraphRouteResultSchema.d.ts.map +1 -0
  442. package/script/helpers/validateGraphRouteResultSchema.js +19 -0
  443. package/script/helpers/validateGraphTemporalEvents.d.ts +7 -0
  444. package/script/helpers/validateGraphTemporalEvents.d.ts.map +1 -0
  445. package/script/helpers/validateGraphTemporalEvents.js +53 -0
  446. package/script/helpers/validateNumericalAnalysis.d.ts +10 -6
  447. package/script/helpers/validateNumericalAnalysis.d.ts.map +1 -1
  448. package/script/helpers/validateNumericalAnalysis.js +10 -6
  449. package/script/helpers/validateVectorRowIds.d.ts +4 -0
  450. package/script/helpers/validateVectorRowIds.d.ts.map +1 -0
  451. package/script/helpers/validateVectorRowIds.js +19 -0
  452. package/script/helpers/vectorDistanceExpression.d.ts +6 -0
  453. package/script/helpers/vectorDistanceExpression.d.ts.map +1 -0
  454. package/script/helpers/vectorDistanceExpression.js +14 -0
  455. package/script/helpers/wrapString.d.ts +10 -7
  456. package/script/helpers/wrapString.d.ts.map +1 -1
  457. package/script/helpers/wrapString.js +10 -7
  458. package/script/methods/addId.d.ts +5 -0
  459. package/script/methods/addId.d.ts.map +1 -0
  460. package/script/methods/addId.js +44 -0
  461. package/script/methods/cache.js +1 -1
  462. package/script/methods/commonNeighbors.d.ts +10 -0
  463. package/script/methods/commonNeighbors.d.ts.map +1 -0
  464. package/script/methods/commonNeighbors.js +140 -0
  465. package/script/methods/connectedComponents.d.ts +9 -0
  466. package/script/methods/connectedComponents.d.ts.map +1 -0
  467. package/script/methods/connectedComponents.js +186 -0
  468. package/script/methods/degree.d.ts +9 -0
  469. package/script/methods/degree.d.ts.map +1 -0
  470. package/script/methods/degree.js +141 -0
  471. package/script/methods/distances.d.ts +12 -0
  472. package/script/methods/distances.d.ts.map +1 -0
  473. package/script/methods/distances.js +203 -0
  474. package/script/methods/findCycles.d.ts +12 -0
  475. package/script/methods/findCycles.d.ts.map +1 -0
  476. package/script/methods/findCycles.js +369 -0
  477. package/script/methods/fuzzyClean.d.ts.map +1 -1
  478. package/script/methods/fuzzyClean.js +17 -136
  479. package/script/methods/fuzzyJoin.js +70 -16
  480. package/script/methods/getTypes.d.ts +1 -1
  481. package/script/methods/hdbscan.d.ts +5 -0
  482. package/script/methods/hdbscan.d.ts.map +1 -0
  483. package/script/methods/hdbscan.js +214 -0
  484. package/script/methods/loadArray.d.ts.map +1 -1
  485. package/script/methods/loadArray.js +2 -19
  486. package/script/methods/mahalanobis.d.ts +5 -0
  487. package/script/methods/mahalanobis.d.ts.map +1 -0
  488. package/script/methods/mahalanobis.js +98 -0
  489. package/script/methods/neighbors.d.ts +9 -0
  490. package/script/methods/neighbors.d.ts.map +1 -0
  491. package/script/methods/neighbors.js +120 -0
  492. package/script/methods/normalizeVector.d.ts +5 -0
  493. package/script/methods/normalizeVector.d.ts.map +1 -0
  494. package/script/methods/normalizeVector.js +138 -0
  495. package/script/methods/paths.d.ts +12 -0
  496. package/script/methods/paths.d.ts.map +1 -0
  497. package/script/methods/paths.js +326 -0
  498. package/script/methods/reachable.d.ts +11 -0
  499. package/script/methods/reachable.d.ts.map +1 -0
  500. package/script/methods/reachable.js +170 -0
  501. package/script/methods/rowToVector.d.ts +5 -0
  502. package/script/methods/rowToVector.d.ts.map +1 -0
  503. package/script/methods/rowToVector.js +83 -0
  504. package/script/methods/shortestPath.d.ts +12 -0
  505. package/script/methods/shortestPath.d.ts.map +1 -0
  506. package/script/methods/shortestPath.js +376 -0
  507. package/script/methods/topologicalSort.d.ts +7 -0
  508. package/script/methods/topologicalSort.d.ts.map +1 -0
  509. package/script/methods/topologicalSort.js +170 -0
  510. package/script/methods/umap.d.ts +5 -0
  511. package/script/methods/umap.d.ts.map +1 -0
  512. package/script/methods/umap.js +162 -0
  513. package/script/methods/updateWithJS.js +9 -21
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = graphRouteResultSelect;
7
+ const quoteIdentifier_js_1 = __importDefault(require("./quoteIdentifier.js"));
8
+ /** Joins ranked route steps to their original input rows for final output. */
9
+ function graphRouteResultSelect(rankedRelation, input, edgeIdColumn, includeStart = false) {
10
+ const q = quoteIdentifier_js_1.default;
11
+ const routeStep = `${q("unnested")}.${q("route_step")}`;
12
+ const originalEdgeId = `${q("original")}.${q(edgeIdColumn.column)}`;
13
+ const edgeMatch = edgeIdColumn.family === "string"
14
+ ? `ENCODE(CAST(${originalEdgeId} AS VARCHAR)) =
15
+ ENCODE(${routeStep}.${q("edgeId")})`
16
+ : `CAST(${originalEdgeId} AS ${edgeIdColumn.idType}) =
17
+ ${routeStep}.${q("edgeId")}`;
18
+ return `SELECT ${includeStart ? `${q("ranked")}.${q("start")},\n ` : ""}${q("ranked")}.${q("pathId")},
19
+ CAST(${q("unnested")}.${q("step")} AS BIGINT) AS ${q("step")},
20
+ ${routeStep}.${q("weight")} AS ${q("weight")},
21
+ ${routeStep}.${q("distance")} AS ${q("total")},
22
+ ${q("original")}.*
23
+ FROM ${rankedRelation} AS ${q("ranked")},
24
+ UNNEST(${q("ranked")}.${q("steps")}) WITH ORDINALITY AS ${q("unnested")}(${q("route_step")}, ${q("step")})
25
+ INNER JOIN ${input} AS ${q("original")}
26
+ ON ${edgeMatch}
27
+ ORDER BY ${includeStart ? `${q("ranked")}.${q("__start_key")}, ` : ""}${q("ranked")}.${q("pathId")}, ${q("unnested")}.${q("step")}`;
28
+ }
@@ -5,9 +5,6 @@ import type SimpleTable from "../class/SimpleTable.js";
5
5
  * Uses `getTypes()` to inspect column types and checks for any column
6
6
  * whose type normalizes to `"geometry"`.
7
7
  *
8
- * @param table - The SimpleTable instance to inspect.
9
- * @returns `true` if at least one geometry column exists, `false` otherwise.
10
- *
11
8
  * @example
12
9
  * ```ts
13
10
  * const hasGeo = await hasGeometryColumn(table);
@@ -15,6 +12,10 @@ import type SimpleTable from "../class/SimpleTable.js";
15
12
  * console.log("This table contains geometry columns");
16
13
  * }
17
14
  * ```
15
+ *
16
+ * @param table - The SimpleTable instance to inspect.
17
+ *
18
+ * @returns `true` if at least one geometry column exists, `false` otherwise.
18
19
  */
19
20
  export default function hasGeometryColumn(table: SimpleTable): Promise<boolean>;
20
21
  //# sourceMappingURL=hasGeometryColumn.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hasGeometryColumn.d.ts","sourceRoot":"","sources":["../../src/helpers/hasGeometryColumn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAEvD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAA8B,iBAAiB,CAC7C,KAAK,EAAE,WAAW,GACjB,OAAO,CAAC,OAAO,CAAC,CAGlB"}
1
+ {"version":3,"file":"hasGeometryColumn.d.ts","sourceRoot":"","sources":["../../src/helpers/hasGeometryColumn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAEvD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAA8B,iBAAiB,CAC7C,KAAK,EAAE,WAAW,GACjB,OAAO,CAAC,OAAO,CAAC,CAGlB"}
@@ -7,9 +7,6 @@ exports.default = hasGeometryColumn;
7
7
  * Uses `getTypes()` to inspect column types and checks for any column
8
8
  * whose type normalizes to `"geometry"`.
9
9
  *
10
- * @param table - The SimpleTable instance to inspect.
11
- * @returns `true` if at least one geometry column exists, `false` otherwise.
12
- *
13
10
  * @example
14
11
  * ```ts
15
12
  * const hasGeo = await hasGeometryColumn(table);
@@ -17,6 +14,10 @@ exports.default = hasGeometryColumn;
17
14
  * console.log("This table contains geometry columns");
18
15
  * }
19
16
  * ```
17
+ *
18
+ * @param table - The SimpleTable instance to inspect.
19
+ *
20
+ * @returns `true` if at least one geometry column exists, `false` otherwise.
20
21
  */
21
22
  async function hasGeometryColumn(table) {
22
23
  const types = await table.getTypes();
@@ -0,0 +1,2 @@
1
+ export default function initialUmapCoordinates(count: number, seed: number): Float64Array<ArrayBuffer>;
2
+ //# sourceMappingURL=initialUmapCoordinates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initialUmapCoordinates.d.ts","sourceRoot":"","sources":["../../src/helpers/initialUmapCoordinates.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,6BAGzE"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = initialUmapCoordinates;
7
+ const umapRandom_js_1 = __importDefault(require("./umapRandom.js"));
8
+ function initialUmapCoordinates(count, seed) {
9
+ const random = (0, umapRandom_js_1.default)(seed);
10
+ return Float64Array.from({ length: count * 2 }, () => random() * 20 - 10);
11
+ }
@@ -0,0 +1,10 @@
1
+ import type { DuckDBConnection } from "@duckdb/node-api";
2
+ /**
3
+ * Inspect connectivity of an edge relation while transferring ids, not vectors.
4
+ * Isolated vertices count as one-point components. Invalid ids fail closed.
5
+ */
6
+ export default function inspectGraphConnectivity(connection: DuckDBConnection, edges: string, vertexCount: number): Promise<{
7
+ componentCount: number;
8
+ sizes: number[];
9
+ }>;
10
+ //# sourceMappingURL=inspectGraphConnectivity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspectGraphConnectivity.d.ts","sourceRoot":"","sources":["../../src/helpers/inspectGraphConnectivity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;GAGG;AACH,wBAA8B,wBAAwB,CACpD,UAAU,EAAE,gBAAgB,EAC5B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAoDtD"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = inspectGraphConnectivity;
4
+ /**
5
+ * Inspect connectivity of an edge relation while transferring ids, not vectors.
6
+ * Isolated vertices count as one-point components. Invalid ids fail closed.
7
+ */
8
+ async function inspectGraphConnectivity(connection, edges, vertexCount) {
9
+ if (!Number.isSafeInteger(vertexCount) || vertexCount < 1 ||
10
+ vertexCount > 2147483647) {
11
+ throw new Error("Graph vertex count must fit a positive INTEGER vertex count.");
12
+ }
13
+ const parent = new Int32Array(vertexCount);
14
+ const sizes = new Int32Array(vertexCount).fill(1);
15
+ for (let vertex = 0; vertex < vertexCount; vertex++)
16
+ parent[vertex] = vertex;
17
+ const root = (vertex) => {
18
+ while (parent[vertex] !== vertex) {
19
+ parent[vertex] = parent[parent[vertex]];
20
+ vertex = parent[vertex];
21
+ }
22
+ return vertex;
23
+ };
24
+ const rows = await connection.stream(`SELECT source,target FROM ${edges}`);
25
+ while (true) {
26
+ const chunk = await rows.fetchChunk();
27
+ if (!chunk || chunk.rowCount === 0)
28
+ break;
29
+ const sources = chunk.getColumnVector(0);
30
+ const targets = chunk.getColumnVector(1);
31
+ for (let row = 0; row < chunk.rowCount; row++) {
32
+ const sourceValue = sources.getItem(row);
33
+ const targetValue = targets.getItem(row);
34
+ const source = Number(sourceValue);
35
+ const target = Number(targetValue);
36
+ if (sourceValue === null || targetValue === null ||
37
+ !Number.isSafeInteger(source) || source < 0 || source >= vertexCount ||
38
+ !Number.isSafeInteger(target) || target < 0 || target >= vertexCount) {
39
+ throw new Error("Graph edge contains an invalid vertex id.");
40
+ }
41
+ let sourceRoot = root(source), targetRoot = root(target);
42
+ if (sourceRoot === targetRoot)
43
+ continue;
44
+ if (sizes[sourceRoot] < sizes[targetRoot]) {
45
+ [sourceRoot, targetRoot] = [targetRoot, sourceRoot];
46
+ }
47
+ parent[targetRoot] = sourceRoot;
48
+ sizes[sourceRoot] += sizes[targetRoot];
49
+ }
50
+ }
51
+ const componentSizes = [];
52
+ for (let vertex = 0; vertex < vertexCount; vertex++) {
53
+ if (root(vertex) === vertex)
54
+ componentSizes.push(sizes[vertex]);
55
+ }
56
+ componentSizes.sort((a, b) => b - a);
57
+ return { componentCount: componentSizes.length, sizes: componentSizes };
58
+ }
@@ -5,19 +5,6 @@ type DuckDBValue = NativeDuckDBValue;
5
5
  * Combines a table or database's logging defaults with query-specific options.
6
6
  * Use this helper with `queryDB()` when implementing an extension.
7
7
  *
8
- * @param simple - The logging defaults from a table or database.
9
- * @param simple.rowsToLog - The default number of rows to display.
10
- * @param simple.charsToLog - The default maximum characters to display per cell.
11
- * @param options - Query-specific settings, which take precedence over defaults.
12
- * @param options.table - The table name used for diagnostics, or `null`.
13
- * @param options.method - The calling method used for diagnostics, or `null`.
14
- * @param options.parameters - Arguments included in error diagnostics, or `null`.
15
- * @param options.rowsToLog - Overrides the default number of displayed rows.
16
- * @param options.returnData - Whether to return converted rows. Defaults to false.
17
- * @param options.values - DuckDB-native values bound to SQL placeholders, in order.
18
- * @param options.noClean - Whether to preserve the SQL text without cleaning it.
19
- * @returns The merged query options without modifying either argument.
20
- *
21
8
  * @example
22
9
  * ```ts
23
10
  * import { mergeOptions } from "@nshiab/simple-data-analysis-core/helpers";
@@ -30,6 +17,30 @@ type DuckDBValue = NativeDuckDBValue;
30
17
  * });
31
18
  * console.log(options.rowsToLog, options.returnData);
32
19
  * ```
20
+ *
21
+ * @param simple - The logging defaults from a table or database.
22
+ *
23
+ * @param simple.rowsToLog - The default number of rows to display.
24
+ *
25
+ * @param simple.charsToLog - The default maximum characters to display per cell.
26
+ *
27
+ * @param options - Query-specific settings, which take precedence over defaults.
28
+ *
29
+ * @param options.table - The table name used for diagnostics, or `null`.
30
+ *
31
+ * @param options.method - The calling method used for diagnostics, or `null`.
32
+ *
33
+ * @param options.parameters - Arguments included in error diagnostics, or `null`.
34
+ *
35
+ * @param options.rowsToLog - Overrides the default number of displayed rows.
36
+ *
37
+ * @param options.returnData - Whether to return converted rows. Defaults to false.
38
+ *
39
+ * @param options.values - DuckDB-native values bound to SQL placeholders, in order.
40
+ *
41
+ * @param options.noClean - Whether to preserve the SQL text without cleaning it.
42
+ *
43
+ * @returns The merged query options without modifying either argument.
33
44
  */
34
45
  export default function mergeOptions(simple: {
35
46
  rowsToLog: number;
@@ -1 +1 @@
1
- {"version":3,"file":"mergeOptions.d.ts","sourceRoot":"","sources":["../../src/helpers/mergeOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAEzE,kGAAkG;AAClG,KAAK,WAAW,GAAG,iBAAiB,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EAC7D,OAAO,EAAE;IACP,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACA;IACD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAWA"}
1
+ {"version":3,"file":"mergeOptions.d.ts","sourceRoot":"","sources":["../../src/helpers/mergeOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAEzE,kGAAkG;AAClG,KAAK,WAAW,GAAG,iBAAiB,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EAC7D,OAAO,EAAE;IACP,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACA;IACD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAWA"}
@@ -5,19 +5,6 @@ exports.default = mergeOptions;
5
5
  * Combines a table or database's logging defaults with query-specific options.
6
6
  * Use this helper with `queryDB()` when implementing an extension.
7
7
  *
8
- * @param simple - The logging defaults from a table or database.
9
- * @param simple.rowsToLog - The default number of rows to display.
10
- * @param simple.charsToLog - The default maximum characters to display per cell.
11
- * @param options - Query-specific settings, which take precedence over defaults.
12
- * @param options.table - The table name used for diagnostics, or `null`.
13
- * @param options.method - The calling method used for diagnostics, or `null`.
14
- * @param options.parameters - Arguments included in error diagnostics, or `null`.
15
- * @param options.rowsToLog - Overrides the default number of displayed rows.
16
- * @param options.returnData - Whether to return converted rows. Defaults to false.
17
- * @param options.values - DuckDB-native values bound to SQL placeholders, in order.
18
- * @param options.noClean - Whether to preserve the SQL text without cleaning it.
19
- * @returns The merged query options without modifying either argument.
20
- *
21
8
  * @example
22
9
  * ```ts
23
10
  * import { mergeOptions } from "@nshiab/simple-data-analysis-core/helpers";
@@ -30,6 +17,30 @@ exports.default = mergeOptions;
30
17
  * });
31
18
  * console.log(options.rowsToLog, options.returnData);
32
19
  * ```
20
+ *
21
+ * @param simple - The logging defaults from a table or database.
22
+ *
23
+ * @param simple.rowsToLog - The default number of rows to display.
24
+ *
25
+ * @param simple.charsToLog - The default maximum characters to display per cell.
26
+ *
27
+ * @param options - Query-specific settings, which take precedence over defaults.
28
+ *
29
+ * @param options.table - The table name used for diagnostics, or `null`.
30
+ *
31
+ * @param options.method - The calling method used for diagnostics, or `null`.
32
+ *
33
+ * @param options.parameters - Arguments included in error diagnostics, or `null`.
34
+ *
35
+ * @param options.rowsToLog - Overrides the default number of displayed rows.
36
+ *
37
+ * @param options.returnData - Whether to return converted rows. Defaults to false.
38
+ *
39
+ * @param options.values - DuckDB-native values bound to SQL placeholders, in order.
40
+ *
41
+ * @param options.noClean - Whether to preserve the SQL text without cleaning it.
42
+ *
43
+ * @returns The merged query options without modifying either argument.
33
44
  */
34
45
  function mergeOptions(simple, options) {
35
46
  return {
@@ -0,0 +1,7 @@
1
+ import type prepareUmapLayoutOptions from "./prepareUmapLayoutOptions.js";
2
+ export default function optimizeUmapLayout(graph: {
3
+ source: Uint32Array;
4
+ target: Uint32Array;
5
+ weight: Float64Array;
6
+ }, initial: Float64Array, options: ReturnType<typeof prepareUmapLayoutOptions>): Float64Array;
7
+ //# sourceMappingURL=optimizeUmapLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimizeUmapLayout.d.ts","sourceRoot":"","sources":["../../src/helpers/optimizeUmapLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,wBAAwB,MAAM,+BAA+B,CAAC;AAS1E,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,KAAK,EAAE;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,YAAY,CAAA;CAAE,EACzE,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,GACnD,YAAY,CA2Fd"}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = optimizeUmapLayout;
7
+ const umapRandom_js_1 = __importDefault(require("./umapRandom.js"));
8
+ // Internal interface. Graph entries are directed, in a stable order; the fuzzy
9
+ // union graph supplies both orientations. Coordinates are interleaved x,y.
10
+ // Inputs are borrowed read-only. State is O(edges + vertices), never O(n²).
11
+ // Implements reference Euclidean UMAP SGD: scheduled attractive edges, sampled
12
+ // repulsion, clipped gradients, symmetric attractive updates, linear decay.
13
+ // Algorithm: https://umap-learn.readthedocs.io/en/latest/how_umap_works.html
14
+ function optimizeUmapLayout(graph, initial, options) {
15
+ const { epochs, seed, learningRate, negativeSamples, curve: [a, b] } = options;
16
+ const count = initial.length / 2;
17
+ if (!Number.isInteger(count) || count < 3 || count > 0xffffffff) {
18
+ throw new Error("Expected interleaved coordinates for at least three vertices.");
19
+ }
20
+ for (const value of initial) {
21
+ if (!Number.isFinite(value)) {
22
+ throw new Error("Initial coordinates must be finite.");
23
+ }
24
+ }
25
+ const { source, target, weight } = graph;
26
+ if (!weight.length || source.length !== weight.length ||
27
+ target.length !== weight.length)
28
+ throw new Error("Invalid graph column lengths.");
29
+ let maximum = 0;
30
+ for (let edge = 0; edge < weight.length; edge++) {
31
+ if (source[edge] >= count || target[edge] >= count ||
32
+ source[edge] === target[edge])
33
+ throw new Error("Graph contains an invalid vertex or self edge.");
34
+ if (!Number.isFinite(weight[edge]) || weight[edge] < 0 || weight[edge] > 1)
35
+ throw new Error("Graph weights must be between zero and one.");
36
+ maximum = Math.max(maximum, weight[edge]);
37
+ }
38
+ if (!maximum)
39
+ throw new Error("Graph must contain a positive edge.");
40
+ const period = new Float64Array(weight.length);
41
+ const nextPositive = new Float64Array(weight.length);
42
+ const nextNegative = new Float64Array(weight.length);
43
+ // Reference pruning uses 500 when explicitly requesting at most ten epochs.
44
+ const threshold = maximum / (epochs > 10 ? epochs : 500);
45
+ for (let edge = 0; edge < weight.length; edge++) {
46
+ period[edge] = weight[edge] > 0 && weight[edge] >= threshold
47
+ ? epochs / ((weight[edge] / maximum) * epochs)
48
+ : Infinity;
49
+ nextPositive[edge] = period[edge];
50
+ nextNegative[edge] = period[edge] / negativeSamples;
51
+ }
52
+ const coordinates = initial.slice();
53
+ const random = (0, umapRandom_js_1.default)(seed ^ 0x7f4a7c15);
54
+ const clip = (gradient) => Math.max(-4, Math.min(4, gradient));
55
+ let alpha = learningRate;
56
+ for (let epoch = 0; epoch < epochs; epoch++) {
57
+ for (let edge = 0; edge < weight.length; edge++) {
58
+ if (nextPositive[edge] > epoch)
59
+ continue;
60
+ const u = source[edge] * 2, v = target[edge] * 2;
61
+ let dx = coordinates[u] - coordinates[v], dy = coordinates[u + 1] - coordinates[v + 1];
62
+ let squared = dx * dx + dy * dy;
63
+ if (squared > 0) {
64
+ const attraction = -2 * a * b * Math.pow(squared, b - 1) /
65
+ (1 + a * Math.pow(squared, b));
66
+ const gx = clip(attraction * dx) * alpha, gy = clip(attraction * dy) * alpha;
67
+ coordinates[u] += gx;
68
+ coordinates[u + 1] += gy;
69
+ coordinates[v] -= gx;
70
+ coordinates[v + 1] -= gy;
71
+ }
72
+ nextPositive[edge] += period[edge];
73
+ const negativePeriod = period[edge] / negativeSamples;
74
+ const draws = Math.floor((epoch - nextNegative[edge]) / negativePeriod);
75
+ for (let draw = 0; draw < draws; draw++) {
76
+ const other = Math.floor(random() * count) * 2;
77
+ dx = coordinates[u] - coordinates[other];
78
+ dy = coordinates[u + 1] - coordinates[other + 1];
79
+ squared = dx * dx + dy * dy;
80
+ // Coincident points get zero repulsive gradient, as in current Python
81
+ // UMAP; this intentionally differs from UMAP-JS's constant +4 fallback.
82
+ if (squared > 0) {
83
+ const repulsion = 2 * b /
84
+ ((0.001 + squared) * (1 + a * Math.pow(squared, b)));
85
+ coordinates[u] += clip(repulsion * dx) * alpha;
86
+ coordinates[u + 1] += clip(repulsion * dy) * alpha;
87
+ }
88
+ }
89
+ nextNegative[edge] += draws * negativePeriod;
90
+ }
91
+ alpha = learningRate * (1 - epoch / epochs);
92
+ }
93
+ for (const value of coordinates) {
94
+ if (!Number.isFinite(value)) {
95
+ throw new Error("UMAP optimization produced a non-finite coordinate.");
96
+ }
97
+ }
98
+ return coordinates;
99
+ }
@@ -3,16 +3,18 @@
3
3
  * quotes escaped, dates become quoted ISO strings, and null, undefined, or NaN
4
4
  * become `"NULL"`. Numbers and booleans are returned unchanged.
5
5
  *
6
- * @param value - A string, number, boolean, Date, null, or undefined.
7
- * @returns A SQL literal, or the original number or boolean.
8
- * @throws If the value has an unsupported type.
9
- *
10
6
  * @example
11
7
  * ```ts
12
8
  * import { parseValue } from "@nshiab/simple-data-analysis-core/helpers";
13
9
  * console.log(parseValue("O'Brien")); // "'O''Brien'"
14
10
  * console.log(parseValue(null)); // "NULL"
15
11
  * ```
12
+ *
13
+ * @param value - A string, number, boolean, Date, null, or undefined.
14
+ *
15
+ * @returns A SQL literal, or the original number or boolean.
16
+ *
17
+ * @throws If the value has an unsupported type.
16
18
  */
17
19
  export default function parseValue(value: unknown): string | boolean | number;
18
20
  //# sourceMappingURL=parseValue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseValue.d.ts","sourceRoot":"","sources":["../../src/helpers/parseValue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAc5E"}
1
+ {"version":3,"file":"parseValue.d.ts","sourceRoot":"","sources":["../../src/helpers/parseValue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAc5E"}
@@ -6,16 +6,18 @@ exports.default = parseValue;
6
6
  * quotes escaped, dates become quoted ISO strings, and null, undefined, or NaN
7
7
  * become `"NULL"`. Numbers and booleans are returned unchanged.
8
8
  *
9
- * @param value - A string, number, boolean, Date, null, or undefined.
10
- * @returns A SQL literal, or the original number or boolean.
11
- * @throws If the value has an unsupported type.
12
- *
13
9
  * @example
14
10
  * ```ts
15
11
  * import { parseValue } from "@nshiab/simple-data-analysis-core/helpers";
16
12
  * console.log(parseValue("O'Brien")); // "'O''Brien'"
17
13
  * console.log(parseValue(null)); // "NULL"
18
14
  * ```
15
+ *
16
+ * @param value - A string, number, boolean, Date, null, or undefined.
17
+ *
18
+ * @returns A SQL literal, or the original number or boolean.
19
+ *
20
+ * @throws If the value has an unsupported type.
19
21
  */
20
22
  function parseValue(value) {
21
23
  if (Number.isNaN(value) || value === undefined || value === null) {
@@ -0,0 +1,31 @@
1
+ import type { TableSchema } from "./pendingOps.js";
2
+ import { type GraphId, type PreparedGraphStarts } from "./prepareGraphStarts.js";
3
+ export type PreparedGraphRouteEndpoints = {
4
+ end: PreparedGraphStarts;
5
+ start: PreparedGraphStarts;
6
+ values: PreparedGraphStarts;
7
+ };
8
+ /** Prepares and validates the two scalar endpoints shared by route methods. */
9
+ export declare function prepareGraphRouteEndpoints(start: GraphId, end: GraphId, method: string): PreparedGraphRouteEndpoints;
10
+ /** Validates the columns shared by edge-route methods from queued schema data. */
11
+ export declare function validateGraphRouteInputs(schema: TableSchema, source: string, target: string, edgeId: string, endpoints: PreparedGraphRouteEndpoints, weight: string | undefined, method: string): {
12
+ distanceType: string;
13
+ edgeIdType: string;
14
+ nodeIdType: string;
15
+ };
16
+ /** Prepares the typed SQL expressions shared by edge-route enumeration. */
17
+ export declare function prepareGraphRouteSql(input: string, schema: TableSchema, source: string, target: string, edgeId: string, endpoints: PreparedGraphRouteEndpoints, weight: string | undefined, method: string): {
18
+ distanceType: string;
19
+ edgeIdColumn: import("./getGraphEdgeIdColumn.js").GraphEdgeIdColumn;
20
+ edgeKey: string;
21
+ edgeWeight: string;
22
+ endpointValue: string;
23
+ keyType: string;
24
+ stepType: string;
25
+ input: string;
26
+ schema: TableSchema;
27
+ traversal: import("./prepareGraphTraversal.js").PreparedGraphTraversal;
28
+ typedEdgeId: string;
29
+ weightType: string | undefined;
30
+ };
31
+ //# sourceMappingURL=prepareGraphRouteSql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareGraphRouteSql.d.ts","sourceRoot":"","sources":["../../src/helpers/prepareGraphRouteSql.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAA2B,EACzB,KAAK,OAAO,EACZ,KAAK,mBAAmB,EACzB,MAAM,yBAAyB,CAAC;AAMjC,MAAM,MAAM,2BAA2B,GAAG;IACxC,GAAG,EAAE,mBAAmB,CAAC;IACzB,KAAK,EAAE,mBAAmB,CAAC;IAC3B,MAAM,EAAE,mBAAmB,CAAC;CAC7B,CAAC;AAEF,+EAA+E;AAC/E,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,MAAM,GACb,2BAA2B,CA+B7B;AAED,kFAAkF;AAClF,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,2BAA2B,EACtC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,MAAM,EAAE,MAAM;;;;EAmBf;AAED,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,2BAA2B,EACtC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,MAAM,EAAE,MAAM;;;;;;;;;;;;;EAkDf"}
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.prepareGraphRouteEndpoints = prepareGraphRouteEndpoints;
40
+ exports.validateGraphRouteInputs = validateGraphRouteInputs;
41
+ exports.prepareGraphRouteSql = prepareGraphRouteSql;
42
+ const getGraphEdgeIdColumn_js_1 = __importDefault(require("./getGraphEdgeIdColumn.js"));
43
+ const getGraphWeightColumn_js_1 = __importDefault(require("./getGraphWeightColumn.js"));
44
+ const validateGraphRouteResultSchema_js_1 = __importDefault(require("./validateGraphRouteResultSchema.js"));
45
+ const prepareGraphStarts_js_1 = __importDefault(require("./prepareGraphStarts.js"));
46
+ const prepareGraphTraversal_js_1 = __importStar(require("./prepareGraphTraversal.js"));
47
+ const quoteIdentifier_js_1 = __importDefault(require("./quoteIdentifier.js"));
48
+ /** Prepares and validates the two scalar endpoints shared by route methods. */
49
+ function prepareGraphRouteEndpoints(start, end, method) {
50
+ if (Array.isArray(start)) {
51
+ throw new TypeError(`${method} start must be one node ID.`);
52
+ }
53
+ if (Array.isArray(end)) {
54
+ throw new TypeError(`${method} end must be one node ID.`);
55
+ }
56
+ const preparedStart = (0, prepareGraphStarts_js_1.default)(start, method);
57
+ const preparedEnd = (0, prepareGraphStarts_js_1.default)(end, method);
58
+ if (preparedStart.family !== preparedEnd.family) {
59
+ throw new TypeError(`${method} start and end must both be string IDs or both be numeric IDs.`);
60
+ }
61
+ if (preparedStart.values[0] === preparedEnd.values[0]) {
62
+ throw new TypeError(`${method} start and end must be different. Use distances() to measure return routes or findCycles() to find loops.`);
63
+ }
64
+ return {
65
+ start: preparedStart,
66
+ end: preparedEnd,
67
+ values: {
68
+ family: preparedStart.family,
69
+ numericValues: [
70
+ ...preparedStart.numericValues,
71
+ ...preparedEnd.numericValues,
72
+ ],
73
+ values: [preparedStart.values[0], preparedEnd.values[0]],
74
+ },
75
+ };
76
+ }
77
+ /** Validates the columns shared by edge-route methods from queued schema data. */
78
+ function validateGraphRouteInputs(schema, source, target, edgeId, endpoints, weight, method) {
79
+ const nodes = (0, prepareGraphTraversal_js_1.validateGraphStarts)(schema, source, target, endpoints.values, method);
80
+ const edges = (0, getGraphEdgeIdColumn_js_1.default)(schema, edgeId, method);
81
+ const weightColumn = weight === undefined
82
+ ? undefined
83
+ : (0, getGraphWeightColumn_js_1.default)(schema, weight, method);
84
+ (0, validateGraphRouteResultSchema_js_1.default)(schema, method);
85
+ return {
86
+ distanceType: weightColumn?.distanceType ?? "BIGINT",
87
+ edgeIdType: edges.idType,
88
+ nodeIdType: nodes.idType,
89
+ };
90
+ }
91
+ /** Prepares the typed SQL expressions shared by edge-route enumeration. */
92
+ function prepareGraphRouteSql(input, schema, source, target, edgeId, endpoints, weight, method) {
93
+ (0, validateGraphRouteResultSchema_js_1.default)(schema, method);
94
+ const traversal = (0, prepareGraphTraversal_js_1.default)(input, schema, source, target, endpoints.values, method);
95
+ const edgeIdColumn = (0, getGraphEdgeIdColumn_js_1.default)(schema, edgeId, method);
96
+ const weightColumn = weight === undefined
97
+ ? undefined
98
+ : (0, getGraphWeightColumn_js_1.default)(schema, weight, method);
99
+ const distanceType = weightColumn?.distanceType ?? "BIGINT";
100
+ const q = quoteIdentifier_js_1.default;
101
+ const edgeIdReference = `${q("edges")}.${q(edgeIdColumn.column)}`;
102
+ const typedEdgeId = `CAST(${edgeIdReference} AS ${edgeIdColumn.idType})`;
103
+ const edgeKey = edgeIdColumn.family === "string"
104
+ ? `ENCODE(${typedEdgeId})`
105
+ : typedEdgeId;
106
+ const edgeWeight = weightColumn === undefined
107
+ ? `CAST(1 AS ${distanceType})`
108
+ : `CAST(${q("edges")}.${q(weightColumn.column)} AS ${distanceType})`;
109
+ const keyType = edgeIdColumn.family === "string"
110
+ ? "BLOB"
111
+ : edgeIdColumn.idType;
112
+ const stepType = `STRUCT(${q("edgeId")} ${edgeIdColumn.idType}, ${q("source")} ${traversal.endpoints.idType}, ${q("target")} ${traversal.endpoints.idType}, ${q("weight")} ${distanceType}, ${q("distance")} ${distanceType})`;
113
+ return {
114
+ distanceType,
115
+ edgeIdColumn,
116
+ edgeKey,
117
+ edgeWeight,
118
+ endpointValue: `TRY_CAST(? AS ${traversal.endpoints.idType})`,
119
+ keyType,
120
+ stepType,
121
+ input,
122
+ schema,
123
+ traversal,
124
+ typedEdgeId,
125
+ weightType: weightColumn?.type,
126
+ };
127
+ }
@@ -0,0 +1,9 @@
1
+ export type GraphId = string | number | bigint;
2
+ export type PreparedGraphStarts = {
3
+ family: "string" | "numeric";
4
+ numericValues: bigint[];
5
+ values: string[];
6
+ };
7
+ /** Validates and snapshots scalar-or-array graph starting IDs. */
8
+ export default function prepareGraphStarts(start: GraphId | GraphId[], method: string, argument?: string, scalar?: boolean): PreparedGraphStarts;
9
+ //# sourceMappingURL=prepareGraphStarts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareGraphStarts.d.ts","sourceRoot":"","sources":["../../src/helpers/prepareGraphStarts.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/C,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC7B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,kEAAkE;AAClE,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,KAAK,EAAE,OAAO,GAAG,OAAO,EAAE,EAC1B,MAAM,EAAE,MAAM,EACd,QAAQ,SAAU,EAClB,MAAM,UAAQ,GACb,mBAAmB,CAoErB"}