Skip to content

Commit

Permalink
refactor: Rename node to indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
cvauclair committed Dec 12, 2024
1 parent 63d48bb commit 4ef890e
Show file tree
Hide file tree
Showing 51 changed files with 9,277 additions and 56 deletions.
62 changes: 31 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = [ "api",
"cli", "codegen", "core", "ipfs", "node", "sink", "web3-utils",
"cli", "codegen", "core", "ipfs", "indexer", "sink", "web3-utils",
]

3 changes: 2 additions & 1 deletion api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ futures = "0.3.31"
juniper = "0.16.1"
juniper_axum = "0.1.1"
juniper_graphql_ws = "0.4.0"
kg-node = { version = "0.1.0", path = "../node" }
serde = "1.0.216"
serde_json = "1.0.133"
tokio = { version = "1.42.0", features = ["macros", "rt-multi-thread"] }
tracing = "0.1.41"
tracing-subscriber = "0.3.19"

indexer = { version = "0.1.0", path = "../indexer" }

[dev-dependencies]
serde_path_to_error = "0.1.16"
8 changes: 4 additions & 4 deletions api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ use juniper::{
Executor, GraphQLScalar, RootNode, ScalarValue,
};
use juniper_axum::{extract::JuniperRequest, graphiql, playground, response::JuniperResponse};
use kg_node::kg;
use indexer::kg;
use tokio::net::TcpListener;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

#[derive(Clone)]
pub struct KnowledgeGraph(Arc<kg_node::kg::Client>);
pub struct KnowledgeGraph(Arc<indexer::kg::Client>);

impl juniper::Context for KnowledgeGraph {}

