@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 @@
1
+ {"version":3,"file":"readScalarNumber.d.ts","sourceRoot":"","sources":["../../src/helpers/readScalarNumber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,wBAA8B,gBAAgB,CAC5C,UAAU,EAAE,gBAAgB,EAC5B,GAAG,EAAE,MAAM,mBAGZ"}
@@ -0,0 +1,4 @@
1
+ // For internal queries returning a single numeric value, such as row counts.
2
+ export default async function readScalarNumber(connection, sql) {
3
+ return Number((await connection.runAndReadAll(sql)).getRowsJS()[0][0]);
4
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"runQuery.d.ts","sourceRoot":"","sources":["../../src/helpers/runQuery.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,gBAAgB,EAIrB,KAAK,UAAU,EAEf,KAAK,WAAW,EAIjB,MAAM,kBAAkB,CAAC;AAI1B,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9C,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AA8CF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,MAAM,GAAG,IAAW,GAC9B,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAoCjC;AAED,wBAA8B,QAAQ,CACpC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,gBAAgB,EAC5B,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,eAAe,GACvB,OAAO,CACN;IACA,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,EAAE,GACD,IAAI,CACP,CAoEA"}
1
+ {"version":3,"file":"runQuery.d.ts","sourceRoot":"","sources":["../../src/helpers/runQuery.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,gBAAgB,EAIrB,KAAK,UAAU,EAEf,KAAK,WAAW,EAIjB,MAAM,kBAAkB,CAAC;AAI1B,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9C,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AA8CF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,MAAM,GAAG,IAAW,GAC9B,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAoCjC;AAED,wBAA8B,QAAQ,CACpC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,gBAAgB,EAC5B,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,eAAe,GACvB,OAAO,CACN;IACA,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,EAAE,GACD,IAAI,CACP,CAiFA"}
@@ -99,9 +99,23 @@ export default async function runQuery(query, connection, returnData, options) {
99
99
  for (let j = 0; j < columnCount; j++) {
100
100
  const columnName = columnNames[j];
101
101
  const converter = converters[j];
102
- chunk.visitColumnValues(j, (value, rowIndex) => {
103
- rows[base + rowIndex][columnName] = converter(value);
104
- });
102
+ if (columnName === "__proto__") {
103
+ // This valid SQL identifier must define data, not invoke Node's
104
+ // legacy Object.prototype setter. Keep ordinary columns fast.
105
+ chunk.visitColumnValues(j, (value, rowIndex) => {
106
+ Object.defineProperty(rows[base + rowIndex], columnName, {
107
+ value: converter(value),
108
+ enumerable: true,
109
+ configurable: true,
110
+ writable: true,
111
+ });
112
+ });
113
+ }
114
+ else {
115
+ chunk.visitColumnValues(j, (value, rowIndex) => {
116
+ rows[base + rowIndex][columnName] = converter(value);
117
+ });
118
+ }
105
119
  }
106
120
  }
107
121
  return rows;
@@ -0,0 +1,11 @@
1
+ export type FuzzyPair = {
2
+ left_value: string;
3
+ right_value: string;
4
+ left_cnt: number;
5
+ right_cnt: number;
6
+ score: number;
7
+ };
8
+ export type FuzzyStrategy = "mostCommon" | "longestString" | "shortestString" | "mostCentral" | "maxScore";
9
+ /** Groups matching values transitively and chooses each component's canonical value. */
10
+ export default function selectFuzzyReplacements(pairs: FuzzyPair[], strategy: FuzzyStrategy): Map<string, string>;
11
+ //# sourceMappingURL=selectFuzzyReplacements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectFuzzyReplacements.d.ts","sourceRoot":"","sources":["../../src/helpers/selectFuzzyReplacements.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,eAAe,GACf,gBAAgB,GAChB,aAAa,GACb,UAAU,CAAC;AAEf,wFAAwF;AACxF,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,KAAK,EAAE,SAAS,EAAE,EAClB,QAAQ,EAAE,aAAa,GACtB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CA8HrB"}
@@ -0,0 +1,124 @@
1
+ /** Groups matching values transitively and chooses each component's canonical value. */
2
+ export default function selectFuzzyReplacements(pairs, strategy) {
3
+ // Build count map from the pairs — no separate query needed.
4
+ const countMap = new Map();
5
+ for (const { left_value, left_cnt, right_value, right_cnt } of pairs) {
6
+ countMap.set(left_value, Number(left_cnt));
7
+ countMap.set(right_value, Number(right_cnt));
8
+ }
9
+ // Union-Find — only over values that actually participate in a pair.
10
+ const parent = new Map();
11
+ const find = (x) => {
12
+ if (!parent.has(x))
13
+ parent.set(x, x);
14
+ if (parent.get(x) !== x)
15
+ parent.set(x, find(parent.get(x)));
16
+ return parent.get(x);
17
+ };
18
+ const union = (a, b) => {
19
+ const ra = find(a);
20
+ const rb = find(b);
21
+ if (ra !== rb)
22
+ parent.set(ra, rb);
23
+ };
24
+ for (const v of countMap.keys())
25
+ find(v);
26
+ for (const { left_value, right_value } of pairs) {
27
+ union(left_value, right_value);
28
+ }
29
+ // Group values by their cluster root.
30
+ const clusters = new Map();
31
+ for (const v of countMap.keys()) {
32
+ const root = find(v);
33
+ if (!clusters.has(root))
34
+ clusters.set(root, []);
35
+ clusters.get(root).push(v);
36
+ }
37
+ // Pick the canonical value for each cluster.
38
+ const replacement = new Map();
39
+ // Every pair belongs to exactly one component. Accumulate scores globally,
40
+ // at most once, instead of scanning all pairs separately for each cluster.
41
+ // Keep this lazy: distinct counts/lengths can choose a winner without scores.
42
+ // Iterating in the original pair order also preserves floating-point ties.
43
+ let scoreSum = null;
44
+ const getScoreSum = () => {
45
+ if (scoreSum === null) {
46
+ scoreSum = new Map();
47
+ for (const { left_value, right_value, score } of pairs) {
48
+ scoreSum.set(left_value, (scoreSum.get(left_value) ?? 0) + score);
49
+ scoreSum.set(right_value, (scoreSum.get(right_value) ?? 0) + score);
50
+ }
51
+ }
52
+ return scoreSum;
53
+ };
54
+ let scoreMax = null;
55
+ const getScoreMax = () => {
56
+ if (scoreMax === null) {
57
+ scoreMax = new Map();
58
+ for (const { left_value, right_value, score } of pairs) {
59
+ scoreMax.set(left_value, Math.max(scoreMax.get(left_value) ?? 0, score));
60
+ scoreMax.set(right_value, Math.max(scoreMax.get(right_value) ?? 0, score));
61
+ }
62
+ }
63
+ return scoreMax;
64
+ };
65
+ for (const members of clusters.values()) {
66
+ if (members.length === 1)
67
+ continue;
68
+ // Sum-based comparator: highest total similarity, then alphabetical.
69
+ const byScore = (a, b) => {
70
+ const sum = getScoreSum();
71
+ const sa = sum.get(a) ?? 0;
72
+ const sb = sum.get(b) ?? 0;
73
+ if (sa !== sb)
74
+ return sa > sb ? a : b;
75
+ return a <= b ? a : b; // alphabetical tie-break
76
+ };
77
+ // Max-based comparator: highest single-pair score, then sum, then alphabetical.
78
+ const byMaxScore = (a, b) => {
79
+ const mx = getScoreMax();
80
+ const ma = mx.get(a) ?? 0;
81
+ const mb = mx.get(b) ?? 0;
82
+ if (ma !== mb)
83
+ return ma > mb ? a : b;
84
+ return byScore(a, b); // sum then alphabetical tie-break
85
+ };
86
+ let canonical;
87
+ if (strategy === "longestString") {
88
+ canonical = members.reduce((a, b) => {
89
+ if (a.length !== b.length)
90
+ return a.length > b.length ? a : b;
91
+ return byScore(a, b);
92
+ });
93
+ }
94
+ else if (strategy === "shortestString") {
95
+ canonical = members.reduce((a, b) => {
96
+ if (a.length !== b.length)
97
+ return a.length < b.length ? a : b;
98
+ return byScore(a, b);
99
+ });
100
+ }
101
+ else if (strategy === "mostCommon") {
102
+ canonical = members.reduce((a, b) => {
103
+ const ca = countMap.get(a) ?? 0;
104
+ const cb = countMap.get(b) ?? 0;
105
+ if (ca !== cb)
106
+ return ca > cb ? a : b;
107
+ return byScore(a, b);
108
+ });
109
+ }
110
+ else if (strategy === "mostCentral") {
111
+ // Most central string — highest total similarity to all other cluster members.
112
+ canonical = members.reduce((a, b) => byScore(a, b));
113
+ }
114
+ else {
115
+ // "maxScore": the string participating in the single highest-scoring pair.
116
+ canonical = members.reduce((a, b) => byMaxScore(a, b));
117
+ }
118
+ for (const m of members) {
119
+ if (m !== canonical)
120
+ replacement.set(m, canonical);
121
+ }
122
+ }
123
+ return replacement;
124
+ }
@@ -0,0 +1,14 @@
1
+ import type { DuckDBConnection } from "@duckdb/node-api";
2
+ /**
3
+ * Stabilizes cosine arithmetic in a caller-owned private vector relation.
4
+ * The already-quoted relation has unique vertex ids and a fixed-size DOUBLE
5
+ * vec column. Source data must be retained separately by the caller.
6
+ *
7
+ * Safe vectors keep their existing arithmetic and tie behavior. Outside the
8
+ * safe range, divide by the largest absolute component, then by the resulting
9
+ * length. This preserves direction without overflowing or underflowing norms.
10
+ * The bounds keep squared-norm products between 1e-300 and 1e300, with room
11
+ * for rounding. Only the private vec column changes; no scratch tables remain.
12
+ */
13
+ export default function stabilizeCosineVectors(connection: DuckDBConnection, rows: string): Promise<void>;
14
+ //# sourceMappingURL=stabilizeCosineVectors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stabilizeCosineVectors.d.ts","sourceRoot":"","sources":["../../src/helpers/stabilizeCosineVectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD;;;;;;;;;;GAUG;AACH,wBAA8B,sBAAsB,CAClD,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
@@ -0,0 +1,34 @@
1
+ import readScalarNumber from "./readScalarNumber.js";
2
+ /**
3
+ * Stabilizes cosine arithmetic in a caller-owned private vector relation.
4
+ * The already-quoted relation has unique vertex ids and a fixed-size DOUBLE
5
+ * vec column. Source data must be retained separately by the caller.
6
+ *
7
+ * Safe vectors keep their existing arithmetic and tie behavior. Outside the
8
+ * safe range, divide by the largest absolute component, then by the resulting
9
+ * length. This preserves direction without overflowing or underflowing norms.
10
+ * The bounds keep squared-norm products between 1e-300 and 1e300, with room
11
+ * for rounding. Only the private vec column changes; no scratch tables remain.
12
+ */
13
+ export default async function stabilizeCosineVectors(connection, rows) {
14
+ if (await readScalarNumber(connection, `SELECT count(*) FROM ${rows} WHERE vec IS NULL
15
+ OR len(vec)=0 OR list_count(vec)!=len(vec)
16
+ OR NOT list_bool_and(list_transform(vec, value -> isfinite(value)))
17
+ OR list_max(list_transform(vec, value -> abs(value)))=0`)) {
18
+ throw new Error("Cosine distance requires finite, non-null values and nonzero vectors.");
19
+ }
20
+ await connection.run(`WITH magnitudes AS MATERIALIZED (
21
+ SELECT vertex,vec,list_max(list_transform(vec, value -> abs(value))) AS magnitude
22
+ FROM ${rows}
23
+ ), scaled AS MATERIALIZED (
24
+ SELECT vertex,list_transform(vec, value -> value / magnitude) AS vec
25
+ FROM magnitudes
26
+ WHERE magnitude < 1e-75 OR magnitude > 1e75 / sqrt(len(vec))
27
+ ), lengths AS MATERIALIZED (
28
+ SELECT vertex,vec,sqrt(list_sum(list_transform(vec, value -> value * value))) AS norm
29
+ FROM scaled
30
+ )
31
+ UPDATE ${rows} AS target SET vec=cast_to_type(
32
+ list_transform(lengths.vec, value -> value / lengths.norm),target.vec)
33
+ FROM lengths WHERE target.vertex=lengths.vertex`);
34
+ }
@@ -2,15 +2,16 @@
2
2
  * Normalizes a string or array of strings to a new array.
3
3
  * Existing arrays are copied so callers can change the result independently.
4
4
  *
5
- * @param argument - One string or an array of strings.
6
- * @returns A new array containing the supplied strings.
7
- *
8
5
  * @example
9
6
  * ```ts
10
7
  * import { stringToArray } from "@nshiab/simple-data-analysis-core/helpers";
11
8
  * console.log(stringToArray("name")); // ["name"]
12
9
  * console.log(stringToArray(["name", "age"])); // ["name", "age"]
13
10
  * ```
11
+ *
12
+ * @param argument - One string or an array of strings.
13
+ *
14
+ * @returns A new array containing the supplied strings.
14
15
  */
15
16
  export default function stringToArray(argument: string | string[]): string[];
16
17
  //# sourceMappingURL=stringToArray.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stringToArray.d.ts","sourceRoot":"","sources":["../../src/helpers/stringToArray.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CAQ3E"}
1
+ {"version":3,"file":"stringToArray.d.ts","sourceRoot":"","sources":["../../src/helpers/stringToArray.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CAQ3E"}
@@ -2,15 +2,16 @@
2
2
  * Normalizes a string or array of strings to a new array.
3
3
  * Existing arrays are copied so callers can change the result independently.
4
4
  *
5
- * @param argument - One string or an array of strings.
6
- * @returns A new array containing the supplied strings.
7
- *
8
5
  * @example
9
6
  * ```ts
10
7
  * import { stringToArray } from "@nshiab/simple-data-analysis-core/helpers";
11
8
  * console.log(stringToArray("name")); // ["name"]
12
9
  * console.log(stringToArray(["name", "age"])); // ["name", "age"]
13
10
  * ```
11
+ *
12
+ * @param argument - One string or an array of strings.
13
+ *
14
+ * @returns A new array containing the supplied strings.
14
15
  */
15
16
  export default function stringToArray(argument) {
16
17
  if (Array.isArray(argument)) {
@@ -0,0 +1,2 @@
1
+ export default function umapRandom(seed: number): () => number;
2
+ //# sourceMappingURL=umapRandom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"umapRandom.d.ts","sourceRoot":"","sources":["../../src/helpers/umapRandom.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,IAAI,EAAE,MAAM,gBAQ9C"}
@@ -0,0 +1,10 @@
1
+ // Mulberry32: separate initialization and sampling streams, stable per seed.
2
+ export default function umapRandom(seed) {
3
+ let state = seed >>> 0;
4
+ return () => {
5
+ state = (state + 0x6D2B79F5) | 0;
6
+ let value = Math.imul(state ^ state >>> 15, 1 | state);
7
+ value ^= value + Math.imul(value ^ value >>> 7, 61 | value);
8
+ return ((value ^ value >>> 14) >>> 0) / 4294967296;
9
+ };
10
+ }
@@ -18,12 +18,6 @@ import type SimpleTable from "../class/SimpleTable.js";
18
18
  * inputs or overwritten as outputs; use updateWithJS() for editable GeoJSON.
19
19
  * This SQL-only preservation path accepts any source CRS.
20
20
  *
21
- * @param table - Table to enrich.
22
- * @param inputColumns - Columns available to the callback.
23
- * @param outputColumns - Generated columns to add or replace.
24
- * @param generate - Produces one result per input row, in input order.
25
- * @param options - Controls the maximum rows read, generated, and staged at once.
26
- * @returns Resolves after merging the generated columns into the table.
27
21
  * @example
28
22
  * ```ts
29
23
  * queueAsyncBarrier(table, {
@@ -35,6 +29,18 @@ import type SimpleTable from "../class/SimpleTable.js";
35
29
  * });
36
30
  * await table.log();
37
31
  * ```
32
+ *
33
+ * @param table - Table to enrich.
34
+ *
35
+ * @param inputColumns - Columns available to the callback.
36
+ *
37
+ * @param outputColumns - Generated columns to add or replace.
38
+ *
39
+ * @param generate - Produces one result per input row, in input order.
40
+ *
41
+ * @param options - Controls the maximum rows read, generated, and staged at once.
42
+ *
43
+ * @returns Resolves after merging the generated columns into the table.
38
44
  */
39
45
  export default function updateColumnsWithJS(table: SimpleTable, inputColumns: string[], outputColumns: string[], generate: (rows: {
40
46
  [key: string]: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"updateColumnsWithJS.d.ts","sourceRoot":"","sources":["../../src/helpers/updateColumnsWithJS.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAMvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAA8B,mBAAmB,CAC/C,KAAK,EAAE,WAAW,EAClB,YAAY,EAAE,MAAM,EAAE,EACtB,aAAa,EAAE,MAAM,EAAE,EACvB,QAAQ,EAAE,CACR,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,KAC/B,OAAO,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,CAAC,EAC1C,OAAO,GAAE;IACP;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACf,GACL,OAAO,CAAC,IAAI,CAAC,CAoJf"}
1
+ {"version":3,"file":"updateColumnsWithJS.d.ts","sourceRoot":"","sources":["../../src/helpers/updateColumnsWithJS.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAMvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAA8B,mBAAmB,CAC/C,KAAK,EAAE,WAAW,EAClB,YAAY,EAAE,MAAM,EAAE,EACtB,aAAa,EAAE,MAAM,EAAE,EACvB,QAAQ,EAAE,CACR,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,KAC/B,OAAO,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,CAAC,EAC1C,OAAO,GAAE;IACP;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACf,GACL,OAAO,CAAC,IAAI,CAAC,CAoJf"}
@@ -21,12 +21,6 @@ import { executePreparedArray, prepareArray } from "../methods/loadArray.js";
21
21
  * inputs or overwritten as outputs; use updateWithJS() for editable GeoJSON.
22
22
  * This SQL-only preservation path accepts any source CRS.
23
23
  *
24
- * @param table - Table to enrich.
25
- * @param inputColumns - Columns available to the callback.
26
- * @param outputColumns - Generated columns to add or replace.
27
- * @param generate - Produces one result per input row, in input order.
28
- * @param options - Controls the maximum rows read, generated, and staged at once.
29
- * @returns Resolves after merging the generated columns into the table.
30
24
  * @example
31
25
  * ```ts
32
26
  * queueAsyncBarrier(table, {
@@ -38,6 +32,18 @@ import { executePreparedArray, prepareArray } from "../methods/loadArray.js";
38
32
  * });
39
33
  * await table.log();
40
34
  * ```
35
+ *
36
+ * @param table - Table to enrich.
37
+ *
38
+ * @param inputColumns - Columns available to the callback.
39
+ *
40
+ * @param outputColumns - Generated columns to add or replace.
41
+ *
42
+ * @param generate - Produces one result per input row, in input order.
43
+ *
44
+ * @param options - Controls the maximum rows read, generated, and staged at once.
45
+ *
46
+ * @returns Resolves after merging the generated columns into the table.
41
47
  */
42
48
  export default async function updateColumnsWithJS(table, inputColumns, outputColumns, generate, options = {}) {
43
49
  const batchSize = options.batchSize ?? 1000;
@@ -0,0 +1,4 @@
1
+ import type { TableSchema } from "./pendingOps.js";
2
+ /** Validates that route result columns do not replace original input columns. */
3
+ export default function validateGraphRouteResultSchema(schema: TableSchema, method: string, additionalResultColumns?: readonly string[]): void;
4
+ //# sourceMappingURL=validateGraphRouteResultSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateGraphRouteResultSchema.d.ts","sourceRoot":"","sources":["../../src/helpers/validateGraphRouteResultSchema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAKnD,iFAAiF;AACjF,MAAM,CAAC,OAAO,UAAU,8BAA8B,CACpD,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,MAAM,EACd,uBAAuB,GAAE,SAAS,MAAM,EAAO,GAC9C,IAAI,CAkBN"}
@@ -0,0 +1,13 @@
1
+ import foldIdentifier from "./foldIdentifier.js";
2
+ import quoteIdentifier from "./quoteIdentifier.js";
3
+ const resultColumns = ["pathId", "step", "weight", "total"];
4
+ /** Validates that route result columns do not replace original input columns. */
5
+ export default function validateGraphRouteResultSchema(schema, method, additionalResultColumns = []) {
6
+ for (const resultColumn of [...resultColumns, ...additionalResultColumns]) {
7
+ const folded = foldIdentifier(resultColumn);
8
+ const inputColumn = Object.keys(schema).find((column) => foldIdentifier(column) === folded);
9
+ if (inputColumn !== undefined) {
10
+ throw new Error(`${method} cannot add ${quoteIdentifier(resultColumn)} because input column ${quoteIdentifier(inputColumn)} conflicts with that result column. Rename ${quoteIdentifier(inputColumn)} with renameColumns() before calculating the graph.`);
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,7 @@
1
+ import type SimpleTable from "../class/SimpleTable.js";
2
+ import { type PreparedGraphTemporalOptions } from "./prepareGraphTemporalSql.js";
3
+ /** Rejects invalid selected timestamps before a chronological graph runs. */
4
+ export default function validateGraphTemporalEvents(simpleTable: SimpleTable, options: PreparedGraphTemporalOptions, method: string, parameters: {
5
+ [key: string]: unknown;
6
+ }): Promise<void>;
7
+ //# sourceMappingURL=validateGraphTemporalEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateGraphTemporalEvents.d.ts","sourceRoot":"","sources":["../../src/helpers/validateGraphTemporalEvents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAEvD,OAAgC,EAC9B,KAAK,4BAA4B,EAClC,MAAM,8BAA8B,CAAC;AAItC,6EAA6E;AAC7E,wBAA8B,2BAA2B,CACvD,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,4BAA4B,EACrC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GACrC,OAAO,CAAC,IAAI,CAAC,CAiDf"}
@@ -0,0 +1,47 @@
1
+ import mergeOptions from "./mergeOptions.js";
2
+ import prepareGraphTemporalSql from "./prepareGraphTemporalSql.js";
3
+ import queryDB from "./queryDB.js";
4
+ import quoteIdentifier from "./quoteIdentifier.js";
5
+ /** Rejects invalid selected timestamps before a chronological graph runs. */
6
+ export default async function validateGraphTemporalEvents(simpleTable, options, method, parameters) {
7
+ const schema = await simpleTable.getTypes();
8
+ const temporal = prepareGraphTemporalSql(schema, options, method);
9
+ const q = quoteIdentifier;
10
+ const eventsName = "__graph_temporal_events";
11
+ const events = q(eventsName);
12
+ const eventStart = `${events}.${q("__event_start")}`;
13
+ const eventEnd = `${events}.${q("__event_end")}`;
14
+ const rows = await queryDB(simpleTable, `SELECT CASE
15
+ WHEN ${eventStart} IS NULL THEN 1
16
+ WHEN ${eventEnd} IS NULL THEN 2
17
+ WHEN NOT isfinite(${eventStart}) THEN 3
18
+ WHEN NOT isfinite(${eventEnd}) THEN 4
19
+ ELSE 5
20
+ END AS ${q("reason")}
21
+ FROM (
22
+ SELECT ${temporal.eventSelections().join(", ")}
23
+ FROM ${q(simpleTable.name)}
24
+ ) AS ${events}
25
+ WHERE (${temporal.eventValidity(eventsName)}) IS NOT TRUE
26
+ LIMIT 1`, mergeOptions(simpleTable, {
27
+ table: simpleTable.name,
28
+ method,
29
+ parameters,
30
+ returnData: true,
31
+ }));
32
+ const reason = rows?.[0]?.reason;
33
+ if (reason === undefined)
34
+ return;
35
+ const startColumn = temporal.startTimeColumn ?? temporal.endTimeColumn;
36
+ const endColumn = temporal.endTimeColumn ?? temporal.startTimeColumn;
37
+ const message = reason === 1
38
+ ? `selected start-time column ${q(startColumn)} contains a null timestamp.`
39
+ : reason === 2
40
+ ? `selected end-time column ${q(endColumn)} contains a null timestamp.`
41
+ : reason === 3
42
+ ? `selected start-time column ${q(startColumn)} contains an infinite timestamp.`
43
+ : reason === 4
44
+ ? `selected end-time column ${q(endColumn)} contains an infinite timestamp.`
45
+ : `selected end-time column ${q(endColumn)} contains a timestamp before its start in ${q(startColumn)}.`;
46
+ throw new TypeError(`${method} ${message}`);
47
+ }
@@ -2,12 +2,6 @@ import type { TableSchema } from "./pendingOps.js";
2
2
  /**
3
3
  * Validates the column options shared by numerical pair analyses.
4
4
  *
5
- * @param types - The schema of the table being analyzed.
6
- * @param options - The optional x and y columns selected by the caller.
7
- * @param method - The SDA method performing the analysis.
8
- * @param tableName - The name of the table being analyzed.
9
- * @returns All numeric columns in the table schema.
10
- *
11
5
  * @example
12
6
  * ```ts
13
7
  * const columns = validateNumericalAnalysis(
@@ -17,6 +11,16 @@ import type { TableSchema } from "./pendingOps.js";
17
11
  * "measurements",
18
12
  * );
19
13
  * ```
14
+ *
15
+ * @param types - The schema of the table being analyzed.
16
+ *
17
+ * @param options - The optional x and y columns selected by the caller.
18
+ *
19
+ * @param method - The SDA method performing the analysis.
20
+ *
21
+ * @param tableName - The name of the table being analyzed.
22
+ *
23
+ * @returns All numeric columns in the table schema.
20
24
  */
21
25
  export default function validateNumericalAnalysis(types: TableSchema, options: {
22
26
  x?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"validateNumericalAnalysis.d.ts","sourceRoot":"","sources":["../../src/helpers/validateNumericalAnalysis.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EACnC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,MAAM,EAAE,CAoDV"}
1
+ {"version":3,"file":"validateNumericalAnalysis.d.ts","sourceRoot":"","sources":["../../src/helpers/validateNumericalAnalysis.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EACnC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,MAAM,EAAE,CAoDV"}
@@ -3,12 +3,6 @@ import keepNumericalColumns from "./keepNumericalColumns.js";
3
3
  /**
4
4
  * Validates the column options shared by numerical pair analyses.
5
5
  *
6
- * @param types - The schema of the table being analyzed.
7
- * @param options - The optional x and y columns selected by the caller.
8
- * @param method - The SDA method performing the analysis.
9
- * @param tableName - The name of the table being analyzed.
10
- * @returns All numeric columns in the table schema.
11
- *
12
6
  * @example
13
7
  * ```ts
14
8
  * const columns = validateNumericalAnalysis(
@@ -18,6 +12,16 @@ import keepNumericalColumns from "./keepNumericalColumns.js";
18
12
  * "measurements",
19
13
  * );
20
14
  * ```
15
+ *
16
+ * @param types - The schema of the table being analyzed.
17
+ *
18
+ * @param options - The optional x and y columns selected by the caller.
19
+ *
20
+ * @param method - The SDA method performing the analysis.
21
+ *
22
+ * @param tableName - The name of the table being analyzed.
23
+ *
24
+ * @returns All numeric columns in the table schema.
21
25
  */
22
26
  export default function validateNumericalAnalysis(types, options, method, tableName) {
23
27
  if (options.x === undefined && options.y !== undefined) {
@@ -0,0 +1,4 @@
1
+ import type { DuckDBConnection } from "@duckdb/node-api";
2
+ /** Validate the positional identity contract before bounded vector scans. */
3
+ export default function validateVectorRowIds(connection: DuckDBConnection, rows: string, count: number): Promise<void>;
4
+ //# sourceMappingURL=validateVectorRowIds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateVectorRowIds.d.ts","sourceRoot":"","sources":["../../src/helpers/validateVectorRowIds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,6EAA6E;AAC7E,wBAA8B,oBAAoB,CAChD,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAuBf"}
@@ -0,0 +1,16 @@
1
+ /** Validate the positional identity contract before bounded vector scans. */
2
+ export default async function validateVectorRowIds(connection, rows, count) {
3
+ // Graph state and DuckDB scratch schemas use signed INTEGER vertex ids.
4
+ if (!Number.isSafeInteger(count) || count < 1 || count > 2147483647) {
5
+ throw new Error("Vector row count must fit a positive INTEGER vertex count.");
6
+ }
7
+ const [actual, distinct, minimum, maximum, invalid] = (await connection.runAndReadAll(`SELECT count(*),count(DISTINCT vertex),
8
+ min(vertex),max(vertex),count(*) FILTER (
9
+ WHERE vertex IS NULL OR vertex!=trunc(vertex)) FROM ${rows}`))
10
+ .getRowsJS()[0];
11
+ if (Number(actual) !== count || Number(distinct) !== count ||
12
+ Number(minimum) !== 0 || Number(maximum) !== count - 1 ||
13
+ Number(invalid) !== 0) {
14
+ throw new Error(`Vector rows must contain exactly ${count} unique integer vertex ids from 0 to ${count - 1}.`);
15
+ }
16
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Build a DOUBLE-precision distance expression for prepared vector aliases.
3
+ * Cosine callers first stabilize their private rows with stabilizeCosineVectors.
4
+ */
5
+ export default function vectorDistanceExpression(left: string, right: string, metric: "euclidean" | "cosine"): string;
6
+ //# sourceMappingURL=vectorDistanceExpression.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vectorDistanceExpression.d.ts","sourceRoot":"","sources":["../../src/helpers/vectorDistanceExpression.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,WAAW,GAAG,QAAQ,GAC7B,MAAM,CAKR"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Build a DOUBLE-precision distance expression for prepared vector aliases.
3
+ * Cosine callers first stabilize their private rows with stabilizeCosineVectors.
4
+ */
5
+ export default function vectorDistanceExpression(left, right, metric) {
6
+ if (metric === "euclidean")
7
+ return `array_distance(${left},${right})`;
8
+ // DuckDB can return tiny positive or negative errors for equal/cosine-aligned
9
+ // vectors. Exact equality also makes duplicate behavior deterministic.
10
+ return `CASE WHEN ${left}=${right} THEN 0 ELSE greatest(0,array_cosine_distance(${left},${right})) END`;
11
+ }
@@ -4,13 +4,6 @@
4
4
  * will be broken at the character boundary. This function is primarily used
5
5
  * for preparing text to be displayed in console tables.
6
6
  *
7
- * @param str - The string to wrap.
8
- * @param maxWidth - The maximum width of each line.
9
- * @param wordWrap - If true, attempts to break at word boundaries. If false,
10
- * breaks at character boundaries. Defaults to `true`.
11
- * @returns The wrapped string with newline characters inserted at appropriate
12
- * positions.
13
- *
14
7
  * @example
15
8
  * ```typescript
16
9
  * const text = "This is a very long sentence that needs to be wrapped";
@@ -30,6 +23,16 @@
30
23
  * // Output: Thisisaver
31
24
  * // ylongword
32
25
  * ```
26
+ *
27
+ * @param str - The string to wrap.
28
+ *
29
+ * @param maxWidth - The maximum width of each line.
30
+ *
31
+ * @param wordWrap - If true, attempts to break at word boundaries. If false,
32
+ * breaks at character boundaries. Defaults to `true`.
33
+ *
34
+ * @returns The wrapped string with newline characters inserted at appropriate
35
+ * positions.
33
36
  */
34
37
  export default function wrapString(str: string, maxWidth: number, wordWrap?: boolean): string;
35
38
  //# sourceMappingURL=wrapString.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wrapString.d.ts","sourceRoot":"","sources":["../../src/helpers/wrapString.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,QAAQ,UAAO,GACd,MAAM,CAqDR"}
1
+ {"version":3,"file":"wrapString.d.ts","sourceRoot":"","sources":["../../src/helpers/wrapString.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,QAAQ,UAAO,GACd,MAAM,CAqDR"}