Skip to content

Commit b80a5db

Browse files
authored
H-2444: Add Turbine from BP incubator (#56)
1 parent 8d51bb5 commit b80a5db

File tree

112 files changed

+18415
-1
lines changed

Some content is hidden

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

112 files changed

+18415
-1
lines changed

.cargo/config.toml

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
[target.'cfg(all())']
2+
rustflags = [
3+
"-Wclippy::all",
4+
"-Wclippy::as_underscore",
5+
"-Wclippy::await_holding_lock",
6+
"-Wclippy::char_lit_as_u8",
7+
"-Wclippy::checked_conversions",
8+
"-Wclippy::clone_on_ref_ptr",
9+
"-Wclippy::create_dir",
10+
"-Wclippy::dbg_macro",
11+
"-Wclippy::debug_assert_with_mut_call",
12+
"-Wclippy::default_union_representation",
13+
"-Wclippy::deref_by_slicing",
14+
"-Wclippy::doc_markdown",
15+
"-Wclippy::empty_enum",
16+
"-Wclippy::empty_structs_with_brackets",
17+
"-Wclippy::enum_glob_use",
18+
"-Wclippy::exit",
19+
"-Wclippy::expl_impl_clone_on_copy",
20+
"-Wclippy::explicit_deref_methods",
21+
"-Wclippy::explicit_into_iter_loop",
22+
"-Wclippy::fallible_impl_from",
23+
"-Wclippy::filetype_is_file",
24+
"-Wclippy::filter_map_next",
25+
"-Wclippy::flat_map_option",
26+
"-Wclippy::float_cmp_const",
27+
"-Wclippy::fn_params_excessive_bools",
28+
"-Wclippy::from_iter_instead_of_collect",
29+
"-Wclippy::get_unwrap",
30+
"-Wclippy::if_let_mutex",
31+
"-Wclippy::if_then_some_else_none",
32+
"-Wclippy::implicit_clone",
33+
"-Wclippy::imprecise_flops",
34+
"-Wclippy::inefficient_to_string",
35+
"-Wclippy::invalid_upcast_comparisons",
36+
"-Wclippy::large_digit_groups",
37+
"-Wclippy::large_stack_arrays",
38+
"-Wclippy::large_types_passed_by_value",
39+
"-Wclippy::let_unit_value",
40+
"-Wclippy::linkedlist",
41+
"-Wclippy::lossy_float_literal",
42+
"-Wclippy::macro_use_imports",
43+
"-Wclippy::manual_ok_or",
44+
"-Wclippy::map_err_ignore",
45+
"-Wclippy::map_flatten",
46+
"-Wclippy::map_unwrap_or",
47+
"-Wclippy::match_on_vec_items",
48+
"-Wclippy::match_same_arms",
49+
"-Wclippy::match_wild_err_arm",
50+
"-Wclippy::match_wildcard_for_single_variants",
51+
"-Wclippy::mem_forget",
52+
"-Wclippy::mismatched_target_os",
53+
"-Wclippy::missing_enforced_import_renames",
54+
"-Wclippy::mod_module_files",
55+
"-Wclippy::mut_mut",
56+
"-Wclippy::mutex_integer",
57+
"-Wclippy::needless_borrow",
58+
"-Wclippy::needless_continue",
59+
"-Wclippy::needless_for_each",
60+
"-Wclippy::nursery",
61+
"-Wclippy::option_option",
62+
"-Wclippy::path_buf_push_overwrite",
63+
"-Wclippy::pedantic",
64+
"-Wclippy::print_stderr",
65+
"-Wclippy::print_stdout",
66+
"-Wclippy::ptr_as_ptr",
67+
"-Wclippy::rc_buffer",
68+
"-Wclippy::rc_mutex",
69+
"-Wclippy::ref_option_ref",
70+
"-Wclippy::rest_pat_in_fully_bound_structs",
71+
"-Wclippy::same_functions_in_if_condition",
72+
"-Wclippy::same_name_method",
73+
"-Wclippy::semicolon_if_nothing_returned",
74+
"-Wclippy::single_match_else",
75+
"-Wclippy::str_to_string",
76+
"-Wclippy::string_add",
77+
"-Wclippy::string_add_assign",
78+
"-Wclippy::string_lit_as_bytes",
79+
"-Wclippy::string_slice",
80+
"-Wclippy::string_to_string",
81+
"-Wclippy::todo",
82+
"-Wclippy::trait_duplication_in_bounds",
83+
"-Wclippy::try_err",
84+
"-Wclippy::undocumented_unsafe_blocks",
85+
"-Wclippy::unnecessary_self_imports",
86+
"-Wclippy::unnested_or_patterns",
87+
"-Wclippy::unused_self",
88+
"-Wclippy::unwrap_used",
89+
"-Wclippy::use_debug",
90+
"-Wclippy::useless_transmute",
91+
"-Wclippy::verbose_file_reads",
92+
"-Wclippy::zero_sized_map_values",
93+
"-Wfuture_incompatible",
94+
"-Wnonstandard_style",
95+
"-Wunreachable_pub",
96+
"-Aclippy::module_name_repetitions",
97+
"-Aclippy::redundant_pub_crate",
98+
"-Amissing_docs",
99+
]

.gitignore

+16-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,20 @@
1111
.config/**/*.log
1212
dist/
1313
node_modules/
14-
target/
1514
test_artifacts/
15+
16+
### Rust template
17+
# Generated by Cargo
18+
# will have compiled files and executables
19+
debug/
20+
target/
21+
22+
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
23+
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
24+
Cargo.lock
25+
26+
# These are backup files generated by rustfmt
27+
**/*.rs.bk
28+
29+
# MSVC Windows builds of rustc generate these, which store debugging information
30+
*.pdb

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ The [HASH] app seeks to enable its users to make better decisions by utilizing a
2525
- [`sim-core-plugins`](apps/sim-core-plugins) contains an example external plugin developed for hCore, which provides a visual interface for process modeling
2626
- [`sim-engine`](apps/sim-engine) contains [HASH Engine], a versatile agent-based simulation engine written in Rust (with support for TypeScript & Python sims)
2727

28+
## Libs
29+
30+
### Block Protocol Libraries
31+
32+
- [`turbine`](libs/turbine)
33+
- [`turbine-transformer`](libs/turbine-transformer)
34+
2835
## POCs
2936

3037
The `pocs` folder contains **proof of concepts** and other one-off experiments.

libs/turbine-transformer/.DS_Store

6 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
[target.'cfg(all())']
2+
rustflags = [
3+
"-Wclippy::all",
4+
"-Wclippy::as_underscore",
5+
"-Wclippy::await_holding_lock",
6+
"-Wclippy::char_lit_as_u8",
7+
"-Wclippy::checked_conversions",
8+
"-Wclippy::clone_on_ref_ptr",
9+
"-Wclippy::create_dir",
10+
"-Wclippy::dbg_macro",
11+
"-Wclippy::debug_assert_with_mut_call",
12+
"-Wclippy::default_union_representation",
13+
"-Wclippy::deref_by_slicing",
14+
"-Wclippy::doc_markdown",
15+
"-Wclippy::empty_enum",
16+
"-Wclippy::empty_structs_with_brackets",
17+
"-Wclippy::enum_glob_use",
18+
"-Wclippy::exit",
19+
"-Wclippy::expl_impl_clone_on_copy",
20+
"-Wclippy::explicit_deref_methods",
21+
"-Wclippy::explicit_into_iter_loop",
22+
"-Wclippy::fallible_impl_from",
23+
"-Wclippy::filetype_is_file",
24+
"-Wclippy::filter_map_next",
25+
"-Wclippy::flat_map_option",
26+
"-Wclippy::float_cmp_const",
27+
"-Wclippy::fn_params_excessive_bools",
28+
"-Wclippy::from_iter_instead_of_collect",
29+
"-Wclippy::get_unwrap",
30+
"-Wclippy::if_let_mutex",
31+
"-Wclippy::if_then_some_else_none",
32+
"-Wclippy::implicit_clone",
33+
"-Wclippy::imprecise_flops",
34+
"-Wclippy::inefficient_to_string",
35+
"-Wclippy::invalid_upcast_comparisons",
36+
"-Wclippy::large_digit_groups",
37+
"-Wclippy::large_stack_arrays",
38+
"-Wclippy::large_types_passed_by_value",
39+
"-Wclippy::let_unit_value",
40+
"-Wclippy::linkedlist",
41+
"-Wclippy::lossy_float_literal",
42+
"-Wclippy::macro_use_imports",
43+
"-Wclippy::manual_ok_or",
44+
"-Wclippy::map_err_ignore",
45+
"-Wclippy::map_flatten",
46+
"-Wclippy::map_unwrap_or",
47+
"-Wclippy::match_on_vec_items",
48+
"-Wclippy::match_same_arms",
49+
"-Wclippy::match_wild_err_arm",
50+
"-Wclippy::match_wildcard_for_single_variants",
51+
"-Wclippy::mem_forget",
52+
"-Wclippy::mismatched_target_os",
53+
"-Wclippy::missing_enforced_import_renames",
54+
"-Wclippy::mod_module_files",
55+
"-Wclippy::mut_mut",
56+
"-Wclippy::mutex_integer",
57+
"-Wclippy::needless_borrow",
58+
"-Wclippy::needless_continue",
59+
"-Wclippy::needless_for_each",
60+
"-Wclippy::nursery",
61+
"-Wclippy::option_option",
62+
"-Wclippy::path_buf_push_overwrite",
63+
"-Wclippy::pedantic",
64+
"-Wclippy::print_stderr",
65+
"-Wclippy::print_stdout",
66+
"-Wclippy::ptr_as_ptr",
67+
"-Wclippy::rc_buffer",
68+
"-Wclippy::rc_mutex",
69+
"-Wclippy::ref_option_ref",
70+
"-Wclippy::rest_pat_in_fully_bound_structs",
71+
"-Wclippy::same_functions_in_if_condition",
72+
"-Wclippy::same_name_method",
73+
"-Wclippy::semicolon_if_nothing_returned",
74+
"-Wclippy::single_match_else",
75+
"-Wclippy::str_to_string",
76+
"-Wclippy::string_add",
77+
"-Wclippy::string_add_assign",
78+
"-Wclippy::string_lit_as_bytes",
79+
"-Wclippy::string_slice",
80+
"-Wclippy::string_to_string",
81+
"-Wclippy::todo",
82+
"-Wclippy::trait_duplication_in_bounds",
83+
"-Wclippy::try_err",
84+
"-Wclippy::undocumented_unsafe_blocks",
85+
"-Wclippy::unnecessary_self_imports",
86+
"-Wclippy::unnested_or_patterns",
87+
"-Wclippy::unused_self",
88+
"-Wclippy::unwrap_used",
89+
"-Wclippy::use_debug",
90+
"-Wclippy::useless_transmute",
91+
"-Wclippy::verbose_file_reads",
92+
"-Wclippy::zero_sized_map_values",
93+
"-Wfuture_incompatible",
94+
"-Wnonstandard_style",
95+
"-Wunreachable_pub",
96+
"-Aclippy::module_name_repetitions",
97+
"-Aclippy::redundant_pub_crate",
98+
"-Amissing_docs",
99+
]

libs/turbine-transformer/Cargo.toml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "turbine-transformer"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
petgraph = "0.6.3"
10+
error-stack = { version = "0.4.1", default-features = false }
11+
funty = "3.0.0-rc2"
12+
serde_json = "1.0.96"
13+
ordered-float = "3.7.0"
14+
paste = "1.0.12"
15+
hashbrown = "0.13.2"
16+
17+
turbine = { path = "../turbine/lib/turbine" }

libs/turbine-transformer/README.md

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# `turbine-transformer`
2+
3+
> Origin of the name: A wind turbine uses wind to generate electricity through rotation. The transformer is used to
4+
> transform the voltage. This project aims to take the input from the turbine and transform it, by applying a set of
5+
> instructions.
6+
7+
8+
The goal of the project is to supplement the HASH REST-APIs query abilities with a more powerful query language. This
9+
has some trade-offs, you will still need to load in all entities from HASH, but you can then filter them down to the
10+
ones you want.
11+
12+
This is _very_ early in development, and is not ready for production use. Tests are missing, and the API is not stable.
13+
Especially the names of the different types are likely to change. Do not expect this to be usable in production, over
14+
the next weeks and months I will be working on this project to make it more stable and usable.
15+
16+
## Examples
17+
18+
```rust
19+
use turbine_transformer::View;
20+
21+
fn main() {
22+
let view = View::new(&mut subgraph.entities);
23+
let always_include = /* entity id */;
24+
25+
view.select(vec![
26+
Statement::type_()
27+
.or_id(always_include)
28+
.or_type::<User>()
29+
.or_type::<Post>()
30+
.or_inherits_from::<Person>()
31+
.and(
32+
PropertyMatch::equals(
33+
JsonPath::new().then::<Name>(),
34+
"John Doe"
35+
)
36+
)
37+
.with_links()
38+
.with_left(
39+
TypeMatch::new()
40+
.or_type::<User>()
41+
.or_type::<Post>()
42+
)
43+
.with_right(
44+
TypeMatch::new()
45+
.or_type::<User>()
46+
.or_type::<Post>()
47+
)
48+
]);
49+
50+
// You can also update selected entities
51+
view.select_properties(vec![
52+
Select::new(TypeMatch::new().or_type::<User>(), Action::Exclude)
53+
.do_(StaticAction::new::<Name>())
54+
.do_(StaticAction::new::<Email>())
55+
.do_(StaticAction::new::<Password>())
56+
]);
57+
58+
// ... or change the value of specific properties
59+
view.update_properties(vec![
60+
Update::new(TypeMatch::new().or_type::<User>())
61+
.do_(StaticUpdate::new::<Name>("John Doe"))
62+
]);
63+
64+
// or remap a specific user name to a different value
65+
view.update_properties(vec![
66+
Update::new(TypeMatch::new().or_type::<User>().or(
67+
PropertyMatch::equals(
68+
JsonPath::new().then::<Name>(),
69+
"John Doe"
70+
)
71+
))
72+
.do_(StaticUpdate::new::<Name>("Doe John"))
73+
]);
74+
}
75+
```
76+
77+
## Credit
78+
79+
Developed by [Bilal Mahmoud](https://github.com/indietyp).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "nightly-2023-08-28"
3+
components = ["cargo", "clippy", "rustfmt", "rust-std", "rust-src"]

libs/turbine-transformer/rustfmt.toml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# General
2+
edition = "2021" # Default: "2015"
3+
unstable_features = true # Default: false
4+
version = "Two" # Default: "One"
5+
6+
# Settings
7+
condense_wildcard_suffixes = true # Default: false
8+
overflow_delimited_expr = true # Default: false
9+
reorder_impl_items = true # Default: false
10+
use_field_init_shorthand = true # Default: false
11+
use_try_shorthand = true # Default: false
12+
wrap_comments = true # Default: false
13+
14+
# Parameters
15+
comment_width = 100 # Default: 80
16+
hex_literal_case = "Upper" # Default: "Preserve"
17+
18+
# Areas
19+
format_code_in_doc_comments = true # Default: false
20+
format_generated_files = true # Default: false
21+
format_macro_matchers = true # Default: false
22+
format_macro_bodies = true # Default: false
23+
format_strings = true # Default: false
24+
25+
# Imports
26+
imports_granularity = "Crate" # Default: "Preserve"
27+
group_imports = "StdExternalCrate" # Default: "Preserve"
28+
29+
# Diagnostics
30+
error_on_unformatted = true # Default: false
6 KB
Binary file not shown.

0 commit comments

Comments
 (0)