Skip to content

Commit

Permalink
more refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Nov 3, 2024
1 parent 832d886 commit 8eb4105
Show file tree
Hide file tree
Showing 60 changed files with 9,425 additions and 4,886 deletions.
2 changes: 1 addition & 1 deletion clift/src/api/initiate_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub enum InitiateUploadError {
CantReadBodyDuringError(reqwest::Error),
#[error("got error from api: {0}")]
APIError(String),
#[error("cant parse json: {0}")]
#[error("cant unresolved json: {0}")]
CantParseJson(#[from] serde_json::Error),
#[error("got failure from ft: {0:?}")]
GotFailure(std::collections::HashMap<String, String>),
Expand Down
2 changes: 1 addition & 1 deletion design/new-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub struct Section {
}

pub enum AST {
// ftd::ast::Ast
// ftd::resolved::Ast
#[serde(rename = "import")]
Import(ftd::ast::Import),
#[serde(rename = "record")]
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion fastn-core/src/commands/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn parsed_to_sections(input: &str) -> Vec<Section> {
sections.push(section);
} else {
panic!(
"`{}`: can't parse",
"`{}`: can't unresolved",
input
.split_once('\n')
.map(|(v, _)| v.to_string())
Expand Down
2 changes: 1 addition & 1 deletion fastn-core/src/commands/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub(crate) fn get_ftd_json(

match stage {
"p1" => get_p1_json(document),
"ast" => get_ast_json(document),
"resolved" => get_ast_json(document),
_ => unimplemented!(),
}
}
Expand Down
4 changes: 2 additions & 2 deletions fastn-core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ impl Config {
};
if let Some((v, _)) = id.split_once('/') {
fastn_core::Version::parse(v)
fastn_core::Version::unresolved(v)
} else {
Ok(fastn_core::Version::base())
}
Expand Down Expand Up @@ -931,7 +931,7 @@ impl Config {
Ok(fastn_manifest_processed) => fastn_manifest_processed,
Err(e) => {
return Err(fastn_core::Error::PackageError {
message: format!("failed to parse fastn.manifest.ftd: {:?}", &e),
message: format!("failed to unresolved fastn.manifest.ftd: {:?}", &e),
});
}
};
Expand Down
2 changes: 1 addition & 1 deletion fastn-core/src/config/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub async fn fastn_doc(
match fastn_core::doc::parse_ftd("fastn", doc.as_str(), &lib) {
Ok(v) => Ok(v),
Err(e) => Err(fastn_core::Error::PackageError {
message: format!("failed to parse FASTN.ftd 3: {:?}", &e),
message: format!("failed to unresolved FASTN.ftd 3: {:?}", &e),
}),
}
}
Expand Down
2 changes: 1 addition & 1 deletion fastn-core/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl Request {
) {
headers.insert(k, v.clone());
} else {
tracing::warn!("failed to parse header: {key:?} {value:?}");
tracing::warn!("failed to unresolved header: {key:?} {value:?}");
}
}
headers
Expand Down
24 changes: 12 additions & 12 deletions fastn-core/src/library2022/processor/google_sheets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ fn to_interpreter_value(
serde_json::Value::String(v) => v.to_string(),
_ => {
return ftd::interpreter::utils::e2(
format!("Can't parse to string, found: {}", &val.v),
format!("Can't unresolved to string, found: {}", &val.v),
doc.name,
line_number,
)
Expand All @@ -200,7 +200,7 @@ fn to_interpreter_value(
serde_json::Value::Number(n) => {
n.as_f64().map(|f| f as i64).ok_or_else(|| {
ftd::interpreter::Error::ParseError {
message: format!("Can't parse to integer, found: {}", &val.v),
message: format!("Can't unresolved to integer, found: {}", &val.v),
doc_id: doc.name.to_string(),
line_number,
}
Expand All @@ -209,22 +209,22 @@ fn to_interpreter_value(
serde_json::Value::String(s) => {
s.parse::<i64>()
.map_err(|_| ftd::interpreter::Error::ParseError {
message: format!("Can't parse to integer, found: {}", &val.v),
message: format!("Can't unresolved to integer, found: {}", &val.v),
doc_id: doc.name.to_string(),
line_number,
})?
}
_ => {
return Err(ftd::interpreter::Error::ParseError {
message: format!("Can't parse to integer, found: {}", &val.v),
message: format!("Can't unresolved to integer, found: {}", &val.v),
doc_id: doc.name.to_string(),
line_number,
})
}
},
t => {
return Err(ftd::interpreter::Error::ParseError {
message: format!("Can't parse to integer, found: {t}"),
message: format!("Can't unresolved to integer, found: {t}"),
doc_id: doc.name.to_string(),
line_number,
})
Expand All @@ -236,22 +236,22 @@ fn to_interpreter_value(
serde_json::Value::Number(n) => {
n.as_f64()
.ok_or_else(|| ftd::interpreter::Error::ParseError {
message: format!("Can't parse to decimal, found: {}", &val.v),
message: format!("Can't unresolved to decimal, found: {}", &val.v),
doc_id: doc.name.to_string(),
line_number,
})?
}
serde_json::Value::String(s) => {
s.parse::<f64>()
.map_err(|_| ftd::interpreter::Error::ParseError {
message: format!("Can't parse to decimal, found: {}", &val.v),
message: format!("Can't unresolved to decimal, found: {}", &val.v),
doc_id: doc.name.to_string(),
line_number,
})?
}
_ => {
return Err(ftd::interpreter::Error::ParseError {
message: format!("Can't parse to decimal, found: {}", &val.v),
message: format!("Can't unresolved to decimal, found: {}", &val.v),
doc_id: doc.name.to_string(),
line_number,
})
Expand All @@ -264,14 +264,14 @@ fn to_interpreter_value(
serde_json::Value::String(s) => {
s.parse::<bool>()
.map_err(|_| ftd::interpreter::Error::ParseError {
message: format!("Can't parse to boolean, found: {}", &val.v),
message: format!("Can't unresolved to boolean, found: {}", &val.v),
doc_id: doc.name.to_string(),
line_number,
})?
}
_ => {
return Err(ftd::interpreter::Error::ParseError {
message: format!("Can't parse to boolean, found: {}", &val.v),
message: format!("Can't unresolved to boolean, found: {}", &val.v),
doc_id: doc.name.to_string(),
line_number,
})
Expand Down Expand Up @@ -351,7 +351,7 @@ fn parse_json(
match serde_json::from_str::<QueryResponse>(json) {
Ok(response) => Ok(response),
Err(e) => ftd::interpreter::utils::e2(
format!("Failed to parse query response: {:?}", e),
format!("Failed to unresolved query response: {:?}", e),
doc_name,
line_number,
),
Expand Down Expand Up @@ -541,7 +541,7 @@ pub(crate) fn parse_query(
}
State::ParseError(error) => {
return Err(ftd::interpreter::Error::ParseError {
message: format!("Failed to parse SQL Query: {}", error),
message: format!("Failed to unresolved SQL Query: {}", error),
doc_id: doc.name.to_string(),
line_number,
});
Expand Down
2 changes: 1 addition & 1 deletion fastn-core/src/library2022/processor/pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fn resolve_variable_from_headers(
Ok(r) => Ok(r),
Err(e) => ftd::interpreter::utils::e2(
format!(
"failed to parse `{var}: {val}` into {into}: {e}",
"failed to unresolved `{var}: {val}` into {into}: {e}",
e = e.to_string()
),
doc_name,
Expand Down
2 changes: 1 addition & 1 deletion fastn-core/src/library2022/processor/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub async fn process(

let stage = headers
.get_optional_string_by_key("stage", doc.name, value.line_number())?
.unwrap_or_else(|| "ast".to_string());
.unwrap_or_else(|| "resolved".to_string());

let file = req_config
.get_file_and_package_by_id(path.as_str(), preview_session_id)
Expand Down
2 changes: 1 addition & 1 deletion fastn-core/src/library2022/processor/toc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn process(
doc.name,
)
.map_err(|e| ftd::ftd2021::p1::Error::ParseError {
message: format!("Cannot parse body: {:?}", e),
message: format!("Cannot unresolved body: {:?}", e),
doc_id: doc.name.to_string(),
line_number,
})?
Expand Down
10 changes: 5 additions & 5 deletions fastn-core/src/package/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl fastn_core::Package {
Ok(v) => v,
Err(e) => {
return Err(fastn_core::Error::PackageError {
message: format!("failed to parse FASTN.ftd: {:?}", &e),
message: format!("failed to unresolved FASTN.ftd: {:?}", &e),
});
}
};
Expand Down Expand Up @@ -267,7 +267,7 @@ impl fastn_core::Package {
}
Err(e) => {
return Err(fastn_core::Error::PackageError {
message: format!("failed to parse fastn.manifest.ftd: {:?}", &e),
message: format!("failed to unresolved fastn.manifest.ftd: {:?}", &e),
});
}
}
Expand Down Expand Up @@ -387,7 +387,7 @@ impl fastn_core::Package {
}
Err(e) => {
return Err(fastn_core::Error::PackageError {
message: format!("failed to parse fastn.manifest.ftd: {:?}", &e),
message: format!("failed to unresolved fastn.manifest.ftd: {:?}", &e),
});
}
}
Expand Down Expand Up @@ -449,7 +449,7 @@ impl fastn_core::Package {
Ok(v) => v,
Err(e) => {
return Err(fastn_core::Error::PackageError {
message: format!("failed to parse FASTN.ftd 2: {:?}", &e),
message: format!("failed to unresolved FASTN.ftd 2: {:?}", &e),
});
}
}
Expand Down Expand Up @@ -568,7 +568,7 @@ impl fastn_core::Package {
Ok(v) => v,
Err(e) => {
return Err(fastn_core::Error::PackageError {
message: format!("failed to parse FASTN.ftd 2: {:?}", &e),
message: format!("failed to unresolved FASTN.ftd 2: {:?}", &e),
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion fastn-core/src/package/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ impl Package {
path = fastn_path.to_string()
);
return Err(fastn_core::Error::PackageError {
message: format!("failed to parse FASTN.ftd: {:?}", &e),
message: format!("failed to unresolved FASTN.ftd: {:?}", &e),
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions fastn-core/src/package/package_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,9 @@ pub(crate) async fn read_ftd_2022(
{
Ok(v) => v,
Err(e) => {
tracing::error!(msg = "failed to parse", doc = main.id.as_str());
tracing::error!(msg = "failed to unresolved", doc = main.id.as_str());
return Err(fastn_core::Error::PackageError {
message: format!("failed to parse {:?}", &e),
message: format!("failed to unresolved {:?}", &e),
});
}
};
Expand Down Expand Up @@ -504,9 +504,9 @@ pub(crate) async fn read_ftd_2023(
{
Ok(v) => v,
Err(e) => {
tracing::error!(msg = "failed to parse", doc = main.id.as_str());
tracing::error!(msg = "failed to unresolved", doc = main.id.as_str());
return Err(fastn_core::Error::PackageError {
message: format!("failed to parse {:?}", &e),
message: format!("failed to unresolved {:?}", &e),
});
}
};
Expand Down
2 changes: 1 addition & 1 deletion fastn-core/src/package/redirects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl UrlMappingsTemp {
self.find_url_mappings(url_mappings_body)
}

// todo: parse dynamic-urls in this later
// todo: unresolved dynamic-urls in this later
/// Parses url mappings from fastn.url-mappings body
///
/// and returns UrlMappings { redirects, endpoints }
Expand Down
2 changes: 1 addition & 1 deletion fastn-core/src/sitemap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl SitemapElement {

// If url contains path parameters so it will set those parameters
// /person/<string:username>/<integer:age>
// In that case it will parse and set parameters `username` and `age`
// In that case it will unresolved and set parameters `username` and `age`
pub(crate) fn set_path_params(&mut self, url: &str) -> Result<(), ParseError> {
let params = utils::parse_named_params(url)?;

Expand Down
2 changes: 1 addition & 1 deletion fastn-core/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) async fn resolve_snapshots(
let b = match fastn_core::doc::parse_ftd(".latest.ftd", content, &lib) {
Ok(v) => v,
Err(e) => {
eprintln!("failed to parse .latest.ftd: {:?}", &e);
eprintln!("failed to unresolved .latest.ftd: {:?}", &e);
todo!();
}
};
Expand Down
2 changes: 1 addition & 1 deletion fastn-core/src/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub(crate) async fn get_tracks(
let b = match fastn_core::doc::parse_ftd(base_path.to_string().as_str(), doc.as_str(), &lib) {
Ok(v) => v,
Err(e) => {
eprintln!("failed to parse {}: {:?}", base_path, &e);
eprintln!("failed to unresolved {}: {:?}", base_path, &e);
todo!();
}
};
Expand Down
26 changes: 14 additions & 12 deletions fastn-core/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub async fn handle_wasm(
header_name.as_str().to_string(),
header_value
.to_str()
.expect("Unable to parse header value")
.expect("Unable to unresolved header value")
.to_string(),
));
});
Expand All @@ -147,17 +147,19 @@ pub async fn handle_wasm(
method: req.method(),
payload: body_str,
};
fastn_core::time("WASM Guest function").it(match import.handlerequest(&mut store, request) {
Ok(data) => Ok(actix_web::HttpResponse::Ok()
.content_type(actix_web::http::header::ContentType::json())
.status(if data.success {
actix_web::http::StatusCode::OK
} else {
actix_web::http::StatusCode::BAD_REQUEST
})
.body(data.data)),
Err(err) => Err(WASMError::WasmFunctionInvoke(err.to_string())),
})
fastn_core::time("WASM Guest function").it(
match import.handlerequest(&mut store, request) {
Ok(data) => Ok(actix_web::HttpResponse::Ok()
.content_type(actix_web::http::header::ContentType::json())
.status(if data.success {
actix_web::http::StatusCode::OK
} else {
actix_web::http::StatusCode::BAD_REQUEST
})
.body(data.data)),
Err(err) => Err(WASMError::WasmFunctionInvoke(err.to_string())),
},
)
}
fastn_core::time("WASM Execution: ").it(match inner(req, wasm_module, backend_headers).await {
Ok(resp) => resp,
Expand Down
2 changes: 1 addition & 1 deletion fastn-ds/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub enum WasmReadError {
pub enum HttpError {
#[error("http error {0}")]
ReqwestError(#[from] reqwest::Error),
#[error("url parse error {0}")]
#[error("url unresolved error {0}")]
URLParseError(#[from] url::ParseError),
#[error("generic error {message}")]
GenericError { message: String },
Expand Down
2 changes: 1 addition & 1 deletion fastn-expr/src/interpolator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[derive(thiserror::Error, Debug)]
pub enum InterpolationError {
#[error("Failed to parse interpolation: {0}")]
#[error("Failed to unresolved interpolation: {0}")]
FailedToParse(#[from] fastn_expr::parser::ParseError),
#[error("Failed to interpolate: {0}")]
CantInterpolate(String),
Expand Down
4 changes: 2 additions & 2 deletions fastn-grammar/src/evalexpr/token/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,9 @@ fn partial_tokens_to_tokens(mut tokens: &[PartialToken]) -> EvalexprResult<Vec<T
Some(Token::Boolean(boolean))
} else {
// If there are two tokens following this one, check if the next one is
// a plus or a minus. If so, then attempt to parse all three tokens as a
// a plus or a minus. If so, then attempt to unresolved all three tokens as a
// scientific notation number of the form `<coefficient>e{+,-}<exponent>`,
// for example [Literal("10e"), Minus, Literal("3")] => "1e-3".parse().
// for example [Literal("10e"), Minus, Literal("3")] => "1e-3".unresolved().
match (second, third) {
(Some(second), Some(third))
if second == PartialToken::Minus
Expand Down
2 changes: 1 addition & 1 deletion fastn-issues/src/initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub enum FastnFTDError {
#[from]
source: FileAsStringError,
},
#[error("Cant parse FASTN.ftd: {source}")]
#[error("Cant unresolved FASTN.ftd: {source}")]
ParseFASTNFile {
#[from]
source: OldFastnParseError,
Expand Down
Loading

0 comments on commit 8eb4105

Please sign in to comment.