Skip to content
Merged
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
1,711 changes: 954 additions & 757 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ server = [
"libc",
"log",
"sha2",
"sqlx-type",
"qusql-sqlx-type",
"sqlx",
"tempfile",
"tokio-tasks",
Expand Down Expand Up @@ -60,31 +60,31 @@ indicatif = "0.18"
itertools = "0.14"
libc = {version="0.2", optional = true}
log = {version = "0.4", optional=true}
nix = { version = "0.30", default-features = false, features = ["signal", "user", "fs", "event", "socket", "uio", "term"], optional = true }
nix = { version = "0.31", default-features = false, features = ["signal", "user", "fs", "event", "socket", "uio", "term"], optional = true }
passfd = {version = "0.1", optional=true}
rand = "0.9"
reqwest = {version = "0.12", default-features = false, features=['json', 'rustls-tls-webpki-roots']}
rand = "0.10"
reqwest = {version = "0.13", default-features = false, features=['json', 'rustls']}
rpassword = "7"
rusqlite = { version = "0.32", features = ["bundled"], optional=true}
rustls = {version = "0.23", features=["aws_lc_rs"]}
sdnotify = {version = "0.2", default-features = false, optional=true}
serde = { version = "1", default-features = false, features=['std', 'derive']}
serde = { version = "=1.0.224", default-features = false, features=['std', 'derive']}
serde_json = { version = "1", default-features = false, features=['std', "float_roundtrip", "preserve_order"] }
serde_repr = {version = "0.1"}
serde_yaml = "0.9"
sha2 = {version="0.10", optional = true}
simple_logger = {version = "5", default-features=false}
sqlx = { version = "0.8", features = ["sqlite", "runtime-tokio", "chrono"], optional = true, default-features = false}
sqlx-type = {version = "0.4", optional = true}
qusql-sqlx-type = {version = "0.0.1", optional = true}
tempfile = {version="3", optional=true}
tokio = { version = "1", default-features = false, features=['rt', 'net', 'fs', 'sync', 'macros', 'time', 'process', 'signal', 'io-std', 'rt-multi-thread'] }
tokio-rustls = "0.26"
tokio-tasks = {version = "0.5", optional=true}
tokio-tungstenite = { version = "0.27", features=['rustls-tls-webpki-roots']}
tokio-tungstenite = { version = "0.28", features=['rustls-tls-webpki-roots']}
tokio-util = {version = "0.7", features = ["io"], optional = true}
totp-rs= {version="5", features = ["otpauth"], optional = true}
ts-rs = {version="11", features = ["serde-compat", "chrono-impl", "serde-json-impl", "no-serde-warnings", "indexmap-impl"]}
ts-rs = {version="12", features = ["serde-compat", "chrono-impl", "serde-json-impl", "no-serde-warnings", "indexmap-impl"]}
uuid = {version="1", features = ["v4", "serde"], optional = true}
webpki = "0.22"
webpki-roots = "1"
zip = {version= "4", default-features = false, features=['deflate']}
zip = {version= "7", default-features = false, features=['deflate']}
266 changes: 133 additions & 133 deletions src/action_types.rs

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions src/bin/export_ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ struct Args {
pub fn main() -> Result<()> {
let args = Args::parse();

let mut exports = vec![serde_json::Value::export_to_string().unwrap()];
let config = ts_rs::Config::new();

let mut exports = vec![serde_json::Value::export_to_string(&config).unwrap()];
exports.push("export type JsonMap = { [key in string]?: JsonValue };".to_string());
exports.extend(page_types::export_ts());
exports.extend(type_types::export_ts());
exports.extend(action_types::export_ts());
exports.extend(page_types::export_ts(&config));
exports.extend(type_types::export_ts(&config));
exports.extend(action_types::export_ts(&config));

let mut imported = HashSet::new();
let mut exported = HashSet::new();
Expand Down
2 changes: 1 addition & 1 deletion src/bin/server/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use crate::{
};
use anyhow::{Context, Result};
use log::info;
use qusql_sqlx_type::query;
use sadmin2::type_types::{
HOST_ID, IContainsIter, IDependsIter, IVariablesIter, ROOT_ID, ROOT_INSTANCE_ID, ValueMap,
};
use serde::{Deserialize, Serialize, de::DeserializeOwned};
use sqlx::{Executor, SqlitePool};
use sqlx_type::query;

#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
Expand Down
2 changes: 1 addition & 1 deletion src/bin/server/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use base64::Engine;
use base64::prelude::BASE64_STANDARD;
use futures::pin_mut;
use log::{error, info};
use qusql_sqlx_type::{query, query_as};
use sadmin2::client_message::{
ClientHostMessage, HostClientMessage, RunScriptMessage, RunScriptOutType, RunScriptStdinType,
};
Expand All @@ -35,7 +36,6 @@ use sadmin2::type_types::{
};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use sqlx_type::{query, query_as};
use tokio::select;
use tokio_tasks::{RunToken, set_location};

Expand Down
2 changes: 1 addition & 1 deletion src/bin/server/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use anyhow::{Context, Result, bail};
use base64::{Engine, prelude::BASE64_STANDARD};
use futures::future::join_all;
use log::{error, info, warn};
use qusql_sqlx_type::{query, query_as};
use serde::{Deserialize, Serialize};
use sqlx::SqlitePool;
use sqlx_type::{query, query_as};
use std::{
borrow::Cow,
collections::{HashMap, HashSet},
Expand Down
4 changes: 2 additions & 2 deletions src/bin/server/docker_web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ use base64::Engine;
use base64::prelude::BASE64_STANDARD;
use futures::StreamExt;
use log::info;
use qusql_sqlx_type::query;
use sadmin2::finite_float::ToFinite;
use serde::{Deserialize, Serialize};
use sha2::Digest;
use sha2::Sha256;
use sqlx_type::query;
use tokio::io::AsyncWriteExt;
use tokio::sync::Mutex as TMutex;
use tokio_util::io::ReaderStream;
Expand Down Expand Up @@ -308,7 +308,7 @@ pub async fn images_handler(
WState(state): WState<Arc<State>>,
Path(project): Path<String>,
) -> Result<Json<ImagesResult>, WebError> {
let rows = sqlx_type::query_as!(
let rows = qusql_sqlx_type::query_as!(
DockerImageTagRow,
"SELECT `id`, `hash`, `time`, `project`, `user`, `tag`, `pin`, `labels`,
`removed` FROM `docker_images` WHERE `project` = ? ORDER BY `time`",
Expand Down
2 changes: 1 addition & 1 deletion src/bin/server/get_auth.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{action_types::IAuthStatus, db::get_user_content, state::State};
use anyhow::{Context, Result};
use sqlx_type::query;
use qusql_sqlx_type::query;

pub async fn get_auth(state: &State, host: Option<&str>, sid: Option<&str>) -> Result<IAuthStatus> {
let Some(sid) = sid else {
Expand Down
4 changes: 2 additions & 2 deletions src/bin/server/hostclient.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::{Context, Result, bail};
use bytes::{Buf, BytesMut};
use log::{error, info, warn};
use rand::Rng;
use qusql_sqlx_type::query;
use rand::RngExt;
use rustls::pki_types::{CertificateDer, PrivateKeyDer, pem::PemObject};
use serde::Deserialize;
use serde_json::Value;
use sqlx_type::query;
use std::{
collections::{HashMap, HashSet, hash_map::Entry},
net::SocketAddr,
Expand Down
2 changes: 1 addition & 1 deletion src/bin/server/modified_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
use anyhow::{Context, Result, anyhow, bail};
use futures::future::join_all;
use log::{error, info, warn};
use qusql_sqlx_type::query;
use sadmin2::{
client_message::{
ClientHostMessage, DataSource, FailureMessage, HostClientMessage, RunScriptMessage,
Expand All @@ -21,7 +22,6 @@ use sadmin2::{
type_types::ValueMap,
};
use serde::Deserialize;
use sqlx_type::query;
use std::{borrow::Cow, collections::HashMap, sync::Arc, time::Duration};
use tokio_tasks::{RunToken, cancelable};

Expand Down
2 changes: 1 addition & 1 deletion src/bin/server/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
webclient,
};
use anyhow::{Context, Result};
use qusql_sqlx_type::query;
use sadmin2::finite_float::ToFinite;
use sqlx_type::query;

pub async fn get_resent(state: &State) -> Result<Vec<IMessage>> {
let now = std::time::SystemTime::now()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/server/vanta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{sync::Arc, time::Duration};
use anyhow::{Context, Result, bail};
use futures::future::join_all;
use log::{error, info};
use qusql_sqlx_type::query;
use sadmin2::{
client_message::{
ClientHostMessage, HostClientMessage, RunInstantMessage, RunInstantStdinOutputType,
Expand All @@ -12,7 +13,6 @@ use sadmin2::{
};
use serde::{Deserialize, Serialize};
use sqlx::SqlitePool;
use sqlx_type::query;
use tokio::time::timeout;
use tokio_tasks::{RunToken, cancelable};

Expand Down
2 changes: 1 addition & 1 deletion src/bin/server/webclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use futures::{
stream::{SplitSink, SplitStream},
};
use log::{error, info, warn};
use qusql_sqlx_type::{query, query_as};
use serde::{Deserialize, Serialize};
use sqlx_type::{query, query_as};
use std::{
collections::{HashMap, hash_map::Entry},
net::SocketAddr,
Expand Down
12 changes: 6 additions & 6 deletions src/finite_float.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::ops::Deref;

use serde::{Deserialize, Serialize};
use ts_rs::TS;
use ts_rs::{Config, TS};

#[derive(Debug)]
pub struct NotFiniteFloat;
Expand Down Expand Up @@ -99,23 +99,23 @@ impl TS for FiniteF64 {
type WithoutGenerics = Self;
type OptionInnerType = Self;

fn decl() -> String {
fn decl(_config: &Config) -> String {
panic!("FiniteF64 cannot be declared")
}

fn decl_concrete() -> String {
fn decl_concrete(_config: &Config) -> String {
panic!("FiniteF64 cannot be declared")
}

fn name() -> String {
fn name(_config: &Config) -> String {
"number".to_owned()
}

fn inline() -> String {
fn inline(_config: &Config) -> String {
"number".to_owned()
}

fn inline_flattened() -> String {
fn inline_flattened(_config: &Config) -> String {
panic!("FiniteF64 cannot be flattened")
}
}
Expand Down
32 changes: 16 additions & 16 deletions src/page_types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize, Serializer, ser::SerializeMap};
use ts_rs::TS;
use ts_rs::{Config, TS};

#[derive(Serialize, Deserialize, Debug, Clone, TS)]
#[serde(rename_all = "camelCase")]
Expand Down Expand Up @@ -75,16 +75,16 @@ impl ::ts_rs::TS for IPage {
type WithoutGenerics = IPage;
type OptionInnerType = Self;

fn ident() -> String {
fn ident(_config: &Config) -> String {
"IPage".to_owned()
}
fn name() -> String {
fn name(_config: &Config) -> String {
"IPage".to_owned()
}
fn decl_concrete() -> String {
fn decl_concrete(_config: &Config) -> String {
todo!();
}
fn decl() -> String {
fn decl(_config: &Config) -> String {
"type IPage = | { type: PAGE_TYPE.Dashbord }\
| ({ type: PAGE_TYPE.Deployment } \
| { type: PAGE_TYPE.DeploymentDetails } & IDeploymentDetailsPage)\
Expand All @@ -101,11 +101,11 @@ impl ::ts_rs::TS for IPage {
.to_string()
}

fn inline() -> String {
fn inline(_config: &Config) -> String {
todo!();
}

fn inline_flattened() -> String {
fn inline_flattened(_config: &Config) -> String {
todo!()
}

Expand Down Expand Up @@ -228,7 +228,7 @@ impl<'de> serde::Deserialize<'de> for IPage {
}
}

pub fn export_ts() -> Vec<String> {
pub fn export_ts(config: &Config) -> Vec<String> {
vec![
"export enum PAGE_TYPE { \
Dashbord = 0, \
Expand All @@ -246,13 +246,13 @@ pub fn export_ts() -> Vec<String> {
Search = 12, \
}"
.to_string(),
IObjectListPage::export_to_string().unwrap(),
IObjectPage::export_to_string().unwrap(),
IDeploymentDetailsPage::export_to_string().unwrap(),
IDockerImageHistory::export_to_string().unwrap(),
IDockerContainerDetails::export_to_string().unwrap(),
IDockerContainerHistory::export_to_string().unwrap(),
IModifiedFilePage::export_to_string().unwrap(),
IPage::export_to_string().unwrap(),
IObjectListPage::export_to_string(config).unwrap(),
IObjectPage::export_to_string(config).unwrap(),
IDeploymentDetailsPage::export_to_string(config).unwrap(),
IDockerImageHistory::export_to_string(config).unwrap(),
IDockerContainerDetails::export_to_string(config).unwrap(),
IDockerContainerHistory::export_to_string(config).unwrap(),
IModifiedFilePage::export_to_string(config).unwrap(),
IPage::export_to_string(config).unwrap(),
]
}
38 changes: 19 additions & 19 deletions src/type_types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize, Serializer, de, ser::SerializeMap};
use serde_json::Value;
use ts_rs::TS;
use ts_rs::{Config, TS};
pub type ValueMap = serde_json::Map<String, Value>;

#[derive(Serialize, Deserialize, Debug, Clone, TS)]
Expand Down Expand Up @@ -120,16 +120,16 @@ pub enum ITypeProp {
impl TS for ITypeProp {
type WithoutGenerics = ITypeProp;
type OptionInnerType = Self;
fn ident() -> String {
fn ident(_config: &Config) -> String {
"ITypeProp".to_owned()
}
fn name() -> String {
fn name(_config: &Config) -> String {
"ITypeProp".to_owned()
}
fn decl_concrete() -> String {
fn decl_concrete(_config: &Config) -> String {
todo!();
}
fn decl() -> String {
fn decl(_config: &Config) -> String {
"type ITypeProp = | { type: TypePropType.none }\
| ({ type: TypePropType.bool } & IBoolTypeProp)\
| ({ type: TypePropType.text } & ITextTypeProp)\
Expand All @@ -141,10 +141,10 @@ impl TS for ITypeProp {
| { type: TypePropType.monitor };"
.to_string()
}
fn inline() -> String {
fn inline(_config: &Config) -> String {
todo!()
}
fn inline_flattened() -> String {
fn inline_flattened(_config: &Config) -> String {
todo!()
}
fn output_path() -> Option<std::path::PathBuf> {
Expand Down Expand Up @@ -470,7 +470,7 @@ pub const HOST_VARIABLE_ID: i64 = 10840;
pub const PACKAGE_ID: i64 = 10;
pub const ROOT_INSTANCE_ID: i64 = 100;

pub fn export_ts() -> Vec<String> {
pub fn export_ts(config: &Config) -> Vec<String> {
vec![
format!("export const {} = {};", "TYPE_ID", TYPE_ID),
format!("export const {} = {};", "HOST_ID", HOST_ID),
Expand Down Expand Up @@ -502,16 +502,16 @@ pub fn export_ts() -> Vec<String> {
monitor = 8,\
}"
.to_string(),
IBoolTypeProp::export_to_string().unwrap(),
ITextTypeProp::export_to_string().unwrap(),
IPasswordTypeProp::export_to_string().unwrap(),
IDocumentTypeProp::export_to_string().unwrap(),
IChoiceTypeProp::export_to_string().unwrap(),
INumberTypeProp::export_to_string().unwrap(),
ITypeContentTypeProp::export_to_string().unwrap(),
ITypeProp::export_to_string().unwrap(),
KindType::export_to_string().unwrap(),
IType::export_to_string().unwrap(),
IVariable::export_to_string().unwrap(),
IBoolTypeProp::export_to_string(config).unwrap(),
ITextTypeProp::export_to_string(config).unwrap(),
IPasswordTypeProp::export_to_string(config).unwrap(),
IDocumentTypeProp::export_to_string(config).unwrap(),
IChoiceTypeProp::export_to_string(config).unwrap(),
INumberTypeProp::export_to_string(config).unwrap(),
ITypeContentTypeProp::export_to_string(config).unwrap(),
ITypeProp::export_to_string(config).unwrap(),
KindType::export_to_string(config).unwrap(),
IType::export_to_string(config).unwrap(),
IVariable::export_to_string(config).unwrap(),
]
}
Loading