versioning of FK for archiving
This commit is contained in:
2
client
2
client
Submodule client updated: 1e3c9de431...a330f74709
@@ -83,6 +83,11 @@ message PostTableDefinitionRequest {
|
|||||||
// to individual MONEY-column currencies: tables may hold money in any currency, and amounts convert
|
// to individual MONEY-column currencies: tables may hold money in any currency, and amounts convert
|
||||||
// to this one when they reach the ledger.
|
// to this one when they reach the ledger.
|
||||||
string accounting_currency = 8;
|
string accounting_currency = 8;
|
||||||
|
|
||||||
|
// When true, the table is stored once in the global physical schema and is
|
||||||
|
// visible from every profile. profile_name and accounting_currency are ignored.
|
||||||
|
bool global = 9;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defines the input for explicitly creating tables backed by one invoice
|
// Defines the input for explicitly creating tables backed by one invoice
|
||||||
@@ -237,6 +242,9 @@ message ProfileTreeResponse {
|
|||||||
|
|
||||||
// "dynamic" for user-defined tables, "system" for backend-managed tables.
|
// "dynamic" for user-defined tables, "system" for backend-managed tables.
|
||||||
string table_kind = 5;
|
string table_kind = 5;
|
||||||
|
|
||||||
|
// True when this table is shared by every profile.
|
||||||
|
bool global = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Profile (schema) entry.
|
// Profile (schema) entry.
|
||||||
@@ -313,6 +321,7 @@ message TableDetail {
|
|||||||
repeated string row_display_columns = 6;
|
repeated string row_display_columns = 6;
|
||||||
map<string, ColumnBehavior> column_behaviors = 7;
|
map<string, ColumnBehavior> column_behaviors = 7;
|
||||||
string table_kind = 8;
|
string table_kind = 8;
|
||||||
|
bool global = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server-owned behavior for one logical column returned in table details.
|
// Server-owned behavior for one logical column returned in table details.
|
||||||
|
|||||||
@@ -47,6 +47,18 @@ service TablesData {
|
|||||||
// - Updates the row and returns the id; queues search indexing (best effort)
|
// - Updates the row and returns the id; queues search indexing (best effort)
|
||||||
rpc PutTableData(PutTableDataRequest) returns (PutTableDataResponse);
|
rpc PutTableData(PutTableDataRequest) returns (PutTableDataResponse);
|
||||||
|
|
||||||
|
// Performs a PUT after the user explicitly accepted its cross-profile impact.
|
||||||
|
// This is meaningful only for global tables; ordinary tables behave exactly
|
||||||
|
// like PutTableData.
|
||||||
|
rpc PutTableDataConfirmed(PutTableDataRequest) returns (PutTableDataResponse);
|
||||||
|
|
||||||
|
// Lists the other profiles whose rows currently point at this global row.
|
||||||
|
rpc GetGlobalTableUpdateImpact(GlobalTableUpdateImpactRequest) returns (GlobalTableUpdateImpactResponse);
|
||||||
|
|
||||||
|
// Snapshots the current version of a global row and advances its version.
|
||||||
|
// Existing references remain immutable; new references use the new version.
|
||||||
|
rpc ArchiveGlobalTableData(ArchiveGlobalTableDataRequest) returns (ArchiveGlobalTableDataResponse);
|
||||||
|
|
||||||
// Soft-delete a single record (sets deleted = true) if it exists and is not already deleted.
|
// Soft-delete a single record (sets deleted = true) if it exists and is not already deleted.
|
||||||
//
|
//
|
||||||
// Behavior:
|
// Behavior:
|
||||||
@@ -68,6 +80,9 @@ service TablesData {
|
|||||||
// - If the physical table is missing but the definition exists, returns INTERNAL
|
// - If the physical table is missing but the definition exists, returns INTERNAL
|
||||||
rpc GetTableData(GetTableDataRequest) returns (GetTableDataResponse);
|
rpc GetTableData(GetTableDataRequest) returns (GetTableDataResponse);
|
||||||
|
|
||||||
|
// Fetches one exact version of a global row.
|
||||||
|
rpc GetGlobalTableDataVersion(GetGlobalTableDataVersionRequest) returns (GetTableDataResponse);
|
||||||
|
|
||||||
// Count non-deleted rows in a table.
|
// Count non-deleted rows in a table.
|
||||||
//
|
//
|
||||||
// Behavior:
|
// Behavior:
|
||||||
@@ -214,6 +229,32 @@ message PutTableDataResponse {
|
|||||||
int64 row_revision = 4;
|
int64 row_revision = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message GlobalTableUpdateImpactRequest {
|
||||||
|
string profile_name = 1;
|
||||||
|
string table_name = 2;
|
||||||
|
int64 id = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GlobalTableUpdateImpactResponse {
|
||||||
|
repeated string affected_profiles = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ArchiveGlobalTableDataRequest {
|
||||||
|
string profile_name = 1;
|
||||||
|
string table_name = 2;
|
||||||
|
int64 id = 3;
|
||||||
|
int64 expected_revision = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ArchiveGlobalTableDataResponse {
|
||||||
|
bool success = 1;
|
||||||
|
int64 archived_version = 2;
|
||||||
|
string archived_at = 3;
|
||||||
|
repeated string affected_profiles = 4;
|
||||||
|
int64 current_version = 5;
|
||||||
|
int64 row_revision = 6;
|
||||||
|
}
|
||||||
|
|
||||||
// Soft-delete a single row.
|
// Soft-delete a single row.
|
||||||
message DeleteTableDataRequest {
|
message DeleteTableDataRequest {
|
||||||
// Required. Profile (schema) name.
|
// Required. Profile (schema) name.
|
||||||
@@ -245,6 +286,14 @@ message GetTableDataRequest {
|
|||||||
|
|
||||||
// Required. Id of the row to fetch.
|
// Required. Id of the row to fetch.
|
||||||
int64 id = 3;
|
int64 id = 3;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetGlobalTableDataVersionRequest {
|
||||||
|
string profile_name = 1;
|
||||||
|
string table_name = 2;
|
||||||
|
int64 id = 3;
|
||||||
|
int64 version = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Row payload: all columns returned as strings.
|
// Row payload: all columns returned as strings.
|
||||||
@@ -264,6 +313,9 @@ message GetTableDataResponse {
|
|||||||
// identified by its id alone.
|
// identified by its id alone.
|
||||||
repeated string row_display_values = 2;
|
repeated string row_display_values = 2;
|
||||||
repeated string row_display_columns = 3;
|
repeated string row_display_columns = 3;
|
||||||
|
|
||||||
|
// Version paired with each global-link column in this row.
|
||||||
|
map<string, int64> link_versions = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count non-deleted rows.
|
// Count non-deleted rows.
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ pub const ERROR_REASON_METADATA_KEY: &str = "komp-ac-error-reason";
|
|||||||
pub const COMPUTED_VALUE_MISMATCH_REASON: &str = "computed-value-mismatch";
|
pub const COMPUTED_VALUE_MISMATCH_REASON: &str = "computed-value-mismatch";
|
||||||
pub const ROW_STALE_REASON: &str = "row-stale";
|
pub const ROW_STALE_REASON: &str = "row-stale";
|
||||||
pub const ROW_ID_CONFLICT_REASON: &str = "row-id-conflict";
|
pub const ROW_ID_CONFLICT_REASON: &str = "row-id-conflict";
|
||||||
|
pub const GLOBAL_UPDATE_CONFIRMATION_REASON: &str = "global-update-confirmation";
|
||||||
|
|||||||
Binary file not shown.
@@ -37,6 +37,10 @@ pub struct PostTableDefinitionRequest {
|
|||||||
/// to this one when they reach the ledger.
|
/// to this one when they reach the ledger.
|
||||||
#[prost(string, tag = "8")]
|
#[prost(string, tag = "8")]
|
||||||
pub accounting_currency: ::prost::alloc::string::String,
|
pub accounting_currency: ::prost::alloc::string::String,
|
||||||
|
/// When true, the table is stored once in the global physical schema and is
|
||||||
|
/// visible from every profile. profile_name and accounting_currency are ignored.
|
||||||
|
#[prost(bool, tag = "9")]
|
||||||
|
pub global: bool,
|
||||||
}
|
}
|
||||||
/// Defines the input for explicitly creating tables backed by one invoice
|
/// Defines the input for explicitly creating tables backed by one invoice
|
||||||
/// template. typst_source must contain exactly one field declaration:
|
/// template. typst_source must contain exactly one field declaration:
|
||||||
@@ -215,6 +219,9 @@ pub mod profile_tree_response {
|
|||||||
/// "dynamic" for user-defined tables, "system" for backend-managed tables.
|
/// "dynamic" for user-defined tables, "system" for backend-managed tables.
|
||||||
#[prost(string, tag = "5")]
|
#[prost(string, tag = "5")]
|
||||||
pub table_kind: ::prost::alloc::string::String,
|
pub table_kind: ::prost::alloc::string::String,
|
||||||
|
/// True when this table is shared by every profile.
|
||||||
|
#[prost(bool, tag = "6")]
|
||||||
|
pub global: bool,
|
||||||
}
|
}
|
||||||
/// Profile (schema) entry.
|
/// Profile (schema) entry.
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
@@ -324,6 +331,8 @@ pub struct TableDetail {
|
|||||||
>,
|
>,
|
||||||
#[prost(string, tag = "8")]
|
#[prost(string, tag = "8")]
|
||||||
pub table_kind: ::prost::alloc::string::String,
|
pub table_kind: ::prost::alloc::string::String,
|
||||||
|
#[prost(bool, tag = "9")]
|
||||||
|
pub global: bool,
|
||||||
}
|
}
|
||||||
/// Server-owned behavior for one logical column returned in table details.
|
/// Server-owned behavior for one logical column returned in table details.
|
||||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||||
|
|||||||
@@ -149,6 +149,46 @@ pub struct PutTableDataResponse {
|
|||||||
#[prost(int64, tag = "4")]
|
#[prost(int64, tag = "4")]
|
||||||
pub row_revision: i64,
|
pub row_revision: i64,
|
||||||
}
|
}
|
||||||
|
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||||
|
pub struct GlobalTableUpdateImpactRequest {
|
||||||
|
#[prost(string, tag = "1")]
|
||||||
|
pub profile_name: ::prost::alloc::string::String,
|
||||||
|
#[prost(string, tag = "2")]
|
||||||
|
pub table_name: ::prost::alloc::string::String,
|
||||||
|
#[prost(int64, tag = "3")]
|
||||||
|
pub id: i64,
|
||||||
|
}
|
||||||
|
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||||
|
pub struct GlobalTableUpdateImpactResponse {
|
||||||
|
#[prost(string, repeated, tag = "1")]
|
||||||
|
pub affected_profiles: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
|
||||||
|
}
|
||||||
|
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||||
|
pub struct ArchiveGlobalTableDataRequest {
|
||||||
|
#[prost(string, tag = "1")]
|
||||||
|
pub profile_name: ::prost::alloc::string::String,
|
||||||
|
#[prost(string, tag = "2")]
|
||||||
|
pub table_name: ::prost::alloc::string::String,
|
||||||
|
#[prost(int64, tag = "3")]
|
||||||
|
pub id: i64,
|
||||||
|
#[prost(int64, tag = "4")]
|
||||||
|
pub expected_revision: i64,
|
||||||
|
}
|
||||||
|
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||||
|
pub struct ArchiveGlobalTableDataResponse {
|
||||||
|
#[prost(bool, tag = "1")]
|
||||||
|
pub success: bool,
|
||||||
|
#[prost(int64, tag = "2")]
|
||||||
|
pub archived_version: i64,
|
||||||
|
#[prost(string, tag = "3")]
|
||||||
|
pub archived_at: ::prost::alloc::string::String,
|
||||||
|
#[prost(string, repeated, tag = "4")]
|
||||||
|
pub affected_profiles: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
|
||||||
|
#[prost(int64, tag = "5")]
|
||||||
|
pub current_version: i64,
|
||||||
|
#[prost(int64, tag = "6")]
|
||||||
|
pub row_revision: i64,
|
||||||
|
}
|
||||||
/// Soft-delete a single row.
|
/// Soft-delete a single row.
|
||||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||||
pub struct DeleteTableDataRequest {
|
pub struct DeleteTableDataRequest {
|
||||||
@@ -185,6 +225,17 @@ pub struct GetTableDataRequest {
|
|||||||
#[prost(int64, tag = "3")]
|
#[prost(int64, tag = "3")]
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
}
|
}
|
||||||
|
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||||
|
pub struct GetGlobalTableDataVersionRequest {
|
||||||
|
#[prost(string, tag = "1")]
|
||||||
|
pub profile_name: ::prost::alloc::string::String,
|
||||||
|
#[prost(string, tag = "2")]
|
||||||
|
pub table_name: ::prost::alloc::string::String,
|
||||||
|
#[prost(int64, tag = "3")]
|
||||||
|
pub id: i64,
|
||||||
|
#[prost(int64, tag = "4")]
|
||||||
|
pub version: i64,
|
||||||
|
}
|
||||||
/// Row payload: all columns returned as strings.
|
/// Row payload: all columns returned as strings.
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct GetTableDataResponse {
|
pub struct GetTableDataResponse {
|
||||||
@@ -209,6 +260,9 @@ pub struct GetTableDataResponse {
|
|||||||
pub row_display_values: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
|
pub row_display_values: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
|
||||||
#[prost(string, repeated, tag = "3")]
|
#[prost(string, repeated, tag = "3")]
|
||||||
pub row_display_columns: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
|
pub row_display_columns: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
|
||||||
|
/// Version paired with each global-link column in this row.
|
||||||
|
#[prost(map = "string, int64", tag = "4")]
|
||||||
|
pub link_versions: ::std::collections::HashMap<::prost::alloc::string::String, i64>,
|
||||||
}
|
}
|
||||||
/// Count non-deleted rows.
|
/// Count non-deleted rows.
|
||||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||||
@@ -443,6 +497,99 @@ pub mod tables_data_client {
|
|||||||
);
|
);
|
||||||
self.inner.unary(req, path, codec).await
|
self.inner.unary(req, path, codec).await
|
||||||
}
|
}
|
||||||
|
/// Performs a PUT after the user explicitly accepted its cross-profile impact.
|
||||||
|
/// This is meaningful only for global tables; ordinary tables behave exactly
|
||||||
|
/// like PutTableData.
|
||||||
|
pub async fn put_table_data_confirmed(
|
||||||
|
&mut self,
|
||||||
|
request: impl tonic::IntoRequest<super::PutTableDataRequest>,
|
||||||
|
) -> std::result::Result<
|
||||||
|
tonic::Response<super::PutTableDataResponse>,
|
||||||
|
tonic::Status,
|
||||||
|
> {
|
||||||
|
self.inner
|
||||||
|
.ready()
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
tonic::Status::unknown(
|
||||||
|
format!("Service was not ready: {}", e.into()),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
let codec = tonic_prost::ProstCodec::default();
|
||||||
|
let path = http::uri::PathAndQuery::from_static(
|
||||||
|
"/komp_ac.tables_data.TablesData/PutTableDataConfirmed",
|
||||||
|
);
|
||||||
|
let mut req = request.into_request();
|
||||||
|
req.extensions_mut()
|
||||||
|
.insert(
|
||||||
|
GrpcMethod::new(
|
||||||
|
"komp_ac.tables_data.TablesData",
|
||||||
|
"PutTableDataConfirmed",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
self.inner.unary(req, path, codec).await
|
||||||
|
}
|
||||||
|
/// Lists the other profiles whose rows currently point at this global row.
|
||||||
|
pub async fn get_global_table_update_impact(
|
||||||
|
&mut self,
|
||||||
|
request: impl tonic::IntoRequest<super::GlobalTableUpdateImpactRequest>,
|
||||||
|
) -> std::result::Result<
|
||||||
|
tonic::Response<super::GlobalTableUpdateImpactResponse>,
|
||||||
|
tonic::Status,
|
||||||
|
> {
|
||||||
|
self.inner
|
||||||
|
.ready()
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
tonic::Status::unknown(
|
||||||
|
format!("Service was not ready: {}", e.into()),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
let codec = tonic_prost::ProstCodec::default();
|
||||||
|
let path = http::uri::PathAndQuery::from_static(
|
||||||
|
"/komp_ac.tables_data.TablesData/GetGlobalTableUpdateImpact",
|
||||||
|
);
|
||||||
|
let mut req = request.into_request();
|
||||||
|
req.extensions_mut()
|
||||||
|
.insert(
|
||||||
|
GrpcMethod::new(
|
||||||
|
"komp_ac.tables_data.TablesData",
|
||||||
|
"GetGlobalTableUpdateImpact",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
self.inner.unary(req, path, codec).await
|
||||||
|
}
|
||||||
|
/// Snapshots the current version of a global row and advances its version.
|
||||||
|
/// Existing references remain immutable; new references use the new version.
|
||||||
|
pub async fn archive_global_table_data(
|
||||||
|
&mut self,
|
||||||
|
request: impl tonic::IntoRequest<super::ArchiveGlobalTableDataRequest>,
|
||||||
|
) -> std::result::Result<
|
||||||
|
tonic::Response<super::ArchiveGlobalTableDataResponse>,
|
||||||
|
tonic::Status,
|
||||||
|
> {
|
||||||
|
self.inner
|
||||||
|
.ready()
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
tonic::Status::unknown(
|
||||||
|
format!("Service was not ready: {}", e.into()),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
let codec = tonic_prost::ProstCodec::default();
|
||||||
|
let path = http::uri::PathAndQuery::from_static(
|
||||||
|
"/komp_ac.tables_data.TablesData/ArchiveGlobalTableData",
|
||||||
|
);
|
||||||
|
let mut req = request.into_request();
|
||||||
|
req.extensions_mut()
|
||||||
|
.insert(
|
||||||
|
GrpcMethod::new(
|
||||||
|
"komp_ac.tables_data.TablesData",
|
||||||
|
"ArchiveGlobalTableData",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
self.inner.unary(req, path, codec).await
|
||||||
|
}
|
||||||
/// Soft-delete a single record (sets deleted = true) if it exists and is not already deleted.
|
/// Soft-delete a single record (sets deleted = true) if it exists and is not already deleted.
|
||||||
///
|
///
|
||||||
/// Behavior:
|
/// Behavior:
|
||||||
@@ -514,6 +661,36 @@ pub mod tables_data_client {
|
|||||||
);
|
);
|
||||||
self.inner.unary(req, path, codec).await
|
self.inner.unary(req, path, codec).await
|
||||||
}
|
}
|
||||||
|
/// Fetches one exact version of a global row.
|
||||||
|
pub async fn get_global_table_data_version(
|
||||||
|
&mut self,
|
||||||
|
request: impl tonic::IntoRequest<super::GetGlobalTableDataVersionRequest>,
|
||||||
|
) -> std::result::Result<
|
||||||
|
tonic::Response<super::GetTableDataResponse>,
|
||||||
|
tonic::Status,
|
||||||
|
> {
|
||||||
|
self.inner
|
||||||
|
.ready()
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
tonic::Status::unknown(
|
||||||
|
format!("Service was not ready: {}", e.into()),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
let codec = tonic_prost::ProstCodec::default();
|
||||||
|
let path = http::uri::PathAndQuery::from_static(
|
||||||
|
"/komp_ac.tables_data.TablesData/GetGlobalTableDataVersion",
|
||||||
|
);
|
||||||
|
let mut req = request.into_request();
|
||||||
|
req.extensions_mut()
|
||||||
|
.insert(
|
||||||
|
GrpcMethod::new(
|
||||||
|
"komp_ac.tables_data.TablesData",
|
||||||
|
"GetGlobalTableDataVersion",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
self.inner.unary(req, path, codec).await
|
||||||
|
}
|
||||||
/// Count non-deleted rows in a table.
|
/// Count non-deleted rows in a table.
|
||||||
///
|
///
|
||||||
/// Behavior:
|
/// Behavior:
|
||||||
@@ -655,6 +832,33 @@ pub mod tables_data_server {
|
|||||||
tonic::Response<super::PutTableDataResponse>,
|
tonic::Response<super::PutTableDataResponse>,
|
||||||
tonic::Status,
|
tonic::Status,
|
||||||
>;
|
>;
|
||||||
|
/// Performs a PUT after the user explicitly accepted its cross-profile impact.
|
||||||
|
/// This is meaningful only for global tables; ordinary tables behave exactly
|
||||||
|
/// like PutTableData.
|
||||||
|
async fn put_table_data_confirmed(
|
||||||
|
&self,
|
||||||
|
request: tonic::Request<super::PutTableDataRequest>,
|
||||||
|
) -> std::result::Result<
|
||||||
|
tonic::Response<super::PutTableDataResponse>,
|
||||||
|
tonic::Status,
|
||||||
|
>;
|
||||||
|
/// Lists the other profiles whose rows currently point at this global row.
|
||||||
|
async fn get_global_table_update_impact(
|
||||||
|
&self,
|
||||||
|
request: tonic::Request<super::GlobalTableUpdateImpactRequest>,
|
||||||
|
) -> std::result::Result<
|
||||||
|
tonic::Response<super::GlobalTableUpdateImpactResponse>,
|
||||||
|
tonic::Status,
|
||||||
|
>;
|
||||||
|
/// Snapshots the current version of a global row and advances its version.
|
||||||
|
/// Existing references remain immutable; new references use the new version.
|
||||||
|
async fn archive_global_table_data(
|
||||||
|
&self,
|
||||||
|
request: tonic::Request<super::ArchiveGlobalTableDataRequest>,
|
||||||
|
) -> std::result::Result<
|
||||||
|
tonic::Response<super::ArchiveGlobalTableDataResponse>,
|
||||||
|
tonic::Status,
|
||||||
|
>;
|
||||||
/// Soft-delete a single record (sets deleted = true) if it exists and is not already deleted.
|
/// Soft-delete a single record (sets deleted = true) if it exists and is not already deleted.
|
||||||
///
|
///
|
||||||
/// Behavior:
|
/// Behavior:
|
||||||
@@ -688,6 +892,14 @@ pub mod tables_data_server {
|
|||||||
tonic::Response<super::GetTableDataResponse>,
|
tonic::Response<super::GetTableDataResponse>,
|
||||||
tonic::Status,
|
tonic::Status,
|
||||||
>;
|
>;
|
||||||
|
/// Fetches one exact version of a global row.
|
||||||
|
async fn get_global_table_data_version(
|
||||||
|
&self,
|
||||||
|
request: tonic::Request<super::GetGlobalTableDataVersionRequest>,
|
||||||
|
) -> std::result::Result<
|
||||||
|
tonic::Response<super::GetTableDataResponse>,
|
||||||
|
tonic::Status,
|
||||||
|
>;
|
||||||
/// Count non-deleted rows in a table.
|
/// Count non-deleted rows in a table.
|
||||||
///
|
///
|
||||||
/// Behavior:
|
/// Behavior:
|
||||||
@@ -934,6 +1146,152 @@ pub mod tables_data_server {
|
|||||||
};
|
};
|
||||||
Box::pin(fut)
|
Box::pin(fut)
|
||||||
}
|
}
|
||||||
|
"/komp_ac.tables_data.TablesData/PutTableDataConfirmed" => {
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
struct PutTableDataConfirmedSvc<T: TablesData>(pub Arc<T>);
|
||||||
|
impl<
|
||||||
|
T: TablesData,
|
||||||
|
> tonic::server::UnaryService<super::PutTableDataRequest>
|
||||||
|
for PutTableDataConfirmedSvc<T> {
|
||||||
|
type Response = super::PutTableDataResponse;
|
||||||
|
type Future = BoxFuture<
|
||||||
|
tonic::Response<Self::Response>,
|
||||||
|
tonic::Status,
|
||||||
|
>;
|
||||||
|
fn call(
|
||||||
|
&mut self,
|
||||||
|
request: tonic::Request<super::PutTableDataRequest>,
|
||||||
|
) -> Self::Future {
|
||||||
|
let inner = Arc::clone(&self.0);
|
||||||
|
let fut = async move {
|
||||||
|
<T as TablesData>::put_table_data_confirmed(&inner, request)
|
||||||
|
.await
|
||||||
|
};
|
||||||
|
Box::pin(fut)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let accept_compression_encodings = self.accept_compression_encodings;
|
||||||
|
let send_compression_encodings = self.send_compression_encodings;
|
||||||
|
let max_decoding_message_size = self.max_decoding_message_size;
|
||||||
|
let max_encoding_message_size = self.max_encoding_message_size;
|
||||||
|
let inner = self.inner.clone();
|
||||||
|
let fut = async move {
|
||||||
|
let method = PutTableDataConfirmedSvc(inner);
|
||||||
|
let codec = tonic_prost::ProstCodec::default();
|
||||||
|
let mut grpc = tonic::server::Grpc::new(codec)
|
||||||
|
.apply_compression_config(
|
||||||
|
accept_compression_encodings,
|
||||||
|
send_compression_encodings,
|
||||||
|
)
|
||||||
|
.apply_max_message_size_config(
|
||||||
|
max_decoding_message_size,
|
||||||
|
max_encoding_message_size,
|
||||||
|
);
|
||||||
|
let res = grpc.unary(method, req).await;
|
||||||
|
Ok(res)
|
||||||
|
};
|
||||||
|
Box::pin(fut)
|
||||||
|
}
|
||||||
|
"/komp_ac.tables_data.TablesData/GetGlobalTableUpdateImpact" => {
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
struct GetGlobalTableUpdateImpactSvc<T: TablesData>(pub Arc<T>);
|
||||||
|
impl<
|
||||||
|
T: TablesData,
|
||||||
|
> tonic::server::UnaryService<super::GlobalTableUpdateImpactRequest>
|
||||||
|
for GetGlobalTableUpdateImpactSvc<T> {
|
||||||
|
type Response = super::GlobalTableUpdateImpactResponse;
|
||||||
|
type Future = BoxFuture<
|
||||||
|
tonic::Response<Self::Response>,
|
||||||
|
tonic::Status,
|
||||||
|
>;
|
||||||
|
fn call(
|
||||||
|
&mut self,
|
||||||
|
request: tonic::Request<
|
||||||
|
super::GlobalTableUpdateImpactRequest,
|
||||||
|
>,
|
||||||
|
) -> Self::Future {
|
||||||
|
let inner = Arc::clone(&self.0);
|
||||||
|
let fut = async move {
|
||||||
|
<T as TablesData>::get_global_table_update_impact(
|
||||||
|
&inner,
|
||||||
|
request,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
};
|
||||||
|
Box::pin(fut)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let accept_compression_encodings = self.accept_compression_encodings;
|
||||||
|
let send_compression_encodings = self.send_compression_encodings;
|
||||||
|
let max_decoding_message_size = self.max_decoding_message_size;
|
||||||
|
let max_encoding_message_size = self.max_encoding_message_size;
|
||||||
|
let inner = self.inner.clone();
|
||||||
|
let fut = async move {
|
||||||
|
let method = GetGlobalTableUpdateImpactSvc(inner);
|
||||||
|
let codec = tonic_prost::ProstCodec::default();
|
||||||
|
let mut grpc = tonic::server::Grpc::new(codec)
|
||||||
|
.apply_compression_config(
|
||||||
|
accept_compression_encodings,
|
||||||
|
send_compression_encodings,
|
||||||
|
)
|
||||||
|
.apply_max_message_size_config(
|
||||||
|
max_decoding_message_size,
|
||||||
|
max_encoding_message_size,
|
||||||
|
);
|
||||||
|
let res = grpc.unary(method, req).await;
|
||||||
|
Ok(res)
|
||||||
|
};
|
||||||
|
Box::pin(fut)
|
||||||
|
}
|
||||||
|
"/komp_ac.tables_data.TablesData/ArchiveGlobalTableData" => {
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
struct ArchiveGlobalTableDataSvc<T: TablesData>(pub Arc<T>);
|
||||||
|
impl<
|
||||||
|
T: TablesData,
|
||||||
|
> tonic::server::UnaryService<super::ArchiveGlobalTableDataRequest>
|
||||||
|
for ArchiveGlobalTableDataSvc<T> {
|
||||||
|
type Response = super::ArchiveGlobalTableDataResponse;
|
||||||
|
type Future = BoxFuture<
|
||||||
|
tonic::Response<Self::Response>,
|
||||||
|
tonic::Status,
|
||||||
|
>;
|
||||||
|
fn call(
|
||||||
|
&mut self,
|
||||||
|
request: tonic::Request<super::ArchiveGlobalTableDataRequest>,
|
||||||
|
) -> Self::Future {
|
||||||
|
let inner = Arc::clone(&self.0);
|
||||||
|
let fut = async move {
|
||||||
|
<T as TablesData>::archive_global_table_data(
|
||||||
|
&inner,
|
||||||
|
request,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
};
|
||||||
|
Box::pin(fut)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let accept_compression_encodings = self.accept_compression_encodings;
|
||||||
|
let send_compression_encodings = self.send_compression_encodings;
|
||||||
|
let max_decoding_message_size = self.max_decoding_message_size;
|
||||||
|
let max_encoding_message_size = self.max_encoding_message_size;
|
||||||
|
let inner = self.inner.clone();
|
||||||
|
let fut = async move {
|
||||||
|
let method = ArchiveGlobalTableDataSvc(inner);
|
||||||
|
let codec = tonic_prost::ProstCodec::default();
|
||||||
|
let mut grpc = tonic::server::Grpc::new(codec)
|
||||||
|
.apply_compression_config(
|
||||||
|
accept_compression_encodings,
|
||||||
|
send_compression_encodings,
|
||||||
|
)
|
||||||
|
.apply_max_message_size_config(
|
||||||
|
max_decoding_message_size,
|
||||||
|
max_encoding_message_size,
|
||||||
|
);
|
||||||
|
let res = grpc.unary(method, req).await;
|
||||||
|
Ok(res)
|
||||||
|
};
|
||||||
|
Box::pin(fut)
|
||||||
|
}
|
||||||
"/komp_ac.tables_data.TablesData/DeleteTableData" => {
|
"/komp_ac.tables_data.TablesData/DeleteTableData" => {
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
struct DeleteTableDataSvc<T: TablesData>(pub Arc<T>);
|
struct DeleteTableDataSvc<T: TablesData>(pub Arc<T>);
|
||||||
@@ -1024,6 +1382,58 @@ pub mod tables_data_server {
|
|||||||
};
|
};
|
||||||
Box::pin(fut)
|
Box::pin(fut)
|
||||||
}
|
}
|
||||||
|
"/komp_ac.tables_data.TablesData/GetGlobalTableDataVersion" => {
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
struct GetGlobalTableDataVersionSvc<T: TablesData>(pub Arc<T>);
|
||||||
|
impl<
|
||||||
|
T: TablesData,
|
||||||
|
> tonic::server::UnaryService<
|
||||||
|
super::GetGlobalTableDataVersionRequest,
|
||||||
|
> for GetGlobalTableDataVersionSvc<T> {
|
||||||
|
type Response = super::GetTableDataResponse;
|
||||||
|
type Future = BoxFuture<
|
||||||
|
tonic::Response<Self::Response>,
|
||||||
|
tonic::Status,
|
||||||
|
>;
|
||||||
|
fn call(
|
||||||
|
&mut self,
|
||||||
|
request: tonic::Request<
|
||||||
|
super::GetGlobalTableDataVersionRequest,
|
||||||
|
>,
|
||||||
|
) -> Self::Future {
|
||||||
|
let inner = Arc::clone(&self.0);
|
||||||
|
let fut = async move {
|
||||||
|
<T as TablesData>::get_global_table_data_version(
|
||||||
|
&inner,
|
||||||
|
request,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
};
|
||||||
|
Box::pin(fut)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let accept_compression_encodings = self.accept_compression_encodings;
|
||||||
|
let send_compression_encodings = self.send_compression_encodings;
|
||||||
|
let max_decoding_message_size = self.max_decoding_message_size;
|
||||||
|
let max_encoding_message_size = self.max_encoding_message_size;
|
||||||
|
let inner = self.inner.clone();
|
||||||
|
let fut = async move {
|
||||||
|
let method = GetGlobalTableDataVersionSvc(inner);
|
||||||
|
let codec = tonic_prost::ProstCodec::default();
|
||||||
|
let mut grpc = tonic::server::Grpc::new(codec)
|
||||||
|
.apply_compression_config(
|
||||||
|
accept_compression_encodings,
|
||||||
|
send_compression_encodings,
|
||||||
|
)
|
||||||
|
.apply_max_message_size_config(
|
||||||
|
max_decoding_message_size,
|
||||||
|
max_encoding_message_size,
|
||||||
|
);
|
||||||
|
let res = grpc.unary(method, req).await;
|
||||||
|
Ok(res)
|
||||||
|
};
|
||||||
|
Box::pin(fut)
|
||||||
|
}
|
||||||
"/komp_ac.tables_data.TablesData/GetTableDataCount" => {
|
"/komp_ac.tables_data.TablesData/GetTableDataCount" => {
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
struct GetTableDataCountSvc<T: TablesData>(pub Arc<T>);
|
struct GetTableDataCountSvc<T: TablesData>(pub Arc<T>);
|
||||||
|
|||||||
2
server
2
server
Submodule server updated: 3bf72f51a6...ac0c12a7ac
@@ -35,6 +35,7 @@ pub(crate) struct TableDraft {
|
|||||||
/// Profile name typed in when creating a new profile.
|
/// Profile name typed in when creating a new profile.
|
||||||
pub profile_name_input: String,
|
pub profile_name_input: String,
|
||||||
pub creating_new_profile: bool,
|
pub creating_new_profile: bool,
|
||||||
|
pub global: bool,
|
||||||
pub accounting_currency: String,
|
pub accounting_currency: String,
|
||||||
|
|
||||||
pub table_name: String,
|
pub table_name: String,
|
||||||
@@ -69,11 +70,11 @@ impl TableDraft {
|
|||||||
// ---- field visibility (the same rules the TUI canvas applies) --------
|
// ---- field visibility (the same rules the TUI canvas applies) --------
|
||||||
|
|
||||||
pub(crate) fn show_profile_name_input(&self) -> bool {
|
pub(crate) fn show_profile_name_input(&self) -> bool {
|
||||||
self.creating_new_profile
|
self.creating_new_profile && !self.global
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn show_accounting_currency(&self) -> bool {
|
pub(crate) fn show_accounting_currency(&self) -> bool {
|
||||||
self.creating_new_profile
|
self.creating_new_profile && !self.global
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- mutations -------------------------------------------------------
|
// ---- mutations -------------------------------------------------------
|
||||||
@@ -211,10 +212,10 @@ impl TableDraft {
|
|||||||
/// Every check the client runs before it will save.
|
/// Every check the client runs before it will save.
|
||||||
pub(crate) fn validate(&self) -> Result<(), String> {
|
pub(crate) fn validate(&self) -> Result<(), String> {
|
||||||
let profile_name = self.effective_profile_name();
|
let profile_name = self.effective_profile_name();
|
||||||
if self.creating_new_profile && profile_name.is_empty() {
|
if !self.global && self.creating_new_profile && profile_name.is_empty() {
|
||||||
return Err("Enter a name for the new profile.".to_string());
|
return Err("Enter a name for the new profile.".to_string());
|
||||||
}
|
}
|
||||||
if let Some(error) = validate_identifier(&profile_name, "Profile name", false) {
|
if !self.global && let Some(error) = validate_identifier(&profile_name, "Profile name", false) {
|
||||||
return Err(error);
|
return Err(error);
|
||||||
}
|
}
|
||||||
if let Some(error) = validate_accounting_currency(self) {
|
if let Some(error) = validate_accounting_currency(self) {
|
||||||
@@ -244,18 +245,19 @@ impl TableDraft {
|
|||||||
profile_name: self.effective_profile_name(),
|
profile_name: self.effective_profile_name(),
|
||||||
columns: proto_columns(&self.columns.added),
|
columns: proto_columns(&self.columns.added),
|
||||||
indexes: self.columns.selected_index_names(),
|
indexes: self.columns.selected_index_names(),
|
||||||
accounting_currency: if self.creating_new_profile {
|
accounting_currency: if self.creating_new_profile && !self.global {
|
||||||
self.accounting_currency.trim().to_ascii_uppercase()
|
self.accounting_currency.trim().to_ascii_uppercase()
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
String::new()
|
||||||
},
|
},
|
||||||
row_display_columns: self.row_display_columns.clone(),
|
row_display_columns: self.row_display_columns.clone(),
|
||||||
|
global: self.global,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn validate_accounting_currency(draft: &TableDraft) -> Option<String> {
|
pub(crate) fn validate_accounting_currency(draft: &TableDraft) -> Option<String> {
|
||||||
if !draft.creating_new_profile {
|
if !draft.creating_new_profile || draft.global {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let currency = draft.accounting_currency.to_ascii_uppercase();
|
let currency = draft.accounting_currency.to_ascii_uppercase();
|
||||||
|
|||||||
@@ -60,7 +60,26 @@ pub(crate) async fn load_page(
|
|||||||
.into_inner();
|
.into_inner();
|
||||||
|
|
||||||
let effective_profile = draft.effective_profile_name();
|
let effective_profile = draft.effective_profile_name();
|
||||||
match tree
|
if draft.global {
|
||||||
|
let global_tables = tree
|
||||||
|
.profiles
|
||||||
|
.iter()
|
||||||
|
.flat_map(|profile| profile.tables.iter())
|
||||||
|
.filter(|table| table.global)
|
||||||
|
.map(|table| table.name.clone())
|
||||||
|
.collect::<std::collections::BTreeSet<_>>()
|
||||||
|
.into_iter()
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
draft.existing_profile_tables = tree
|
||||||
|
.profiles
|
||||||
|
.iter()
|
||||||
|
.flat_map(|profile| profile.tables.iter())
|
||||||
|
.map(|table| table.name.clone())
|
||||||
|
.collect::<std::collections::BTreeSet<_>>()
|
||||||
|
.into_iter()
|
||||||
|
.collect();
|
||||||
|
draft.set_available_relation_tables(global_tables);
|
||||||
|
} else { match tree
|
||||||
.profiles
|
.profiles
|
||||||
.iter()
|
.iter()
|
||||||
.find(|profile| profile.name == effective_profile)
|
.find(|profile| profile.name == effective_profile)
|
||||||
@@ -82,7 +101,7 @@ pub(crate) async fn load_page(
|
|||||||
draft.existing_profile_tables.clear();
|
draft.existing_profile_tables.clear();
|
||||||
draft.relation_tables.clear();
|
draft.relation_tables.clear();
|
||||||
}
|
}
|
||||||
}
|
}}
|
||||||
|
|
||||||
Ok(AddTablePageState {
|
Ok(AddTablePageState {
|
||||||
nav: crate::ui::Nav::new(headers, "admin").with_authorization(&authorization),
|
nav: crate::ui::Nav::new(headers, "admin").with_authorization(&authorization),
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ pub(crate) async fn create_table(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut definitions = state.definitions;
|
let mut definitions = state.definitions;
|
||||||
match definitions.post_table_definition(request).await {
|
let result = definitions.post_table_definition(request).await;
|
||||||
|
match result {
|
||||||
Ok(response) if response.get_ref().success => {
|
Ok(response) if response.get_ref().success => {
|
||||||
let location = format!(
|
let location = format!(
|
||||||
"/admin/table-definition?profile={profile_name}&table={}",
|
"/admin/table-definition?profile={profile_name}&table={}",
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ pub(crate) struct BuilderForm {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub accounting_currency: String,
|
pub accounting_currency: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
pub global: bool,
|
||||||
|
#[serde(default)]
|
||||||
pub table_name: String,
|
pub table_name: String,
|
||||||
|
|
||||||
// The pending column being described in the input panel.
|
// The pending column being described in the input panel.
|
||||||
@@ -134,6 +136,7 @@ impl BuilderForm {
|
|||||||
profile_name_input: self.profile_name_input.clone(),
|
profile_name_input: self.profile_name_input.clone(),
|
||||||
creating_new_profile,
|
creating_new_profile,
|
||||||
accounting_currency: self.accounting_currency.clone(),
|
accounting_currency: self.accounting_currency.clone(),
|
||||||
|
global: self.global,
|
||||||
table_name: self.table_name.clone(),
|
table_name: self.table_name.clone(),
|
||||||
columns,
|
columns,
|
||||||
relation_tables: self.relation_tables.clone(),
|
relation_tables: self.relation_tables.clone(),
|
||||||
|
|||||||
@@ -24,6 +24,15 @@
|
|||||||
<section class="builder-section">
|
<section class="builder-section">
|
||||||
<h2>Table</h2>
|
<h2>Table</h2>
|
||||||
<div class="form-grid">
|
<div class="form-grid">
|
||||||
|
<label>Scope
|
||||||
|
<span><input type="checkbox" name="global" value="true"
|
||||||
|
{% if page.draft.global %}checked{% endif %}
|
||||||
|
hx-post="/admin/tables/builder" hx-trigger="change"
|
||||||
|
hx-include="#table-form" hx-target="#builder" hx-swap="innerHTML"
|
||||||
|
hx-vals='{"action": "refresh"}'> Shared across profiles</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
{% if !page.draft.global %}
|
||||||
<label>Profile
|
<label>Profile
|
||||||
<select name="profile_name" hx-post="/admin/tables/builder" hx-trigger="change"
|
<select name="profile_name" hx-post="/admin/tables/builder" hx-trigger="change"
|
||||||
hx-include="#table-form" hx-target="#builder" hx-swap="innerHTML"
|
hx-include="#table-form" hx-target="#builder" hx-swap="innerHTML"
|
||||||
@@ -35,6 +44,9 @@
|
|||||||
<option value="__new__" {% if page.draft.creating_new_profile %}selected{% endif %}>+ New profile…</option>
|
<option value="__new__" {% if page.draft.creating_new_profile %}selected{% endif %}>+ New profile…</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
{% else %}
|
||||||
|
<input type="hidden" name="profile_name" value="{{ page.draft.profile_name }}">
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if page.draft.show_profile_name_input() %}
|
{% if page.draft.show_profile_name_input() %}
|
||||||
<label>New profile name
|
<label>New profile name
|
||||||
|
|||||||
Reference in New Issue
Block a user