@nshiab/simple-data-analysis-core 2.0.9 → 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.
- package/esm/class/SDAError.d.ts +6 -6
- package/esm/class/SDAError.js +6 -6
- package/esm/class/Simple.d.ts +9 -9
- package/esm/class/Simple.js +9 -9
- package/esm/class/SimpleDB.d.ts +80 -76
- package/esm/class/SimpleDB.d.ts.map +1 -1
- package/esm/class/SimpleDB.js +80 -76
- package/esm/class/SimpleTable.d.ts +2795 -1139
- package/esm/class/SimpleTable.d.ts.map +1 -1
- package/esm/class/SimpleTable.js +2781 -1149
- package/esm/helpers/buildApproximateMutualReachabilityMst.d.ts +45 -0
- package/esm/helpers/buildApproximateMutualReachabilityMst.d.ts.map +1 -0
- package/esm/helpers/buildApproximateMutualReachabilityMst.js +212 -0
- package/esm/helpers/buildChronologicalGraphComponentsSql.d.ts +14 -0
- package/esm/helpers/buildChronologicalGraphComponentsSql.d.ts.map +1 -0
- package/esm/helpers/buildChronologicalGraphComponentsSql.js +167 -0
- package/esm/helpers/buildExactMutualReachabilityMst.d.ts +28 -0
- package/esm/helpers/buildExactMutualReachabilityMst.d.ts.map +1 -0
- package/esm/helpers/buildExactMutualReachabilityMst.js +97 -0
- package/esm/helpers/buildGraphTemporalCostStateSql.d.ts +12 -0
- package/esm/helpers/buildGraphTemporalCostStateSql.d.ts.map +1 -0
- package/esm/helpers/buildGraphTemporalCostStateSql.js +86 -0
- package/esm/helpers/buildGraphTemporalReachabilitySql.d.ts +13 -0
- package/esm/helpers/buildGraphTemporalReachabilitySql.d.ts.map +1 -0
- package/esm/helpers/buildGraphTemporalReachabilitySql.js +70 -0
- package/esm/helpers/buildSparseMutualReachabilityMst.d.ts +10 -0
- package/esm/helpers/buildSparseMutualReachabilityMst.d.ts.map +1 -0
- package/esm/helpers/buildSparseMutualReachabilityMst.js +47 -0
- package/esm/helpers/buildUmapGraph.d.ts +2 -5
- package/esm/helpers/buildUmapGraph.d.ts.map +1 -1
- package/esm/helpers/buildUmapGraph.js +6 -100
- package/esm/helpers/buildVectorNeighbors.d.ts +45 -0
- package/esm/helpers/buildVectorNeighbors.d.ts.map +1 -0
- package/esm/helpers/buildVectorNeighbors.js +170 -0
- package/esm/helpers/buildWeakGraphComponentsSql.d.ts +3 -0
- package/esm/helpers/buildWeakGraphComponentsSql.d.ts.map +1 -0
- package/esm/helpers/buildWeakGraphComponentsSql.js +32 -0
- package/esm/helpers/camelCase.d.ts +7 -5
- package/esm/helpers/camelCase.d.ts.map +1 -1
- package/esm/helpers/camelCase.js +7 -5
- package/esm/helpers/capitalize.d.ts +6 -4
- package/esm/helpers/capitalize.d.ts.map +1 -1
- package/esm/helpers/capitalize.js +6 -4
- package/esm/helpers/clusterHdbscan.d.ts +18 -0
- package/esm/helpers/clusterHdbscan.d.ts.map +1 -0
- package/esm/helpers/clusterHdbscan.js +342 -0
- package/esm/helpers/computeCovariance.d.ts +16 -0
- package/esm/helpers/computeCovariance.d.ts.map +1 -0
- package/esm/helpers/computeCovariance.js +99 -0
- package/esm/helpers/computeMahalanobisDistances.d.ts +14 -0
- package/esm/helpers/computeMahalanobisDistances.d.ts.map +1 -0
- package/esm/helpers/computeMahalanobisDistances.js +87 -0
- package/esm/helpers/createDirectory.d.ts +4 -3
- package/esm/helpers/createDirectory.d.ts.map +1 -1
- package/esm/helpers/createDirectory.js +4 -3
- package/esm/helpers/dataToArrays.d.ts +6 -4
- package/esm/helpers/dataToArrays.d.ts.map +1 -1
- package/esm/helpers/dataToArrays.js +6 -4
- package/esm/helpers/extractTypes.d.ts +1 -1
- package/esm/helpers/extractTypes.js +4 -9
- package/esm/helpers/factorCovariance.d.ts +17 -0
- package/esm/helpers/factorCovariance.d.ts.map +1 -0
- package/esm/helpers/factorCovariance.js +189 -0
- package/esm/helpers/findGeoColumn.d.ts +6 -4
- package/esm/helpers/findGeoColumn.d.ts.map +1 -1
- package/esm/helpers/findGeoColumn.js +6 -4
- package/esm/helpers/findGeoColumnFromSchema.d.ts +8 -5
- package/esm/helpers/findGeoColumnFromSchema.d.ts.map +1 -1
- package/esm/helpers/findGeoColumnFromSchema.js +8 -5
- package/esm/helpers/formatDate.d.ts +12 -6
- package/esm/helpers/formatDate.d.ts.map +1 -1
- package/esm/helpers/formatDate.js +12 -6
- package/esm/helpers/formatMissingTables.d.ts +8 -5
- package/esm/helpers/formatMissingTables.d.ts.map +1 -1
- package/esm/helpers/formatMissingTables.js +8 -5
- package/esm/helpers/formatNumber.d.ts +19 -10
- package/esm/helpers/formatNumber.d.ts.map +1 -1
- package/esm/helpers/formatNumber.js +32 -17
- package/esm/helpers/getGraphEdgeIdColumn.d.ts +9 -0
- package/esm/helpers/getGraphEdgeIdColumn.d.ts.map +1 -0
- package/esm/helpers/getGraphEdgeIdColumn.js +25 -0
- package/esm/helpers/getGraphEndpointColumns.d.ts +11 -0
- package/esm/helpers/getGraphEndpointColumns.d.ts.map +1 -0
- package/esm/helpers/getGraphEndpointColumns.js +160 -0
- package/esm/helpers/getGraphWeightColumn.d.ts +10 -0
- package/esm/helpers/getGraphWeightColumn.d.ts.map +1 -0
- package/esm/helpers/getGraphWeightColumn.js +40 -0
- package/esm/helpers/graphRouteResultSchema.d.ts +4 -0
- package/esm/helpers/graphRouteResultSchema.d.ts.map +1 -0
- package/esm/helpers/graphRouteResultSchema.js +12 -0
- package/esm/helpers/graphRouteResultSelect.d.ts +4 -0
- package/esm/helpers/graphRouteResultSelect.d.ts.map +1 -0
- package/esm/helpers/graphRouteResultSelect.js +22 -0
- package/esm/helpers/hasGeometryColumn.d.ts +4 -3
- package/esm/helpers/hasGeometryColumn.d.ts.map +1 -1
- package/esm/helpers/hasGeometryColumn.js +4 -3
- package/esm/helpers/inspectGraphConnectivity.d.ts +10 -0
- package/esm/helpers/inspectGraphConnectivity.d.ts.map +1 -0
- package/esm/helpers/inspectGraphConnectivity.js +55 -0
- package/esm/helpers/mergeOptions.d.ts +24 -13
- package/esm/helpers/mergeOptions.d.ts.map +1 -1
- package/esm/helpers/mergeOptions.js +24 -13
- package/esm/helpers/parseValue.d.ts +6 -4
- package/esm/helpers/parseValue.d.ts.map +1 -1
- package/esm/helpers/parseValue.js +6 -4
- package/esm/helpers/prepareGraphRouteSql.d.ts +31 -0
- package/esm/helpers/prepareGraphRouteSql.d.ts.map +1 -0
- package/esm/helpers/prepareGraphRouteSql.js +86 -0
- package/esm/helpers/prepareGraphStarts.d.ts +9 -0
- package/esm/helpers/prepareGraphStarts.d.ts.map +1 -0
- package/esm/helpers/prepareGraphStarts.js +68 -0
- package/esm/helpers/prepareGraphTemporalSql.d.ts +28 -0
- package/esm/helpers/prepareGraphTemporalSql.d.ts.map +1 -0
- package/esm/helpers/prepareGraphTemporalSql.js +154 -0
- package/esm/helpers/prepareGraphTraversal.d.ts +19 -0
- package/esm/helpers/prepareGraphTraversal.d.ts.map +1 -0
- package/esm/helpers/prepareGraphTraversal.js +79 -0
- package/esm/helpers/prepareNumericFeatures.d.ts +41 -0
- package/esm/helpers/prepareNumericFeatures.d.ts.map +1 -0
- package/esm/helpers/prepareNumericFeatures.js +210 -0
- package/esm/helpers/prettyDuration.d.ts +14 -8
- package/esm/helpers/prettyDuration.d.ts.map +1 -1
- package/esm/helpers/prettyDuration.js +14 -8
- package/esm/helpers/printTable.d.ts +18 -13
- package/esm/helpers/printTable.d.ts.map +1 -1
- package/esm/helpers/printTable.js +18 -13
- package/esm/helpers/publishPreparedColumns.d.ts +37 -0
- package/esm/helpers/publishPreparedColumns.d.ts.map +1 -0
- package/esm/helpers/publishPreparedColumns.js +113 -0
- package/esm/helpers/queryDB.d.ts +24 -13
- package/esm/helpers/queryDB.d.ts.map +1 -1
- package/esm/helpers/queryDB.js +24 -13
- package/esm/helpers/queueAsyncBarrier.d.ts +12 -7
- package/esm/helpers/queueAsyncBarrier.d.ts.map +1 -1
- package/esm/helpers/queueAsyncBarrier.js +12 -7
- package/esm/helpers/queueGraphResult.d.ts +18 -0
- package/esm/helpers/queueGraphResult.d.ts.map +1 -0
- package/esm/helpers/queueGraphResult.js +39 -0
- package/esm/helpers/quoteIdentifier.d.ts +4 -3
- package/esm/helpers/quoteIdentifier.d.ts.map +1 -1
- package/esm/helpers/quoteIdentifier.js +4 -3
- package/esm/helpers/quoteQualifiedIdentifier.d.ts +6 -4
- package/esm/helpers/quoteQualifiedIdentifier.d.ts.map +1 -1
- package/esm/helpers/quoteQualifiedIdentifier.js +6 -4
- package/esm/helpers/runQuery.d.ts.map +1 -1
- package/esm/helpers/runQuery.js +17 -3
- package/esm/helpers/selectFuzzyReplacements.d.ts +11 -0
- package/esm/helpers/selectFuzzyReplacements.d.ts.map +1 -0
- package/esm/helpers/selectFuzzyReplacements.js +124 -0
- package/esm/helpers/stabilizeCosineVectors.d.ts +14 -0
- package/esm/helpers/stabilizeCosineVectors.d.ts.map +1 -0
- package/esm/helpers/stabilizeCosineVectors.js +34 -0
- package/esm/helpers/stringToArray.d.ts +4 -3
- package/esm/helpers/stringToArray.d.ts.map +1 -1
- package/esm/helpers/stringToArray.js +4 -3
- package/esm/helpers/updateColumnsWithJS.d.ts +12 -6
- package/esm/helpers/updateColumnsWithJS.d.ts.map +1 -1
- package/esm/helpers/updateColumnsWithJS.js +12 -6
- package/esm/helpers/validateGraphRouteResultSchema.d.ts +4 -0
- package/esm/helpers/validateGraphRouteResultSchema.d.ts.map +1 -0
- package/esm/helpers/validateGraphRouteResultSchema.js +13 -0
- package/esm/helpers/validateGraphTemporalEvents.d.ts +7 -0
- package/esm/helpers/validateGraphTemporalEvents.d.ts.map +1 -0
- package/esm/helpers/validateGraphTemporalEvents.js +47 -0
- package/esm/helpers/validateNumericalAnalysis.d.ts +10 -6
- package/esm/helpers/validateNumericalAnalysis.d.ts.map +1 -1
- package/esm/helpers/validateNumericalAnalysis.js +10 -6
- package/esm/helpers/validateVectorRowIds.d.ts +4 -0
- package/esm/helpers/validateVectorRowIds.d.ts.map +1 -0
- package/esm/helpers/validateVectorRowIds.js +16 -0
- package/esm/helpers/vectorDistanceExpression.d.ts +6 -0
- package/esm/helpers/vectorDistanceExpression.d.ts.map +1 -0
- package/esm/helpers/vectorDistanceExpression.js +11 -0
- package/esm/helpers/wrapString.d.ts +10 -7
- package/esm/helpers/wrapString.d.ts.map +1 -1
- package/esm/helpers/wrapString.js +10 -7
- package/esm/methods/addId.d.ts +5 -0
- package/esm/methods/addId.d.ts.map +1 -0
- package/esm/methods/addId.js +38 -0
- package/esm/methods/commonNeighbors.d.ts +10 -0
- package/esm/methods/commonNeighbors.d.ts.map +1 -0
- package/esm/methods/commonNeighbors.js +101 -0
- package/esm/methods/connectedComponents.d.ts +9 -0
- package/esm/methods/connectedComponents.d.ts.map +1 -0
- package/esm/methods/connectedComponents.js +147 -0
- package/esm/methods/degree.d.ts +9 -0
- package/esm/methods/degree.d.ts.map +1 -0
- package/esm/methods/degree.js +135 -0
- package/esm/methods/distances.d.ts +12 -0
- package/esm/methods/distances.d.ts.map +1 -0
- package/esm/methods/distances.js +164 -0
- package/esm/methods/findCycles.d.ts +12 -0
- package/esm/methods/findCycles.d.ts.map +1 -0
- package/esm/methods/findCycles.js +330 -0
- package/esm/methods/fuzzyClean.d.ts.map +1 -1
- package/esm/methods/fuzzyClean.js +17 -136
- package/esm/methods/fuzzyJoin.js +70 -16
- package/esm/methods/getTypes.d.ts +1 -1
- package/esm/methods/hdbscan.d.ts +5 -0
- package/esm/methods/hdbscan.d.ts.map +1 -0
- package/esm/methods/hdbscan.js +208 -0
- package/esm/methods/mahalanobis.d.ts +5 -0
- package/esm/methods/mahalanobis.d.ts.map +1 -0
- package/esm/methods/mahalanobis.js +92 -0
- package/esm/methods/neighbors.d.ts +9 -0
- package/esm/methods/neighbors.d.ts.map +1 -0
- package/esm/methods/neighbors.js +81 -0
- package/esm/methods/normalizeVector.d.ts +5 -0
- package/esm/methods/normalizeVector.d.ts.map +1 -0
- package/esm/methods/normalizeVector.js +132 -0
- package/esm/methods/paths.d.ts +12 -0
- package/esm/methods/paths.d.ts.map +1 -0
- package/esm/methods/paths.js +287 -0
- package/esm/methods/reachable.d.ts +11 -0
- package/esm/methods/reachable.d.ts.map +1 -0
- package/esm/methods/reachable.js +131 -0
- package/esm/methods/rowToVector.d.ts +5 -0
- package/esm/methods/rowToVector.d.ts.map +1 -0
- package/esm/methods/rowToVector.js +77 -0
- package/esm/methods/shortestPath.d.ts +12 -0
- package/esm/methods/shortestPath.d.ts.map +1 -0
- package/esm/methods/shortestPath.js +337 -0
- package/esm/methods/topologicalSort.d.ts +7 -0
- package/esm/methods/topologicalSort.d.ts.map +1 -0
- package/esm/methods/topologicalSort.js +164 -0
- package/llm.md +2106 -143
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/script/class/SDAError.d.ts +6 -6
- package/script/class/SDAError.js +6 -6
- package/script/class/Simple.d.ts +9 -9
- package/script/class/Simple.js +9 -9
- package/script/class/SimpleDB.d.ts +80 -76
- package/script/class/SimpleDB.d.ts.map +1 -1
- package/script/class/SimpleDB.js +80 -76
- package/script/class/SimpleTable.d.ts +2795 -1139
- package/script/class/SimpleTable.d.ts.map +1 -1
- package/script/class/SimpleTable.js +2781 -1149
- package/script/helpers/buildApproximateMutualReachabilityMst.d.ts +45 -0
- package/script/helpers/buildApproximateMutualReachabilityMst.d.ts.map +1 -0
- package/script/helpers/buildApproximateMutualReachabilityMst.js +219 -0
- package/script/helpers/buildChronologicalGraphComponentsSql.d.ts +14 -0
- package/script/helpers/buildChronologicalGraphComponentsSql.d.ts.map +1 -0
- package/script/helpers/buildChronologicalGraphComponentsSql.js +174 -0
- package/script/helpers/buildExactMutualReachabilityMst.d.ts +28 -0
- package/script/helpers/buildExactMutualReachabilityMst.d.ts.map +1 -0
- package/script/helpers/buildExactMutualReachabilityMst.js +103 -0
- package/script/helpers/buildGraphTemporalCostStateSql.d.ts +12 -0
- package/script/helpers/buildGraphTemporalCostStateSql.d.ts.map +1 -0
- package/script/helpers/buildGraphTemporalCostStateSql.js +92 -0
- package/script/helpers/buildGraphTemporalReachabilitySql.d.ts +13 -0
- package/script/helpers/buildGraphTemporalReachabilitySql.d.ts.map +1 -0
- package/script/helpers/buildGraphTemporalReachabilitySql.js +76 -0
- package/script/helpers/buildSparseMutualReachabilityMst.d.ts +10 -0
- package/script/helpers/buildSparseMutualReachabilityMst.d.ts.map +1 -0
- package/script/helpers/buildSparseMutualReachabilityMst.js +50 -0
- package/script/helpers/buildUmapGraph.d.ts +2 -5
- package/script/helpers/buildUmapGraph.d.ts.map +1 -1
- package/script/helpers/buildUmapGraph.js +6 -100
- package/script/helpers/buildVectorNeighbors.d.ts +45 -0
- package/script/helpers/buildVectorNeighbors.d.ts.map +1 -0
- package/script/helpers/buildVectorNeighbors.js +176 -0
- package/script/helpers/buildWeakGraphComponentsSql.d.ts +3 -0
- package/script/helpers/buildWeakGraphComponentsSql.d.ts.map +1 -0
- package/script/helpers/buildWeakGraphComponentsSql.js +38 -0
- package/script/helpers/camelCase.d.ts +7 -5
- package/script/helpers/camelCase.d.ts.map +1 -1
- package/script/helpers/camelCase.js +7 -5
- package/script/helpers/capitalize.d.ts +6 -4
- package/script/helpers/capitalize.d.ts.map +1 -1
- package/script/helpers/capitalize.js +6 -4
- package/script/helpers/clusterHdbscan.d.ts +18 -0
- package/script/helpers/clusterHdbscan.d.ts.map +1 -0
- package/script/helpers/clusterHdbscan.js +346 -0
- package/script/helpers/computeCovariance.d.ts +16 -0
- package/script/helpers/computeCovariance.d.ts.map +1 -0
- package/script/helpers/computeCovariance.js +105 -0
- package/script/helpers/computeMahalanobisDistances.d.ts +14 -0
- package/script/helpers/computeMahalanobisDistances.d.ts.map +1 -0
- package/script/helpers/computeMahalanobisDistances.js +93 -0
- package/script/helpers/createDirectory.d.ts +4 -3
- package/script/helpers/createDirectory.d.ts.map +1 -1
- package/script/helpers/createDirectory.js +4 -3
- package/script/helpers/dataToArrays.d.ts +6 -4
- package/script/helpers/dataToArrays.d.ts.map +1 -1
- package/script/helpers/dataToArrays.js +6 -4
- package/script/helpers/extractTypes.d.ts +1 -1
- package/script/helpers/extractTypes.js +4 -9
- package/script/helpers/factorCovariance.d.ts +17 -0
- package/script/helpers/factorCovariance.d.ts.map +1 -0
- package/script/helpers/factorCovariance.js +194 -0
- package/script/helpers/findGeoColumn.d.ts +6 -4
- package/script/helpers/findGeoColumn.d.ts.map +1 -1
- package/script/helpers/findGeoColumn.js +6 -4
- package/script/helpers/findGeoColumnFromSchema.d.ts +8 -5
- package/script/helpers/findGeoColumnFromSchema.d.ts.map +1 -1
- package/script/helpers/findGeoColumnFromSchema.js +8 -5
- package/script/helpers/formatDate.d.ts +12 -6
- package/script/helpers/formatDate.d.ts.map +1 -1
- package/script/helpers/formatDate.js +12 -6
- package/script/helpers/formatMissingTables.d.ts +8 -5
- package/script/helpers/formatMissingTables.d.ts.map +1 -1
- package/script/helpers/formatMissingTables.js +8 -5
- package/script/helpers/formatNumber.d.ts +19 -10
- package/script/helpers/formatNumber.d.ts.map +1 -1
- package/script/helpers/formatNumber.js +32 -17
- package/script/helpers/getGraphEdgeIdColumn.d.ts +9 -0
- package/script/helpers/getGraphEdgeIdColumn.d.ts.map +1 -0
- package/script/helpers/getGraphEdgeIdColumn.js +31 -0
- package/script/helpers/getGraphEndpointColumns.d.ts +11 -0
- package/script/helpers/getGraphEndpointColumns.d.ts.map +1 -0
- package/script/helpers/getGraphEndpointColumns.js +166 -0
- package/script/helpers/getGraphWeightColumn.d.ts +10 -0
- package/script/helpers/getGraphWeightColumn.d.ts.map +1 -0
- package/script/helpers/getGraphWeightColumn.js +46 -0
- package/script/helpers/graphRouteResultSchema.d.ts +4 -0
- package/script/helpers/graphRouteResultSchema.d.ts.map +1 -0
- package/script/helpers/graphRouteResultSchema.js +18 -0
- package/script/helpers/graphRouteResultSelect.d.ts +4 -0
- package/script/helpers/graphRouteResultSelect.d.ts.map +1 -0
- package/script/helpers/graphRouteResultSelect.js +28 -0
- package/script/helpers/hasGeometryColumn.d.ts +4 -3
- package/script/helpers/hasGeometryColumn.d.ts.map +1 -1
- package/script/helpers/hasGeometryColumn.js +4 -3
- package/script/helpers/inspectGraphConnectivity.d.ts +10 -0
- package/script/helpers/inspectGraphConnectivity.d.ts.map +1 -0
- package/script/helpers/inspectGraphConnectivity.js +58 -0
- package/script/helpers/mergeOptions.d.ts +24 -13
- package/script/helpers/mergeOptions.d.ts.map +1 -1
- package/script/helpers/mergeOptions.js +24 -13
- package/script/helpers/parseValue.d.ts +6 -4
- package/script/helpers/parseValue.d.ts.map +1 -1
- package/script/helpers/parseValue.js +6 -4
- package/script/helpers/prepareGraphRouteSql.d.ts +31 -0
- package/script/helpers/prepareGraphRouteSql.d.ts.map +1 -0
- package/script/helpers/prepareGraphRouteSql.js +127 -0
- package/script/helpers/prepareGraphStarts.d.ts +9 -0
- package/script/helpers/prepareGraphStarts.d.ts.map +1 -0
- package/script/helpers/prepareGraphStarts.js +71 -0
- package/script/helpers/prepareGraphTemporalSql.d.ts +28 -0
- package/script/helpers/prepareGraphTemporalSql.d.ts.map +1 -0
- package/script/helpers/prepareGraphTemporalSql.js +161 -0
- package/script/helpers/prepareGraphTraversal.d.ts +19 -0
- package/script/helpers/prepareGraphTraversal.d.ts.map +1 -0
- package/script/helpers/prepareGraphTraversal.js +87 -0
- package/script/helpers/prepareNumericFeatures.d.ts +41 -0
- package/script/helpers/prepareNumericFeatures.d.ts.map +1 -0
- package/script/helpers/prepareNumericFeatures.js +217 -0
- package/script/helpers/prettyDuration.d.ts +14 -8
- package/script/helpers/prettyDuration.d.ts.map +1 -1
- package/script/helpers/prettyDuration.js +14 -8
- package/script/helpers/printTable.d.ts +18 -13
- package/script/helpers/printTable.d.ts.map +1 -1
- package/script/helpers/printTable.js +18 -13
- package/script/helpers/publishPreparedColumns.d.ts +37 -0
- package/script/helpers/publishPreparedColumns.d.ts.map +1 -0
- package/script/helpers/publishPreparedColumns.js +119 -0
- package/script/helpers/queryDB.d.ts +24 -13
- package/script/helpers/queryDB.d.ts.map +1 -1
- package/script/helpers/queryDB.js +24 -13
- package/script/helpers/queueAsyncBarrier.d.ts +12 -7
- package/script/helpers/queueAsyncBarrier.d.ts.map +1 -1
- package/script/helpers/queueAsyncBarrier.js +12 -7
- package/script/helpers/queueGraphResult.d.ts +18 -0
- package/script/helpers/queueGraphResult.d.ts.map +1 -0
- package/script/helpers/queueGraphResult.js +45 -0
- package/script/helpers/quoteIdentifier.d.ts +4 -3
- package/script/helpers/quoteIdentifier.d.ts.map +1 -1
- package/script/helpers/quoteIdentifier.js +4 -3
- package/script/helpers/quoteQualifiedIdentifier.d.ts +6 -4
- package/script/helpers/quoteQualifiedIdentifier.d.ts.map +1 -1
- package/script/helpers/quoteQualifiedIdentifier.js +6 -4
- package/script/helpers/runQuery.d.ts.map +1 -1
- package/script/helpers/runQuery.js +17 -3
- package/script/helpers/selectFuzzyReplacements.d.ts +11 -0
- package/script/helpers/selectFuzzyReplacements.d.ts.map +1 -0
- package/script/helpers/selectFuzzyReplacements.js +127 -0
- package/script/helpers/stabilizeCosineVectors.d.ts +14 -0
- package/script/helpers/stabilizeCosineVectors.d.ts.map +1 -0
- package/script/helpers/stabilizeCosineVectors.js +40 -0
- package/script/helpers/stringToArray.d.ts +4 -3
- package/script/helpers/stringToArray.d.ts.map +1 -1
- package/script/helpers/stringToArray.js +4 -3
- package/script/helpers/updateColumnsWithJS.d.ts +12 -6
- package/script/helpers/updateColumnsWithJS.d.ts.map +1 -1
- package/script/helpers/updateColumnsWithJS.js +12 -6
- package/script/helpers/validateGraphRouteResultSchema.d.ts +4 -0
- package/script/helpers/validateGraphRouteResultSchema.d.ts.map +1 -0
- package/script/helpers/validateGraphRouteResultSchema.js +19 -0
- package/script/helpers/validateGraphTemporalEvents.d.ts +7 -0
- package/script/helpers/validateGraphTemporalEvents.d.ts.map +1 -0
- package/script/helpers/validateGraphTemporalEvents.js +53 -0
- package/script/helpers/validateNumericalAnalysis.d.ts +10 -6
- package/script/helpers/validateNumericalAnalysis.d.ts.map +1 -1
- package/script/helpers/validateNumericalAnalysis.js +10 -6
- package/script/helpers/validateVectorRowIds.d.ts +4 -0
- package/script/helpers/validateVectorRowIds.d.ts.map +1 -0
- package/script/helpers/validateVectorRowIds.js +19 -0
- package/script/helpers/vectorDistanceExpression.d.ts +6 -0
- package/script/helpers/vectorDistanceExpression.d.ts.map +1 -0
- package/script/helpers/vectorDistanceExpression.js +14 -0
- package/script/helpers/wrapString.d.ts +10 -7
- package/script/helpers/wrapString.d.ts.map +1 -1
- package/script/helpers/wrapString.js +10 -7
- package/script/methods/addId.d.ts +5 -0
- package/script/methods/addId.d.ts.map +1 -0
- package/script/methods/addId.js +44 -0
- package/script/methods/commonNeighbors.d.ts +10 -0
- package/script/methods/commonNeighbors.d.ts.map +1 -0
- package/script/methods/commonNeighbors.js +140 -0
- package/script/methods/connectedComponents.d.ts +9 -0
- package/script/methods/connectedComponents.d.ts.map +1 -0
- package/script/methods/connectedComponents.js +186 -0
- package/script/methods/degree.d.ts +9 -0
- package/script/methods/degree.d.ts.map +1 -0
- package/script/methods/degree.js +141 -0
- package/script/methods/distances.d.ts +12 -0
- package/script/methods/distances.d.ts.map +1 -0
- package/script/methods/distances.js +203 -0
- package/script/methods/findCycles.d.ts +12 -0
- package/script/methods/findCycles.d.ts.map +1 -0
- package/script/methods/findCycles.js +369 -0
- package/script/methods/fuzzyClean.d.ts.map +1 -1
- package/script/methods/fuzzyClean.js +17 -136
- package/script/methods/fuzzyJoin.js +70 -16
- package/script/methods/getTypes.d.ts +1 -1
- package/script/methods/hdbscan.d.ts +5 -0
- package/script/methods/hdbscan.d.ts.map +1 -0
- package/script/methods/hdbscan.js +214 -0
- package/script/methods/mahalanobis.d.ts +5 -0
- package/script/methods/mahalanobis.d.ts.map +1 -0
- package/script/methods/mahalanobis.js +98 -0
- package/script/methods/neighbors.d.ts +9 -0
- package/script/methods/neighbors.d.ts.map +1 -0
- package/script/methods/neighbors.js +120 -0
- package/script/methods/normalizeVector.d.ts +5 -0
- package/script/methods/normalizeVector.d.ts.map +1 -0
- package/script/methods/normalizeVector.js +138 -0
- package/script/methods/paths.d.ts +12 -0
- package/script/methods/paths.d.ts.map +1 -0
- package/script/methods/paths.js +326 -0
- package/script/methods/reachable.d.ts +11 -0
- package/script/methods/reachable.d.ts.map +1 -0
- package/script/methods/reachable.js +170 -0
- package/script/methods/rowToVector.d.ts +5 -0
- package/script/methods/rowToVector.d.ts.map +1 -0
- package/script/methods/rowToVector.js +83 -0
- package/script/methods/shortestPath.d.ts +12 -0
- package/script/methods/shortestPath.d.ts.map +1 -0
- package/script/methods/shortestPath.js +376 -0
- package/script/methods/topologicalSort.d.ts +7 -0
- package/script/methods/topologicalSort.d.ts.map +1 -0
- package/script/methods/topologicalSort.js +170 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inspect connectivity of an edge relation while transferring ids, not vectors.
|
|
3
|
+
* Isolated vertices count as one-point components. Invalid ids fail closed.
|
|
4
|
+
*/
|
|
5
|
+
export default async function inspectGraphConnectivity(connection, edges, vertexCount) {
|
|
6
|
+
if (!Number.isSafeInteger(vertexCount) || vertexCount < 1 ||
|
|
7
|
+
vertexCount > 2147483647) {
|
|
8
|
+
throw new Error("Graph vertex count must fit a positive INTEGER vertex count.");
|
|
9
|
+
}
|
|
10
|
+
const parent = new Int32Array(vertexCount);
|
|
11
|
+
const sizes = new Int32Array(vertexCount).fill(1);
|
|
12
|
+
for (let vertex = 0; vertex < vertexCount; vertex++)
|
|
13
|
+
parent[vertex] = vertex;
|
|
14
|
+
const root = (vertex) => {
|
|
15
|
+
while (parent[vertex] !== vertex) {
|
|
16
|
+
parent[vertex] = parent[parent[vertex]];
|
|
17
|
+
vertex = parent[vertex];
|
|
18
|
+
}
|
|
19
|
+
return vertex;
|
|
20
|
+
};
|
|
21
|
+
const rows = await connection.stream(`SELECT source,target FROM ${edges}`);
|
|
22
|
+
while (true) {
|
|
23
|
+
const chunk = await rows.fetchChunk();
|
|
24
|
+
if (!chunk || chunk.rowCount === 0)
|
|
25
|
+
break;
|
|
26
|
+
const sources = chunk.getColumnVector(0);
|
|
27
|
+
const targets = chunk.getColumnVector(1);
|
|
28
|
+
for (let row = 0; row < chunk.rowCount; row++) {
|
|
29
|
+
const sourceValue = sources.getItem(row);
|
|
30
|
+
const targetValue = targets.getItem(row);
|
|
31
|
+
const source = Number(sourceValue);
|
|
32
|
+
const target = Number(targetValue);
|
|
33
|
+
if (sourceValue === null || targetValue === null ||
|
|
34
|
+
!Number.isSafeInteger(source) || source < 0 || source >= vertexCount ||
|
|
35
|
+
!Number.isSafeInteger(target) || target < 0 || target >= vertexCount) {
|
|
36
|
+
throw new Error("Graph edge contains an invalid vertex id.");
|
|
37
|
+
}
|
|
38
|
+
let sourceRoot = root(source), targetRoot = root(target);
|
|
39
|
+
if (sourceRoot === targetRoot)
|
|
40
|
+
continue;
|
|
41
|
+
if (sizes[sourceRoot] < sizes[targetRoot]) {
|
|
42
|
+
[sourceRoot, targetRoot] = [targetRoot, sourceRoot];
|
|
43
|
+
}
|
|
44
|
+
parent[targetRoot] = sourceRoot;
|
|
45
|
+
sizes[sourceRoot] += sizes[targetRoot];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const componentSizes = [];
|
|
49
|
+
for (let vertex = 0; vertex < vertexCount; vertex++) {
|
|
50
|
+
if (root(vertex) === vertex)
|
|
51
|
+
componentSizes.push(sizes[vertex]);
|
|
52
|
+
}
|
|
53
|
+
componentSizes.sort((a, b) => b - a);
|
|
54
|
+
return { componentCount: componentSizes.length, sizes: componentSizes };
|
|
55
|
+
}
|
|
@@ -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
|
|
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"}
|
|
@@ -2,19 +2,6 @@
|
|
|
2
2
|
* Combines a table or database's logging defaults with query-specific options.
|
|
3
3
|
* Use this helper with `queryDB()` when implementing an extension.
|
|
4
4
|
*
|
|
5
|
-
* @param simple - The logging defaults from a table or database.
|
|
6
|
-
* @param simple.rowsToLog - The default number of rows to display.
|
|
7
|
-
* @param simple.charsToLog - The default maximum characters to display per cell.
|
|
8
|
-
* @param options - Query-specific settings, which take precedence over defaults.
|
|
9
|
-
* @param options.table - The table name used for diagnostics, or `null`.
|
|
10
|
-
* @param options.method - The calling method used for diagnostics, or `null`.
|
|
11
|
-
* @param options.parameters - Arguments included in error diagnostics, or `null`.
|
|
12
|
-
* @param options.rowsToLog - Overrides the default number of displayed rows.
|
|
13
|
-
* @param options.returnData - Whether to return converted rows. Defaults to false.
|
|
14
|
-
* @param options.values - DuckDB-native values bound to SQL placeholders, in order.
|
|
15
|
-
* @param options.noClean - Whether to preserve the SQL text without cleaning it.
|
|
16
|
-
* @returns The merged query options without modifying either argument.
|
|
17
|
-
*
|
|
18
5
|
* @example
|
|
19
6
|
* ```ts
|
|
20
7
|
* import { mergeOptions } from "@nshiab/simple-data-analysis-core/helpers";
|
|
@@ -27,6 +14,30 @@
|
|
|
27
14
|
* });
|
|
28
15
|
* console.log(options.rowsToLog, options.returnData);
|
|
29
16
|
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param simple - The logging defaults from a table or database.
|
|
19
|
+
*
|
|
20
|
+
* @param simple.rowsToLog - The default number of rows to display.
|
|
21
|
+
*
|
|
22
|
+
* @param simple.charsToLog - The default maximum characters to display per cell.
|
|
23
|
+
*
|
|
24
|
+
* @param options - Query-specific settings, which take precedence over defaults.
|
|
25
|
+
*
|
|
26
|
+
* @param options.table - The table name used for diagnostics, or `null`.
|
|
27
|
+
*
|
|
28
|
+
* @param options.method - The calling method used for diagnostics, or `null`.
|
|
29
|
+
*
|
|
30
|
+
* @param options.parameters - Arguments included in error diagnostics, or `null`.
|
|
31
|
+
*
|
|
32
|
+
* @param options.rowsToLog - Overrides the default number of displayed rows.
|
|
33
|
+
*
|
|
34
|
+
* @param options.returnData - Whether to return converted rows. Defaults to false.
|
|
35
|
+
*
|
|
36
|
+
* @param options.values - DuckDB-native values bound to SQL placeholders, in order.
|
|
37
|
+
*
|
|
38
|
+
* @param options.noClean - Whether to preserve the SQL text without cleaning it.
|
|
39
|
+
*
|
|
40
|
+
* @returns The merged query options without modifying either argument.
|
|
30
41
|
*/
|
|
31
42
|
export default function mergeOptions(simple, options) {
|
|
32
43
|
return {
|
|
@@ -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
|
|
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"}
|
|
@@ -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) {
|
|
18
20
|
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,86 @@
|
|
|
1
|
+
import getGraphEdgeIdColumn from "./getGraphEdgeIdColumn.js";
|
|
2
|
+
import getGraphWeightColumn from "./getGraphWeightColumn.js";
|
|
3
|
+
import validateGraphRouteResultSchema from "./validateGraphRouteResultSchema.js";
|
|
4
|
+
import prepareGraphStarts from "./prepareGraphStarts.js";
|
|
5
|
+
import prepareGraphTraversal, { validateGraphStarts, } from "./prepareGraphTraversal.js";
|
|
6
|
+
import quoteIdentifier from "./quoteIdentifier.js";
|
|
7
|
+
/** Prepares and validates the two scalar endpoints shared by route methods. */
|
|
8
|
+
export function prepareGraphRouteEndpoints(start, end, method) {
|
|
9
|
+
if (Array.isArray(start)) {
|
|
10
|
+
throw new TypeError(`${method} start must be one node ID.`);
|
|
11
|
+
}
|
|
12
|
+
if (Array.isArray(end)) {
|
|
13
|
+
throw new TypeError(`${method} end must be one node ID.`);
|
|
14
|
+
}
|
|
15
|
+
const preparedStart = prepareGraphStarts(start, method);
|
|
16
|
+
const preparedEnd = prepareGraphStarts(end, method);
|
|
17
|
+
if (preparedStart.family !== preparedEnd.family) {
|
|
18
|
+
throw new TypeError(`${method} start and end must both be string IDs or both be numeric IDs.`);
|
|
19
|
+
}
|
|
20
|
+
if (preparedStart.values[0] === preparedEnd.values[0]) {
|
|
21
|
+
throw new TypeError(`${method} start and end must be different. Use distances() to measure return routes or findCycles() to find loops.`);
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
start: preparedStart,
|
|
25
|
+
end: preparedEnd,
|
|
26
|
+
values: {
|
|
27
|
+
family: preparedStart.family,
|
|
28
|
+
numericValues: [
|
|
29
|
+
...preparedStart.numericValues,
|
|
30
|
+
...preparedEnd.numericValues,
|
|
31
|
+
],
|
|
32
|
+
values: [preparedStart.values[0], preparedEnd.values[0]],
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Validates the columns shared by edge-route methods from queued schema data. */
|
|
37
|
+
export function validateGraphRouteInputs(schema, source, target, edgeId, endpoints, weight, method) {
|
|
38
|
+
const nodes = validateGraphStarts(schema, source, target, endpoints.values, method);
|
|
39
|
+
const edges = getGraphEdgeIdColumn(schema, edgeId, method);
|
|
40
|
+
const weightColumn = weight === undefined
|
|
41
|
+
? undefined
|
|
42
|
+
: getGraphWeightColumn(schema, weight, method);
|
|
43
|
+
validateGraphRouteResultSchema(schema, method);
|
|
44
|
+
return {
|
|
45
|
+
distanceType: weightColumn?.distanceType ?? "BIGINT",
|
|
46
|
+
edgeIdType: edges.idType,
|
|
47
|
+
nodeIdType: nodes.idType,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** Prepares the typed SQL expressions shared by edge-route enumeration. */
|
|
51
|
+
export function prepareGraphRouteSql(input, schema, source, target, edgeId, endpoints, weight, method) {
|
|
52
|
+
validateGraphRouteResultSchema(schema, method);
|
|
53
|
+
const traversal = prepareGraphTraversal(input, schema, source, target, endpoints.values, method);
|
|
54
|
+
const edgeIdColumn = getGraphEdgeIdColumn(schema, edgeId, method);
|
|
55
|
+
const weightColumn = weight === undefined
|
|
56
|
+
? undefined
|
|
57
|
+
: getGraphWeightColumn(schema, weight, method);
|
|
58
|
+
const distanceType = weightColumn?.distanceType ?? "BIGINT";
|
|
59
|
+
const q = quoteIdentifier;
|
|
60
|
+
const edgeIdReference = `${q("edges")}.${q(edgeIdColumn.column)}`;
|
|
61
|
+
const typedEdgeId = `CAST(${edgeIdReference} AS ${edgeIdColumn.idType})`;
|
|
62
|
+
const edgeKey = edgeIdColumn.family === "string"
|
|
63
|
+
? `ENCODE(${typedEdgeId})`
|
|
64
|
+
: typedEdgeId;
|
|
65
|
+
const edgeWeight = weightColumn === undefined
|
|
66
|
+
? `CAST(1 AS ${distanceType})`
|
|
67
|
+
: `CAST(${q("edges")}.${q(weightColumn.column)} AS ${distanceType})`;
|
|
68
|
+
const keyType = edgeIdColumn.family === "string"
|
|
69
|
+
? "BLOB"
|
|
70
|
+
: edgeIdColumn.idType;
|
|
71
|
+
const stepType = `STRUCT(${q("edgeId")} ${edgeIdColumn.idType}, ${q("source")} ${traversal.endpoints.idType}, ${q("target")} ${traversal.endpoints.idType}, ${q("weight")} ${distanceType}, ${q("distance")} ${distanceType})`;
|
|
72
|
+
return {
|
|
73
|
+
distanceType,
|
|
74
|
+
edgeIdColumn,
|
|
75
|
+
edgeKey,
|
|
76
|
+
edgeWeight,
|
|
77
|
+
endpointValue: `TRY_CAST(? AS ${traversal.endpoints.idType})`,
|
|
78
|
+
keyType,
|
|
79
|
+
stepType,
|
|
80
|
+
input,
|
|
81
|
+
schema,
|
|
82
|
+
traversal,
|
|
83
|
+
typedEdgeId,
|
|
84
|
+
weightType: weightColumn?.type,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -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"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Validates and snapshots scalar-or-array graph starting IDs. */
|
|
2
|
+
export default function prepareGraphStarts(start, method, argument = "start", scalar = false) {
|
|
3
|
+
const starts = Array.isArray(start) ? [...start] : [start];
|
|
4
|
+
if (starts.length === 0) {
|
|
5
|
+
throw new TypeError(`${method} ${argument} must not be an empty array.`);
|
|
6
|
+
}
|
|
7
|
+
let family;
|
|
8
|
+
const values = [];
|
|
9
|
+
const numericValues = [];
|
|
10
|
+
const seen = new Set();
|
|
11
|
+
const duplicates = [];
|
|
12
|
+
for (const value of starts) {
|
|
13
|
+
const valueFamily = typeof value === "string"
|
|
14
|
+
? "string"
|
|
15
|
+
: typeof value === "number" || typeof value === "bigint"
|
|
16
|
+
? "numeric"
|
|
17
|
+
: undefined;
|
|
18
|
+
if (valueFamily === undefined) {
|
|
19
|
+
throw new TypeError(scalar
|
|
20
|
+
? `${method} ${argument} must be a string or a whole number.`
|
|
21
|
+
: `${method} ${argument} must be a string, a whole number, or an array of those values.`);
|
|
22
|
+
}
|
|
23
|
+
if (family !== undefined && family !== valueFamily) {
|
|
24
|
+
throw new TypeError(`${method} ${argument} must not mix string and numeric IDs.`);
|
|
25
|
+
}
|
|
26
|
+
family = valueFamily;
|
|
27
|
+
let encoded;
|
|
28
|
+
if (typeof value === "number") {
|
|
29
|
+
if (!Number.isSafeInteger(value)) {
|
|
30
|
+
throw new TypeError(`${method} ${argument} contains ${value}, which is not a safe whole number. Use a bigint for exact integer IDs outside JavaScript's safe integer range.`);
|
|
31
|
+
}
|
|
32
|
+
encoded = BigInt(value).toString();
|
|
33
|
+
numericValues.push(BigInt(value));
|
|
34
|
+
}
|
|
35
|
+
else if (typeof value === "bigint") {
|
|
36
|
+
encoded = value.toString();
|
|
37
|
+
numericValues.push(value);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
encoded = value;
|
|
41
|
+
}
|
|
42
|
+
const key = `${valueFamily}:${encoded}`;
|
|
43
|
+
if (seen.has(key)) {
|
|
44
|
+
if (!duplicates.some((duplicate) => graphIdsEqual(duplicate, value))) {
|
|
45
|
+
duplicates.push(value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
seen.add(key);
|
|
50
|
+
values.push(encoded);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (duplicates.length > 0) {
|
|
54
|
+
throw new TypeError(`${method} ${argument} contains duplicate IDs: ${duplicates.map(formatGraphId).join(", ")}.`);
|
|
55
|
+
}
|
|
56
|
+
return { family: family, numericValues, values };
|
|
57
|
+
}
|
|
58
|
+
function graphIdsEqual(left, right) {
|
|
59
|
+
if (typeof left === "string" || typeof right === "string") {
|
|
60
|
+
return left === right;
|
|
61
|
+
}
|
|
62
|
+
return BigInt(left) === BigInt(right);
|
|
63
|
+
}
|
|
64
|
+
function formatGraphId(value) {
|
|
65
|
+
if (typeof value === "string")
|
|
66
|
+
return JSON.stringify(value);
|
|
67
|
+
return typeof value === "bigint" ? `${value}n` : String(value);
|
|
68
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TableSchema } from "./pendingOps.js";
|
|
2
|
+
import type { GraphDirection } from "./prepareGraphTraversal.js";
|
|
3
|
+
export type GraphTemporalOptions = {
|
|
4
|
+
endTimeColumn?: string;
|
|
5
|
+
minGapMs?: number;
|
|
6
|
+
startTimeColumn?: string;
|
|
7
|
+
strictOrdering?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type PreparedGraphTemporalOptions = {
|
|
10
|
+
endTimeColumn?: string;
|
|
11
|
+
gapMicroseconds: bigint;
|
|
12
|
+
startTimeColumn?: string;
|
|
13
|
+
strictOrdering: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type PreparedGraphTemporalSql = {
|
|
16
|
+
endTimeColumn?: string;
|
|
17
|
+
eventSelections: (tableAlias?: string) => string[];
|
|
18
|
+
eventValidity: (tableAlias?: string) => string;
|
|
19
|
+
gapParameter: string;
|
|
20
|
+
gapUnit: "microsecond" | "nanosecond";
|
|
21
|
+
startTimeColumn?: string;
|
|
22
|
+
transition: (currentAlias: string, candidateAlias: string, direction: Exclude<GraphDirection, "both">, gapExpression: string) => string;
|
|
23
|
+
};
|
|
24
|
+
/** Validates chronological options before a graph operation is queued. */
|
|
25
|
+
export declare function prepareGraphTemporalOptions(options: GraphTemporalOptions, direction: GraphDirection | undefined, method: string): PreparedGraphTemporalOptions | undefined;
|
|
26
|
+
/** Prepares native-precision event and transition SQL from a queued schema. */
|
|
27
|
+
export default function prepareGraphTemporalSql(schema: TableSchema, options: PreparedGraphTemporalOptions, method: string): PreparedGraphTemporalSql;
|
|
28
|
+
//# sourceMappingURL=prepareGraphTemporalSql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareGraphTemporalSql.d.ts","sourceRoot":"","sources":["../../src/helpers/prepareGraphTemporalSql.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAGjE,MAAM,MAAM,oBAAoB,GAAG;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,CAAC,UAAU,CAAC,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IACnD,aAAa,EAAE,CAAC,UAAU,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,aAAa,GAAG,YAAY,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,CACV,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,OAAO,CAAC,cAAc,EAAE,MAAM,CAAC,EAC1C,aAAa,EAAE,MAAM,KAClB,MAAM,CAAC;CACb,CAAC;AAWF,0EAA0E;AAC1E,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,oBAAoB,EAC7B,SAAS,EAAE,cAAc,GAAG,SAAS,EACrC,MAAM,EAAE,MAAM,GACb,4BAA4B,GAAG,SAAS,CAkE1C;AAED,+EAA+E;AAC/E,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,4BAA4B,EACrC,MAAM,EAAE,MAAM,GACb,wBAAwB,CAwE1B"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import foldIdentifier from "./foldIdentifier.js";
|
|
2
|
+
import quoteIdentifier from "./quoteIdentifier.js";
|
|
3
|
+
const temporalTypes = new Set([
|
|
4
|
+
"DATE",
|
|
5
|
+
"TIMESTAMP",
|
|
6
|
+
"TIMESTAMP_S",
|
|
7
|
+
"TIMESTAMP_MS",
|
|
8
|
+
"TIMESTAMP_NS",
|
|
9
|
+
"TIMESTAMP WITH TIME ZONE",
|
|
10
|
+
]);
|
|
11
|
+
/** Validates chronological options before a graph operation is queued. */
|
|
12
|
+
export function prepareGraphTemporalOptions(options, direction, method) {
|
|
13
|
+
const startTimeColumn = options.startTimeColumn;
|
|
14
|
+
const endTimeColumn = options.endTimeColumn;
|
|
15
|
+
if (startTimeColumn !== undefined && typeof startTimeColumn !== "string") {
|
|
16
|
+
throw new TypeError(`${method} options.startTimeColumn must be a string.`);
|
|
17
|
+
}
|
|
18
|
+
if (endTimeColumn !== undefined && typeof endTimeColumn !== "string") {
|
|
19
|
+
throw new TypeError(`${method} options.endTimeColumn must be a string.`);
|
|
20
|
+
}
|
|
21
|
+
if (options.strictOrdering !== undefined &&
|
|
22
|
+
typeof options.strictOrdering !== "boolean") {
|
|
23
|
+
throw new TypeError(`${method} options.strictOrdering must be a boolean.`);
|
|
24
|
+
}
|
|
25
|
+
if (options.minGapMs !== undefined && typeof options.minGapMs !== "number") {
|
|
26
|
+
throw new TypeError(`${method} options.minGapMs must be a number.`);
|
|
27
|
+
}
|
|
28
|
+
const hasTimeColumn = startTimeColumn !== undefined ||
|
|
29
|
+
endTimeColumn !== undefined;
|
|
30
|
+
const hasTemporalSetting = options.minGapMs !== undefined ||
|
|
31
|
+
options.strictOrdering !== undefined;
|
|
32
|
+
if (!hasTimeColumn) {
|
|
33
|
+
if (hasTemporalSetting) {
|
|
34
|
+
throw new TypeError(`${method} options.minGapMs and options.strictOrdering require options.startTimeColumn or options.endTimeColumn.`);
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
if (direction === "both") {
|
|
39
|
+
throw new TypeError(`${method} options.direction cannot be "both" when chronological options are supplied.`);
|
|
40
|
+
}
|
|
41
|
+
const minGapMs = options.minGapMs ?? 0;
|
|
42
|
+
if (!Number.isFinite(minGapMs) || minGapMs < 0 || !Number.isInteger(minGapMs)) {
|
|
43
|
+
throw new TypeError(`${method} options.minGapMs must be a finite, non-negative integer.`);
|
|
44
|
+
}
|
|
45
|
+
if (minGapMs > Number.MAX_SAFE_INTEGER) {
|
|
46
|
+
throw new TypeError(`${method} options.minGapMs must not exceed Number.MAX_SAFE_INTEGER.`);
|
|
47
|
+
}
|
|
48
|
+
const gapMicroseconds = BigInt(minGapMs) * 1000n;
|
|
49
|
+
return {
|
|
50
|
+
endTimeColumn,
|
|
51
|
+
gapMicroseconds,
|
|
52
|
+
startTimeColumn,
|
|
53
|
+
strictOrdering: options.strictOrdering ?? true,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** Prepares native-precision event and transition SQL from a queued schema. */
|
|
57
|
+
export default function prepareGraphTemporalSql(schema, options, method) {
|
|
58
|
+
const start = options.startTimeColumn === undefined
|
|
59
|
+
? undefined
|
|
60
|
+
: getTemporalColumn(schema, options.startTimeColumn, method);
|
|
61
|
+
const end = options.endTimeColumn === undefined
|
|
62
|
+
? undefined
|
|
63
|
+
: getTemporalColumn(schema, options.endTimeColumn, method);
|
|
64
|
+
if (start?.zoned !== undefined && end?.zoned !== undefined) {
|
|
65
|
+
if (start.zoned !== end.zoned) {
|
|
66
|
+
throw new TypeError(`${method} cannot mix time-zone-aware and time-zone-naive chronological columns. Convert both columns to the same timestamp domain first.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const startColumn = start?.column ?? end.column;
|
|
70
|
+
const endColumn = end?.column ?? start.column;
|
|
71
|
+
const startType = start?.type ?? end.type;
|
|
72
|
+
const endType = end?.type ?? start.type;
|
|
73
|
+
const gapUnit = start?.type === "TIMESTAMP_NS" ||
|
|
74
|
+
end?.type === "TIMESTAMP_NS"
|
|
75
|
+
? "nanosecond"
|
|
76
|
+
: "microsecond";
|
|
77
|
+
const gap = gapUnit === "nanosecond"
|
|
78
|
+
? options.gapMicroseconds * 1000n
|
|
79
|
+
: options.gapMicroseconds;
|
|
80
|
+
const q = quoteIdentifier;
|
|
81
|
+
const reference = (alias, column) => `${alias === undefined ? "" : `${q(alias)}.`}${q(column)}`;
|
|
82
|
+
const eventReference = (alias, name) => `${alias === undefined ? "" : `${q(alias)}.`}${q(name)}`;
|
|
83
|
+
return {
|
|
84
|
+
startTimeColumn: start?.column,
|
|
85
|
+
endTimeColumn: end?.column,
|
|
86
|
+
gapParameter: gap.toString(),
|
|
87
|
+
gapUnit,
|
|
88
|
+
eventSelections: (alias) => [
|
|
89
|
+
`row_number() OVER () AS ${q("__event_id")}`,
|
|
90
|
+
`${reference(alias, startColumn)} AS ${q("__event_start")}`,
|
|
91
|
+
`${reference(alias, endColumn)} AS ${q("__event_end")}`,
|
|
92
|
+
],
|
|
93
|
+
eventValidity: (alias) => {
|
|
94
|
+
const eventStart = eventReference(alias, "__event_start");
|
|
95
|
+
const eventEnd = eventReference(alias, "__event_end");
|
|
96
|
+
return `CASE
|
|
97
|
+
WHEN ${eventStart} IS NULL OR ${eventEnd} IS NULL THEN false
|
|
98
|
+
WHEN NOT isfinite(${eventStart}) OR NOT isfinite(${eventEnd}) THEN false
|
|
99
|
+
ELSE ${temporalUnits(eventEnd, endType, gapUnit)} >= ${temporalUnits(eventStart, startType, gapUnit)}
|
|
100
|
+
END`;
|
|
101
|
+
},
|
|
102
|
+
transition: (currentAlias, candidateAlias, direction, gapExpression) => {
|
|
103
|
+
const currentStart = eventReference(currentAlias, "__event_start");
|
|
104
|
+
const currentEnd = eventReference(currentAlias, "__event_end");
|
|
105
|
+
const candidateStart = eventReference(candidateAlias, "__event_start");
|
|
106
|
+
const candidateEnd = eventReference(candidateAlias, "__event_end");
|
|
107
|
+
const earlierEnd = direction === "outgoing" ? currentEnd : candidateEnd;
|
|
108
|
+
const laterStart = direction === "outgoing"
|
|
109
|
+
? candidateStart
|
|
110
|
+
: currentStart;
|
|
111
|
+
const elapsed = `${temporalUnits(laterStart, startType, gapUnit)} - ${temporalUnits(earlierEnd, endType, gapUnit)}`;
|
|
112
|
+
const ordering = options.strictOrdering
|
|
113
|
+
? `
|
|
114
|
+
AND ${elapsed} > 0`
|
|
115
|
+
: "";
|
|
116
|
+
return `${elapsed} >= ${gapExpression}${ordering}`;
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function temporalUnits(expression, type, unit) {
|
|
121
|
+
// Widen before scaling/subtraction to preserve precision and the DATE range.
|
|
122
|
+
const scale = unit === "nanosecond" ? 1000n : 1n;
|
|
123
|
+
if (type === "DATE") {
|
|
124
|
+
return `(CAST(date_diff('day', DATE '1970-01-01', ${expression}) AS HUGEINT) * ${86400000000n * scale})`;
|
|
125
|
+
}
|
|
126
|
+
if (type === "TIMESTAMP_NS") {
|
|
127
|
+
return `CAST(epoch_ns(${expression}) AS HUGEINT)`;
|
|
128
|
+
}
|
|
129
|
+
return `(CAST(epoch_us(${expression}) AS HUGEINT) * ${scale})`;
|
|
130
|
+
}
|
|
131
|
+
function getTemporalColumn(schema, requested, method) {
|
|
132
|
+
const folded = foldIdentifier(requested);
|
|
133
|
+
const column = Object.keys(schema).find((name) => foldIdentifier(name) === folded);
|
|
134
|
+
if (column === undefined) {
|
|
135
|
+
throw new Error(`${method} the column ${quoteIdentifier(requested)} does not exist. Check for typos, or load the data first.`);
|
|
136
|
+
}
|
|
137
|
+
const type = normalizeTemporalType(schema[column]);
|
|
138
|
+
if (!temporalTypes.has(type)) {
|
|
139
|
+
throw new TypeError(`${method} requires DATE or TIMESTAMP chronological columns, but column ${quoteIdentifier(column)} has type ${schema[column].toUpperCase()}.`);
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
column,
|
|
143
|
+
type,
|
|
144
|
+
zoned: type === "TIMESTAMP WITH TIME ZONE",
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function normalizeTemporalType(type) {
|
|
148
|
+
const normalized = type.toUpperCase();
|
|
149
|
+
if (normalized === "TIMESTAMPTZ")
|
|
150
|
+
return "TIMESTAMP WITH TIME ZONE";
|
|
151
|
+
if (normalized === "TIMESTAMP WITHOUT TIME ZONE")
|
|
152
|
+
return "TIMESTAMP";
|
|
153
|
+
return normalized;
|
|
154
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type GraphEndpointColumns } from "./getGraphEndpointColumns.js";
|
|
2
|
+
import type { TableSchema } from "./pendingOps.js";
|
|
3
|
+
import type { PreparedGraphStarts } from "./prepareGraphStarts.js";
|
|
4
|
+
export type GraphDirection = "outgoing" | "incoming" | "both";
|
|
5
|
+
export type PreparedGraphTraversal = {
|
|
6
|
+
edges: (direction: GraphDirection, selections?: string[]) => string;
|
|
7
|
+
endpoints: GraphEndpointColumns;
|
|
8
|
+
key: (expression: string) => string;
|
|
9
|
+
relationNames: (names: string[]) => Record<string, string>;
|
|
10
|
+
startValues: string;
|
|
11
|
+
};
|
|
12
|
+
export type PreparedGraphSql = Omit<PreparedGraphTraversal, "startValues">;
|
|
13
|
+
/** Prepares exact-ID SQL shared by graph traversal methods. */
|
|
14
|
+
export default function prepareGraphTraversal(input: string, schema: TableSchema, source: string, target: string, starts: PreparedGraphStarts, method: string, argument?: string): PreparedGraphTraversal;
|
|
15
|
+
/** Prepares exact-ID edge SQL for graph methods without starting nodes. */
|
|
16
|
+
export declare function prepareGraphSql(input: string, schema: TableSchema, source: string, target: string, method: string): PreparedGraphSql;
|
|
17
|
+
/** Validates supplied starts against resolved endpoint ID types. */
|
|
18
|
+
export declare function validateGraphStarts(schema: TableSchema, source: string, target: string, starts: PreparedGraphStarts, method: string, argument?: string): GraphEndpointColumns;
|
|
19
|
+
//# sourceMappingURL=prepareGraphTraversal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareGraphTraversal.d.ts","sourceRoot":"","sources":["../../src/helpers/prepareGraphTraversal.ts"],"names":[],"mappings":"AACA,OAAgC,EAC9B,KAAK,oBAAoB,EAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGnE,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;AAE9D,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,CAAC,SAAS,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;IACpE,SAAS,EAAE,oBAAoB,CAAC;IAChC,GAAG,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3D,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,sBAAsB,EAAE,aAAa,CAAC,CAAC;AAE3E,+DAA+D;AAC/D,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,MAAM,EACd,QAAQ,SAAU,GACjB,sBAAsB,CAcxB;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,gBAAgB,CAKlB;AAwCD,oEAAoE;AACpE,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,MAAM,EACd,QAAQ,SAAU,GACjB,oBAAoB,CAyBtB"}
|