@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.
- 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 +2805 -1077
- package/esm/class/SimpleTable.d.ts.map +1 -1
- package/esm/class/SimpleTable.js +2777 -1077
- package/esm/helpers/appendColumnBatches.d.ts +3 -0
- package/esm/helpers/appendColumnBatches.d.ts.map +1 -0
- package/esm/helpers/appendColumnBatches.js +21 -0
- 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 +21 -0
- package/esm/helpers/buildUmapGraph.d.ts.map +1 -0
- package/esm/helpers/buildUmapGraph.js +61 -0
- 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/cacheDatabase.d.ts.map +1 -1
- package/esm/helpers/cacheDatabase.js +2 -1
- 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/fitUmapCurve.d.ts +2 -0
- package/esm/helpers/fitUmapCurve.d.ts.map +1 -0
- package/esm/helpers/fitUmapCurve.js +66 -0
- 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/initialUmapCoordinates.d.ts +2 -0
- package/esm/helpers/initialUmapCoordinates.d.ts.map +1 -0
- package/esm/helpers/initialUmapCoordinates.js +5 -0
- 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/optimizeUmapLayout.d.ts +7 -0
- package/esm/helpers/optimizeUmapLayout.d.ts.map +1 -0
- package/esm/helpers/optimizeUmapLayout.js +93 -0
- 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/prepareUmapLayoutOptions.d.ts +14 -0
- package/esm/helpers/prepareUmapLayoutOptions.d.ts.map +1 -0
- package/esm/helpers/prepareUmapLayoutOptions.js +23 -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/readScalarNumber.d.ts +3 -0
- package/esm/helpers/readScalarNumber.d.ts.map +1 -0
- package/esm/helpers/readScalarNumber.js +4 -0
- 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/umapRandom.d.ts +2 -0
- package/esm/helpers/umapRandom.d.ts.map +1 -0
- package/esm/helpers/umapRandom.js +10 -0
- 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/cache.js +1 -1
- 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/loadArray.d.ts.map +1 -1
- package/esm/methods/loadArray.js +3 -20
- 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/esm/methods/umap.d.ts +5 -0
- package/esm/methods/umap.d.ts.map +1 -0
- package/esm/methods/umap.js +156 -0
- package/esm/methods/updateWithJS.js +9 -21
- package/llm.md +2170 -128
- 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 +2805 -1077
- package/script/class/SimpleTable.d.ts.map +1 -1
- package/script/class/SimpleTable.js +2777 -1077
- package/script/helpers/appendColumnBatches.d.ts +3 -0
- package/script/helpers/appendColumnBatches.d.ts.map +1 -0
- package/script/helpers/appendColumnBatches.js +24 -0
- 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 +21 -0
- package/script/helpers/buildUmapGraph.d.ts.map +1 -0
- package/script/helpers/buildUmapGraph.js +67 -0
- 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/cacheDatabase.d.ts.map +1 -1
- package/script/helpers/cacheDatabase.js +2 -1
- 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/fitUmapCurve.d.ts +2 -0
- package/script/helpers/fitUmapCurve.d.ts.map +1 -0
- package/script/helpers/fitUmapCurve.js +69 -0
- 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/initialUmapCoordinates.d.ts +2 -0
- package/script/helpers/initialUmapCoordinates.d.ts.map +1 -0
- package/script/helpers/initialUmapCoordinates.js +11 -0
- 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/optimizeUmapLayout.d.ts +7 -0
- package/script/helpers/optimizeUmapLayout.d.ts.map +1 -0
- package/script/helpers/optimizeUmapLayout.js +99 -0
- 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/prepareUmapLayoutOptions.d.ts +14 -0
- package/script/helpers/prepareUmapLayoutOptions.d.ts.map +1 -0
- package/script/helpers/prepareUmapLayoutOptions.js +29 -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/readScalarNumber.d.ts +3 -0
- package/script/helpers/readScalarNumber.d.ts.map +1 -0
- package/script/helpers/readScalarNumber.js +7 -0
- 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/umapRandom.d.ts +2 -0
- package/script/helpers/umapRandom.d.ts.map +1 -0
- package/script/helpers/umapRandom.js +13 -0
- 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/cache.js +1 -1
- 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/loadArray.d.ts.map +1 -1
- package/script/methods/loadArray.js +2 -19
- 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
- package/script/methods/umap.d.ts +5 -0
- package/script/methods/umap.d.ts.map +1 -0
- package/script/methods/umap.js +162 -0
- package/script/methods/updateWithJS.js +9 -21
|
@@ -5,9 +5,6 @@ import type SimpleTable from "../class/SimpleTable.js";
|
|
|
5
5
|
* Uses `getTypes()` to inspect column types and checks for any column
|
|
6
6
|
* whose type normalizes to `"geometry"`.
|
|
7
7
|
*
|
|
8
|
-
* @param table - The SimpleTable instance to inspect.
|
|
9
|
-
* @returns `true` if at least one geometry column exists, `false` otherwise.
|
|
10
|
-
*
|
|
11
8
|
* @example
|
|
12
9
|
* ```ts
|
|
13
10
|
* const hasGeo = await hasGeometryColumn(table);
|
|
@@ -15,6 +12,10 @@ import type SimpleTable from "../class/SimpleTable.js";
|
|
|
15
12
|
* console.log("This table contains geometry columns");
|
|
16
13
|
* }
|
|
17
14
|
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param table - The SimpleTable instance to inspect.
|
|
17
|
+
*
|
|
18
|
+
* @returns `true` if at least one geometry column exists, `false` otherwise.
|
|
18
19
|
*/
|
|
19
20
|
export default function hasGeometryColumn(table: SimpleTable): Promise<boolean>;
|
|
20
21
|
//# sourceMappingURL=hasGeometryColumn.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasGeometryColumn.d.ts","sourceRoot":"","sources":["../../src/helpers/hasGeometryColumn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"hasGeometryColumn.d.ts","sourceRoot":"","sources":["../../src/helpers/hasGeometryColumn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAEvD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAA8B,iBAAiB,CAC7C,KAAK,EAAE,WAAW,GACjB,OAAO,CAAC,OAAO,CAAC,CAGlB"}
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
* Uses `getTypes()` to inspect column types and checks for any column
|
|
5
5
|
* whose type normalizes to `"geometry"`.
|
|
6
6
|
*
|
|
7
|
-
* @param table - The SimpleTable instance to inspect.
|
|
8
|
-
* @returns `true` if at least one geometry column exists, `false` otherwise.
|
|
9
|
-
*
|
|
10
7
|
* @example
|
|
11
8
|
* ```ts
|
|
12
9
|
* const hasGeo = await hasGeometryColumn(table);
|
|
@@ -14,6 +11,10 @@
|
|
|
14
11
|
* console.log("This table contains geometry columns");
|
|
15
12
|
* }
|
|
16
13
|
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param table - The SimpleTable instance to inspect.
|
|
16
|
+
*
|
|
17
|
+
* @returns `true` if at least one geometry column exists, `false` otherwise.
|
|
17
18
|
*/
|
|
18
19
|
export default async function hasGeometryColumn(table) {
|
|
19
20
|
const types = await table.getTypes();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialUmapCoordinates.d.ts","sourceRoot":"","sources":["../../src/helpers/initialUmapCoordinates.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,6BAGzE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DuckDBConnection } from "@duckdb/node-api";
|
|
2
|
+
/**
|
|
3
|
+
* Inspect connectivity of an edge relation while transferring ids, not vectors.
|
|
4
|
+
* Isolated vertices count as one-point components. Invalid ids fail closed.
|
|
5
|
+
*/
|
|
6
|
+
export default function inspectGraphConnectivity(connection: DuckDBConnection, edges: string, vertexCount: number): Promise<{
|
|
7
|
+
componentCount: number;
|
|
8
|
+
sizes: number[];
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=inspectGraphConnectivity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspectGraphConnectivity.d.ts","sourceRoot":"","sources":["../../src/helpers/inspectGraphConnectivity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;GAGG;AACH,wBAA8B,wBAAwB,CACpD,UAAU,EAAE,gBAAgB,EAC5B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAoDtD"}
|
|
@@ -0,0 +1,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 {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type prepareUmapLayoutOptions from "./prepareUmapLayoutOptions.js";
|
|
2
|
+
export default function optimizeUmapLayout(graph: {
|
|
3
|
+
source: Uint32Array;
|
|
4
|
+
target: Uint32Array;
|
|
5
|
+
weight: Float64Array;
|
|
6
|
+
}, initial: Float64Array, options: ReturnType<typeof prepareUmapLayoutOptions>): Float64Array;
|
|
7
|
+
//# sourceMappingURL=optimizeUmapLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optimizeUmapLayout.d.ts","sourceRoot":"","sources":["../../src/helpers/optimizeUmapLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,wBAAwB,MAAM,+BAA+B,CAAC;AAS1E,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,KAAK,EAAE;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,YAAY,CAAA;CAAE,EACzE,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,GACnD,YAAY,CA2Fd"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import umapRandom from "./umapRandom.js";
|
|
2
|
+
// Internal interface. Graph entries are directed, in a stable order; the fuzzy
|
|
3
|
+
// union graph supplies both orientations. Coordinates are interleaved x,y.
|
|
4
|
+
// Inputs are borrowed read-only. State is O(edges + vertices), never O(n²).
|
|
5
|
+
// Implements reference Euclidean UMAP SGD: scheduled attractive edges, sampled
|
|
6
|
+
// repulsion, clipped gradients, symmetric attractive updates, linear decay.
|
|
7
|
+
// Algorithm: https://umap-learn.readthedocs.io/en/latest/how_umap_works.html
|
|
8
|
+
export default function optimizeUmapLayout(graph, initial, options) {
|
|
9
|
+
const { epochs, seed, learningRate, negativeSamples, curve: [a, b] } = options;
|
|
10
|
+
const count = initial.length / 2;
|
|
11
|
+
if (!Number.isInteger(count) || count < 3 || count > 0xffffffff) {
|
|
12
|
+
throw new Error("Expected interleaved coordinates for at least three vertices.");
|
|
13
|
+
}
|
|
14
|
+
for (const value of initial) {
|
|
15
|
+
if (!Number.isFinite(value)) {
|
|
16
|
+
throw new Error("Initial coordinates must be finite.");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const { source, target, weight } = graph;
|
|
20
|
+
if (!weight.length || source.length !== weight.length ||
|
|
21
|
+
target.length !== weight.length)
|
|
22
|
+
throw new Error("Invalid graph column lengths.");
|
|
23
|
+
let maximum = 0;
|
|
24
|
+
for (let edge = 0; edge < weight.length; edge++) {
|
|
25
|
+
if (source[edge] >= count || target[edge] >= count ||
|
|
26
|
+
source[edge] === target[edge])
|
|
27
|
+
throw new Error("Graph contains an invalid vertex or self edge.");
|
|
28
|
+
if (!Number.isFinite(weight[edge]) || weight[edge] < 0 || weight[edge] > 1)
|
|
29
|
+
throw new Error("Graph weights must be between zero and one.");
|
|
30
|
+
maximum = Math.max(maximum, weight[edge]);
|
|
31
|
+
}
|
|
32
|
+
if (!maximum)
|
|
33
|
+
throw new Error("Graph must contain a positive edge.");
|
|
34
|
+
const period = new Float64Array(weight.length);
|
|
35
|
+
const nextPositive = new Float64Array(weight.length);
|
|
36
|
+
const nextNegative = new Float64Array(weight.length);
|
|
37
|
+
// Reference pruning uses 500 when explicitly requesting at most ten epochs.
|
|
38
|
+
const threshold = maximum / (epochs > 10 ? epochs : 500);
|
|
39
|
+
for (let edge = 0; edge < weight.length; edge++) {
|
|
40
|
+
period[edge] = weight[edge] > 0 && weight[edge] >= threshold
|
|
41
|
+
? epochs / ((weight[edge] / maximum) * epochs)
|
|
42
|
+
: Infinity;
|
|
43
|
+
nextPositive[edge] = period[edge];
|
|
44
|
+
nextNegative[edge] = period[edge] / negativeSamples;
|
|
45
|
+
}
|
|
46
|
+
const coordinates = initial.slice();
|
|
47
|
+
const random = umapRandom(seed ^ 0x7f4a7c15);
|
|
48
|
+
const clip = (gradient) => Math.max(-4, Math.min(4, gradient));
|
|
49
|
+
let alpha = learningRate;
|
|
50
|
+
for (let epoch = 0; epoch < epochs; epoch++) {
|
|
51
|
+
for (let edge = 0; edge < weight.length; edge++) {
|
|
52
|
+
if (nextPositive[edge] > epoch)
|
|
53
|
+
continue;
|
|
54
|
+
const u = source[edge] * 2, v = target[edge] * 2;
|
|
55
|
+
let dx = coordinates[u] - coordinates[v], dy = coordinates[u + 1] - coordinates[v + 1];
|
|
56
|
+
let squared = dx * dx + dy * dy;
|
|
57
|
+
if (squared > 0) {
|
|
58
|
+
const attraction = -2 * a * b * Math.pow(squared, b - 1) /
|
|
59
|
+
(1 + a * Math.pow(squared, b));
|
|
60
|
+
const gx = clip(attraction * dx) * alpha, gy = clip(attraction * dy) * alpha;
|
|
61
|
+
coordinates[u] += gx;
|
|
62
|
+
coordinates[u + 1] += gy;
|
|
63
|
+
coordinates[v] -= gx;
|
|
64
|
+
coordinates[v + 1] -= gy;
|
|
65
|
+
}
|
|
66
|
+
nextPositive[edge] += period[edge];
|
|
67
|
+
const negativePeriod = period[edge] / negativeSamples;
|
|
68
|
+
const draws = Math.floor((epoch - nextNegative[edge]) / negativePeriod);
|
|
69
|
+
for (let draw = 0; draw < draws; draw++) {
|
|
70
|
+
const other = Math.floor(random() * count) * 2;
|
|
71
|
+
dx = coordinates[u] - coordinates[other];
|
|
72
|
+
dy = coordinates[u + 1] - coordinates[other + 1];
|
|
73
|
+
squared = dx * dx + dy * dy;
|
|
74
|
+
// Coincident points get zero repulsive gradient, as in current Python
|
|
75
|
+
// UMAP; this intentionally differs from UMAP-JS's constant +4 fallback.
|
|
76
|
+
if (squared > 0) {
|
|
77
|
+
const repulsion = 2 * b /
|
|
78
|
+
((0.001 + squared) * (1 + a * Math.pow(squared, b)));
|
|
79
|
+
coordinates[u] += clip(repulsion * dx) * alpha;
|
|
80
|
+
coordinates[u + 1] += clip(repulsion * dy) * alpha;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
nextNegative[edge] += draws * negativePeriod;
|
|
84
|
+
}
|
|
85
|
+
alpha = learningRate * (1 - epoch / epochs);
|
|
86
|
+
}
|
|
87
|
+
for (const value of coordinates) {
|
|
88
|
+
if (!Number.isFinite(value)) {
|
|
89
|
+
throw new Error("UMAP optimization produced a non-finite coordinate.");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return coordinates;
|
|
93
|
+
}
|
|
@@ -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"}
|