From efab80c1093a37bc9997cdd32410a6fe9df98739 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Fri, 10 May 2024 00:42:50 +0530 Subject: [PATCH 01/32] feat(wasm): support for NPM and Browser --- Cargo.lock | 23 +++++- Cargo.toml | 4 +- src/lib.rs | 1 + tailcall-query-plan/src/plan.rs | 2 +- tailcall-wasm/Cargo.toml | 24 ++++++ tailcall-wasm/example/browser/index.html | 78 +++++++++++++++++++ tailcall-wasm/example/node/index.js | 45 +++++++++++ tailcall-wasm/example/node/package.json | 22 ++++++ tailcall-wasm/package.json | 11 +++ tailcall-wasm/src/builder.rs | 99 ++++++++++++++++++++++++ tailcall-wasm/src/cache.rs | 30 +++++++ tailcall-wasm/src/env.rs | 23 ++++++ tailcall-wasm/src/file.rs | 32 ++++++++ tailcall-wasm/src/http.rs | 46 +++++++++++ tailcall-wasm/src/js_val.rs | 27 +++++++ tailcall-wasm/src/lib.rs | 61 +++++++++++++++ tailcall-wasm/src/runtime.rs | 40 ++++++++++ 17 files changed, 565 insertions(+), 3 deletions(-) create mode 100644 tailcall-wasm/Cargo.toml create mode 100644 tailcall-wasm/example/browser/index.html create mode 100644 tailcall-wasm/example/node/index.js create mode 100644 tailcall-wasm/example/node/package.json create mode 100644 tailcall-wasm/package.json create mode 100644 tailcall-wasm/src/builder.rs create mode 100644 tailcall-wasm/src/cache.rs create mode 100644 tailcall-wasm/src/env.rs create mode 100644 tailcall-wasm/src/file.rs create mode 100644 tailcall-wasm/src/http.rs create mode 100644 tailcall-wasm/src/js_val.rs create mode 100644 tailcall-wasm/src/lib.rs create mode 100644 tailcall-wasm/src/runtime.rs diff --git a/Cargo.lock b/Cargo.lock index df3b18a596..c6e7dd004b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2251,7 +2251,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.6", "tokio", "tower-service", "tracing", @@ -5272,6 +5272,27 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "tailcall-wasm" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-graphql-value", + "async-std", + "async-trait", + "console_error_panic_hook", + "dashmap", + "hyper 0.14.28", + "reqwest", + "serde_json", + "tailcall", + "tracing", + "tracing-subscriber", + "tracing-subscriber-wasm", + "wasm-bindgen", + "wasm-bindgen-futures", +] + [[package]] name = "tailcall_query_plan" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 36d4dda135..d85c47db36 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -211,7 +211,9 @@ members = [ "tailcall-query-plan", "tailcall-fixtures", "tailcall-upstream-grpc", - "tailcall-tracker"] + "tailcall-tracker", + "tailcall-wasm" +] # Boost execution_spec snapshot diffing performance [profile.dev.package] diff --git a/src/lib.rs b/src/lib.rs index 41eae53292..f445d951e8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,6 +27,7 @@ pub use core::merge_right::MergeRight; pub use core::mustache::Mustache; pub use core::path::PathString; pub use core::print_schema::print_schema; +pub use core::rest::EndpointSet; pub use core::runtime::TargetRuntime; pub use core::scalar::{is_predefined_scalar, CUSTOM_SCALARS}; pub use core::tracing::{ diff --git a/tailcall-query-plan/src/plan.rs b/tailcall-query-plan/src/plan.rs index 85c5d4f5e5..724c9032fd 100644 --- a/tailcall-query-plan/src/plan.rs +++ b/tailcall-query-plan/src/plan.rs @@ -234,7 +234,7 @@ impl FieldTree { if let Some(index) = parent_list_index { list.get(index) } else { - return Err(anyhow!("Expected parent list index")); + return Err(anyhow!("Expected parent list index.html")); } } _ => None, diff --git a/tailcall-wasm/Cargo.toml b/tailcall-wasm/Cargo.toml new file mode 100644 index 0000000000..61357055aa --- /dev/null +++ b/tailcall-wasm/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "tailcall-wasm" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +tailcall = {path = "..", default-features = false} +wasm-bindgen = "0.2.86" +wasm-bindgen-futures = "0.4.42" +anyhow = "1.0.83" +async-trait = "0.1.80" +console_error_panic_hook = "0.1.7" +reqwest = { version = "0.11", default-features = false } +async-std = "1.12.0" +tracing = "0.1.40" +tracing-subscriber = "0.3.18" +tracing-subscriber-wasm = "0.1.0" +hyper = { version = "0.14.28", default-features = false } +dashmap = "5.5.3" +async-graphql-value = "7.0.5" +serde_json = "1.0.117" \ No newline at end of file diff --git a/tailcall-wasm/example/browser/index.html b/tailcall-wasm/example/browser/index.html new file mode 100644 index 0000000000..c8c79c938c --- /dev/null +++ b/tailcall-wasm/example/browser/index.html @@ -0,0 +1,78 @@ + + + + + hello-wasm example + + + +
+ + + +

