Skip to content

Commit

Permalink
refactor: Rename crates to match reference implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
cvauclair committed Dec 12, 2024
1 parent e5bfbbe commit f51c740
Show file tree
Hide file tree
Showing 88 changed files with 182 additions and 184 deletions.
136 changes: 68 additions & 68 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", "indexer", "sink", "web3-utils",
"cli", "codegen", "sdk", "ipfs", "sink", "substreams-utils", "web3-utils",
]

2 changes: 1 addition & 1 deletion api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ 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" }
sink = { version = "0.1.0", path = "../sink" }

[dev-dependencies]
serde_path_to_error = "0.1.16"
6 changes: 3 additions & 3 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 indexer::kg;
use sink::kg;
use tokio::net::TcpListener;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

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

Check warning on line 23 in api/src/main.rs

View workflow job for this annotation

GitHub Actions / stable / fmt

Diff in /home/runner/work/kg-node/kg-node/api/src/main.rs
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 = indexer::kg::Client::new(
let kg_client = sink::kg::Client::new(
&args.neo4j_args.neo4j_uri,
&args.neo4j_args.neo4j_user,
&args.neo4j_args.neo4j_pass,
Expand Down
6 changes: 3 additions & 3 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ version = "0.1.0"
edition = "2021"

[dependencies]
kg-codegen = { version = "0.1.0", path = "../codegen" }
kg-core = { version = "0.1.0", path = "../core" }
indexer = { version = "0.1.0", path = "../indexer" }
codegen = { version = "0.1.0", path = "../codegen" }
sdk = { version = "0.1.0", path = "../sdk" }
sink = { version = "0.1.0", path = "../sink" }
ipfs = { version = "0.1.0", path = "../ipfs" }

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

Expand Down Expand Up @@ -67,7 +65,7 @@ async fn main() -> anyhow::Result<()> {
}
}
Command::Codegen => {
let code = kg_codegen::codegen(&kg_client).await?;
let code = codegen::codegen(&kg_client).await?;
std::fs::write("./src/space.ts", code)?;
println!("Generated code has been written to ./src/space.ts");
}
Expand Down
6 changes: 3 additions & 3 deletions codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "kg-codegen"
name = "codegen"
version = "0.1.0"
edition = "2021"

Expand All @@ -15,5 +15,5 @@ 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" }
sdk = { version = "0.1.0", path = "../sdk" }
sink = { version = "0.1.0", path = "../sink" }
12 changes: 6 additions & 6 deletions codegen/src/lib.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_core::system_ids;
use indexer::kg::mapping::{Named, Node};
use sdk::system_ids;
use sink::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: &indexer::kg::Client, attributes: &[&(Node<Named>, Option<Node<Named>>)]) -> Constructor {
pub fn gen_type_constructor(kg: &sink::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: &indexer::kg::Client, entity: &Node<Named>) -> anyhow::Result<Decl> {
pub async fn gen_type(kg: &sink::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: &indexer::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: &indexer::kg::Client) -> anyhow::Result<Program> {
pub async fn gen_types(kg: &sink::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: &indexer::kg::Client) -> anyhow::Result<Program> {
}

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

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

use futures::{stream, StreamExt, TryStreamExt};
use indexer::kg::grc20;
use indexer::system_ids;
use sink::kg::grc20;
use sink::system_ids;
use swc::config::SourceMapsConfig;
use swc::PrintArgs;
use swc_common::{sync::Lrc, SourceMap, Span, SyntaxContext};
use swc_core::{quote, quote_expr};
use swc_sdk::{quote, quote_expr};
use swc_ecma_ast::{
AssignExpr, AssignOp, AssignTarget, BindingIdent, BlockStmt, Class, ClassDecl, ClassMember, ClassMethod, ClassProp, Constructor, Decl, EsVersion, Expr, ExprStmt, Function, Ident, IdentName, MemberExpr, MemberProp, MethodKind, Param, ParamOrTsParamProp, Pat, PropName, ReturnStmt, SimpleAssignTarget, Stmt, ThisExpr, Tpl, TsInterfaceBody, TsInterfaceDecl, TsKeywordType, TsPropertySignature, TsType, TsTypeAnn, TsTypeElement
};
Expand Down
33 changes: 0 additions & 33 deletions indexer/Cargo.toml

This file was deleted.

5 changes: 0 additions & 5 deletions indexer/src/lib.rs

This file was deleted.

Loading

0 comments on commit f51c740

Please sign in to comment.