Skip to content

Commit 0b93333

Browse files
authored
Migrating from http 0.* to 1.*, and IOS v.3.0.0 (#7)
* Migrating from http 0.* to 1.*, and IOS v.3.0.0 * Fixing format
1 parent 9432b59 commit 0b93333

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+967
-1038
lines changed

Cargo.lock

+480-81
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
[workspace]
2-
32
resolver = "2"
4-
53
members = [
64
"api",
75
"event-core",
86
"gateway",
9-
"watchdog"
7+
"watchdog",
108
]
119

1210
[workspace.dependencies]
1311
anyhow = "1.0.75"
12+
async-recursion = "1.0.5"
1413
async-trait = "0.1.74"
15-
axum = "0.6.20"
16-
axum-macros = "0.3.8"
14+
axum = {version = "0.7", features = ["macros"]}
1715
base64 = "0.21.5"
1816
base64ct = { version = "1.6.0", features = ["alloc"] }
1917
bson = "2.7.0"
2018
chrono = { version = "0.4.31", features = ["serde"] }
2119
convert_case = "0.6.0"
2220
dotenvy = "0.15.7"
2321
envconfig = "0.10.0"
24-
fake = { version = "=2.9.1", features = [
22+
fake = { version = "2.9.2", features = [
2523
"uuid",
2624
"derive",
2725
"dummy",
@@ -34,9 +32,9 @@ fake = { version = "=2.9.1", features = [
3432
futures = "0.3.28"
3533
futures-util = "0.3.28"
3634
handlebars = "4.4.0"
37-
http = "0.2.9"
38-
http-serde-ext = "0.1.8"
39-
integrationos-domain = "1.0.0"
35+
http = "1.1.0"
36+
http-serde-ext = "1.0.2"
37+
integrationos-domain = "3.0.0"
4038
js-sandbox-ios = "0.1.0"
4139
jsonpath_lib = "0.3.0"
4240
jsonwebtoken = "8.3.0"
@@ -48,7 +46,7 @@ openapiv3 = { version = "2.0.0", features = ["skip_serializing_defaults"] }
4846
rand = "0.8.5"
4947
redis = { version = "0.23.3", features = ["connection-manager", "tokio-comp"] }
5048
regex = "1.10.2"
51-
reqwest = { version = "0.11.22", features = [
49+
reqwest = { version = "0.12.3", features = [
5250
"json",
5351
"rustls-tls",
5452
], default-features = false }
@@ -64,7 +62,7 @@ tokio = { version = "1.33.0", features = [
6462
"time",
6563
"sync",
6664
] }
67-
tower-http = { version = "0.4.4", features = [
65+
tower-http = { version = "0.5", features = [
6866
"trace",
6967
"cors",
7068
"sensitive-headers",
@@ -76,4 +74,4 @@ uuid = { version = "1.5.0", features = ["v4", "serde"] }
7674
validator = { version = "0.16.1", features = ["derive"] }
7775

7876
[profile.release]
79-
lto = true
77+
lto = "thin"

api/Cargo.toml

+3-6
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,14 @@ convert_case.workspace = true
1515
dotenvy.workspace = true
1616
envconfig.workspace = true
1717
fake = { workspace = true, optional = true }
18-
futures.workspace = true
1918
futures-util.workspace = true
19+
futures.workspace = true
2020
handlebars.workspace = true
2121
http-serde-ext.workspace = true
2222
http.workspace = true
2323
hyper = "0.14.27"
2424
indexmap = "2.1.0"
25-
integrationos-domain = { workspace = true, features = [
26-
"unified",
27-
"metrics",
28-
"axum-error",
29-
] }
25+
integrationos-domain = { workspace = true, features = [ "unified", "metrics", "axum-error", ] }
3026
jsonwebtoken.workspace = true
3127
moka.workspace = true
3228
mongodb.workspace = true
@@ -43,6 +39,7 @@ strum.workspace = true
4339
tokio.workspace = true
4440
tower = { version = "0.4.13", features = ["filter"] }
4541
tower-http.workspace = true
42+
tower_governor = "0.3.2"
4643
tracing-subscriber.workspace = true
4744
tracing.workspace = true
4845
validator.workspace = true

api/src/config.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55

66
use envconfig::Envconfig;
77
use integrationos_domain::cache::CacheConfig as RedisConfig;
8-
use integrationos_domain::common::{
8+
use integrationos_domain::{
99
claude::ClaudeConfig, database::DatabaseConfig, openai::OpenAiConfig, secrets::SecretsConfig,
1010
};
1111

@@ -55,6 +55,11 @@ pub struct Config {
5555
default = "2thZ2UiOnsibmFtZSI6IlN0YXJ0dXBsa3NoamRma3NqZGhma3NqZGhma3NqZG5jhYtggfaP9ubmVjdGlvbnMiOjUwMDAwMCwibW9kdWxlcyI6NSwiZW5kcG9pbnRzIjo3b4e05e2-f050-401f-9822-44f43f71753c"
5656
)]
5757
pub jwt_secret: String,
58+
#[envconfig(from = "BURST_RATE_LIMIT", default = "1")]
59+
pub burst_rate_limit: u64,
60+
/// Burst size limit
61+
#[envconfig(from = "BURST_SIZE_LIMIT", default = "30")]
62+
pub burst_size: u32,
5863
#[envconfig(from = "API_VERSION", default = "v1")]
5964
pub api_version: String,
6065
#[envconfig(from = "MOCK_LLM", default = "false")]

api/src/endpoints/common_model.rs

+15-23
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ use axum::{
1212
use integrationos_domain::{
1313
algebra::{MongoStore, StoreExt},
1414
api_model_config::Lang,
15-
common::{
16-
common_model::{CommonModel, Field},
17-
event_access::EventAccess,
18-
json_schema::JsonSchema,
19-
},
15+
common_model::{CommonModel, Field},
2016
id::{prefix::IdPrefix, Id},
17+
json_schema::JsonSchema,
2118
IntegrationOSError,
2219
};
2320
use mongodb::bson::doc;
@@ -83,33 +80,28 @@ impl CrudHook<CommonModel> for CreateRequest {
8380

8481
impl CrudRequest for CreateRequest {
8582
type Output = CommonModel;
86-
type Error = ();
8783

88-
fn into_public(self) -> Result<Self::Output, Self::Error> {
84+
fn output(&self) -> Option<Self::Output> {
8985
let mut record = Self::Output {
9086
id: Id::now(IdPrefix::CommonModel),
91-
name: self.name,
92-
fields: self.fields,
93-
sample: self.sample,
94-
category: self.category,
87+
name: self.name.clone(),
88+
fields: self.fields.clone(),
89+
sample: self.sample.clone(),
90+
category: self.category.clone(),
9591
primary: self.primary,
9692
interface: Default::default(),
9793
record_metadata: Default::default(),
9894
};
99-
record.record_metadata.version = self.version;
100-
Ok(record)
95+
record.record_metadata.version = self.version.clone();
96+
Some(record)
10197
}
10298

103-
fn into_with_event_access(self, _event_access: Arc<EventAccess>) -> Self::Output {
104-
unimplemented!()
105-
}
106-
107-
fn update(self, record: &mut Self::Output) {
108-
record.name = self.name;
109-
record.record_metadata.version = self.version;
110-
record.fields = self.fields;
111-
record.category = self.category;
112-
record.sample = self.sample;
99+
fn update(&self, record: &mut Self::Output) {
100+
record.name = self.name.clone();
101+
record.record_metadata.version = self.version.clone();
102+
record.fields = self.fields.clone();
103+
record.category = self.category.clone();
104+
record.sample = self.sample.clone();
113105
}
114106

115107
fn get_store(stores: AppStores) -> MongoStore<Self::Output> {

api/src/endpoints/connection.rs

+5-17
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ use convert_case::{Case, Casing};
1818
use http::HeaderMap;
1919
use integrationos_domain::{
2020
algebra::{MongoStore, StoreExt},
21-
common::{
22-
connection_definition::ConnectionDefinition, event_access::EventAccess,
23-
record_metadata::RecordMetadata, settings::Settings, Connection, Throughput,
24-
},
21+
connection_definition::ConnectionDefinition,
22+
event_access::EventAccess,
2523
id::{prefix::IdPrefix, Id},
24+
record_metadata::RecordMetadata,
25+
settings::Settings,
26+
Connection, Throughput,
2627
};
2728
use mongodb::bson::doc;
2829
use mongodb::bson::Regex;
@@ -93,23 +94,10 @@ async fn test_connection(
9394

9495
impl CrudRequest for CreateConnectionPayload {
9596
type Output = Connection;
96-
type Error = ();
97-
98-
fn into_with_event_access(self, _event_access: Arc<EventAccess>) -> Self::Output {
99-
unimplemented!()
100-
}
101-
102-
fn update(self, _record: &mut Self::Output) {
103-
unimplemented!()
104-
}
10597

10698
fn get_store(stores: AppStores) -> MongoStore<Self::Output> {
10799
stores.connection
108100
}
109-
110-
fn into_public(self) -> Result<Self::Output, Self::Error> {
111-
unimplemented!()
112-
}
113101
}
114102

115103
pub async fn create_connection(

api/src/endpoints/connection_definition.rs

+29-37
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{
2-
create, delete, update, ApiResult, CachedRequest, CrudHook, CrudRequest, ReadResponse,
2+
create, delete, update, ApiResult, CachedRequest, CrudHook, CrudRequest, ReadResponse, Unit,
33
};
44
use crate::{
55
internal_server_error, not_found,
@@ -12,19 +12,16 @@ use axum::{
1212
};
1313
use integrationos_domain::{
1414
algebra::{MongoStore, StoreExt},
15-
common::{
16-
api_model_config::AuthMethod,
17-
connection_definition::{
18-
AuthSecret, ConnectionDefinition, ConnectionDefinitionType, ConnectionForm,
19-
FormDataItem, Frontend, Paths, Spec,
20-
},
21-
event_access::EventAccess,
22-
record_metadata::RecordMetadata,
23-
settings::Settings,
24-
},
15+
api_model_config::AuthMethod,
2516
connection_definition::ConnectionStatus,
17+
connection_definition::{
18+
AuthSecret, ConnectionDefinition, ConnectionDefinitionType, ConnectionForm, FormDataItem,
19+
Frontend, Paths, Spec,
20+
},
2621
connection_model_definition::{ConnectionModelDefinition, CrudAction},
2722
id::{prefix::IdPrefix, Id},
23+
record_metadata::RecordMetadata,
24+
settings::Settings,
2825
};
2926
use moka::future::Cache;
3027
use mongodb::bson::doc;
@@ -255,9 +252,8 @@ pub async fn public_get_connection_details(
255252

256253
impl CrudRequest for CreateRequest {
257254
type Output = ConnectionDefinition;
258-
type Error = ();
259255

260-
fn into_public(self) -> Result<Self::Output, Self::Error> {
256+
fn output(&self) -> Option<Self::Output> {
261257
let auth_secrets: Vec<AuthSecret> = self
262258
.authentication
263259
.iter()
@@ -287,48 +283,44 @@ impl CrudRequest for CreateRequest {
287283

288284
let mut record = Self::Output {
289285
id: Id::now(IdPrefix::ConnectionDefinition),
290-
platform_version: self.platform_version,
286+
platform_version: self.platform_version.clone(),
291287
platform: self.platform.clone(),
292-
status: self.status,
293-
r#type: self.r#type,
288+
status: self.status.clone(),
289+
r#type: self.r#type.clone(),
294290
name: self.name.clone(),
295291
key,
296292
frontend: Frontend {
297293
spec: Spec {
298-
title: self.name,
299-
description: self.description,
300-
platform: self.platform,
301-
category: self.category,
302-
image: self.image,
303-
tags: self.tags,
294+
title: self.name.clone(),
295+
description: self.description.clone(),
296+
platform: self.platform.clone(),
297+
category: self.category.clone(),
298+
image: self.image.clone(),
299+
tags: self.tags.clone(),
304300
},
305301
connection_form,
306302
},
307303
test_connection: self.test_connection,
308304
auth_secrets,
309-
auth_method: self.auth_method,
310-
paths: self.paths,
311-
settings: self.settings,
305+
auth_method: self.auth_method.clone(),
306+
paths: self.paths.clone(),
307+
settings: self.settings.clone(),
312308
hidden: false,
313309
record_metadata: RecordMetadata::default(),
314310
};
315311

316312
record.record_metadata.active = self.active;
317-
Ok(record)
318-
}
319-
320-
fn into_with_event_access(self, _event_access: Arc<EventAccess>) -> Self::Output {
321-
unimplemented!()
313+
Some(record)
322314
}
323315

324-
fn update(self, record: &mut Self::Output) {
325-
record.name = self.name;
326-
record.frontend.spec.description = self.description;
327-
record.frontend.spec.category = self.category;
328-
record.frontend.spec.image = self.image;
329-
record.frontend.spec.tags = self.tags;
316+
fn update(&self, record: &mut Self::Output) -> Unit {
317+
record.name = self.name.clone();
318+
record.frontend.spec.description = self.description.clone();
319+
record.frontend.spec.category = self.category.clone();
320+
record.frontend.spec.image = self.image.clone();
321+
record.frontend.spec.tags = self.tags.clone();
330322
record.test_connection = self.test_connection;
331-
record.platform = self.platform;
323+
record.platform = self.platform.clone();
332324
record.record_metadata.active = self.active;
333325
}
334326

0 commit comments

Comments
 (0)