+
+ + + + diff --git a/tailcall-wasm/example/node/index.js b/tailcall-wasm/example/node/index.js new file mode 100644 index 0000000000..6280fff6ca --- /dev/null +++ b/tailcall-wasm/example/node/index.js @@ -0,0 +1,45 @@ +const tc = require("@tailcallhq/tailcall-node") + +async function run() { + try { + await tc.main() // must call + let schema = + "schema\n" + + ' @server(port: 8000, headers: {cors: {allowOrigins: ["*"], allowHeaders: ["*"], allowMethods: [POST, GET, OPTIONS]}})\n' + + ' @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true, batch: {delay: 100}) {\n' + + " query: Query\n" + + "}\n" + + "\n" + + "type Query {\n" + + ' posts: [Post] @http(path: "/posts")\n' + + ' users: [User] @http(path: "/users")\n' + + ' user(id: Int!): User @http(path: "/users/{{.args.id}}")\n' + + "}\n" + + "\n" + + "type User {\n" + + " id: Int!\n" + + " name: String!\n" + + " username: String!\n" + + " email: String!\n" + + " phone: String\n" + + " website: String\n" + + "}\n" + + "\n" + + "type Post {\n" + + " id: Int!\n" + + " userId: Int!\n" + + " title: String!\n" + + " body: String!\n" + + ' user: User @call(steps: [{query: "user", args: {id: "{{.value.userId}}"}}])\n' + + "}\n" + let builder = new tc.TailcallBuilder() + builder = await builder.with_config("jsonplaceholder.graphql", schema) + let executor = await builder.build() + let result = await executor.execute("{posts { id }}") + console.log("result: " + result) + } catch (error) { + console.error("error: " + error) + } +} + +run() diff --git a/tailcall-wasm/example/node/package.json b/tailcall-wasm/example/node/package.json new file mode 100644 index 0000000000..f71c7e9e77 --- /dev/null +++ b/tailcall-wasm/example/node/package.json @@ -0,0 +1,22 @@ +{ + "name": "example", + "version": "0.1.0", + "description": "Example impl for tc nodejs dependency", + "main": "index.js", + "scripts": { + "run": "node index.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/tailcallhq/tailcall.git" + }, + "author": "Sandipsinh Rathod", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/tailcallhq/tailcall/issues" + }, + "homepage": "https://github.com/tailcallhq/tailcall#readme", + "dependencies": { + "@tailcallhq/tailcall-node": "file:../../node/pkg" + } +} diff --git a/tailcall-wasm/package.json b/tailcall-wasm/package.json new file mode 100644 index 0000000000..4fc8bd1d7f --- /dev/null +++ b/tailcall-wasm/package.json @@ -0,0 +1,11 @@ +{ + "scripts": { + "compile node": "wasm-pack build --release --target nodejs --scope tailcallhq --out-dir ./node/pkg", + "compile browser": "wasm-pack build --release --target web --scope tailcallhq --out-dir ./browser/pkg", + "compile": "npm run compile node && npm run compile browser", + "compile dev node": "wasm-pack build --dev --target nodejs --scope tailcallhq --out-dir ./node/pkg", + "compile dev browser": "wasm-pack build --dev --target web --scope tailcallhq --out-dir ./browser/pkg", + "dev": "npm run compile dev node && npm run compile dev browser", + "publish": "npm run compile node && wasm-pack publish --target nodejs" + } +} diff --git a/tailcall-wasm/src/builder.rs b/tailcall-wasm/src/builder.rs new file mode 100644 index 0000000000..ba5eef8207 --- /dev/null +++ b/tailcall-wasm/src/builder.rs @@ -0,0 +1,99 @@ +use std::sync::Arc; + +use tailcall::{AppContext, Blueprint, ConfigReader, EndpointSet, TargetRuntime}; +use wasm_bindgen::prelude::wasm_bindgen; +use wasm_bindgen::JsValue; + +use crate::env::WasmEnv; +use crate::js_val::JsVal; +use crate::runtime::init_rt; +use crate::TailcallExecutor; + +#[wasm_bindgen] +struct TailcallBuilder { + target_runtime: TargetRuntime, + env: WasmEnv, // TODO + configs: Vec, +} + +#[wasm_bindgen] +impl TailcallBuilder { + #[wasm_bindgen(constructor)] + pub fn init() -> Self { + Self { + target_runtime: init_rt(), + env: WasmEnv::init(), + configs: vec![], + } + } + + pub async fn with_file( + self, + path: String, + content: String, + ) -> Result { + self.with_file_inner(path, content) + .await + .map_err(|e| JsValue::from(e.to_string())) + } + async fn with_file_inner>( + self, + path: String, + content: T, + ) -> anyhow::Result { + self.target_runtime + .file + .write(&path, content.as_ref()) + .await?; + Ok(self) + } + + pub async fn with_config( + self, + path: String, + content: String, + ) -> Result { + self.with_config_inner(path, content) + .await + .map_err(|e| JsValue::from(e.to_string())) + } + + async fn with_config_inner( + mut self, + path: String, + content: String, + ) -> anyhow::Result { + self.target_runtime + .file + .write(&path, content.as_bytes()) + .await?; + self.configs.push(path); + Ok(self) + } + + pub fn with_env(self, key: String, val: String) -> TailcallBuilder { + self.env.set(key, val); + self + } + pub async fn build(self) -> Result { + match self.build_inner().await { + Ok(v) => Ok(v), + Err(e) => Err(JsVal::from(e).into()), + } + } + async fn build_inner(mut self) -> anyhow::Result { + self.target_runtime.env = Arc::new(self.env); + + let reader = ConfigReader::init(self.target_runtime.clone()); + let config_module = reader.read_all(&self.configs).await?; + + let blueprint = Blueprint::try_from(&config_module)?; + let app_context = Arc::new(AppContext::new( + blueprint, + self.target_runtime, + EndpointSet::default(), + )); + + Ok(TailcallExecutor { app_context }) + } +} diff --git a/tailcall-wasm/src/cache.rs b/tailcall-wasm/src/cache.rs new file mode 100644 index 0000000000..c3345a551b --- /dev/null +++ b/tailcall-wasm/src/cache.rs @@ -0,0 +1,30 @@ +use std::num::NonZeroU64; + +use async_graphql_value::ConstValue; +use tailcall::Cache; + +pub struct WasmCache {} + +impl WasmCache { + pub fn init() -> Self { + Self {} + } +} + +#[async_trait::async_trait] +impl Cache for WasmCache { + type Key = u64; + type Value = ConstValue; + + async fn set<'a>(&'a self, _: Self::Key, _: Self::Value, _: NonZeroU64) -> anyhow::Result<()> { + todo!() + } + + async fn get<'a>(&'a self, _: &'a Self::Key) -> anyhow::Result> { + todo!() + } + + fn hit_rate(&self) -> Option { + todo!() + } +} diff --git a/tailcall-wasm/src/env.rs b/tailcall-wasm/src/env.rs new file mode 100644 index 0000000000..09a0d2451b --- /dev/null +++ b/tailcall-wasm/src/env.rs @@ -0,0 +1,23 @@ +use std::borrow::Cow; + +use dashmap::DashMap; +use tailcall::EnvIO; + +pub struct WasmEnv { + env: DashMap, +} + +impl WasmEnv { + pub fn init() -> Self { + Self { env: DashMap::new() } + } + pub fn set(&self, key: String, value: String) { + self.env.insert(key, value); + } +} + +impl EnvIO for WasmEnv { + fn get(&self, key: &str) -> Option> { + self.env.get(key).map(|v| Cow::Owned(v.value().clone())) + } +} diff --git a/tailcall-wasm/src/file.rs b/tailcall-wasm/src/file.rs new file mode 100644 index 0000000000..753b1f2674 --- /dev/null +++ b/tailcall-wasm/src/file.rs @@ -0,0 +1,32 @@ +use anyhow::anyhow; +use dashmap::DashMap; +use tailcall::FileIO; + +pub struct WasmFile { + files: DashMap, +} + +impl WasmFile { + pub fn init() -> Self { + Self { files: DashMap::new() } + } +} + +#[async_trait::async_trait] +impl FileIO for WasmFile { + async fn write<'a>(&'a self, path: &'a str, content: &'a [u8]) -> anyhow::Result<()> { + self.files + .insert(path.to_string(), String::from_utf8(content.to_vec())?); + Ok(()) + } + + async fn read<'a>(&'a self, path: &'a str) -> anyhow::Result { + let content = self + .files + .get(path) + .ok_or(anyhow!("File not found"))? + .value() + .clone(); + Ok(content) + } +} diff --git a/tailcall-wasm/src/http.rs b/tailcall-wasm/src/http.rs new file mode 100644 index 0000000000..d775c64657 --- /dev/null +++ b/tailcall-wasm/src/http.rs @@ -0,0 +1,46 @@ +use anyhow::Result; +use async_std::task::spawn_local; +use hyper::body::Bytes; +use reqwest::Client; +use tailcall::{HttpIO, Response}; + +#[derive(Clone)] +pub struct WasmHttp { + client: Client, +} + +impl Default for WasmHttp { + fn default() -> Self { + Self { client: Client::new() } + } +} + +impl WasmHttp { + pub fn init() -> Self { + let client = Client::new(); + Self { client } + } +} + +#[async_trait::async_trait] +impl HttpIO for WasmHttp { + // HttpClientOptions are ignored in Cloudflare + // This is because there is little control over the underlying HTTP client + async fn execute(&self, request: reqwest::Request) -> Result> { + let client = self.client.clone(); + let method = request.method().clone(); + let url = request.url().clone(); + // TODO: remove spawn local + let res = spawn_local(async move { + let response = client + .execute(request) + .await? + .error_for_status() + .map_err(|err| err.without_url())?; + Response::from_reqwest(response).await + }) + .await?; + tracing::info!("{} {} {}", method, url, res.status.as_u16()); + Ok(res) + } +} diff --git a/tailcall-wasm/src/js_val.rs b/tailcall-wasm/src/js_val.rs new file mode 100644 index 0000000000..3f90cbcf2f --- /dev/null +++ b/tailcall-wasm/src/js_val.rs @@ -0,0 +1,27 @@ +use wasm_bindgen::JsValue; + +pub struct JsVal(JsValue); + +impl From for JsValue { + fn from(value: JsVal) -> Self { + value.0 + } +} + +impl From for JsVal { + fn from(value: JsValue) -> Self { + JsVal(value) + } +} + +impl From for JsVal { + fn from(value: String) -> Self { + JsVal(JsValue::from_str(value.as_str())) + } +} + +impl From for JsVal { + fn from(value: anyhow::Error) -> Self { + JsVal(JsValue::from_str(value.to_string().as_str())) + } +} diff --git a/tailcall-wasm/src/lib.rs b/tailcall-wasm/src/lib.rs new file mode 100644 index 0000000000..8d38dad814 --- /dev/null +++ b/tailcall-wasm/src/lib.rs @@ -0,0 +1,61 @@ +#![allow(unused)] + +use std::sync::Arc; + +use serde_json::json; +use tailcall::{handle_request, AppContext, GraphQLRequest}; +use wasm_bindgen::prelude::wasm_bindgen; +use wasm_bindgen::JsValue; + +use crate::js_val::JsVal; + +mod builder; +mod cache; +mod env; +mod file; +mod http; +mod js_val; +mod runtime; + +#[wasm_bindgen] +struct TailcallExecutor { + app_context: Arc, +} + +#[wasm_bindgen] +impl TailcallExecutor { + pub async fn execute(&self, query: String) -> Result { + let result = self.execute_inner(query).await; + match result { + Ok(val) => Ok(JsVal::from(val).into()), + Err(err) => Err(JsVal::from(err).into()), + } + } + async fn execute_inner(&self, query: String) -> anyhow::Result { + let body = json!({"query":query}).to_string(); + let req = + hyper::Request::post("http://fake.host/graphql").body(hyper::body::Body::from(body))?; + + let resp = handle_request::(req, self.app_context.clone()).await?; + tracing::debug!("{:#?}", resp); + + let body_bytes = hyper::body::to_bytes(resp.into_body()).await?; + let body_str = String::from_utf8(body_bytes.to_vec())?; + Ok(body_str) + } +} + +#[wasm_bindgen(start)] +fn main() { + console_error_panic_hook::set_once(); + /* tracing_subscriber::fmt() + .with_writer( + // To avoid trace events in the browser from showing their JS backtrace + tracing_subscriber_wasm::MakeConsoleWriter::default() + .map_trace_level_to(tracing::Level::DEBUG), + ) + // For some reason, if we don't do this in the browser, we get + // a runtime error. + .without_time() + .init();*/ +} diff --git a/tailcall-wasm/src/runtime.rs b/tailcall-wasm/src/runtime.rs new file mode 100644 index 0000000000..195c1cd204 --- /dev/null +++ b/tailcall-wasm/src/runtime.rs @@ -0,0 +1,40 @@ +use std::sync::Arc; + +use tailcall::{EnvIO, FileIO, HttpIO, TargetRuntime}; + +use crate::cache::WasmCache; +use crate::env::WasmEnv; +use crate::file::WasmFile; +use crate::http::WasmHttp; + +fn init_http() -> Arc { + Arc::new(WasmHttp::init()) +} + +fn init_file() -> Arc { + Arc::new(WasmFile::init()) +} + +fn init_env() -> Arc { + Arc::new(WasmEnv::init()) +} + +fn init_cache() -> Arc { + Arc::new(WasmCache::init()) +} + +pub fn init_rt() -> TargetRuntime { + let http = init_http(); + let http2_only = init_http(); + let file = init_file(); + let env = init_env(); + let cache = init_cache(); + TargetRuntime { + http, + http2_only, + env, + file, + cache, + extensions: Arc::new(vec![]), + } +} From b8914c9cfd42d30c2f9fbb9b56f83b08152debb4 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Fri, 10 May 2024 00:45:48 +0530 Subject: [PATCH 02/32] undo accidental change --- tailcall-query-plan/src/plan.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tailcall-query-plan/src/plan.rs b/tailcall-query-plan/src/plan.rs index 724c9032fd..85c5d4f5e5 100644 --- a/tailcall-query-plan/src/plan.rs +++ b/tailcall-query-plan/src/plan.rs @@ -234,7 +234,7 @@ impl FieldTree { if let Some(index) = parent_list_index { list.get(index) } else { - return Err(anyhow!("Expected parent list index.html")); + return Err(anyhow!("Expected parent list index")); } } _ => None, From 569b6f1eb5b5c5c5e4b4ecde6048e122897a17b9 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Fri, 10 May 2024 01:08:47 +0530 Subject: [PATCH 03/32] cleanup example --- Cargo.lock | 1 + tailcall-wasm/Cargo.toml | 3 +- tailcall-wasm/example/browser/index.html | 36 ++++-------------------- tailcall-wasm/example/node/index.js | 30 +------------------- tailcall-wasm/package.json | 6 ++-- tailcall-wasm/src/builder.rs | 14 +++++---- 6 files changed, 20 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c6e7dd004b..6f311a2936 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5289,6 +5289,7 @@ dependencies = [ "tracing", "tracing-subscriber", "tracing-subscriber-wasm", + "url", "wasm-bindgen", "wasm-bindgen-futures", ] diff --git a/tailcall-wasm/Cargo.toml b/tailcall-wasm/Cargo.toml index 61357055aa..b815e7affa 100644 --- a/tailcall-wasm/Cargo.toml +++ b/tailcall-wasm/Cargo.toml @@ -21,4 +21,5 @@ tracing-subscriber-wasm = "0.1.0" hyper = { version = "0.14.28", default-features = false } dashmap = "5.5.3" async-graphql-value = "7.0.5" -serde_json = "1.0.117" \ No newline at end of file +serde_json = "1.0.117" +url = "2.5.0" \ No newline at end of file diff --git a/tailcall-wasm/example/browser/index.html b/tailcall-wasm/example/browser/index.html index c8c79c938c..b8c04fd99c 100644 --- a/tailcall-wasm/example/browser/index.html +++ b/tailcall-wasm/example/browser/index.html @@ -21,40 +21,14 @@ async function setup() { try { - let schema = - "schema\n" + - ' @server(port: 8000, headers: {cors: {allowOrigins: ["*"], allowHeaders: ["*"], allowMethods: [POST, GET, OPTIONS]}})\n' + - ' @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true, batch: {delay: 100}) {\n' + - " query: Query\n" + - "}\n" + - "\n" + - "type Query {\n" + - ' posts: [Post] @http(path: "/posts")\n' + - ' users: [User] @http(path: "/users")\n' + - ' user(id: Int!): User @http(path: "/users/{{.args.id}}")\n' + - "}\n" + - "\n" + - "type User {\n" + - " id: Int!\n" + - " name: String!\n" + - " username: String!\n" + - " email: String!\n" + - " phone: String\n" + - " website: String\n" + - "}\n" + - "\n" + - "type Post {\n" + - " id: Int!\n" + - " userId: Int!\n" + - " title: String!\n" + - " body: String!\n" + - ' user: User @call(steps: [{query: "user", args: {id: "{{.value.userId}}"}}])\n' + - "}\n"; + const urlParams = new URLSearchParams(window.location.search); + let schemaUrl = urlParams.get("config"); + let builder = new TailcallBuilder(); - builder = await builder.with_config("jsonplaceholder.graphql", schema); + builder = await builder.with_config("jsonplaceholder.graphql", schemaUrl); executor = await builder.build(); } catch (error) { - console.error("error: " + error); + alert("error: " + error); } } diff --git a/tailcall-wasm/example/node/index.js b/tailcall-wasm/example/node/index.js index 6280fff6ca..66bc79c9b3 100644 --- a/tailcall-wasm/example/node/index.js +++ b/tailcall-wasm/example/node/index.js @@ -3,35 +3,7 @@ const tc = require("@tailcallhq/tailcall-node") async function run() { try { await tc.main() // must call - let schema = - "schema\n" + - ' @server(port: 8000, headers: {cors: {allowOrigins: ["*"], allowHeaders: ["*"], allowMethods: [POST, GET, OPTIONS]}})\n' + - ' @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true, batch: {delay: 100}) {\n' + - " query: Query\n" + - "}\n" + - "\n" + - "type Query {\n" + - ' posts: [Post] @http(path: "/posts")\n' + - ' users: [User] @http(path: "/users")\n' + - ' user(id: Int!): User @http(path: "/users/{{.args.id}}")\n' + - "}\n" + - "\n" + - "type User {\n" + - " id: Int!\n" + - " name: String!\n" + - " username: String!\n" + - " email: String!\n" + - " phone: String\n" + - " website: String\n" + - "}\n" + - "\n" + - "type Post {\n" + - " id: Int!\n" + - " userId: Int!\n" + - " title: String!\n" + - " body: String!\n" + - ' user: User @call(steps: [{query: "user", args: {id: "{{.value.userId}}"}}])\n' + - "}\n" + let schema = "https://raw.githubusercontent.com/tailcallhq/tailcall/main/examples/jsonplaceholder.graphql" let builder = new tc.TailcallBuilder() builder = await builder.with_config("jsonplaceholder.graphql", schema) let executor = await builder.build() diff --git a/tailcall-wasm/package.json b/tailcall-wasm/package.json index 4fc8bd1d7f..13d6607dd6 100644 --- a/tailcall-wasm/package.json +++ b/tailcall-wasm/package.json @@ -2,10 +2,8 @@ "scripts": { "compile node": "wasm-pack build --release --target nodejs --scope tailcallhq --out-dir ./node/pkg", "compile browser": "wasm-pack build --release --target web --scope tailcallhq --out-dir ./browser/pkg", - "compile": "npm run compile node && npm run compile browser", - "compile dev node": "wasm-pack build --dev --target nodejs --scope tailcallhq --out-dir ./node/pkg", - "compile dev browser": "wasm-pack build --dev --target web --scope tailcallhq --out-dir ./browser/pkg", - "dev": "npm run compile dev node && npm run compile dev browser", + "dev node": "wasm-pack build --dev --target nodejs --scope tailcallhq --out-dir ./node/pkg", + "dev browser": "wasm-pack build --dev --target web --scope tailcallhq --out-dir ./browser/pkg", "publish": "npm run compile node && wasm-pack publish --target nodejs" } } diff --git a/tailcall-wasm/src/builder.rs b/tailcall-wasm/src/builder.rs index ba5eef8207..f4a3b96aef 100644 --- a/tailcall-wasm/src/builder.rs +++ b/tailcall-wasm/src/builder.rs @@ -63,11 +63,15 @@ impl TailcallBuilder { path: String, content: String, ) -> anyhow::Result { - self.target_runtime - .file - .write(&path, content.as_bytes()) - .await?; - self.configs.push(path); + if url::Url::parse(&content).is_ok() { + self.configs.push(content); + } else { + self.target_runtime + .file + .write(&path, content.as_bytes()) + .await?; + self.configs.push(path); + } Ok(self) } From c7e6af8726391dd1a168a4a1cac4a865ef242f8c Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Fri, 10 May 2024 10:05:28 +0530 Subject: [PATCH 04/32] fix log --- tailcall-wasm/example/node/index.js | 1 - tailcall-wasm/src/lib.rs | 22 ++++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tailcall-wasm/example/node/index.js b/tailcall-wasm/example/node/index.js index 66bc79c9b3..9b1f932396 100644 --- a/tailcall-wasm/example/node/index.js +++ b/tailcall-wasm/example/node/index.js @@ -2,7 +2,6 @@ const tc = require("@tailcallhq/tailcall-node") async function run() { try { - await tc.main() // must call let schema = "https://raw.githubusercontent.com/tailcallhq/tailcall/main/examples/jsonplaceholder.graphql" let builder = new tc.TailcallBuilder() builder = await builder.with_config("jsonplaceholder.graphql", schema) diff --git a/tailcall-wasm/src/lib.rs b/tailcall-wasm/src/lib.rs index 8d38dad814..237a4349e2 100644 --- a/tailcall-wasm/src/lib.rs +++ b/tailcall-wasm/src/lib.rs @@ -1,5 +1,6 @@ #![allow(unused)] +use std::panic; use std::sync::Arc; use serde_json::json; @@ -48,14 +49,15 @@ impl TailcallExecutor { #[wasm_bindgen(start)] fn main() { console_error_panic_hook::set_once(); - /* tracing_subscriber::fmt() - .with_writer( - // To avoid trace events in the browser from showing their JS backtrace - tracing_subscriber_wasm::MakeConsoleWriter::default() - .map_trace_level_to(tracing::Level::DEBUG), - ) - // For some reason, if we don't do this in the browser, we get - // a runtime error. - .without_time() - .init();*/ + + tracing_subscriber::fmt() + .with_writer( + // To avoid trace events in the browser from showing their JS backtrace + tracing_subscriber_wasm::MakeConsoleWriter::default() + .map_trace_level_to(tracing::Level::DEBUG), + ) + // For some reason, if we don't do this in the browser, we get + // a runtime error. + .without_time() + .init(); } From 8d10713470214683bebeb0843c96f3b9711e8e05 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Fri, 10 May 2024 10:50:36 +0530 Subject: [PATCH 05/32] add tests --- .github/workflows/ci.yml | 21 +++++++++++++++++- Cargo.lock | 32 ++++++++++++++++++++++++++++ tailcall-wasm/.cargo/config | 5 +++++ tailcall-wasm/Cargo.toml | 7 ++++-- tailcall-wasm/src/builder.rs | 2 +- tailcall-wasm/src/lib.rs | 41 ++++++++++++++++++++++++++++++++++-- 6 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 tailcall-wasm/.cargo/config diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f8d54bc51..772f975532 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,9 +58,28 @@ jobs: - name: Build run: cargo lambda build - test_cf: + test_wasm: name: Run Tests (WASM) runs-on: ubuntu-latest + defaults: + run: + working-directory: ./tailcall-wasm + steps: + - uses: actions/checkout@v4 + - name: Install Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + target: wasm32-unknown-unknown + + - name: Install Wasm Pack + run: cargo install wasm-bindgen-cli --vers "0.2.92" + + - name: Test WASM + run: cargo test + + test_cf: + name: Run Tests (Cloudflare) + runs-on: ubuntu-latest defaults: run: working-directory: ./tailcall-cloudflare diff --git a/Cargo.lock b/Cargo.lock index 6f311a2936..d6e477fcbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4503,6 +4503,12 @@ dependencies = [ "syn 2.0.61", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.2.0" @@ -5292,6 +5298,7 @@ dependencies = [ "url", "wasm-bindgen", "wasm-bindgen-futures", + "wasm-bindgen-test", ] [[package]] @@ -6110,6 +6117,31 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +[[package]] +name = "wasm-bindgen-test" +version = "0.3.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9bf62a58e0780af3e852044583deee40983e5886da43a271dd772379987667b" +dependencies = [ + "console_error_panic_hook", + "js-sys", + "scoped-tls", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" +dependencies = [ + "proc-macro2 1.0.82", + "quote 1.0.36", + "syn 2.0.61", +] + [[package]] name = "wasm-streams" version = "0.4.0" diff --git a/tailcall-wasm/.cargo/config b/tailcall-wasm/.cargo/config new file mode 100644 index 0000000000..b409bc6f2c --- /dev/null +++ b/tailcall-wasm/.cargo/config @@ -0,0 +1,5 @@ +[target.wasm32-unknown-unknown] +runner = 'wasm-bindgen-test-runner' + +[build] +target = "wasm32-unknown-unknown" \ No newline at end of file diff --git a/tailcall-wasm/Cargo.toml b/tailcall-wasm/Cargo.toml index b815e7affa..588e9d7d98 100644 --- a/tailcall-wasm/Cargo.toml +++ b/tailcall-wasm/Cargo.toml @@ -8,7 +8,7 @@ crate-type = ["cdylib"] [dependencies] tailcall = {path = "..", default-features = false} -wasm-bindgen = "0.2.86" +wasm-bindgen = "0.2.92" wasm-bindgen-futures = "0.4.42" anyhow = "1.0.83" async-trait = "0.1.80" @@ -22,4 +22,7 @@ hyper = { version = "0.14.28", default-features = false } dashmap = "5.5.3" async-graphql-value = "7.0.5" serde_json = "1.0.117" -url = "2.5.0" \ No newline at end of file +url = "2.5.0" + +[dev-dependencies] +wasm-bindgen-test = "0.3.42" \ No newline at end of file diff --git a/tailcall-wasm/src/builder.rs b/tailcall-wasm/src/builder.rs index f4a3b96aef..9be5c9575d 100644 --- a/tailcall-wasm/src/builder.rs +++ b/tailcall-wasm/src/builder.rs @@ -10,7 +10,7 @@ use crate::runtime::init_rt; use crate::TailcallExecutor; #[wasm_bindgen] -struct TailcallBuilder { +pub struct TailcallBuilder { target_runtime: TargetRuntime, env: WasmEnv, // TODO configs: Vec, diff --git a/tailcall-wasm/src/lib.rs b/tailcall-wasm/src/lib.rs index 237a4349e2..ae2dc5938b 100644 --- a/tailcall-wasm/src/lib.rs +++ b/tailcall-wasm/src/lib.rs @@ -19,7 +19,7 @@ mod js_val; mod runtime; #[wasm_bindgen] -struct TailcallExecutor { +pub struct TailcallExecutor { app_context: Arc, } @@ -47,7 +47,7 @@ impl TailcallExecutor { } #[wasm_bindgen(start)] -fn main() { +fn start() { console_error_panic_hook::set_once(); tracing_subscriber::fmt() @@ -61,3 +61,40 @@ fn main() { .without_time() .init(); } + +#[cfg(test)] +mod tests { + use std::collections::HashMap; + + use anyhow::anyhow; + use serde_json::{json, Value}; + use wasm_bindgen_test::wasm_bindgen_test; + + const CONFIG: &str = r#" + schema @server(port: 8000) { + query: Query + } + + type Query { + hello: String! @expr(body: "Alo") + } + "#; + + #[wasm_bindgen_test] + async fn test_fetch() { + super::start(); + let executor = super::builder::TailcallBuilder::init() + .with_config("hello.graphql".to_string(), CONFIG.to_string()) + .await + .unwrap() + .build() + .await + .unwrap(); + let response = executor + .execute("query { hello }".to_string()) + .await + .unwrap(); + let value: Value = serde_json::from_str(&response.as_string().unwrap()).unwrap(); + assert_eq!(value, json!({"data": {"hello": "Alo"}})); + } +} From fda4ab825c0ea685142dd661a0f73bfdd66c8de8 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Fri, 10 May 2024 10:57:41 +0530 Subject: [PATCH 06/32] make WASM test mandatory for release --- .github/workflows/ci.yml | 5 +---- tailcall-wasm/.cargo/{config => config.toml} | 0 tailcall-wasm/src/lib.rs | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) rename tailcall-wasm/.cargo/{config => config.toml} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 772f975532..857ac21446 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,9 +92,6 @@ jobs: with: target: wasm32-unknown-unknown - - name: Build WASM - run: cargo check --lib --target wasm32-unknown-unknown - working-directory: ./tailcall-cloudflare - name: Install Node.js uses: actions/setup-node@v4 with: @@ -249,7 +246,7 @@ jobs: # TODO: move to separate file to separate responsibilities release: name: Release - needs: [test, draft_release, check_if_build, test_cf] + needs: [test, draft_release, check_if_build, test_cf, test_wasm] # TODO: put a condition to separate job that other will depend on to remove duplication? if: github.event_name == 'push' && github.ref == 'refs/heads/main' && (needs.check_if_build.outputs.check_if_build == 'true') runs-on: ${{ matrix.os }} diff --git a/tailcall-wasm/.cargo/config b/tailcall-wasm/.cargo/config.toml similarity index 100% rename from tailcall-wasm/.cargo/config rename to tailcall-wasm/.cargo/config.toml diff --git a/tailcall-wasm/src/lib.rs b/tailcall-wasm/src/lib.rs index ae2dc5938b..a37fc5160e 100644 --- a/tailcall-wasm/src/lib.rs +++ b/tailcall-wasm/src/lib.rs @@ -81,7 +81,7 @@ mod tests { "#; #[wasm_bindgen_test] - async fn test_fetch() { + async fn test() { super::start(); let executor = super::builder::TailcallBuilder::init() .with_config("hello.graphql".to_string(), CONFIG.to_string()) From 953046ffdf90b6ac87a805216b3f3c8182e06b1a Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Fri, 10 May 2024 11:19:07 +0530 Subject: [PATCH 07/32] miscellaneous --- Cargo.lock | 15 ++++++++++++--- tailcall-wasm/example/browser/index.html | 3 +-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6e477fcbf..8c13681e5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2500,6 +2500,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -3523,7 +3532,7 @@ dependencies = [ "bincode", "either", "fnv", - "itertools 0.11.0", + "itertools 0.12.1", "lazy_static", "nom", "quick-xml", @@ -3775,7 +3784,7 @@ checksum = "80b776a1b2dc779f5ee0641f8ade0125bc1298dd41a9a0c16d8bd57b42d222b1" dependencies = [ "bytes", "heck 0.5.0", - "itertools 0.11.0", + "itertools 0.12.1", "log", "multimap", "once_cell", @@ -3795,7 +3804,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" dependencies = [ "anyhow", - "itertools 0.11.0", + "itertools 0.12.1", "proc-macro2 1.0.82", "quote 1.0.36", "syn 2.0.61", diff --git a/tailcall-wasm/example/browser/index.html b/tailcall-wasm/example/browser/index.html index b8c04fd99c..178083d204 100644 --- a/tailcall-wasm/example/browser/index.html +++ b/tailcall-wasm/example/browser/index.html @@ -35,8 +35,7 @@ async function runQuery() { let query = document.getElementById("queryInput").value; try { - let result = await executor.execute(query); - document.getElementById("result").textContent = result; + document.getElementById("result").textContent = await executor.execute(query); } catch (error) { console.error("Error executing query: " + error); document.getElementById("result").textContent = "Error: " + error; From 885852da753833016400afa5257a449f3ca9ad46 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Fri, 10 May 2024 13:25:45 +0530 Subject: [PATCH 08/32] fix wasm build --- Cargo.lock | 74 ++++++++++++++++++++++++++++++------ Cargo.toml | 2 +- tailcall-wasm/Cargo.toml | 3 +- tailcall-wasm/src/cache.rs | 30 --------------- tailcall-wasm/src/lib.rs | 1 - tailcall-wasm/src/runtime.rs | 8 ++-- 6 files changed, 69 insertions(+), 49 deletions(-) delete mode 100644 tailcall-wasm/src/cache.rs diff --git a/Cargo.lock b/Cargo.lock index 8c13681e5b..5097be0a4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1074,7 +1074,7 @@ dependencies = [ "crossterm_winapi", "libc", "mio", - "parking_lot", + "parking_lot 0.12.1", "signal-hook", "signal-hook-mio", "winapi", @@ -1201,7 +1201,7 @@ dependencies = [ "hashbrown 0.14.3", "lock_api", "once_cell", - "parking_lot_core", + "parking_lot_core 0.9.9", ] [[package]] @@ -3025,7 +3025,7 @@ dependencies = [ "event-listener 5.3.0", "futures-util", "once_cell", - "parking_lot", + "parking_lot 0.12.1", "quanta", "rustc_version", "smallvec", @@ -3392,6 +3392,17 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.6", +] + [[package]] name = "parking_lot" version = "0.12.1" @@ -3399,7 +3410,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core", + "parking_lot_core 0.9.9", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall 0.2.16", + "smallvec", + "winapi", ] [[package]] @@ -3410,7 +3435,7 @@ checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.4.1", "smallvec", "windows-targets 0.48.5", ] @@ -3761,7 +3786,7 @@ dependencies = [ "fnv", "lazy_static", "memchr", - "parking_lot", + "parking_lot 0.12.1", "protobuf 2.28.0", "thiserror", ] @@ -4096,6 +4121,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.4.1" @@ -4892,7 +4926,7 @@ checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" dependencies = [ "new_debug_unreachable", "once_cell", - "parking_lot", + "parking_lot 0.12.1", "phf_shared 0.10.0", "precomputed-hash", ] @@ -5308,6 +5342,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test", + "wasm-timer", ] [[package]] @@ -5342,7 +5377,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96374855068f47402c3121c6eed88d29cb1de8f3ab27090e273e420bdabcf050" dependencies = [ - "parking_lot", + "parking_lot 0.12.1", ] [[package]] @@ -5492,7 +5527,7 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot", + "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", "socket2 0.5.6", @@ -5859,10 +5894,10 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "ttl_cache" version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4189890526f0168710b6ee65ceaedf1460c48a14318ceec933cb26baa492096a" +source = "git+https://github.com/ssddOnTop/ttl_cache/?branch=chore/drop-since#7840c9e5dfa5916adf2ea12fed4e593c5565333d" dependencies = [ "linked-hash-map", + "wasm-timer", ] [[package]] @@ -6164,6 +6199,21 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wasm-timer" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" +dependencies = [ + "futures", + "js-sys", + "parking_lot 0.11.2", + "pin-utils", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "web-sys" version = "0.3.69" @@ -6220,7 +6270,7 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" dependencies = [ - "redox_syscall", + "redox_syscall 0.4.1", "wasite", "web-sys", ] diff --git a/Cargo.toml b/Cargo.toml index d85c47db36..cf60084f95 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,7 +89,7 @@ async-std = { version = "1.12.0", features = [ "wasm-bindgen-futures", "unstable", ] } -ttl_cache = { version = "0.5.1", features = ["stats"] } +ttl_cache = { git = "https://github.com/ssddOnTop/ttl_cache/", branch = "chore/drop-since", features = ["stats"] } protox = "0.6.0" protox-parse = "0.6.0" prost-reflect = { version = "0.13.1", features = ["serde"] } diff --git a/tailcall-wasm/Cargo.toml b/tailcall-wasm/Cargo.toml index 588e9d7d98..19374c0e42 100644 --- a/tailcall-wasm/Cargo.toml +++ b/tailcall-wasm/Cargo.toml @@ -25,4 +25,5 @@ serde_json = "1.0.117" url = "2.5.0" [dev-dependencies] -wasm-bindgen-test = "0.3.42" \ No newline at end of file +wasm-bindgen-test = "0.3.42" +wasm-timer = "0.2.5" \ No newline at end of file diff --git a/tailcall-wasm/src/cache.rs b/tailcall-wasm/src/cache.rs deleted file mode 100644 index c3345a551b..0000000000 --- a/tailcall-wasm/src/cache.rs +++ /dev/null @@ -1,30 +0,0 @@ -use std::num::NonZeroU64; - -use async_graphql_value::ConstValue; -use tailcall::Cache; - -pub struct WasmCache {} - -impl WasmCache { - pub fn init() -> Self { - Self {} - } -} - -#[async_trait::async_trait] -impl Cache for WasmCache { - type Key = u64; - type Value = ConstValue; - - async fn set<'a>(&'a self, _: Self::Key, _: Self::Value, _: NonZeroU64) -> anyhow::Result<()> { - todo!() - } - - async fn get<'a>(&'a self, _: &'a Self::Key) -> anyhow::Result> { - todo!() - } - - fn hit_rate(&self) -> Option { - todo!() - } -} diff --git a/tailcall-wasm/src/lib.rs b/tailcall-wasm/src/lib.rs index a37fc5160e..f24485eaab 100644 --- a/tailcall-wasm/src/lib.rs +++ b/tailcall-wasm/src/lib.rs @@ -11,7 +11,6 @@ use wasm_bindgen::JsValue; use crate::js_val::JsVal; mod builder; -mod cache; mod env; mod file; mod http; diff --git a/tailcall-wasm/src/runtime.rs b/tailcall-wasm/src/runtime.rs index 195c1cd204..7750ac4a81 100644 --- a/tailcall-wasm/src/runtime.rs +++ b/tailcall-wasm/src/runtime.rs @@ -1,8 +1,8 @@ use std::sync::Arc; -use tailcall::{EnvIO, FileIO, HttpIO, TargetRuntime}; +use async_graphql_value::ConstValue; +use tailcall::{EnvIO, FileIO, HttpIO, InMemoryCache, TargetRuntime}; -use crate::cache::WasmCache; use crate::env::WasmEnv; use crate::file::WasmFile; use crate::http::WasmHttp; @@ -19,8 +19,8 @@ fn init_env() -> Arc { Arc::new(WasmEnv::init()) } -fn init_cache() -> Arc { - Arc::new(WasmCache::init()) +fn init_cache() -> Arc> { + Arc::new(InMemoryCache::new()) } pub fn init_rt() -> TargetRuntime { From 36070dad985f7ed0d22d39cb59e6073e2d994dd5 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Fri, 10 May 2024 13:27:43 +0530 Subject: [PATCH 09/32] update repo --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5097be0a4d..c494c705f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5894,7 +5894,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "ttl_cache" version = "0.5.1" -source = "git+https://github.com/ssddOnTop/ttl_cache/?branch=chore/drop-since#7840c9e5dfa5916adf2ea12fed4e593c5565333d" +source = "git+https://github.com/tailcallhq/ttl_cache/?branch=chore/drop-since#7840c9e5dfa5916adf2ea12fed4e593c5565333d" dependencies = [ "linked-hash-map", "wasm-timer", diff --git a/Cargo.toml b/Cargo.toml index cf60084f95..d0d7dcd458 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,7 +89,7 @@ async-std = { version = "1.12.0", features = [ "wasm-bindgen-futures", "unstable", ] } -ttl_cache = { git = "https://github.com/ssddOnTop/ttl_cache/", branch = "chore/drop-since", features = ["stats"] } +ttl_cache = { git = "https://github.com/tailcallhq/ttl_cache/", branch = "chore/drop-since", features = ["stats"] } protox = "0.6.0" protox-parse = "0.6.0" prost-reflect = { version = "0.13.1", features = ["serde"] } From c186623c2d0e28cf9663383b731abd0ec3cbb5ef Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Fri, 10 May 2024 16:33:24 +0530 Subject: [PATCH 10/32] clean example --- tailcall-wasm/example/browser/index.html | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tailcall-wasm/example/browser/index.html b/tailcall-wasm/example/browser/index.html index 178083d204..74551a54cd 100644 --- a/tailcall-wasm/example/browser/index.html +++ b/tailcall-wasm/example/browser/index.html @@ -27,11 +27,12 @@ let builder = new TailcallBuilder(); builder = await builder.with_config("jsonplaceholder.graphql", schemaUrl); executor = await builder.build(); + let btn = document.getElementById("btn"); + btn.addEventListener("click", runQuery); } catch (error) { alert("error: " + error); } } - async function runQuery() { let query = document.getElementById("queryInput").value; try { @@ -42,10 +43,6 @@ } } setup(); - - let btn = document.getElementById("btn"); - btn.addEventListener("click", runQuery); - From 9d79f9ff9475ad3962b7c998c5929a63b9eb701d Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Fri, 10 May 2024 16:44:21 +0530 Subject: [PATCH 11/32] some cleanups --- tailcall-wasm/src/builder.rs | 16 ++++------------ tailcall-wasm/src/js_val.rs | 27 --------------------------- tailcall-wasm/src/lib.rs | 14 ++++++-------- 3 files changed, 10 insertions(+), 47 deletions(-) delete mode 100644 tailcall-wasm/src/js_val.rs diff --git a/tailcall-wasm/src/builder.rs b/tailcall-wasm/src/builder.rs index 9be5c9575d..f45b4f8540 100644 --- a/tailcall-wasm/src/builder.rs +++ b/tailcall-wasm/src/builder.rs @@ -5,9 +5,8 @@ use wasm_bindgen::prelude::wasm_bindgen; use wasm_bindgen::JsValue; use crate::env::WasmEnv; -use crate::js_val::JsVal; use crate::runtime::init_rt; -use crate::TailcallExecutor; +use crate::{to_val, TailcallExecutor}; #[wasm_bindgen] pub struct TailcallBuilder { @@ -32,9 +31,7 @@ impl TailcallBuilder { path: String, content: String, ) -> Result { - self.with_file_inner(path, content) - .await - .map_err(|e| JsValue::from(e.to_string())) + self.with_file_inner(path, content).await.map_err(to_val) } async fn with_file_inner>( self, @@ -53,9 +50,7 @@ impl TailcallBuilder { path: String, content: String, ) -> Result { - self.with_config_inner(path, content) - .await - .map_err(|e| JsValue::from(e.to_string())) + self.with_config_inner(path, content).await.map_err(to_val) } async fn with_config_inner( @@ -80,10 +75,7 @@ impl TailcallBuilder { self } pub async fn build(self) -> Result { - match self.build_inner().await { - Ok(v) => Ok(v), - Err(e) => Err(JsVal::from(e).into()), - } + self.build_inner().await.map_err(to_val) } async fn build_inner(mut self) -> anyhow::Result { self.target_runtime.env = Arc::new(self.env); diff --git a/tailcall-wasm/src/js_val.rs b/tailcall-wasm/src/js_val.rs deleted file mode 100644 index 3f90cbcf2f..0000000000 --- a/tailcall-wasm/src/js_val.rs +++ /dev/null @@ -1,27 +0,0 @@ -use wasm_bindgen::JsValue; - -pub struct JsVal(JsValue); - -impl From for JsValue { - fn from(value: JsVal) -> Self { - value.0 - } -} - -impl From for JsVal { - fn from(value: JsValue) -> Self { - JsVal(value) - } -} - -impl From for JsVal { - fn from(value: String) -> Self { - JsVal(JsValue::from_str(value.as_str())) - } -} - -impl From for JsVal { - fn from(value: anyhow::Error) -> Self { - JsVal(JsValue::from_str(value.to_string().as_str())) - } -} diff --git a/tailcall-wasm/src/lib.rs b/tailcall-wasm/src/lib.rs index f24485eaab..3d595085f9 100644 --- a/tailcall-wasm/src/lib.rs +++ b/tailcall-wasm/src/lib.rs @@ -1,5 +1,6 @@ #![allow(unused)] +use std::fmt::Display; use std::panic; use std::sync::Arc; @@ -8,13 +9,10 @@ use tailcall::{handle_request, AppContext, GraphQLRequest}; use wasm_bindgen::prelude::wasm_bindgen; use wasm_bindgen::JsValue; -use crate::js_val::JsVal; - mod builder; mod env; mod file; mod http; -mod js_val; mod runtime; #[wasm_bindgen] @@ -25,11 +23,7 @@ pub struct TailcallExecutor { #[wasm_bindgen] impl TailcallExecutor { pub async fn execute(&self, query: String) -> Result { - let result = self.execute_inner(query).await; - match result { - Ok(val) => Ok(JsVal::from(val).into()), - Err(err) => Err(JsVal::from(err).into()), - } + self.execute_inner(query).await.map(to_val).map_err(to_val) } async fn execute_inner(&self, query: String) -> anyhow::Result { let body = json!({"query":query}).to_string(); @@ -61,6 +55,10 @@ fn start() { .init(); } +pub fn to_val(val: T) -> JsValue { + JsValue::from(val.to_string()) +} + #[cfg(test)] mod tests { use std::collections::HashMap; From 8a7f9bfbfe21e840c11636293ec86215e86e5e6f Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Sat, 11 May 2024 11:54:22 +0530 Subject: [PATCH 12/32] drop using ttl_cache fork --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/core/cache.rs | 22 ++++++++++++++++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c494c705f0..f08bedba10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5894,10 +5894,10 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "ttl_cache" version = "0.5.1" -source = "git+https://github.com/tailcallhq/ttl_cache/?branch=chore/drop-since#7840c9e5dfa5916adf2ea12fed4e593c5565333d" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4189890526f0168710b6ee65ceaedf1460c48a14318ceec933cb26baa492096a" dependencies = [ "linked-hash-map", - "wasm-timer", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d0d7dcd458..6435f870fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,7 +89,7 @@ async-std = { version = "1.12.0", features = [ "wasm-bindgen-futures", "unstable", ] } -ttl_cache = { git = "https://github.com/tailcallhq/ttl_cache/", branch = "chore/drop-since", features = ["stats"] } +ttl_cache = "0.5.1" protox = "0.6.0" protox-parse = "0.6.0" prost-reflect = { version = "0.13.1", features = ["serde"] } diff --git a/src/core/cache.rs b/src/core/cache.rs index 4dadc80808..a2022b25f4 100644 --- a/src/core/cache.rs +++ b/src/core/cache.rs @@ -1,5 +1,6 @@ use std::hash::Hash; use std::num::NonZeroU64; +use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Arc, RwLock}; use std::time::Duration; @@ -7,6 +8,8 @@ use ttl_cache::TtlCache; pub struct InMemoryCache { data: Arc>>, + hits: AtomicUsize, + miss: AtomicUsize, } // TODO: take this from the user instead of hardcoding it @@ -20,7 +23,11 @@ impl Default for InMemoryCache { impl InMemoryCache { pub fn new() -> Self { - InMemoryCache { data: Arc::new(RwLock::new(TtlCache::new(CACHE_CAPACITY))) } + InMemoryCache { + data: Arc::new(RwLock::new(TtlCache::new(CACHE_CAPACITY))), + hits: AtomicUsize::new(0), + miss: AtomicUsize::new(0), + } } } @@ -38,13 +45,20 @@ impl crate::core::Cache } async fn get<'a>(&'a self, key: &'a K) -> anyhow::Result> { - Ok(self.data.read().unwrap().get(key).cloned()) + let val = self.data.read().unwrap().get(key).cloned(); + if val.is_some() { + self.hits.fetch_add(1, Ordering::Relaxed); + } else { + self.miss.fetch_add(1, Ordering::Relaxed); + } + Ok(val) } fn hit_rate(&self) -> Option { let cache = self.data.read().unwrap(); - let hits = cache.hit_count(); - let misses = cache.miss_count(); + let hits = self.hits.load(Ordering::Relaxed); + let misses = self.miss.load(Ordering::Relaxed); + drop(cache); if hits + misses > 0 { From 57b0787aaf9bcddbd8e0ce50f0eb161eb4cb8861 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Sat, 11 May 2024 13:43:09 +0530 Subject: [PATCH 13/32] add README.md to `tailcall-wasm` --- tailcall-wasm/README.md | 67 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tailcall-wasm/README.md diff --git a/tailcall-wasm/README.md b/tailcall-wasm/README.md new file mode 100644 index 0000000000..19a095200d --- /dev/null +++ b/tailcall-wasm/README.md @@ -0,0 +1,67 @@ +# Tailcall for Nodejs and Browser + +It is a simple library that allows you to execute graphql queries on Broswr and Nodejs. + +# Setup + +Go to tailcall-wasm dir + +```bash +cd tailcall-wasm +``` + +The [package.json](package.json) file contains the scripts to run the project. + +## Nodejs (locally) + +For test build: + +```bash +npm run dev node # compiles in debug mode +``` + +For release build: + +```bash +npm run compile node # compiles in release mode with optimizations +``` + +By default, the output is in the `node` folder. + +Now to run the example [index.js](example/node/index.js) file: + +```bash +cd example/node && node index.js +``` + +## Browser + +For test build: + +```bash +npm run dev browser # compiles in debug mode +``` + +For release build: + +```bash +npm run compile browser # compiles in release mode with optimizations +``` + +By default, the output is in the `browser` folder. + +Now to run the example [index.html](example/browser/index.html) file: + +Run simple http server in `tailcall-wasm` dir: + +```bash +python3 -m http.server 8000 +``` + +To run the example, open the browser and go to `http://localhost:/example/browser/?config=` + +For example: + +http://localhost:8000/example/browser/?config=https://raw.githubusercontent.com/tailcallhq/tailcall/main/examples/jsonplaceholder.graphql + +Make sure to run the http server in `tailcall-wasm` dir because it imports the compiled WASM files from a relative path to `browser` folder. From d0f6403e6f7b5c17ba544da51b1174fe6c683c89 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Sat, 11 May 2024 13:47:20 +0530 Subject: [PATCH 14/32] update readme --- tailcall-wasm/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tailcall-wasm/README.md b/tailcall-wasm/README.md index 19a095200d..063f0a3842 100644 --- a/tailcall-wasm/README.md +++ b/tailcall-wasm/README.md @@ -17,13 +17,13 @@ The [package.json](package.json) file contains the scripts to run the project. For test build: ```bash -npm run dev node # compiles in debug mode +npm run "dev node" # compiles in debug mode ``` For release build: ```bash -npm run compile node # compiles in release mode with optimizations +npm run "compile node" # compiles in release mode with optimizations ``` By default, the output is in the `node` folder. @@ -39,13 +39,13 @@ cd example/node && node index.js For test build: ```bash -npm run dev browser # compiles in debug mode +npm run "dev browser" # compiles in debug mode ``` For release build: ```bash -npm run compile browser # compiles in release mode with optimizations +npm run "compile browser" # compiles in release mode with optimizations ``` By default, the output is in the `browser` folder. From bb06061fa1ad29f3f4ae2d48f35b808d9c5fe160 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Sat, 11 May 2024 20:19:27 +0530 Subject: [PATCH 15/32] drop unused crate --- Cargo.lock | 70 ++++++---------------------------------- tailcall-wasm/Cargo.toml | 1 - 2 files changed, 10 insertions(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f08bedba10..8c13681e5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1074,7 +1074,7 @@ dependencies = [ "crossterm_winapi", "libc", "mio", - "parking_lot 0.12.1", + "parking_lot", "signal-hook", "signal-hook-mio", "winapi", @@ -1201,7 +1201,7 @@ dependencies = [ "hashbrown 0.14.3", "lock_api", "once_cell", - "parking_lot_core 0.9.9", + "parking_lot_core", ] [[package]] @@ -3025,7 +3025,7 @@ dependencies = [ "event-listener 5.3.0", "futures-util", "once_cell", - "parking_lot 0.12.1", + "parking_lot", "quanta", "rustc_version", "smallvec", @@ -3392,17 +3392,6 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" -[[package]] -name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core 0.8.6", -] - [[package]] name = "parking_lot" version = "0.12.1" @@ -3410,21 +3399,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.9", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" -dependencies = [ - "cfg-if", - "instant", - "libc", - "redox_syscall 0.2.16", - "smallvec", - "winapi", + "parking_lot_core", ] [[package]] @@ -3435,7 +3410,7 @@ checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.4.1", + "redox_syscall", "smallvec", "windows-targets 0.48.5", ] @@ -3786,7 +3761,7 @@ dependencies = [ "fnv", "lazy_static", "memchr", - "parking_lot 0.12.1", + "parking_lot", "protobuf 2.28.0", "thiserror", ] @@ -4121,15 +4096,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.4.1" @@ -4926,7 +4892,7 @@ checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" dependencies = [ "new_debug_unreachable", "once_cell", - "parking_lot 0.12.1", + "parking_lot", "phf_shared 0.10.0", "precomputed-hash", ] @@ -5342,7 +5308,6 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test", - "wasm-timer", ] [[package]] @@ -5377,7 +5342,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96374855068f47402c3121c6eed88d29cb1de8f3ab27090e273e420bdabcf050" dependencies = [ - "parking_lot 0.12.1", + "parking_lot", ] [[package]] @@ -5527,7 +5492,7 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot 0.12.1", + "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2 0.5.6", @@ -6199,21 +6164,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "wasm-timer" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" -dependencies = [ - "futures", - "js-sys", - "parking_lot 0.11.2", - "pin-utils", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "web-sys" version = "0.3.69" @@ -6270,7 +6220,7 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" dependencies = [ - "redox_syscall 0.4.1", + "redox_syscall", "wasite", "web-sys", ] diff --git a/tailcall-wasm/Cargo.toml b/tailcall-wasm/Cargo.toml index 19374c0e42..14465abb1e 100644 --- a/tailcall-wasm/Cargo.toml +++ b/tailcall-wasm/Cargo.toml @@ -26,4 +26,3 @@ url = "2.5.0" [dev-dependencies] wasm-bindgen-test = "0.3.42" -wasm-timer = "0.2.5" \ No newline at end of file From 348d5fd4296271710a6ecee3694f8aeeab0985d7 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Sat, 11 May 2024 20:19:42 +0530 Subject: [PATCH 16/32] drop unused crate --- tailcall-wasm/src/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tailcall-wasm/src/builder.rs b/tailcall-wasm/src/builder.rs index f45b4f8540..1b8e7e93a9 100644 --- a/tailcall-wasm/src/builder.rs +++ b/tailcall-wasm/src/builder.rs @@ -11,7 +11,7 @@ use crate::{to_val, TailcallExecutor}; #[wasm_bindgen] pub struct TailcallBuilder { target_runtime: TargetRuntime, - env: WasmEnv, // TODO + env: WasmEnv, configs: Vec, } From 9b4361f676812cb298332203d1c8f63cdd68f6de Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Sat, 18 May 2024 09:39:31 +0530 Subject: [PATCH 17/32] fix tests --- Cargo.lock | 2 +- tailcall-wasm/src/builder.rs | 6 +++++- tailcall-wasm/src/env.rs | 2 +- tailcall-wasm/src/file.rs | 2 +- tailcall-wasm/src/http.rs | 3 ++- tailcall-wasm/src/lib.rs | 3 ++- tailcall-wasm/src/runtime.rs | 4 +++- 7 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eaa362f728..0eba2cad85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6146,7 +6146,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2 1.0.82", "quote 1.0.36", - "syn 2.0.61", + "syn 2.0.64", ] [[package]] diff --git a/tailcall-wasm/src/builder.rs b/tailcall-wasm/src/builder.rs index 1b8e7e93a9..009cb05a74 100644 --- a/tailcall-wasm/src/builder.rs +++ b/tailcall-wasm/src/builder.rs @@ -1,6 +1,10 @@ use std::sync::Arc; -use tailcall::{AppContext, Blueprint, ConfigReader, EndpointSet, TargetRuntime}; +use tailcall::core::blueprint::Blueprint; +use tailcall::core::config::reader::ConfigReader; +use tailcall::core::http::AppContext; +use tailcall::core::rest::EndpointSet; +use tailcall::core::runtime::TargetRuntime; use wasm_bindgen::prelude::wasm_bindgen; use wasm_bindgen::JsValue; diff --git a/tailcall-wasm/src/env.rs b/tailcall-wasm/src/env.rs index 09a0d2451b..604041cae0 100644 --- a/tailcall-wasm/src/env.rs +++ b/tailcall-wasm/src/env.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use dashmap::DashMap; -use tailcall::EnvIO; +use tailcall::core::EnvIO; pub struct WasmEnv { env: DashMap, diff --git a/tailcall-wasm/src/file.rs b/tailcall-wasm/src/file.rs index 753b1f2674..b00bbe45e1 100644 --- a/tailcall-wasm/src/file.rs +++ b/tailcall-wasm/src/file.rs @@ -1,6 +1,6 @@ use anyhow::anyhow; use dashmap::DashMap; -use tailcall::FileIO; +use tailcall::core::FileIO; pub struct WasmFile { files: DashMap, diff --git a/tailcall-wasm/src/http.rs b/tailcall-wasm/src/http.rs index d775c64657..296a95aa6d 100644 --- a/tailcall-wasm/src/http.rs +++ b/tailcall-wasm/src/http.rs @@ -2,7 +2,8 @@ use anyhow::Result; use async_std::task::spawn_local; use hyper::body::Bytes; use reqwest::Client; -use tailcall::{HttpIO, Response}; +use tailcall::core::http::Response; +use tailcall::core::HttpIO; #[derive(Clone)] pub struct WasmHttp { diff --git a/tailcall-wasm/src/lib.rs b/tailcall-wasm/src/lib.rs index 3d595085f9..975c2a7b53 100644 --- a/tailcall-wasm/src/lib.rs +++ b/tailcall-wasm/src/lib.rs @@ -5,7 +5,8 @@ use std::panic; use std::sync::Arc; use serde_json::json; -use tailcall::{handle_request, AppContext, GraphQLRequest}; +use tailcall::core::async_graphql_hyper::GraphQLRequest; +use tailcall::core::http::{handle_request, AppContext}; use wasm_bindgen::prelude::wasm_bindgen; use wasm_bindgen::JsValue; diff --git a/tailcall-wasm/src/runtime.rs b/tailcall-wasm/src/runtime.rs index 7750ac4a81..af4d6ca64a 100644 --- a/tailcall-wasm/src/runtime.rs +++ b/tailcall-wasm/src/runtime.rs @@ -1,7 +1,9 @@ use std::sync::Arc; use async_graphql_value::ConstValue; -use tailcall::{EnvIO, FileIO, HttpIO, InMemoryCache, TargetRuntime}; +use tailcall::core::cache::InMemoryCache; +use tailcall::core::runtime::TargetRuntime; +use tailcall::core::{EnvIO, FileIO, HttpIO}; use crate::env::WasmEnv; use crate::file::WasmFile; From 2362b3d7b6091daf54e023b676666afb62bf8c4d Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Thu, 23 May 2024 19:40:59 +0530 Subject: [PATCH 18/32] merge --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f567cb6c6..42a628dc34 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6250,9 +6250,9 @@ version = "0.3.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] From 62de817d0b1d490d1a05ea8c6d0392a4fa0a4a71 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Thu, 23 May 2024 20:14:14 +0530 Subject: [PATCH 19/32] change commands --- tailcall-wasm/README.md | 94 ++++++++++++++++++++++++++++++++++---- tailcall-wasm/package.json | 10 ++-- 2 files changed, 89 insertions(+), 15 deletions(-) diff --git a/tailcall-wasm/README.md b/tailcall-wasm/README.md index 063f0a3842..f25492fddf 100644 --- a/tailcall-wasm/README.md +++ b/tailcall-wasm/README.md @@ -4,26 +4,35 @@ It is a simple library that allows you to execute graphql queries on Broswr and # Setup +## Install (npm) + +```shell +npm i @tailcallhq/tailcall-wasm +``` + +## Local setup + +````bash Go to tailcall-wasm dir ```bash cd tailcall-wasm -``` +```` The [package.json](package.json) file contains the scripts to run the project. -## Nodejs (locally) +## Nodejs For test build: ```bash -npm run "dev node" # compiles in debug mode +npm run "dev-node" # compiles in debug mode ``` For release build: ```bash -npm run "compile node" # compiles in release mode with optimizations +npm run "compile-node" # compiles in release mode with optimizations ``` By default, the output is in the `node` folder. @@ -39,13 +48,13 @@ cd example/node && node index.js For test build: ```bash -npm run "dev browser" # compiles in debug mode +npm run "dev-browser" # compiles in debug mode ``` For release build: ```bash -npm run "compile browser" # compiles in release mode with optimizations +npm run "compile-browser" # compiles in release mode with optimizations ``` By default, the output is in the `browser` folder. @@ -58,10 +67,75 @@ Run simple http server in `tailcall-wasm` dir: python3 -m http.server 8000 ``` -To run the example, open the browser and go to `http://localhost:/example/browser/?config=` +# Example -For example: +### NodeJS -http://localhost:8000/example/browser/?config=https://raw.githubusercontent.com/tailcallhq/tailcall/main/examples/jsonplaceholder.graphql +```javascript +const tc = require("@tailcallhq/tailcall-node") -Make sure to run the http server in `tailcall-wasm` dir because it imports the compiled WASM files from a relative path to `browser` folder. +async function run() { + try { + let schema = "https://raw.githubusercontent.com/tailcallhq/tailcall/main/examples/jsonplaceholder.graphql" + let builder = new tc.TailcallBuilder() + builder = await builder.with_config("jsonplaceholder.graphql", schema) + let executor = await builder.build() + let result = await executor.execute("{posts { id }}") + console.log("result: " + result) + } catch (error) { + console.error("error: " + error) + } +} + +run() +``` + +### Browser + +```html + + + + + hello-wasm example + + +
+ + +

+
+ + + + +``` diff --git a/tailcall-wasm/package.json b/tailcall-wasm/package.json index 13d6607dd6..989c14e517 100644 --- a/tailcall-wasm/package.json +++ b/tailcall-wasm/package.json @@ -1,9 +1,9 @@ { "scripts": { - "compile node": "wasm-pack build --release --target nodejs --scope tailcallhq --out-dir ./node/pkg", - "compile browser": "wasm-pack build --release --target web --scope tailcallhq --out-dir ./browser/pkg", - "dev node": "wasm-pack build --dev --target nodejs --scope tailcallhq --out-dir ./node/pkg", - "dev browser": "wasm-pack build --dev --target web --scope tailcallhq --out-dir ./browser/pkg", - "publish": "npm run compile node && wasm-pack publish --target nodejs" + "compile-node": "wasm-pack build --release --target nodejs --scope tailcallhq --out-dir ./node/pkg", + "compile-browser": "wasm-pack build --release --target web --scope tailcallhq --out-dir ./browser/pkg", + "dev-node": "wasm-pack build --dev --target nodejs --scope tailcallhq --out-dir ./node/pkg", + "dev-browser": "wasm-pack build --dev --target web --scope tailcallhq --out-dir ./browser/pkg", + "publish": "npm run compile-node && wasm-pack publish --target nodejs" } } From af0b7305abbfc3a40104cb4685cf931c961b2d04 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Thu, 23 May 2024 20:29:02 +0530 Subject: [PATCH 20/32] test npm publish --- .github/workflows/ci.yml | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a21c51ee00..154d23847c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -479,7 +479,7 @@ jobs: publish_npm_root: name: Publish NPM main package needs: [draft_release, release] - if: (startsWith(github.event.head_commit.message, 'feat') || startsWith(github.event.head_commit.message, 'fix')) && (github.event_name == 'push' && github.ref == 'refs/heads/main') + # if: (startsWith(github.event.head_commit.message, 'feat') || startsWith(github.event.head_commit.message, 'fix')) && (github.event_name == 'push' && github.ref == 'refs/heads/main') runs-on: ubuntu-latest steps: - name: Checkout Current Branch (Fast) @@ -489,28 +489,19 @@ jobs: with: node-version: 20.11.0 registry-url: https://registry.npmjs.org + - name: Setup .npmrc file to publish to npm + run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc - name: Install dependencies run: | - cd npm + cd tailcall-wasm npm install - - name: Run generate-root.js script + - name: Run publish script env: - APP_VERSION: ${{needs.draft_release.outputs.create_release_name }} - run: | - cd npm - npm run gen-root -- --version ${{ env.APP_VERSION }} - - name: Setup .npmrc file to publish to npm - run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" > ~/.npmrc - - name: Publish packages - uses: JS-DevTools/npm-publish@v3 - with: - token: ${{ secrets.NPM_TOKEN }} - package: npm/@tailcallhq/tailcall - access: public - - env: - APP_VERSION: ${{needs.draft_release.outputs.create_release_name }} + APP_VERSION: ${{ needs.draft_release.outputs.create_release_name }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + cd tailcall-wasm + npm run publish build-and-push-image: env: From 85988db4e9f1266aca5ab63bf004256f856fb39d Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Fri, 24 May 2024 12:21:34 +0530 Subject: [PATCH 21/32] drop if statement --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 154d23847c..1d2de15cd7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -479,7 +479,7 @@ jobs: publish_npm_root: name: Publish NPM main package needs: [draft_release, release] - # if: (startsWith(github.event.head_commit.message, 'feat') || startsWith(github.event.head_commit.message, 'fix')) && (github.event_name == 'push' && github.ref == 'refs/heads/main') + if: (startsWith(github.event.head_commit.message, 'feat') || startsWith(github.event.head_commit.message, 'fix')) && (github.event_name == 'push' && github.ref == 'refs/heads/main') runs-on: ubuntu-latest steps: - name: Checkout Current Branch (Fast) From 927017be861e06aa042f35a2881e222d2d70d500 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Fri, 24 May 2024 14:25:48 +0530 Subject: [PATCH 22/32] drop `.cargo/cargo.toml` --- .github/workflows/ci.yml | 2 +- tailcall-wasm/.cargo/config.toml | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 tailcall-wasm/.cargo/config.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d2de15cd7..d99ccd6a4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,7 +75,7 @@ jobs: run: cargo install wasm-bindgen-cli --vers "0.2.92" - name: Test WASM - run: cargo test + run: wasm-pack test --node test_cf: name: Run Tests (Cloudflare) diff --git a/tailcall-wasm/.cargo/config.toml b/tailcall-wasm/.cargo/config.toml deleted file mode 100644 index b409bc6f2c..0000000000 --- a/tailcall-wasm/.cargo/config.toml +++ /dev/null @@ -1,5 +0,0 @@ -[target.wasm32-unknown-unknown] -runner = 'wasm-bindgen-test-runner' - -[build] -target = "wasm32-unknown-unknown" \ No newline at end of file From ea94de41619be9506882f583460c47ad6024e8c5 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Fri, 24 May 2024 14:28:50 +0530 Subject: [PATCH 23/32] fix ci --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d99ccd6a4a..215a2940ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,7 +75,9 @@ jobs: run: cargo install wasm-bindgen-cli --vers "0.2.92" - name: Test WASM - run: wasm-pack test --node + run: | + cargo install wasm-pack + wasm-pack test --node test_cf: name: Run Tests (Cloudflare) From 941f6f5fffd053ca3792a9179cd7f0119cacad6d Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Tue, 28 May 2024 09:31:38 +0530 Subject: [PATCH 24/32] merge --- Cargo.lock | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 900fcebfbb..b192202fb7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4507,6 +4507,12 @@ dependencies = [ "syn 2.0.65", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.2.0" @@ -5304,6 +5310,29 @@ dependencies = [ name = "tailcall-version" version = "0.1.0" +[[package]] +name = "tailcall-wasm" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-graphql-value", + "async-std", + "async-trait", + "console_error_panic_hook", + "dashmap", + "hyper 0.14.28", + "reqwest", + "serde_json", + "tailcall", + "tracing", + "tracing-subscriber", + "tracing-subscriber-wasm", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test", +] + [[package]] name = "tailcall_query_plan" version = "0.1.0" @@ -6113,6 +6142,31 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +[[package]] +name = "wasm-bindgen-test" +version = "0.3.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9bf62a58e0780af3e852044583deee40983e5886da43a271dd772379987667b" +dependencies = [ + "console_error_panic_hook", + "js-sys", + "scoped-tls", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.65", +] + [[package]] name = "wasm-streams" version = "0.4.0" From becb8cf33098ab64913d0e77ba30086e7fec439e Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Mon, 3 Jun 2024 12:41:35 +0530 Subject: [PATCH 25/32] drop file support --- src/core/resource_reader.rs | 2 +- tailcall-wasm/src/builder.rs | 130 +++++++++++++++++++++-------------- tailcall-wasm/src/file.rs | 18 ++--- tailcall-wasm/src/lib.rs | 37 ---------- tailcall-wasm/src/runtime.rs | 2 + 5 files changed, 85 insertions(+), 104 deletions(-) diff --git a/src/core/resource_reader.rs b/src/core/resource_reader.rs index 770fbda457..43b93180d4 100644 --- a/src/core/resource_reader.rs +++ b/src/core/resource_reader.rs @@ -25,7 +25,7 @@ impl ResourceReader { ) -> anyhow::Result> { let files = files.iter().map(|x| { self.read_file(x.to_string()) - .map_err(|e| e.context(x.to_string())) + .map_err(|e| anyhow::anyhow!("{}", e)) }); let content = join_all(files) .await diff --git a/tailcall-wasm/src/builder.rs b/tailcall-wasm/src/builder.rs index 009cb05a74..d0b44f79bc 100644 --- a/tailcall-wasm/src/builder.rs +++ b/tailcall-wasm/src/builder.rs @@ -2,7 +2,9 @@ use std::sync::Arc; use tailcall::core::blueprint::Blueprint; use tailcall::core::config::reader::ConfigReader; +use tailcall::core::config::ConfigModule; use tailcall::core::http::AppContext; +use tailcall::core::merge_right::MergeRight; use tailcall::core::rest::EndpointSet; use tailcall::core::runtime::TargetRuntime; use wasm_bindgen::prelude::wasm_bindgen; @@ -14,62 +16,33 @@ use crate::{to_val, TailcallExecutor}; #[wasm_bindgen] pub struct TailcallBuilder { - target_runtime: TargetRuntime, + reader: ConfigReader, + rt: TargetRuntime, env: WasmEnv, - configs: Vec, + module: ConfigModule, } #[wasm_bindgen] impl TailcallBuilder { #[wasm_bindgen(constructor)] pub fn init() -> Self { - Self { - target_runtime: init_rt(), - env: WasmEnv::init(), - configs: vec![], - } + Self::init_inner(init_rt()) } - pub async fn with_file( - self, - path: String, - content: String, - ) -> Result { - self.with_file_inner(path, content).await.map_err(to_val) - } - async fn with_file_inner>( - self, - path: String, - content: T, - ) -> anyhow::Result { - self.target_runtime - .file - .write(&path, content.as_ref()) - .await?; - Ok(self) + fn init_inner(rt: TargetRuntime) -> Self { + let reader = ConfigReader::init(rt.clone()); + Self { rt, reader, module: Default::default(), env: WasmEnv::init() } } - pub async fn with_config( - self, - path: String, - content: String, - ) -> Result { - self.with_config_inner(path, content).await.map_err(to_val) + pub async fn with_config(self, path: String) -> Result { + self.with_config_inner(path).await.map_err(to_val) } - async fn with_config_inner( - mut self, - path: String, - content: String, - ) -> anyhow::Result { - if url::Url::parse(&content).is_ok() { - self.configs.push(content); + async fn with_config_inner(mut self, url: String) -> anyhow::Result { + if url::Url::parse(&url).is_ok() { + self.module = self.module.merge_right(self.reader.read(url).await?); } else { - self.target_runtime - .file - .write(&path, content.as_bytes()) - .await?; - self.configs.push(path); + return Err(anyhow::anyhow!("Config can only be loaded over URL")); } Ok(self) } @@ -82,18 +55,71 @@ impl TailcallBuilder { self.build_inner().await.map_err(to_val) } async fn build_inner(mut self) -> anyhow::Result { - self.target_runtime.env = Arc::new(self.env); + self.rt.env = Arc::new(self.env); - let reader = ConfigReader::init(self.target_runtime.clone()); - let config_module = reader.read_all(&self.configs).await?; - - let blueprint = Blueprint::try_from(&config_module)?; - let app_context = Arc::new(AppContext::new( - blueprint, - self.target_runtime, - EndpointSet::default(), - )); + let blueprint = Blueprint::try_from(&self.module)?; + let app_context = Arc::new(AppContext::new(blueprint, self.rt, EndpointSet::default())); Ok(TailcallExecutor { app_context }) } } + +#[cfg(test)] +mod tests { + use std::collections::HashMap; + use std::sync::Arc; + + use anyhow::anyhow; + use hyper::body::Bytes; + use reqwest::Request; + use serde_json::{json, Value}; + use tailcall::core::http::Response; + use tailcall::core::HttpIO; + use wasm_bindgen_test::wasm_bindgen_test; + + use crate::runtime::init_rt; + + struct MockHttp {} + + const CONFIG: &str = r#" + schema @server(port: 8000) { + query: Query + } + + type Query { + hello: String! @expr(body: "Alo") + } + "#; + + #[async_trait::async_trait] + impl HttpIO for MockHttp { + async fn execute(&self, request: Request) -> anyhow::Result> { + let resp = tailcall::core::http::Response::empty(); + match request.url().path() { + "/hello.graphql" => Ok(resp.body(Bytes::from(CONFIG))), + _ => Ok(resp), + } + } + } + + #[wasm_bindgen_test] + async fn test() { + crate::start(); + let mut rt = init_rt(); + rt.http = Arc::new(MockHttp {}); + let builder = super::TailcallBuilder::init_inner(rt); + let executor = builder + .with_config("http://fake.host/hello.graphql".to_string()) + .await + .unwrap() + .build() + .await + .unwrap(); + let response = executor + .execute("query { hello }".to_string()) + .await + .unwrap(); + let value: Value = serde_json::from_str(&response.as_string().unwrap()).unwrap(); + assert_eq!(value, json!({"data": {"hello": "Alo"}})); + } +} diff --git a/tailcall-wasm/src/file.rs b/tailcall-wasm/src/file.rs index b00bbe45e1..6f6648bb3e 100644 --- a/tailcall-wasm/src/file.rs +++ b/tailcall-wasm/src/file.rs @@ -2,31 +2,21 @@ use anyhow::anyhow; use dashmap::DashMap; use tailcall::core::FileIO; -pub struct WasmFile { - files: DashMap, -} +pub struct WasmFile {} impl WasmFile { pub fn init() -> Self { - Self { files: DashMap::new() } + Self {} } } #[async_trait::async_trait] impl FileIO for WasmFile { async fn write<'a>(&'a self, path: &'a str, content: &'a [u8]) -> anyhow::Result<()> { - self.files - .insert(path.to_string(), String::from_utf8(content.to_vec())?); - Ok(()) + Err(anyhow::anyhow!("File IO is not supported")) } async fn read<'a>(&'a self, path: &'a str) -> anyhow::Result { - let content = self - .files - .get(path) - .ok_or(anyhow!("File not found"))? - .value() - .clone(); - Ok(content) + Err(anyhow::anyhow!("File IO is not supported")) } } diff --git a/tailcall-wasm/src/lib.rs b/tailcall-wasm/src/lib.rs index 975c2a7b53..874ec9fc14 100644 --- a/tailcall-wasm/src/lib.rs +++ b/tailcall-wasm/src/lib.rs @@ -59,40 +59,3 @@ fn start() { pub fn to_val(val: T) -> JsValue { JsValue::from(val.to_string()) } - -#[cfg(test)] -mod tests { - use std::collections::HashMap; - - use anyhow::anyhow; - use serde_json::{json, Value}; - use wasm_bindgen_test::wasm_bindgen_test; - - const CONFIG: &str = r#" - schema @server(port: 8000) { - query: Query - } - - type Query { - hello: String! @expr(body: "Alo") - } - "#; - - #[wasm_bindgen_test] - async fn test() { - super::start(); - let executor = super::builder::TailcallBuilder::init() - .with_config("hello.graphql".to_string(), CONFIG.to_string()) - .await - .unwrap() - .build() - .await - .unwrap(); - let response = executor - .execute("query { hello }".to_string()) - .await - .unwrap(); - let value: Value = serde_json::from_str(&response.as_string().unwrap()).unwrap(); - assert_eq!(value, json!({"data": {"hello": "Alo"}})); - } -} diff --git a/tailcall-wasm/src/runtime.rs b/tailcall-wasm/src/runtime.rs index af4d6ca64a..fd0cd0b6a5 100644 --- a/tailcall-wasm/src/runtime.rs +++ b/tailcall-wasm/src/runtime.rs @@ -38,5 +38,7 @@ pub fn init_rt() -> TargetRuntime { file, cache, extensions: Arc::new(vec![]), + http_worker: None, + worker: None, } } From f24d3360c68c2c27771ff490caa48a92cdda4b22 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Mon, 3 Jun 2024 12:47:14 +0530 Subject: [PATCH 26/32] fix example --- Cargo.lock | 2 +- tailcall-wasm/example/browser/index.html | 2 +- tailcall-wasm/example/node/index.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d89128914..0dfcac6618 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6208,7 +6208,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] diff --git a/tailcall-wasm/example/browser/index.html b/tailcall-wasm/example/browser/index.html index 74551a54cd..a9cacc5cf1 100644 --- a/tailcall-wasm/example/browser/index.html +++ b/tailcall-wasm/example/browser/index.html @@ -25,7 +25,7 @@ let schemaUrl = urlParams.get("config"); let builder = new TailcallBuilder(); - builder = await builder.with_config("jsonplaceholder.graphql", schemaUrl); + builder = await builder.with_config(schemaUrl); executor = await builder.build(); let btn = document.getElementById("btn"); btn.addEventListener("click", runQuery); diff --git a/tailcall-wasm/example/node/index.js b/tailcall-wasm/example/node/index.js index 9b1f932396..01d4228536 100644 --- a/tailcall-wasm/example/node/index.js +++ b/tailcall-wasm/example/node/index.js @@ -4,7 +4,7 @@ async function run() { try { let schema = "https://raw.githubusercontent.com/tailcallhq/tailcall/main/examples/jsonplaceholder.graphql" let builder = new tc.TailcallBuilder() - builder = await builder.with_config("jsonplaceholder.graphql", schema) + builder = await builder.with_config(schema) let executor = await builder.build() let result = await executor.execute("{posts { id }}") console.log("result: " + result) From 4622063a7a4a43e5148e0625cae1619cb9465da5 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Mon, 10 Jun 2024 00:35:53 +0530 Subject: [PATCH 27/32] fix build --- Cargo.lock | 2 +- tailcall-wasm/src/runtime.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a7d476d2d0..594e7f644a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5346,7 +5346,7 @@ dependencies = [ "async-trait", "console_error_panic_hook", "dashmap", - "hyper 0.14.28", + "hyper 0.14.29", "reqwest", "serde_json", "tailcall", diff --git a/tailcall-wasm/src/runtime.rs b/tailcall-wasm/src/runtime.rs index fd0cd0b6a5..e22b881532 100644 --- a/tailcall-wasm/src/runtime.rs +++ b/tailcall-wasm/src/runtime.rs @@ -2,6 +2,7 @@ use std::sync::Arc; use async_graphql_value::ConstValue; use tailcall::core::cache::InMemoryCache; +use tailcall::core::ir::IoId; use tailcall::core::runtime::TargetRuntime; use tailcall::core::{EnvIO, FileIO, HttpIO}; @@ -21,7 +22,7 @@ fn init_env() -> Arc { Arc::new(WasmEnv::init()) } -fn init_cache() -> Arc> { +fn init_cache() -> Arc> { Arc::new(InMemoryCache::new()) } @@ -38,7 +39,7 @@ pub fn init_rt() -> TargetRuntime { file, cache, extensions: Arc::new(vec![]), - http_worker: None, + cmd_worker: None, worker: None, } } From f6b5146662015b943ff694640dcf92ddba04fade Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Tue, 23 Jul 2024 11:24:29 +0530 Subject: [PATCH 28/32] merge --- Cargo.lock | 552 ++++++++++++++++++++++++----------------------------- 1 file changed, 246 insertions(+), 306 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 594e7f644a..89262509a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] @@ -113,9 +113,9 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys 0.52.0", ] @@ -195,16 +195,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a" dependencies = [ "concurrent-queue", - "event-listener-strategy 0.5.2", + "event-listener-strategy", "futures-core", "pin-project-lite", ] [[package]] name = "async-executor" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b10202063978b3351199d68f8b22c4e47e4b1b822f8d43fd862d5ea8c006b29a" +checksum = "c8828ec6e544c02b0d6691d21ed9f9218d0384a82542855073c2a3f58304aaf0" dependencies = [ "async-task", "concurrent-queue", @@ -221,8 +221,8 @@ checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" dependencies = [ "async-channel 2.3.1", "async-executor", - "async-io 2.3.2", - "async-lock 3.3.0", + "async-io 2.3.3", + "async-lock 3.4.0", "blocking", "futures-lite 2.3.0", "once_cell", @@ -231,9 +231,9 @@ dependencies = [ [[package]] name = "async-graphql" -version = "7.0.6" +version = "7.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf338d20ba5bab309f55ce8df95d65ee19446f7737f06f4a64593ab2c6b546ad" +checksum = "2b76aba2f176af685c2229633881a3adeae51f87ae1811781e73910b7001c93e" dependencies = [ "async-graphql-derive", "async-graphql-parser", @@ -256,7 +256,7 @@ dependencies = [ "multer", "num-traits", "once_cell", - "opentelemetry 0.22.0", + "opentelemetry 0.23.0", "pin-project-lite", "regex", "serde", @@ -269,9 +269,9 @@ dependencies = [ [[package]] name = "async-graphql-derive" -version = "7.0.6" +version = "7.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc51fd6b7102acda72bc94e8ae1543844d5688ff394a6cf7c21f2a07fe2d64e4" +checksum = "72e2e26a6b44bc61df3ca8546402cf9204c28e30c06084cc8e75cd5e34d4f150" dependencies = [ "Inflector", "async-graphql-parser", @@ -280,7 +280,7 @@ dependencies = [ "proc-macro2", "quote", "strum", - "syn 2.0.66", + "syn 2.0.72", "thiserror", ] @@ -319,9 +319,9 @@ dependencies = [ [[package]] name = "async-graphql-parser" -version = "7.0.6" +version = "7.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75361eefd64e39f89bead4cb45fddbaf60ddb0e7b15fb7c852b6088bcd63071f" +checksum = "f801451484b4977d6fe67b29030f81353cabdcbb754e5a064f39493582dac0cf" dependencies = [ "async-graphql-value", "pest", @@ -331,9 +331,9 @@ dependencies = [ [[package]] name = "async-graphql-value" -version = "7.0.6" +version = "7.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1f665d2d52b41c4ed1f01c43f3ef27a2fe0af2452ed5c8bc7ac9b1a8719afaa" +checksum = "69117c43c01d81a69890a9f5dd6235f2f027ca8d1ec62d6d3c5e01ca0edb4f2b" dependencies = [ "bytes", "indexmap 2.2.6", @@ -363,17 +363,17 @@ dependencies = [ [[package]] name = "async-io" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcccb0f599cfa2f8ace422d3555572f47424da5648a4382a9dd0310ff8210884" +checksum = "0d6baa8f0178795da0e71bc42c9e5d13261aac7ee549853162e66a241ba17964" dependencies = [ - "async-lock 3.3.0", + "async-lock 3.4.0", "cfg-if", "concurrent-queue", "futures-io", "futures-lite 2.3.0", "parking", - "polling 3.7.0", + "polling 3.7.2", "rustix 0.38.34", "slab", "tracing", @@ -391,12 +391,12 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" +checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" dependencies = [ - "event-listener 4.0.3", - "event-listener-strategy 0.4.0", + "event-listener 5.3.1", + "event-listener-strategy", "pin-project-lite", ] @@ -434,17 +434,17 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "async-signal" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afe66191c335039c7bb78f99dc7520b0cbb166b3a1cb33a03f53d8a1c6f2afda" +checksum = "794f185324c2f00e771cd9f1ae8b5ac68be2ca7abb129a87afd6e86d228bc54d" dependencies = [ - "async-io 2.3.2", - "async-lock 3.3.0", + "async-io 2.3.3", + "async-lock 3.4.0", "atomic-waker", "cfg-if", "futures-core", @@ -502,7 +502,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -513,13 +513,13 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -544,7 +544,7 @@ dependencies = [ "bytes", "http 1.1.0", "http-body 1.0.0", - "http-serde 2.1.0", + "http-serde 2.1.1", "query_map", "serde", "serde_json", @@ -563,7 +563,7 @@ dependencies = [ "futures-util", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.29", + "hyper 0.14.30", "itoa", "matchit", "memchr", @@ -597,9 +597,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.71" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -708,12 +708,11 @@ dependencies = [ [[package]] name = "blocking" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "495f7104e962b7356f0aeb34247aca1fe7d2e783b346582db7f2904cb5717e88" +checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" dependencies = [ "async-channel 2.3.1", - "async-lock 3.3.0", "async-task", "futures-io", "futures-lite 2.3.0", @@ -808,9 +807,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.98" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" [[package]] name = "cfg-if" @@ -881,9 +880,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.6" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9689a29b593160de5bc4aacab7b5d54fb52231de70122626c178e6a368994c7" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", "clap_derive", @@ -891,9 +890,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.6" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5387378c84f6faa26890ebf9f0a92989f8873d4d380467bcd0d8d8620424df" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ "anstream", "anstyle", @@ -903,21 +902,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.5" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "colorchoice" @@ -1184,7 +1183,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1206,7 +1205,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1289,7 +1288,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1420,12 +1419,9 @@ dependencies = [ [[package]] name = "escape8259" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4911e3666fcd7826997b4745c8224295a6f3072f1418c3067b97a67557ee" -dependencies = [ - "rustversion", -] +checksum = "5692dd7b5a1978a5aeb0ce83b7655c58ca8efdcb79d21036ea249da95afec2c6" [[package]] name = "event-listener" @@ -1446,43 +1442,22 @@ dependencies = [ [[package]] name = "event-listener" -version = "4.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" -dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite", -] - -[[package]] -name = "event-listener" -version = "5.3.0" +version = "5.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d9944b8ca13534cdfb2800775f8dd4902ff3fc75a50101466decadfdf322a24" +checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" dependencies = [ "concurrent-queue", "parking", "pin-project-lite", ] -[[package]] -name = "event-listener-strategy" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" -dependencies = [ - "event-listener 4.0.3", - "pin-project-lite", -] - [[package]] name = "event-listener-strategy" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" dependencies = [ - "event-listener 5.3.0", + "event-listener 5.3.1", "pin-project-lite", ] @@ -1509,8 +1484,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "531e46835a22af56d1e3b66f04844bed63158bc094a628bec1d321d9b4c44bf2" dependencies = [ "bit-set", - "regex-automata 0.4.6", - "regex-syntax 0.8.3", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", ] [[package]] @@ -1653,7 +1628,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1739,9 +1714,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "glob" @@ -2012,6 +1987,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -2103,12 +2084,12 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", - "futures-core", + "futures-util", "http 1.1.0", "http-body 1.0.0", "pin-project-lite", @@ -2174,9 +2155,9 @@ dependencies = [ [[package]] name = "http-serde" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1133cafcce27ea69d35e56b3a8772e265633e04de73c5f4e1afdffc1d19b5419" +checksum = "0f056c8559e3757392c8d091e796416e4649d8e49e88b8d76df6c002f05027fd" dependencies = [ "http 1.1.0", "serde", @@ -2184,9 +2165,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -2209,7 +2190,7 @@ dependencies = [ "crossbeam-utils", "form_urlencoded", "futures-util", - "hyper 0.14.29", + "hyper 0.14.30", "lazy_static", "levenshtein", "log", @@ -2224,9 +2205,9 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.29" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", @@ -2248,9 +2229,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +checksum = "c4fe55fb7a772d59a5ff1dfbff4fe0258d19b89fec4b233e75d35d5d2316badc" dependencies = [ "bytes", "futures-channel", @@ -2273,7 +2254,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.29", + "hyper 0.14.30", "rustls 0.21.12", "tokio", "tokio-rustls 0.24.1", @@ -2287,7 +2268,7 @@ checksum = "399c78f9338483cb7e630c8474b07268983c6bd5acee012e4211f9f7bb21b070" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.29", + "hyper 0.14.30", "log", "rustls 0.22.4", "rustls-native-certs", @@ -2302,7 +2283,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper 0.14.29", + "hyper 0.14.30", "pin-project-lite", "tokio", "tokio-io-timeout", @@ -2310,16 +2291,16 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" +checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" dependencies = [ "bytes", "futures-channel", "futures-util", "http 1.1.0", "http-body 1.0.0", - "hyper 1.3.1", + "hyper 1.4.0", "pin-project-lite", "socket2 0.5.7", "tokio", @@ -2448,7 +2429,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", "windows-sys 0.48.0", ] @@ -2465,7 +2446,7 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", "windows-sys 0.52.0", ] @@ -2494,15 +2475,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.11" @@ -2556,7 +2528,7 @@ dependencies = [ "petgraph", "pico-args", "regex", - "regex-syntax 0.8.3", + "regex-syntax 0.8.4", "string_cache", "term", "tiny-keccak", @@ -2570,17 +2542,17 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" dependencies = [ - "regex-automata 0.4.6", + "regex-automata 0.4.7", ] [[package]] name = "lambda_http" -version = "0.11.1" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ebde9aedfdf8c2bac4365d9adafae6ca6d631b0ea221734ac802595fcd141cb" +checksum = "e8cce88e904c251a1f4f7a40d8ff05446df5fe3b62105d587a9818608e5d866e" dependencies = [ "aws_lambda_events", - "base64 0.21.7", + "base64 0.22.1", "bytes", "encoding_rs", "futures", @@ -2588,7 +2560,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.3.1", + "hyper 1.4.0", "lambda_runtime", "mime", "percent-encoding", @@ -2602,9 +2574,9 @@ dependencies = [ [[package]] name = "lambda_runtime" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae4606aea513f0e614497c0c4556d0e39f51a8434d9d97e592d32f9e615d4232" +checksum = "9be8f0e7a5db270feb93a7a3593c22a4c5fb8e8f260f5f490e0c3a5ffeb009db" dependencies = [ "async-stream", "base64 0.22.1", @@ -2613,8 +2585,8 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "http-serde 2.1.0", - "hyper 1.3.1", + "http-serde 2.1.1", + "hyper 1.4.0", "hyper-util", "lambda_runtime_api_client", "pin-project", @@ -2640,7 +2612,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.3.1", + "hyper 1.4.0", "hyper-util", "tokio", "tower", @@ -2651,9 +2623,9 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "levenshtein" @@ -2703,9 +2675,9 @@ dependencies = [ [[package]] name = "libmimalloc-sys" -version = "0.1.38" +version = "0.1.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7bb23d733dfcc8af652a78b7bf232f0e967710d044732185e561e47c0336b6" +checksum = "23aa6811d3bd4deb8a84dde645f943476d13b248d818edcf8ce0b2f37f036b44" dependencies = [ "cc", "libc", @@ -2770,36 +2742,13 @@ dependencies = [ "value-bag", ] -[[package]] -name = "logos" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c000ca4d908ff18ac99b93a062cb8958d331c3220719c52e77cb19cc6ac5d2c1" -dependencies = [ - "logos-derive 0.13.0", -] - [[package]] name = "logos" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "161971eb88a0da7ae0c333e1063467c5b5727e7fb6b710b8db4814eade3a42e8" dependencies = [ - "logos-derive 0.14.0", -] - -[[package]] -name = "logos-codegen" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc487311295e0002e452025d6b580b77bb17286de87b57138f3b5db711cded68" -dependencies = [ - "beef", - "fnv", - "proc-macro2", - "quote", - "regex-syntax 0.6.29", - "syn 2.0.66", + "logos-derive", ] [[package]] @@ -2813,17 +2762,8 @@ dependencies = [ "lazy_static", "proc-macro2", "quote", - "regex-syntax 0.8.3", - "syn 2.0.66", -] - -[[package]] -name = "logos-derive" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbfc0d229f1f42d790440136d941afd806bc9e949e2bcb8faa813b0f00d1267e" -dependencies = [ - "logos-codegen 0.13.0", + "regex-syntax 0.8.4", + "syn 2.0.72", ] [[package]] @@ -2832,7 +2772,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c2a69b3eb68d5bd595107c9ee58d7e07fe2bb5e360cc85b0f084dedac80de0a" dependencies = [ - "logos-codegen 0.14.0", + "logos-codegen", ] [[package]] @@ -2881,9 +2821,9 @@ checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" [[package]] name = "markdown" -version = "1.0.0-alpha.17" +version = "1.0.0-alpha.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e27d6220ce21f80ce5c4201f23a37c6f1ad037c72c9d1ff215c2919605a5d6" +checksum = "4e61c5c85b392273c4d4ea546e6399ace3e3db172ab01b6de8f3d398d1dbd2ec" dependencies = [ "unicode-id", ] @@ -2926,9 +2866,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" @@ -2971,7 +2911,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -2982,14 +2922,14 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "mimalloc" -version = "0.1.42" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9186d86b79b52f4a77af65604b51225e8db1d6ee7e3f41aec1e40829c71a176" +checksum = "68914350ae34959d83f732418d51e2427a794055d0b9529f48259ac07af65633" dependencies = [ "libmimalloc-sys", ] @@ -3018,9 +2958,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] @@ -3039,16 +2979,16 @@ dependencies = [ [[package]] name = "moka" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e0d88686dc561d743b40de8269b26eaf0dc58781bde087b0984646602021d08" +checksum = "32cf62eb4dd975d2dde76432fb1075c49e3ee2331cf36f1f8fd4b66550d32b6f" dependencies = [ - "async-lock 3.3.0", + "async-lock 3.4.0", "async-trait", "crossbeam-channel", "crossbeam-epoch", "crossbeam-utils", - "event-listener 5.3.0", + "event-listener 5.3.1", "futures-util", "once_cell", "parking_lot", @@ -3168,7 +3108,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", ] @@ -3197,9 +3137,9 @@ dependencies = [ [[package]] name = "object" -version = "0.32.2" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" dependencies = [ "memchr", ] @@ -3450,9 +3390,9 @@ checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -3466,7 +3406,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.1", + "redox_syscall 0.5.2", "smallvec", "windows-targets 0.52.5", ] @@ -3489,9 +3429,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.10" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" +checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" dependencies = [ "memchr", "thiserror", @@ -3518,7 +3458,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -3553,14 +3493,14 @@ dependencies = [ [[package]] name = "phonenumber" -version = "0.3.5+8.13.36" +version = "0.3.6+8.13.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f174c8db59b620032bd52b655fc97000458850fec0db35fcd4e802b668517ec0" +checksum = "11756237b57b8cc5e97dc8b1e70ea436324d30e7075de63b14fd15073a8f692a" dependencies = [ "bincode", "either", "fnv", - "itertools 0.12.1", + "itertools 0.11.0", "lazy_static", "nom", "quick-xml", @@ -3595,7 +3535,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -3612,9 +3552,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "piper" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "464db0c665917b13ebb5d453ccdec4add5658ee1adc7affc7677615356a8afaf" +checksum = "ae1d5c74c9876f070d3e8fd503d748c7d974c3e48da8f41350fa5222ef9b4391" dependencies = [ "atomic-waker", "fastrand 2.1.0", @@ -3667,13 +3607,13 @@ dependencies = [ [[package]] name = "polling" -version = "3.7.0" +version = "3.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645493cf344456ef24219d02a768cf1fb92ddf8c92161679ae3d91b91a637be3" +checksum = "a3ed00ed3fbf728b5816498ecd316d1716eecaced9c0c8d2c5a6740ca214985b" dependencies = [ "cfg-if", "concurrent-queue", - "hermit-abi", + "hermit-abi 0.4.0", "pin-project-lite", "rustix 0.38.34", "tracing", @@ -3715,7 +3655,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -3763,9 +3703,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -3803,7 +3743,7 @@ checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes", "heck", - "itertools 0.12.1", + "itertools 0.11.0", "log", "multimap", "once_cell", @@ -3812,7 +3752,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.66", + "syn 2.0.72", "tempfile", ] @@ -3823,10 +3763,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools 0.11.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -3836,7 +3776,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f5eec97d5d34bdd17ad2db2219aabf46b054c6c41bd5529767c9ce55be5898f" dependencies = [ "base64 0.22.1", - "logos 0.14.0", + "logos", "miette 7.2.0", "once_cell", "prost", @@ -3963,9 +3903,9 @@ checksum = "9653c3ed92974e34c5a6e0a510864dab979760481714c172e0a34e437cb98804" [[package]] name = "protox" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a29b3c5596eb23a849deba860b53ffd468199d9ad5fe4402a7d55379e16aa2d2" +checksum = "ac532509cee918d40f38c3e12f8ef9230f215f017d54de7dd975015538a42ce7" dependencies = [ "bytes", "miette 7.2.0", @@ -3978,11 +3918,11 @@ dependencies = [ [[package]] name = "protox-parse" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "033b939d76d358f7c32120c86c71f515bae45e64f2bde455200356557276276c" +checksum = "7f6c33f43516fe397e2f930779d720ca12cd057f7da4cd6326a0ef78d69dee96" dependencies = [ - "logos 0.13.0", + "logos", "miette 7.2.0", "prost-types", "thiserror", @@ -4117,9 +4057,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ "bitflags 2.5.0", ] @@ -4137,13 +4077,13 @@ dependencies = [ [[package]] name = "reflink-copy" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3138c30c59ed9b8572f82bed97ea591ecd7e45012566046cc39e72679cff22" +checksum = "6d731e7e3ebfcf422d96b8473e507d5b64790900dd5464772d38d1da9da24d3a" dependencies = [ "cfg-if", "rustix 0.38.34", - "windows 0.56.0", + "windows 0.57.0", ] [[package]] @@ -4154,8 +4094,8 @@ checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.6", - "regex-syntax 0.8.3", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", ] [[package]] @@ -4169,13 +4109,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.3", + "regex-syntax 0.8.4", ] [[package]] @@ -4198,9 +4138,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "relative-path" @@ -4222,7 +4162,7 @@ dependencies = [ "h2", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.29", + "hyper 0.14.30", "hyper-rustls 0.24.2", "ipnet", "js-sys", @@ -4327,7 +4267,7 @@ dependencies = [ "proc-macro2", "quote", "rquickjs-core", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -4402,20 +4342,20 @@ dependencies = [ "log", "ring", "rustls-pki-types", - "rustls-webpki 0.102.4", + "rustls-webpki 0.102.5", "subtle", "zeroize", ] [[package]] name = "rustls" -version = "0.23.9" +version = "0.23.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a218f0f6d05669de4eabfb24f31ce802035c952429d037507b4a4a39f0e60c5b" +checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" dependencies = [ "once_cell", "rustls-pki-types", - "rustls-webpki 0.102.4", + "rustls-webpki 0.102.5", "subtle", "zeroize", ] @@ -4470,9 +4410,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.4" +version = "0.102.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" dependencies = [ "ring", "rustls-pki-types", @@ -4511,9 +4451,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0218ceea14babe24a4a5836f86ade86c1effbc198164e619194cb5069187e29" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", "schemars_derive", @@ -4523,14 +4463,14 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed5a1ccce8ff962e31a165d41f6e2a2dd1245099dc4d594f5574a86cd90f4d3" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -4592,9 +4532,9 @@ checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] @@ -4642,13 +4582,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -4659,14 +4599,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ "indexmap 2.2.6", "itoa", @@ -4982,14 +4922,14 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "0d0208408ba0c3df17ed26eb06992cb1a1268d41b2c0e12e65203fbe3972cee5" [[package]] name = "syn" @@ -5004,9 +4944,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -5036,9 +4976,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.30.12" +version = "0.30.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "732ffa00f53e6b2af46208fba5718d9662a421049204e156328b66791ffa15ae" +checksum = "0a5b4ddaee55fb2bea2bf0e5000747e5f5c0de765e5a5ff87f4cd106439f4bb3" dependencies = [ "cfg-if", "core-foundation-sys", @@ -5107,7 +5047,7 @@ dependencies = [ "htpasswd-verify", "http-cache-reqwest", "httpmock", - "hyper 0.14.29", + "hyper 0.14.30", "hyper-rustls 0.25.0", "indexmap 2.2.6", "inquire", @@ -5145,7 +5085,7 @@ dependencies = [ "reqwest-middleware", "resource", "rquickjs", - "rustls 0.23.9", + "rustls 0.23.11", "rustls-pemfile 1.0.4", "rustls-pki-types", "schemars", @@ -5189,7 +5129,7 @@ dependencies = [ "async-graphql-value", "async-trait", "dotenvy", - "hyper 0.14.29", + "hyper 0.14.30", "lambda_http", "lambda_runtime", "reqwest", @@ -5208,7 +5148,7 @@ dependencies = [ "async-std", "async-trait", "console_error_panic_hook", - "hyper 0.14.29", + "hyper 0.14.30", "lazy_static", "protox", "reqwest", @@ -5260,7 +5200,7 @@ version = "0.1.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -5283,7 +5223,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "sysinfo 0.30.12", + "sysinfo 0.30.13", "tailcall-version", "tokio", "tracing", @@ -5309,7 +5249,7 @@ version = "0.1.0" dependencies = [ "anyhow", "http-body-util", - "hyper 0.14.29", + "hyper 0.14.30", "hyper-util", "once_cell", "opentelemetry 0.23.0", @@ -5346,7 +5286,7 @@ dependencies = [ "async-trait", "console_error_panic_hook", "dashmap", - "hyper 0.14.29", + "hyper 0.14.30", "reqwest", "serde_json", "tailcall", @@ -5428,22 +5368,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -5532,9 +5472,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.0" +version = "1.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" dependencies = [ "backtrace", "bytes", @@ -5567,7 +5507,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -5670,7 +5610,7 @@ dependencies = [ "h2", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.29", + "hyper 0.14.30", "hyper-timeout", "percent-encoding", "pin-project", @@ -5697,7 +5637,7 @@ dependencies = [ "proc-macro2", "prost-build", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -5710,7 +5650,7 @@ dependencies = [ "proc-macro2", "prost-build", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -5736,7 +5676,7 @@ dependencies = [ "futures-util", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.29", + "hyper 0.14.30", "opentelemetry 0.22.0", "pin-project-lite", "tonic", @@ -5808,7 +5748,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -5996,9 +5936,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" @@ -6033,9 +5973,9 @@ dependencies = [ [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -6051,9 +5991,9 @@ checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" @@ -6141,7 +6081,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", "wasm-bindgen-shared", ] @@ -6175,7 +6115,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6208,7 +6148,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -6339,11 +6279,11 @@ dependencies = [ [[package]] name = "windows" -version = "0.56.0" +version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132" +checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" dependencies = [ - "windows-core 0.56.0", + "windows-core 0.57.0", "windows-targets 0.52.5", ] @@ -6358,12 +6298,12 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.56.0" +version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4698e52ed2d08f8658ab0c39512a7c00ee5fe2688c65f8c0a4f06750d729f2a6" +checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" dependencies = [ - "windows-implement 0.56.0", - "windows-interface 0.56.0", + "windows-implement 0.57.0", + "windows-interface 0.57.0", "windows-result", "windows-targets 0.52.5", ] @@ -6381,13 +6321,13 @@ dependencies = [ [[package]] name = "windows-implement" -version = "0.56.0" +version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" +checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -6403,20 +6343,20 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.56.0" +version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" +checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "windows-result" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "749f0da9cc72d82e600d8d2e44cadd0b9eedb9038f71a1c58556ac1c5791813b" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" dependencies = [ "windows-targets 0.52.5", ] @@ -6664,7 +6604,7 @@ dependencies = [ "async-trait", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-macro-support", @@ -6692,7 +6632,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -6724,11 +6664,11 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" From 511c3c885ddf7b2eeebdc044df28ed2ba7321870 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Tue, 23 Jul 2024 11:31:02 +0530 Subject: [PATCH 29/32] fix errors --- Cargo.lock | 67 ++++++++++++++++++++++++++++++++++++ tailcall-wasm/src/builder.rs | 2 +- tailcall-wasm/src/lib.rs | 3 +- tailcall-wasm/src/runtime.rs | 2 +- 4 files changed, 71 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca11715a62..40aeeeb6de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1247,6 +1247,19 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7762d17f1241643615821a8455a0b2c3e803784b058693d990b11f2dce25a0ca" +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + [[package]] name = "datatest-stable" version = "0.2.9" @@ -4582,6 +4595,12 @@ dependencies = [ "syn 2.0.72", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.2.0" @@ -5404,6 +5423,29 @@ dependencies = [ name = "tailcall-version" version = "0.1.0" +[[package]] +name = "tailcall-wasm" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-graphql-value", + "async-std", + "async-trait", + "console_error_panic_hook", + "dashmap", + "hyper 0.14.30", + "reqwest", + "serde_json", + "tailcall", + "tracing", + "tracing-subscriber", + "tracing-subscriber-wasm", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test", +] + [[package]] name = "task-local-extensions" version = "0.1.4" @@ -6212,6 +6254,31 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +[[package]] +name = "wasm-bindgen-test" +version = "0.3.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9bf62a58e0780af3e852044583deee40983e5886da43a271dd772379987667b" +dependencies = [ + "console_error_panic_hook", + "js-sys", + "scoped-tls", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "wasm-streams" version = "0.4.0" diff --git a/tailcall-wasm/src/builder.rs b/tailcall-wasm/src/builder.rs index d0b44f79bc..069b086dfc 100644 --- a/tailcall-wasm/src/builder.rs +++ b/tailcall-wasm/src/builder.rs @@ -1,9 +1,9 @@ use std::sync::Arc; +use tailcall::core::app_context::AppContext; use tailcall::core::blueprint::Blueprint; use tailcall::core::config::reader::ConfigReader; use tailcall::core::config::ConfigModule; -use tailcall::core::http::AppContext; use tailcall::core::merge_right::MergeRight; use tailcall::core::rest::EndpointSet; use tailcall::core::runtime::TargetRuntime; diff --git a/tailcall-wasm/src/lib.rs b/tailcall-wasm/src/lib.rs index 874ec9fc14..fbcde1c6ac 100644 --- a/tailcall-wasm/src/lib.rs +++ b/tailcall-wasm/src/lib.rs @@ -5,8 +5,9 @@ use std::panic; use std::sync::Arc; use serde_json::json; +use tailcall::core::app_context::AppContext; use tailcall::core::async_graphql_hyper::GraphQLRequest; -use tailcall::core::http::{handle_request, AppContext}; +use tailcall::core::http::handle_request; use wasm_bindgen::prelude::wasm_bindgen; use wasm_bindgen::JsValue; diff --git a/tailcall-wasm/src/runtime.rs b/tailcall-wasm/src/runtime.rs index e22b881532..25ca9c418e 100644 --- a/tailcall-wasm/src/runtime.rs +++ b/tailcall-wasm/src/runtime.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use async_graphql_value::ConstValue; use tailcall::core::cache::InMemoryCache; -use tailcall::core::ir::IoId; +use tailcall::core::ir::model::IoId; use tailcall::core::runtime::TargetRuntime; use tailcall::core::{EnvIO, FileIO, HttpIO}; From a3faa2822cdd51f31d810da4eda56e105739ec14 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Sat, 27 Jul 2024 15:08:14 +0530 Subject: [PATCH 30/32] update readme --- tailcall-wasm/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tailcall-wasm/README.md b/tailcall-wasm/README.md index f25492fddf..64852c9bc1 100644 --- a/tailcall-wasm/README.md +++ b/tailcall-wasm/README.md @@ -12,7 +12,6 @@ npm i @tailcallhq/tailcall-wasm ## Local setup -````bash Go to tailcall-wasm dir ```bash @@ -67,6 +66,10 @@ Run simple http server in `tailcall-wasm` dir: python3 -m http.server 8000 ``` +you need to pass the schema url as a query parameter as `http://:/?config=` + +sample playground: [link](http://0.0.0.0:8000/example/browser/?config=https://raw.githubusercontent.com/tailcallhq/tailcall/main/examples/jsonplaceholder.graphql) + # Example ### NodeJS From 7813fc36f219e7793f7a5ef0f20a24764715f5d3 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Sat, 27 Jul 2024 15:09:05 +0530 Subject: [PATCH 31/32] lint fixes --- tailcall-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tailcall-wasm/README.md b/tailcall-wasm/README.md index 64852c9bc1..2ddb26d538 100644 --- a/tailcall-wasm/README.md +++ b/tailcall-wasm/README.md @@ -16,7 +16,7 @@ Go to tailcall-wasm dir ```bash cd tailcall-wasm -```` +``` The [package.json](package.json) file contains the scripts to run the project. From 4aa866578ea2aa828221b6472a1624cd163c177a Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Sun, 28 Jul 2024 13:44:19 +0530 Subject: [PATCH 32/32] fix comment --- tailcall-wasm/README.md | 4 ++-- tailcall-wasm/package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tailcall-wasm/README.md b/tailcall-wasm/README.md index 2ddb26d538..98d688e39e 100644 --- a/tailcall-wasm/README.md +++ b/tailcall-wasm/README.md @@ -31,7 +31,7 @@ npm run "dev-node" # compiles in debug mode For release build: ```bash -npm run "compile-node" # compiles in release mode with optimizations +npm run "build-release-node" # compiles in release mode with optimizations ``` By default, the output is in the `node` folder. @@ -53,7 +53,7 @@ npm run "dev-browser" # compiles in debug mode For release build: ```bash -npm run "compile-browser" # compiles in release mode with optimizations +npm run "build-release-browser" # compiles in release mode with optimizations ``` By default, the output is in the `browser` folder. diff --git a/tailcall-wasm/package.json b/tailcall-wasm/package.json index 989c14e517..6eb7f687f7 100644 --- a/tailcall-wasm/package.json +++ b/tailcall-wasm/package.json @@ -1,7 +1,7 @@ { "scripts": { - "compile-node": "wasm-pack build --release --target nodejs --scope tailcallhq --out-dir ./node/pkg", - "compile-browser": "wasm-pack build --release --target web --scope tailcallhq --out-dir ./browser/pkg", + "build-release-node": "wasm-pack build --release --target nodejs --scope tailcallhq --out-dir ./node/pkg", + "build-release-browser": "wasm-pack build --release --target web --scope tailcallhq --out-dir ./browser/pkg", "dev-node": "wasm-pack build --dev --target nodejs --scope tailcallhq --out-dir ./node/pkg", "dev-browser": "wasm-pack build --dev --target web --scope tailcallhq --out-dir ./browser/pkg", "publish": "npm run compile-node && wasm-pack publish --target nodejs"