Expand Down Expand Up @@ -205,7 +205,7 @@ async fn main() -> anyhow::Result<()> {

let args = AppArgs::parse();

let kg_client = kg_node::kg::Client::new(
let kg_client = indexer::kg::Client::new(
&args.neo4j_args.neo4j_uri,
&args.neo4j_args.neo4j_user,
&args.neo4j_args.neo4j_pass,
Expand Down Expand Up @@ -233,7 +233,7 @@ async fn main() -> anyhow::Result<()> {
.layer(Extension(Arc::new(schema)))
.layer(Extension(KnowledgeGraph(Arc::new(kg_client))));

let addr = SocketAddr::from(([127, 0, 0, 1], 8080));
let addr = SocketAddr::from(([0, 0, 0, 0], 8080));
let listener = TcpListener::bind(addr)
.await
.unwrap_or_else(|e| panic!("failed to listen on {addr}: {e}"));
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
kg-codegen = { version = "0.1.0", path = "../codegen" }
kg-core = { version = "0.1.0", path = "../core" }
kg-node = { version = "0.1.0", path = "../node" }
indexer = { version = "0.1.0", path = "../indexer" }
ipfs = { version = "0.1.0", path = "../ipfs" }

anyhow = "1.0.91"
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use futures::{stream, StreamExt, TryStreamExt};
use ipfs::IpfsClient;
use kg_core::ids;
use kg_core::pb::grc20;
use kg_node::kg::{
use indexer::kg::{
self,
entity::{Entity, EntityNode},
};
use kg_node::ops::conversions;
use indexer::ops::conversions;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;

Expand Down
5 changes: 3 additions & 2 deletions codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ version = "0.1.0"
edition = "2021"

[dependencies]
kg-core = { version = "0.1.0", path = "../core" }
kg-node = { version = "0.1.0", path = "../node" }
anyhow = "1.0.91"
futures = "0.3.31"
heck = "0.5.0"
Expand All @@ -16,3 +14,6 @@ swc_ecma_ast = "2.0.0"
swc_ecma_codegen = "2.0.0"
swc_ecma_parser = { version = "3.0.0", features = ["typescript"] }
tracing = "0.1.40"

kg-core = { version = "0.1.0", path = "../core" }
indexer = { version = "0.1.0", path = "../indexer" }
10 changes: 5 additions & 5 deletions codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;

use futures::{stream, StreamExt, TryStreamExt};
use kg_core::system_ids;
use kg_node::kg::mapping::{Named, Node};
use indexer::kg::mapping::{Named, Node};
use swc::config::SourceMapsConfig;
use swc::PrintArgs;
use swc_common::{sync::Lrc, SourceMap, Span};
Expand Down Expand Up @@ -39,7 +39,7 @@ pub fn ts_type_from_value_type(value_type: &Node<Named>) -> TsType {
}
}

pub fn gen_type_constructor(kg: &kg_node::kg::Client, attributes: &[&(Node<Named>, Option<Node<Named>>)]) -> Constructor {
pub fn gen_type_constructor(kg: &indexer::kg::Client, attributes: &[&(Node<Named>, Option<Node<Named>>)]) -> Constructor {
let super_constructor = vec![quote_expr!("super(id, driver)")];

let constuctor_setters = attributes.iter().map(|(attr, _)| {
Expand Down Expand Up @@ -159,7 +159,7 @@ impl EntityExt for Node<Named> {

/// Generate a TypeScript class declaration from an entity.
/// Note: The entity must be a `Type` entity.
pub async fn gen_type(kg: &kg_node::kg::Client, entity: &Node<Named>) -> anyhow::Result<Decl> {
pub async fn gen_type(kg: &indexer::kg::Client, entity: &Node<Named>) -> anyhow::Result<Decl> {
let attrs = kg.attribute_nodes::<Named>(entity.id()).await?;

let typed_attrs = stream::iter(attrs.unique().fix_name_collisions())
Expand Down Expand Up @@ -233,7 +233,7 @@ pub async fn gen_type(kg: &kg_node::kg::Client, entity: &Node<Named>) -> anyhow:
}

/// Generate a TypeScript module containing class definitions from all types in the knowledge graph.
pub async fn gen_types(kg: &kg_node::kg::Client) -> anyhow::Result<Program> {
pub async fn gen_types(kg: &indexer::kg::Client) -> anyhow::Result<Program> {
let import_stmts = vec![
quote!("import { Driver, Node } from 'neo4j-driver';" as ModuleItem),
quote!("import { Entity } from './kg';" as ModuleItem),
Expand Down Expand Up @@ -266,7 +266,7 @@ pub async fn gen_types(kg: &kg_node::kg::Client) -> anyhow::Result<Program> {
}

/// Generate and render TypeScript code from the knowledge graph.
pub async fn codegen(kg: &kg_node::kg::Client) -> anyhow::Result<String> {
pub async fn codegen(kg: &indexer::kg::Client) -> anyhow::Result<String> {
let cm: Lrc<SourceMap> = Default::default();
let compiler = swc::Compiler::new(cm.clone());

Expand Down
4 changes: 2 additions & 2 deletions codegen/src/sample.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::HashMap;

use futures::{stream, StreamExt, TryStreamExt};
use kg_node::kg::grc20;
use kg_node::system_ids;
use indexer::kg::grc20;
use indexer::system_ids;
use swc::config::SourceMapsConfig;
use swc::PrintArgs;
use swc_common::{sync::Lrc, SourceMap, Span, SyntaxContext};
Expand Down
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ serde = { version = "1.0.215", features = ["derive"] }
thiserror = "2.0.3"
tracing = "0.1.40"
uuid = { version = "1.11.0", features = ["v4"] }

web3-utils = { version = "0.1.0", path = "../web3-utils" }
12 changes: 6 additions & 6 deletions node/Cargo.toml → indexer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
[package]
name = "kg-node"
name = "indexer"
version = "0.1.0"
edition = "2021"

[dependencies]
substreams-sink-rust = { version = "0.1.0", path = "../sink" }
kg-core = { version = "0.1.0", path = "../core" }
ipfs = { version = "0.1.0", path = "../ipfs" }
web3-utils = { version = "0.1.0", path = "../web3-utils" }

anyhow = "1.0.89"
chrono = "0.4.38"
clap = { version = "4.5.20", features = ["derive"] }
Expand All @@ -27,6 +22,11 @@ tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
const_format = "0.2.33"

substreams-sink-rust = { version = "0.1.0", path = "../sink" }
kg-core = { version = "0.1.0", path = "../core" }
ipfs = { version = "0.1.0", path = "../ipfs" }
web3-utils = { version = "0.1.0", path = "../web3-utils" }

[dev-dependencies]
serde_path_to_error = "0.1.16"

Expand Down
Binary file added indexer/replay.log
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0 0370cdbd57a946e9a5119c0c1ffc69d7"*0x74519E6EEc5BCFBC4Eb8F1A6d0C6D343173A286b*Bipfs://bafkreifjoq5mgwnfzd253upe7ht5wauzbmghfunz2h72x2v7ugm24foi44*Bipfs://bafkreietwksqbdw3ymhn3naav3pxidvj4jn35dpi3tzxs6huw2mn3mimme*Bipfs://bafkreihlmshzrr7ft4yzvqqxhk3t7x6siupxtlbe3omhf5x5qbgqykdfwy*Bipfs://bafkreigu3afrxuyrtx2fmluhhuhjn46uhaoa3x7not7miwa2jj37ae5kc4*Bipfs://bafkreid4zrqowrjisfdhtr5mqs4po5p5bide57bzfpfxgnijhsjrnl2wgi*Bipfs://bafkreidhdv5rdnmmvxhnvohanjtzoojkkyk5aaxcf54a472m4ixiejbh4m*Bipfs://bafkreibqgzevwvttjkitjxukrx4rh37d7vxeo5xdbau657fswk6aq6h5lm*Bipfs://bafkreiaasdqgcretyt6yr3ey32ornfojz5cjrkntgybsmwrs4grohllvx4*Bipfs://bafkreibubwrxftxwu3bkuu7f4dtf42czwttom7plmnicq7upn4jwcldmla*Bipfs://bafkreia75atlmou2kplbjfhdcb3rzy2pot6kklzklovhimswipg4bijxee*Bipfs://bafkreicy6tlapikboklx3mras6ryadp2yrrtmkricwuw7jxpzvsr5fujjq*Bipfs://bafkreiak3doe63obazzilfygba5dqjkrnkhlef24t4v25m4jcn6y5jldjq*Bipfs://bafkreia67rrpz5lzwljui3ysho7x27kqgnlcxsk2b2gmoxmskksxztxzui*Bipfs://bafkreibzoq6j3tpbsuogej7gcxae7n4tzgjwc346hmvemt5v3e6pgtxyhm*Bipfs://bafkreigykfprqonk5qoasxlsekctk37jcgqa55fkamipujxvhvyjdkwguq*Bipfs://bafkreif44vpef25ctbrhy3o5tegzaviisqvui67o4dppu2napwf2lxnvg4*Bipfs://bafkreigp22ly3xyr3orxob7b7gmaioybz2putwmnb2hkdcu4eadjcyt25e*Bipfs://bafkreif4watuozffk3ckpoecxpkeqf7edebcptmv2vdgasmbb5ufenlnoa*Bipfs://bafkreigwqa5y4hrdy5bs7yu7drma7rdvm4xdnk6s3aquvqvg3o2yxifejy*Bipfs://bafkreiexkx4gqwx3xacskjjklywh2htoucagphrxhkl2r7dxh55f4ngcdq*Bipfs://bafkreibx7xylw5b6jrwquoa346npwlpl7o2pa26xlmkotkhritjqoggyvi*Bipfs://bafkreie2qlesf4guxa5bgq747yg443t7plnn3xp2cq23jyaw43u3hk43y4*Bipfs://bafkreiekhydhjthfhvvvwg5smeuiogznocwvlsipxiiej4f4pxareqqerm*Bipfs://bafkreicmg4alxidb2zmm5agydxwcpwqnkob7lrrzz7j5i6sp6vtqiktf6u*Bipfs://bafkreigdjen2zdbj5vfyuqy7rde36kgkgyl6soltpl7d7lzcvwd2gqcw2m*Bipfs://bafkreih2ln7ldccrmt567gsmzoni2iqgjyiinen53livml27dsrd7jpksa*Bipfs://bafkreiapqskmf7wsvwftyjuzq64mimp6trilaicnm5ojr4h44na3oztmum*Bipfs://bafkreickig2dajbztuaexqt4ivkjtvx3xiikhdlkovxxrncjqmgzy6msoy*Bipfs://bafkreigdtrj3b4ccekdvxfcib5qzu4bimgglcxwvlm2kyymhi3kvggxqs4*Bipfs://bafkreib63ouzjkzm56jzvgzzs6dxlpm5cne7hzpfdgydqu3rs5hvakbm6e*Bipfs://bafkreia2faz5xxjqgmxu4olcs3zhvulomvlxzd6o75sbdpkxw35nd3s67y*Bipfs://bafkreiafij7h4rowtf4pucmdf4miujt4pd57vcbp3xv6ffsxi7x762enye*Bipfs://bafkreih3fqwcrlugz4alp6fzbkpmakhhloafut2je7qcbizodyo5twwh5q*Bipfs://bafkreidrniwrheqattspclyqybyyd5fxduhw7kn7ttpbjgnf5ilxtd2wqm*Bipfs://bafkreicwj6j3pmt7i57547356wbpqhocb6uri3zjufmloyf7j2n6wwa4em*Bipfs://bafkreigtrw4r3gnbyqjklp27udmcgaxb765yy73xdl7sjij4zcaoiaooh4*Bipfs://bafkreidx2f5rfnwanyhbksdrmevcsy7qwo525gcsrxs7vunhkptgsuam6m*Bipfs://bafkreicbgoxwvtoyjkpdid6uiiyc4fdtrllkwmwpmgxpw4lnpqbs72u5aa*Bipfs://bafkreigssxs4bj5ucunc3mavesm4kirgqvlumftaefirzfu6i4lhgqptnu*Bipfs://bafkreihb6la2m6n24gbgzmg7dgujihpn3cnaupt4kselhgjze4rqaegfiu*Bipfs://bafkreifckfoisfpfenvz7ch2aylsyft7ni2u3qoos7s4qdamtmualsw3wa*Bipfs://bafkreia3vh3fmbeh64ey4s35xa6ffxtxoqivogh4ivd2gvulokldnjcyni*Bipfs://bafkreiecqolntwzurzurfbgkgi7mc22by2r562nwa3z4xbq5ml4fa2ca3u*Bipfs://bafkreighoehzqr42rimrwehg4ogb7yyakx2zn5meg7k4rg3wjfc52k7vqa*Bipfs://bafkreieo35fd22kt6r5tt6ufa5ci7lkjmupkpiazjf5zgsiluiascsc2ae*Bipfs://bafkreifijr5v27ddyw5rhan7rkjudaytlx2fa6zs2boori36v7bw4xbt44*Bipfs://bafkreifs4pqq4i54el4jjdf5u3d5bdblszehmkb3nayh4mgezt6aiwkc3u*Bipfs://bafkreiafq4rocvolfu3mutge4zlmwvqzwoi6znk32i7uq3tmdnbfqxuq5i*Bipfs://bafkreicob643ixdokgmrevqau5gmpkpeetsgmskjuiwe4xdhkfm7ickcfa*Bipfs://bafkreiazd2siib23axqpnjcvuxd2fivimffg4pynamzmqdm6flkx5xhj7y*Bipfs://bafkreibnzruo4g6wwjpvfa47klc24vhxof2igfy2etwfib3askxdriwbwy*Bipfs://bafkreigw3ix6kzv5fcuw65i27jasme5o6kanoqklx5br73vx4q5k5qnxju*Bipfs://bafkreia3kn2enxhvbscshxlvyeqrkgd62ihumfx6qeg46ui34iclzt6u4y*Bipfs://bafkreie3rmchnfeia6tws27wvtqmi73gm5uymnrnq2g6tfxvmnolfcxjt4*Bipfs://bafkreibaurtpylruxdm3dcbvxt32h2bvgepams4tzma7c6cmrq4iq2gigm*Bipfs://bafkreide7atuf63kx45ng6lo7ngoxdh5tuqwlznmniedayxkvb5ulw7bwu*Bipfs://bafkreif2s6aqezht7iwnl44zmlukq5q332ykttrojgf4xoojpd5sa5ah5i*Bipfs://bafkreigpyyzgykh6zvpe4iuiot2a6racdhioyu42j6ad5rh5qknsdoobmy*Bipfs://bafkreialm56c7mvqpheloxotb434xki7tfgjrs7skhnnhd64la5wuugtoi*Bipfs://bafkreih5hxm4tiw4jcwqamzclz5spcpbpctia4djd6snofveorv7hgkaiq*Bipfs://bafkreicb6eqjdx6dvwgu3lbka72tntfsq34etqmf5cytdqp67kromcesdi*Bipfs://bafkreidsfzawxporeseo6z5isrhwqjrabpbd7hyvfex2utylhz7nlgsrza*Bipfs://bafkreicvigzb2v3fij2y4posjmqbnor3jwnztmukcd4uxsfdoo7wvqybx4*Bipfs://bafkreigg52h4vifnckmt3kqwyqb4beybpbqheh7rgzgsq34cvwtek2b4n4*Bipfs://bafkreieendtbhazgdyr6b7zt35d4gfmmuzoluitpjhsc7kol34k2ltdirq*Bipfs://bafkreidl2fam4afztxit6jcl7za4j6xhlgbjy4vinwrmrbewo4erp6pppu*Bipfs://bafkreihk2idh3sb5f667uacfnvb7q46y2l6k2ziavo5q2q77hf7l6fqcde*Bipfs://bafkreifzbqpuhc3x74euqyxpojef77r5fnzhreczkryrvatb4zda52xxsq*Bipfs://bafkreie2y2erz3mtcvfjmhnf4eacgysix7lum3x43jxgiyuew2auwg6rw4*Bipfs://bafkreibplw6fvkct42olrww7vu5ky7tdei5ema4vauutm3ezojl7zou63m*Bipfs://bafkreigyzt5xeo4iaussbtma7vsldd4xiae4ahulgkisvjraxab4wbgozy*Bipfs://bafkreib3ryto7s7gsfao6wftw6lygq777gnaemkdhzccqanqoe7nnfeety*Bipfs://bafkreifkfqr2ns3zyqcz5vafqcswba2eemhodqwtspvxmymbjraak2grd4*Bipfs://bafkreigbeolyeyu6kdy2bii2ntsi5qssylsuexkwipwh3sd6pfly2oiace*Bipfs://bafkreigiyxn5jacyfxnip4hwkltj5byzuly52477ooybqnqid2n3m3tmlu*Bipfs://bafkreif5ataazy5cb4vviotr2gvadnvhgqgotzef7wflqhy2nnvgsfjgna*Bipfs://bafkreie2j7zy7eydnkzhr42mqr3ymkhgx2cr4ss7xw2tcqn4t2fwmme7l4*Bipfs://bafkreicf33a5m2twflt2jroyvz7zqihyjkfc2tydmcllvuczrdypb7ateu*Bipfs://bafkreidejqxeryz32zeo3dm7yrqbbxqt4wmmqbcayakn2kixxitph3e2ae*Bipfs://bafkreifuayum4y6pqcfv6br2k4ngrl4fhz34igoh37lwvtrnknh5b2vbsy*Bipfs://bafkreifagyvv4ngrq2kb3xzngahh5n7sjjzc24qi25xkprqe7q24uej5qa*Bipfs://bafkreiez73zfc5ijnjspusiqcdive7ie7ubph25rst2frvpzw2rx3frsbu*Bipfs://bafkreiabs4fyqhkvkhzxcyclq3serprgpoy7tds36wemzoqywy63jeekhy*Bipfs://bafkreigyznnfh6gpyevuatlgsveaz3gpoo7nboray5nijbcb2hngec42re*Bipfs://bafkreidnnijoloqul547lrcxvdr2eae3tjd6nk3gdvd6xnva6iewpigk3i*Bipfs://bafkreiftikyin32lxytm2mbv5mwmoh4lodgwhgtbcxh4fdmbvz4ak4etki*Bipfs://bafkreih33wc5yhc6xc6fchnawfa6t2axtfc37ngaooftaebxr36a34lgua*Bipfs://bafkreiavcv77raw6lfr2y2aud2bmy5mq2eknt57ea7m347vikc2ozlq5xq*Bipfs://bafkreif6vv7i3pljnsauqe6btgo43ipblpzmersavrfe2gol5izi37lwla*Bipfs://bafkreiat2s6ucdun4op6lqxgy7d3gofdjuuj2fr5lvbs2ivvu2skyev5re*Bipfs://bafkreiftb533er5kxthpo2da4syezlunkvkdrrsby37spy3m3a5vm4bn54*Bipfs://bafkreielkphh6wtkrbgjlhwsfwdbmlgkvphefva6fa5iqjf37q3htnnsee*Bipfs://bafkreibezlbqa6py4dubgcfmmdrmr4epk6rfpj4dtuvs35roj2phyikqlm*Bipfs://bafkreihjgrxc4mzikl7cn5bnss4yxtabsczvt4unpgsrb4vehlwskmwh34*Bipfs://bafkreiaqpcjcng2kbekbgk7zkjfe5a3jejyaat4ef4n7ifjt745yvutlny*Bipfs://bafkreieatvhaw7u2ynolbufg3r3nfg5j24zpdwbr2szqoqlxntzi4rdf3y*Bipfs://bafkreidtkskznn7d2zmvpl42dueqeu53gfnprvkb3yqixrvec3tmenizcm*Bipfs://bafkreieapigfr2ayaoknadr5i5kmk7ot2cixeqoc2iiok77mcte37yvroq*Bipfs://bafkreidf7wadtdq5hnkx4n45ucvep2dok5hznww6ortaoq3azymxv5hvya*Bipfs://bafkreiaydilylljbid6sk57wlbsuhgfbbispfdoloyn3svzy4uq6lbexia*Bipfs://bafkreifzec3yq3hcfyxjrehtpj3c7lfoqcaqvscj63hqubuvjiigq26aea

Large diffs are not rendered by default.

Loading

0 comments on commit 4ef890e

Please sign in to comment.