Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/utopia-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct ManifestDataDir {
/// not a side effect of a code change.
// 是迁移文件的**个数**,不是最大的编号(守卫 `schema_version_policy_compares_against_current`
// 按个数比):编号有空缺时两者不同——0071 由一个开放 PR 占着,0072 先落,个数是 71
const CURRENT_SCHEMA_VERSION: u32 = 97;
const CURRENT_SCHEMA_VERSION: u32 = 98;

fn main() -> anyhow::Result<()> {
dotenvy::dotenv().ok();
Expand Down
11 changes: 10 additions & 1 deletion crates/utopia-server/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ pub(crate) mod ontology_routes;
mod question_routes;
mod review_routes;
mod rig_model;
mod rule_expression_input;
pub(crate) mod rule_expression_input;
pub(crate) mod rule_routes;
mod search_routes;
mod settings_routes;
mod sources_routes;
#[cfg(test)]
mod static_files_tests;
mod table_alignment_routes;
mod token_routes;
mod tools;
mod tools_graph;
Expand Down Expand Up @@ -243,6 +244,14 @@ pub fn router(state: AppState, cfg: &AppConfig) -> Router {
)
// 静态段排在 `{mapping_id}` 前面:先跑一遍看数,不落库
.route("/kbs/{id}/mappings/preview", post(mapping_routes::preview))
.route(
"/kbs/{id}/table-alignments",
get(table_alignment_routes::list),
)
.route(
"/kbs/{id}/table-alignments/decision",
post(table_alignment_routes::decide),
)
// 跟一个问题有关的口径(问数用的同一条检索)
.route("/kbs/{id}/mappings/relevant", get(mapping_routes::relevant))
.route(
Expand Down
9 changes: 9 additions & 0 deletions crates/utopia-server/src/api/ontology_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,15 @@ pub async fn decide_proposal(
if !matches!(req.status.as_str(), "adopted" | "rejected") {
return Err(AppError::invalid("bad_status", "status 只能是 adopted 或 rejected").into());
}
// A table cannot use the legacy status-only path: its declarations and
// bindings must commit together even when a client calls this endpoint.
if req.section == utopia_store::table_alignments::SECTION {
return Err(AppError::invalid(
"bad_table_alignment",
"Review the whole table through the table alignment endpoint, including its version",
)
.into());
}
let reason = req
.reason
.as_deref()
Expand Down
2 changes: 1 addition & 1 deletion crates/utopia-server/src/api/rule_expression_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn unsupported() -> AppError {
invalid("Use attributes, literals, arithmetic, CAST AS DOUBLE PRECISION, a simple literal CASE, or date_trunc with year, month or day.")
}

fn compile(text: &str, names: &HashMap<String, Uuid>) -> AppResult<Value> {
pub(crate) fn compile(text: &str, names: &HashMap<String, Uuid>) -> AppResult<Value> {
if text.trim().is_empty() || text.len() > MAX_INPUT_BYTES {
return Err(invalid(
"An expression must contain between one and 8192 bytes.",
Expand Down
55 changes: 55 additions & 0 deletions crates/utopia-server/src/api/table_alignment_routes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
use super::graph_routes::require_kb;
use crate::auth::AuthUser;
use crate::error::ApiResult;
use crate::state::AppState;
use axum::{
extract::{Path, State},
Json,
};
use serde::Deserialize;
use serde_json::{json, Value};
use utopia_core::{models::Role, AppError};
use uuid::Uuid;

pub async fn list(
State(state): State<AppState>,
AuthUser(user): AuthUser,
Path(kb_id): Path<Uuid>,
) -> ApiResult<Json<Value>> {
require_kb(&state, &user, kb_id, Role::Viewer).await?;
let proposals = utopia_store::table_alignments::list(&state.pool, kb_id).await?;
let last_run = utopia_store::exploration_runs::recent(&state.pool, kb_id, 1)
.await?
.into_iter()
.next();
Ok(Json(json!({"items":proposals,"last_run":last_run})))
}

#[derive(Deserialize)]
pub struct Decision {
pub key: String,
pub version: Uuid,
pub status: String,
}

pub async fn decide(
State(state): State<AppState>,
AuthUser(user): AuthUser,
Path(kb_id): Path<Uuid>,
Json(req): Json<Decision>,
) -> ApiResult<Json<Value>> {
require_kb(&state, &user, kb_id, Role::Editor).await?;
if !matches!(req.status.as_str(), "adopted" | "rejected") {
return Err(AppError::invalid("bad_status", "status must be adopted or rejected").into());
}
crate::table_exploration::decide(
&state,
kb_id,
&req.key,
req.version,
req.status == "adopted",
user.id,
)
.await?;
Ok(Json(json!({"ok":true})))
}
1 change: 1 addition & 0 deletions crates/utopia-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ mod readers;
mod retrieval;
mod rss_full_content;
mod state;
mod table_exploration;
mod time_resolution;
mod time_text;
mod type_alignment;
Expand Down
Loading
Loading