chore: bump client api (#4819)

* chore: bump client api

* chore: bump client api

* chore: update ci

* chore: update client api

* chore: ci config

* chore: bump client api

* chore: bump client api

* chore: bump client api
This commit is contained in:
Nathan.fooo 2024-03-07 12:50:28 +08:00 committed by GitHub
parent 780f08dd28
commit 3d8ff062b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 151 additions and 112 deletions

View File

@ -25,6 +25,22 @@ jobs:
test-on-ubuntu: test-on-ubuntu:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
# - name: Maximize build space
# uses: easimon/maximize-build-space@master
# with:
# root-reserve-mb: 2048
# swap-size-mb: 1024
# remove-dotnet: 'true'
#
# # the following step is required to avoid running out of space
# - name: Maximize build space
# run: |
# sudo rm -rf /usr/share/dotnet
# sudo rm -rf /opt/ghc
# sudo rm -rf "/usr/local/share/boost"
# sudo rm -rf "$AGENT_TOOLSDIRECTORY"
# sudo docker image prune --all --force
- name: Checkout source code - name: Checkout source code
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -86,3 +102,8 @@ jobs:
- name: clippy rust-lib - name: clippy rust-lib
run: cargo clippy --all-targets -- -D warnings run: cargo clippy --all-targets -- -D warnings
working-directory: frontend/rust-lib working-directory: frontend/rust-lib
- name: Clean up Docker images
run: |
docker image prune -af
docker volume prune -f

View File

@ -281,7 +281,7 @@ Future<AppFlowyCloudConfiguration> configurationFromUri(
if (authenticatorType == AuthenticatorType.appflowyCloudDevelop) { if (authenticatorType == AuthenticatorType.appflowyCloudDevelop) {
return AppFlowyCloudConfiguration( return AppFlowyCloudConfiguration(
base_url: "$baseUrl:8000", base_url: "$baseUrl:8000",
ws_base_url: "ws://${baseUri.host}:8000/ws", ws_base_url: "ws://${baseUri.host}:8000/ws/v1",
gotrue_url: "$baseUrl:9999", gotrue_url: "$baseUrl:9999",
); );
} else { } else {
@ -319,7 +319,7 @@ Future<String> _getAppFlowyCloudWSUrl(String baseURL) async {
// Construct the WebSocket URL directly from the parsed URI. // Construct the WebSocket URL directly from the parsed URI.
final wsScheme = uri.isScheme('HTTPS') ? 'wss' : 'ws'; final wsScheme = uri.isScheme('HTTPS') ? 'wss' : 'ws';
final wsUrl = Uri(scheme: wsScheme, host: uri.host, path: '/ws'); final wsUrl = Uri(scheme: wsScheme, host: uri.host, path: '/ws/v1');
return wsUrl.toString(); return wsUrl.toString();
} catch (e) { } catch (e) {

View File

@ -162,7 +162,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]] [[package]]
name = "app-error" name = "app-error"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -714,7 +714,7 @@ dependencies = [
[[package]] [[package]]
name = "client-api" name = "client-api"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"again", "again",
"anyhow", "anyhow",
@ -741,6 +741,7 @@ dependencies = [
"realtime-protocol", "realtime-protocol",
"reqwest", "reqwest",
"scraper 0.17.1", "scraper 0.17.1",
"semver",
"serde", "serde",
"serde_json", "serde_json",
"serde_repr", "serde_repr",
@ -1312,7 +1313,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]] [[package]]
name = "database-entity" name = "database-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -2586,7 +2587,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue" name = "gotrue"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"futures-util", "futures-util",
@ -2603,7 +2604,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue-entity" name = "gotrue-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -3058,7 +3059,7 @@ dependencies = [
[[package]] [[package]]
name = "infra" name = "infra"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"reqwest", "reqwest",
@ -4800,7 +4801,7 @@ dependencies = [
[[package]] [[package]]
name = "realtime-entity" name = "realtime-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -4824,7 +4825,7 @@ dependencies = [
[[package]] [[package]]
name = "realtime-protocol" name = "realtime-protocol"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -5317,9 +5318,9 @@ dependencies = [
[[package]] [[package]]
name = "semver" name = "semver"
version = "1.0.17" version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca"
dependencies = [ dependencies = [
"serde", "serde",
] ]
@ -5496,7 +5497,7 @@ dependencies = [
[[package]] [[package]]
name = "shared-entity" name = "shared-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -6240,9 +6241,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.35.1" version = "1.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bytes", "bytes",
@ -6992,13 +6993,14 @@ checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc"
[[package]] [[package]]
name = "websocket" name = "websocket"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"http", "http",
"httparse", "httparse",
"js-sys", "js-sys",
"percent-encoding",
"thiserror", "thiserror",
"tokio", "tokio",
"tokio-tungstenite", "tokio-tungstenite",
@ -7454,7 +7456,7 @@ dependencies = [
[[package]] [[package]]
name = "workspace-template" name = "workspace-template"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",

View File

@ -82,7 +82,7 @@ custom-protocol = ["tauri/custom-protocol"]
# Run the script: # Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id # scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "15c03e4f85fffd35089a82c2a84aca8042a38946" } client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "eb79b9f5e80846bd06b30b4f9c04039ce1452582" }
# Please use the following script to update collab. # Please use the following script to update collab.
# Working directory: frontend # Working directory: frontend
# #

View File

@ -221,7 +221,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]] [[package]]
name = "app-error" name = "app-error"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -545,7 +545,7 @@ dependencies = [
[[package]] [[package]]
name = "client-api" name = "client-api"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"again", "again",
"anyhow", "anyhow",
@ -572,6 +572,7 @@ dependencies = [
"realtime-protocol", "realtime-protocol",
"reqwest", "reqwest",
"scraper 0.17.1", "scraper 0.17.1",
"semver",
"serde", "serde",
"serde_json", "serde_json",
"serde_repr", "serde_repr",
@ -945,7 +946,7 @@ checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"
[[package]] [[package]]
name = "database-entity" name = "database-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -1699,7 +1700,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue" name = "gotrue"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"futures-util", "futures-util",
@ -1716,7 +1717,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue-entity" name = "gotrue-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -2050,7 +2051,7 @@ dependencies = [
[[package]] [[package]]
name = "infra" name = "infra"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"reqwest", "reqwest",
@ -3308,7 +3309,7 @@ dependencies = [
[[package]] [[package]]
name = "realtime-entity" name = "realtime-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -3332,7 +3333,7 @@ dependencies = [
[[package]] [[package]]
name = "realtime-protocol" name = "realtime-protocol"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -3665,6 +3666,12 @@ dependencies = [
"smallvec", "smallvec",
] ]
[[package]]
name = "semver"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.195" version = "1.0.195"
@ -3779,7 +3786,7 @@ dependencies = [
[[package]] [[package]]
name = "shared-entity" name = "shared-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -4145,9 +4152,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.35.1" version = "1.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bytes", "bytes",
@ -4721,13 +4728,14 @@ checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10"
[[package]] [[package]]
name = "websocket" name = "websocket"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"http", "http",
"httparse", "httparse",
"js-sys", "js-sys",
"percent-encoding",
"thiserror", "thiserror",
"tokio", "tokio",
"tokio-tungstenite", "tokio-tungstenite",

View File

@ -55,7 +55,7 @@ codegen-units = 1
# Run the script: # Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id # scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "15c03e4f85fffd35089a82c2a84aca8042a38946" } client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "eb79b9f5e80846bd06b30b4f9c04039ce1452582" }
# Please use the following script to update collab. # Please use the following script to update collab.
# Working directory: frontend # Working directory: frontend
# #

View File

@ -49,14 +49,14 @@ pub fn init_wasm_core() -> js_sys::Promise {
#[cfg(feature = "localhost_dev")] #[cfg(feature = "localhost_dev")]
let config = AFCloudConfiguration { let config = AFCloudConfiguration {
base_url: "http://localhost".to_string(), base_url: "http://localhost".to_string(),
ws_base_url: "ws://localhost/ws".to_string(), ws_base_url: "ws://localhost/ws/v1".to_string(),
gotrue_url: "http://localhost/gotrue".to_string(), gotrue_url: "http://localhost/gotrue".to_string(),
}; };
#[cfg(not(feature = "localhost_dev"))] #[cfg(not(feature = "localhost_dev"))]
let config = AFCloudConfiguration { let config = AFCloudConfiguration {
base_url: "https://beta.appflowy.cloud".to_string(), base_url: "https://beta.appflowy.cloud".to_string(),
ws_base_url: "wss://beta.appflowy.cloud/ws".to_string(), ws_base_url: "wss://beta.appflowy.cloud/ws/v1".to_string(),
gotrue_url: "https://beta.appflowy.cloud/gotrue".to_string(), gotrue_url: "https://beta.appflowy.cloud/gotrue".to_string(),
}; };

View File

@ -24,7 +24,7 @@ impl WASMEventTester {
setup_log(); setup_log();
let config = AFCloudConfiguration { let config = AFCloudConfiguration {
base_url: "http://localhost".to_string(), base_url: "http://localhost".to_string(),
ws_base_url: "ws://localhost/ws".to_string(), ws_base_url: "ws://localhost/ws/v1".to_string(),
gotrue_url: "http://localhost/gotrue".to_string(), gotrue_url: "http://localhost/gotrue".to_string(),
}; };
let core = Arc::new(AppFlowyWASMCore::new("device_id", config).await.unwrap()); let core = Arc::new(AppFlowyWASMCore::new("device_id", config).await.unwrap());

View File

@ -163,7 +163,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]] [[package]]
name = "app-error" name = "app-error"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -673,7 +673,7 @@ dependencies = [
[[package]] [[package]]
name = "client-api" name = "client-api"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"again", "again",
"anyhow", "anyhow",
@ -700,6 +700,7 @@ dependencies = [
"realtime-protocol", "realtime-protocol",
"reqwest", "reqwest",
"scraper 0.17.1", "scraper 0.17.1",
"semver",
"serde", "serde",
"serde_json", "serde_json",
"serde_repr", "serde_repr",
@ -1236,7 +1237,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]] [[package]]
name = "database-entity" name = "database-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -2410,7 +2411,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue" name = "gotrue"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"futures-util", "futures-util",
@ -2427,7 +2428,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue-entity" name = "gotrue-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -2821,7 +2822,7 @@ dependencies = [
[[package]] [[package]]
name = "infra" name = "infra"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"reqwest", "reqwest",
@ -4318,7 +4319,7 @@ dependencies = [
[[package]] [[package]]
name = "realtime-entity" name = "realtime-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -4342,7 +4343,7 @@ dependencies = [
[[package]] [[package]]
name = "realtime-protocol" name = "realtime-protocol"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -4805,6 +4806,12 @@ dependencies = [
"smallvec", "smallvec",
] ]
[[package]]
name = "semver"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.195" version = "1.0.195"
@ -4930,7 +4937,7 @@ dependencies = [
[[package]] [[package]]
name = "shared-entity" name = "shared-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -5364,9 +5371,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.35.1" version = "1.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bytes", "bytes",
@ -6120,13 +6127,14 @@ checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc"
[[package]] [[package]]
name = "websocket" name = "websocket"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"http", "http",
"httparse", "httparse",
"js-sys", "js-sys",
"percent-encoding",
"thiserror", "thiserror",
"tokio", "tokio",
"tokio-tungstenite", "tokio-tungstenite",
@ -6360,7 +6368,7 @@ dependencies = [
[[package]] [[package]]
name = "workspace-template" name = "workspace-template"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=15c03e4f85fffd35089a82c2a84aca8042a38946#15c03e4f85fffd35089a82c2a84aca8042a38946" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=eb79b9f5e80846bd06b30b4f9c04039ce1452582#eb79b9f5e80846bd06b30b4f9c04039ce1452582"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",

View File

@ -105,7 +105,7 @@ incremental = false
# Run the script: # Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id # scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "15c03e4f85fffd35089a82c2a84aca8042a38946" } client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "eb79b9f5e80846bd06b30b4f9c04039ce1452582" }
# Please use the following script to update collab. # Please use the following script to update collab.
# Working directory: frontend # Working directory: frontend
# #

View File

@ -410,7 +410,7 @@ pub async fn user_localhost_af_cloud() {
let base_url = let base_url =
std::env::var("af_cloud_test_base_url").unwrap_or("http://localhost:8000".to_string()); std::env::var("af_cloud_test_base_url").unwrap_or("http://localhost:8000".to_string());
let ws_base_url = let ws_base_url =
std::env::var("af_cloud_test_ws_url").unwrap_or("ws://localhost:8000/ws".to_string()); std::env::var("af_cloud_test_ws_url").unwrap_or("ws://localhost:8000/ws/v1".to_string());
let gotrue_url = let gotrue_url =
std::env::var("af_cloud_test_gotrue_url").unwrap_or("http://localhost:9999".to_string()); std::env::var("af_cloud_test_gotrue_url").unwrap_or("http://localhost:9999".to_string());
AFCloudConfiguration { AFCloudConfiguration {
@ -426,7 +426,7 @@ pub async fn user_localhost_af_cloud() {
#[allow(dead_code)] #[allow(dead_code)]
pub async fn user_localhost_af_cloud_with_nginx() { pub async fn user_localhost_af_cloud_with_nginx() {
std::env::set_var("af_cloud_test_base_url", "http://localhost"); std::env::set_var("af_cloud_test_base_url", "http://localhost");
std::env::set_var("af_cloud_test_ws_url", "ws://localhost/ws"); std::env::set_var("af_cloud_test_ws_url", "ws://localhost/ws/v1");
std::env::set_var("af_cloud_test_gotrue_url", "http://localhost/gotrue"); std::env::set_var("af_cloud_test_gotrue_url", "http://localhost/gotrue");
user_localhost_af_cloud().await user_localhost_af_cloud().await
} }

View File

@ -1,14 +1,17 @@
fn main() { fn main() {
let crate_name = env!("CARGO_PKG_NAME");
#[cfg(feature = "dart")] #[cfg(feature = "dart")]
{ {
flowy_codegen::protobuf_file::dart_gen(crate_name); flowy_codegen::protobuf_file::dart_gen(env!("CARGO_PKG_NAME"));
flowy_codegen::dart_event::gen(crate_name); flowy_codegen::dart_event::gen(env!("CARGO_PKG_NAME"));
} }
#[cfg(feature = "ts")] #[cfg(feature = "ts")]
{ {
flowy_codegen::ts_event::gen(crate_name, flowy_codegen::Project::Tauri); flowy_codegen::ts_event::gen(env!("CARGO_PKG_NAME"), flowy_codegen::Project::Tauri);
flowy_codegen::protobuf_file::ts_gen(crate_name, crate_name, flowy_codegen::Project::Tauri); flowy_codegen::protobuf_file::ts_gen(
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_NAME"),
flowy_codegen::Project::Tauri,
);
} }
} }

View File

@ -360,7 +360,7 @@ async fn get_admin_client(client: &Arc<AFCloudClient>) -> FlowyResult<Client> {
client.gotrue_url(), client.gotrue_url(),
&client.device_id, &client.device_id,
ClientConfiguration::default(), ClientConfiguration::default(),
&client.client_id, &client.client_version.to_string(),
); );
admin_client admin_client
.sign_in_password(&admin_email, &admin_password) .sign_in_password(&admin_email, &admin_password)

View File

@ -49,7 +49,7 @@ impl AppFlowyCloudServer {
config: AFCloudConfiguration, config: AFCloudConfiguration,
enable_sync: bool, enable_sync: bool,
mut device_id: String, mut device_id: String,
app_version: &str, client_version: &str,
) -> Self { ) -> Self {
// The device id can't be empty, so we generate a new one if it is. // The device id can't be empty, so we generate a new one if it is.
if device_id.is_empty() { if device_id.is_empty() {
@ -65,7 +65,7 @@ impl AppFlowyCloudServer {
ClientConfiguration::default() ClientConfiguration::default()
.with_compression_buffer_size(10240) .with_compression_buffer_size(10240)
.with_compression_quality(8), .with_compression_quality(8),
app_version, client_version,
); );
let token_state_rx = api_client.subscribe_token_state(); let token_state_rx = api_client.subscribe_token_state();
let enable_sync = Arc::new(AtomicBool::new(enable_sync)); let enable_sync = Arc::new(AtomicBool::new(enable_sync));
@ -75,13 +75,7 @@ impl AppFlowyCloudServer {
let ws_client = Arc::new(ws_client); let ws_client = Arc::new(ws_client);
let api_client = Arc::new(api_client); let api_client = Arc::new(api_client);
spawn_ws_conn( spawn_ws_conn(token_state_rx, &ws_client, &api_client, &enable_sync);
&device_id,
token_state_rx,
&ws_client,
&api_client,
&enable_sync,
);
Self { Self {
config, config,
client: api_client, client: api_client,
@ -240,13 +234,11 @@ impl AppFlowyServer for AppFlowyCloudServer {
/// This function listens to the `token_state_rx` channel for token state updates. Depending on the /// This function listens to the `token_state_rx` channel for token state updates. Depending on the
/// received state, it either refreshes the WebSocket connection or disconnects from it. /// received state, it either refreshes the WebSocket connection or disconnects from it.
fn spawn_ws_conn( fn spawn_ws_conn(
device_id: &String,
mut token_state_rx: TokenStateReceiver, mut token_state_rx: TokenStateReceiver,
ws_client: &Arc<WSClient>, ws_client: &Arc<WSClient>,
api_client: &Arc<Client>, api_client: &Arc<Client>,
enable_sync: &Arc<AtomicBool>, enable_sync: &Arc<AtomicBool>,
) { ) {
let cloned_device_id = device_id.to_owned();
let weak_ws_client = Arc::downgrade(ws_client); let weak_ws_client = Arc::downgrade(ws_client);
let weak_api_client = Arc::downgrade(api_client); let weak_api_client = Arc::downgrade(api_client);
let enable_sync = enable_sync.clone(); let enable_sync = enable_sync.clone();
@ -257,17 +249,17 @@ fn spawn_ws_conn(
while let Ok(state) = state_recv.recv().await { while let Ok(state) = state_recv.recv().await {
info!("[websocket] state: {:?}", state); info!("[websocket] state: {:?}", state);
match state { match state {
ConnectState::PingTimeout | ConnectState::Closed => { ConnectState::PingTimeout | ConnectState::Lost => {
// Try to reconnect if the connection is timed out. // Try to reconnect if the connection is timed out.
if let Some(api_client) = weak_api_client.upgrade() { if let Some(api_client) = weak_api_client.upgrade() {
if enable_sync.load(Ordering::SeqCst) { if enable_sync.load(Ordering::SeqCst) {
match api_client.ws_url(&cloned_device_id).await { match api_client.ws_connect_info().await {
Ok(ws_addr) => { Ok(conn_info) => {
// sleep two seconds and then try to reconnect // sleep two seconds and then try to reconnect
tokio::time::sleep(Duration::from_secs(2)).await; tokio::time::sleep(Duration::from_secs(2)).await;
event!(tracing::Level::INFO, "🟢reconnecting websocket"); event!(tracing::Level::INFO, "🟢reconnecting websocket");
let _ = ws_client.connect(ws_addr, &cloned_device_id).await; let _ = ws_client.connect(&api_client.ws_addr(), conn_info).await;
}, },
Err(err) => error!("Failed to get ws url: {}, connect state:{:?}", err, state), Err(err) => error!("Failed to get ws url: {}, connect state:{:?}", err, state),
} }
@ -287,7 +279,6 @@ fn spawn_ws_conn(
} }
}); });
let device_id = device_id.to_owned();
let weak_ws_client = Arc::downgrade(ws_client); let weak_ws_client = Arc::downgrade(ws_client);
let weak_api_client = Arc::downgrade(api_client); let weak_api_client = Arc::downgrade(api_client);
af_spawn(async move { af_spawn(async move {
@ -298,9 +289,9 @@ fn spawn_ws_conn(
if let (Some(api_client), Some(ws_client)) = if let (Some(api_client), Some(ws_client)) =
(weak_api_client.upgrade(), weak_ws_client.upgrade()) (weak_api_client.upgrade(), weak_ws_client.upgrade())
{ {
match api_client.ws_url(&device_id).await { match api_client.ws_connect_info().await {
Ok(ws_addr) => { Ok(conn_info) => {
let _ = ws_client.connect(ws_addr, &device_id).await; let _ = ws_client.connect(&api_client.ws_addr(), conn_info).await;
}, },
Err(err) => error!("Failed to get ws url: {}", err), Err(err) => error!("Failed to get ws url: {}", err),
} }

View File

@ -116,7 +116,7 @@ pub trait AppFlowyServer: Send + Sync + 'static {
} }
fn get_ws_state(&self) -> ConnectState { fn get_ws_state(&self) -> ConnectState {
ConnectState::Closed ConnectState::Lost
} }
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]

View File

@ -30,7 +30,7 @@ pub fn af_cloud_server(config: AFCloudConfiguration) -> Arc<AppFlowyCloudServer>
config, config,
true, true,
fake_device_id, fake_device_id,
"flowy-server-test", "0.5.1",
)) ))
} }
@ -51,7 +51,7 @@ pub async fn generate_sign_in_url(user_email: &str, config: &AFCloudConfiguratio
client.gotrue_url(), client.gotrue_url(),
"fake_device_id", "fake_device_id",
ClientConfiguration::default(), ClientConfiguration::default(),
&client.client_id, &client.client_version.to_string(),
); );
admin_client admin_client
.sign_in_password(&admin_email, &admin_password) .sign_in_password(&admin_email, &admin_password)

View File

@ -1,7 +1,7 @@
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::{collections::HashMap, fs, io, sync::Arc, time::Duration}; use std::{collections::HashMap, fs, io, sync::Arc, time::Duration};
use chrono::Local; use chrono::{Days, Local};
use collab_integrate::{CollabKVAction, CollabKVDB, PersistenceError}; use collab_integrate::{CollabKVAction, CollabKVDB, PersistenceError};
use collab_plugins::local_storage::kv::KVTransactionDB; use collab_plugins::local_storage::kv::KVTransactionDB;
use flowy_error::FlowyError; use flowy_error::FlowyError;
@ -323,40 +323,46 @@ impl CollabDBZipBackup {
fn clean_old_backups(&self) -> io::Result<()> { fn clean_old_backups(&self) -> io::Result<()> {
let mut backups = Vec::new(); let mut backups = Vec::new();
let threshold_date = Local::now() - chrono::Duration::days(10); let now = Local::now();
match now.checked_sub_days(Days::new(10)) {
// Collect all backup files None => {
for entry in fs::read_dir(&self.history_folder)? { error!("Failed to calculate threshold date");
let entry = entry?; },
let path = entry.path(); Some(threshold_date) => {
if path.is_file() && path.extension().and_then(|s| s.to_str()) == Some("zip") { // Collect all backup files
let filename = path for entry in fs::read_dir(&self.history_folder)? {
.file_stem() let entry = entry?;
.and_then(|s| s.to_str()) let path = entry.path();
.unwrap_or_default(); if path.is_file() && path.extension().and_then(|s| s.to_str()) == Some("zip") {
let date_str = filename.split('_').last().unwrap_or(""); let filename = path
backups.push((date_str.to_string(), path)); .file_stem()
} .and_then(|s| s.to_str())
} .unwrap_or_default();
let date_str = filename.split('_').last().unwrap_or("");
// Sort backups by date (oldest first) backups.push((date_str.to_string(), path));
backups.sort_by(|a, b| a.0.cmp(&b.0)); }
// Remove backups older than 10 days
let threshold_str = threshold_date.format(zip_time_format()).to_string();
info!("Current backup: {:?}", backups.len());
// If there are more than 10 backups, remove the oldest ones
while backups.len() > 10 {
if let Some((date_str, path)) = backups.first() {
if date_str < &threshold_str {
info!("Remove old backup file: {:?}", path);
fs::remove_file(path)?;
backups.remove(0);
} else {
break;
} }
}
// Sort backups by date (oldest first)
backups.sort_by(|a, b| a.0.cmp(&b.0));
// Remove backups older than 10 days
let threshold_str = threshold_date.format(zip_time_format()).to_string();
info!("Current backup: {:?}", backups.len());
// If there are more than 10 backups, remove the oldest ones
while backups.len() > 10 {
if let Some((date_str, path)) = backups.first() {
if date_str < &threshold_str {
info!("Remove old backup file: {:?}", path);
fs::remove_file(path)?;
backups.remove(0);
} else {
break;
}
}
}
},
} }
Ok(()) Ok(())