lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

commit fd602003e3bf97b53ce41355cecb358c514abf76
parent 6c5fda0a5d1adb57fe1eafa1f6efb8350faf762e
Author: triesap <tyson@radroots.org>
Date:   Wed, 12 Nov 2025 19:08:01 +0000

workspace: add `tangle-schema` crate defining mesh networking data structures

Diffstat:
MCargo.lock | 9+++++++++
MCargo.toml | 2++
AMakefile | 23+++++++++++++++++++++++
Atangle-schema/Cargo.toml | 19+++++++++++++++++++
Atangle-schema/bindings/ts/package.json | 42++++++++++++++++++++++++++++++++++++++++++
Atangle-schema/bindings/ts/src/index.ts | 1+
Atangle-schema/bindings/ts/src/types.ts | 11+++++++++++
Atangle-schema/bindings/ts/tsconfig.cjs.json | 15+++++++++++++++
Atangle-schema/bindings/ts/tsconfig.esm.json | 13+++++++++++++
Atangle-schema/bindings/ts/tsconfig.json | 3+++
Atangle-schema/build.rs | 11+++++++++++
Atangle-schema/src/lib.rs | 2++
Atangle-schema/src/tables/log_error.rs | 88+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atangle-schema/src/tables/mod.rs | 1+
14 files changed, 240 insertions(+), 0 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -1799,6 +1799,15 @@ dependencies = [ ] [[package]] +name = "radroots-tangle-schema" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", + "ts-rs", +] + +[[package]] name = "radroots-trade" version = "0.1.0" dependencies = [ diff --git a/Cargo.toml b/Cargo.toml @@ -12,6 +12,7 @@ members = [ "runtime", "sql-wasm-bridge", "sql-wasm-core", + "tangle-schema", "trade", "types", ] @@ -36,6 +37,7 @@ radroots-net = { path = "net", version = "0.1.0", default-features = false } radroots-net-core = { path = "net-core", version = "0.1.0", default-features = false } radroots-sql-wasm-bridge = { path = "sql-wasm-bridge", version = "0.1.0" } radroots-sql-wasm-core = { path = "sql-wasm-core", version = "0.1.0" } +radroots-tangle-schema = { path = "tangle-schema", version = "0.1.0", default-features = false } radroots-trade = { path = "trade", version = "0.1.0", default-features = false } radroots-types = { path = "types", version = "0.1.0", default-features = false } diff --git a/Makefile b/Makefile @@ -0,0 +1,23 @@ +.PHONY: all bindings clean help + +SHELL := /bin/bash +.SHELLFLAGS := -e -o pipefail -c + +all: bindings + +bindings: + cd tangle-schema && cargo test && cd bindings/ts && yarn build + @echo "Building tangle-sql-core bindings" + cd tangle-sql-core && cargo test && cd bindings/ts && yarn build + @echo "Building types bindings" + cd types && cargo test && cd bindings/ts && yarn build + @echo "All bindings built successfully." + +clean: + cargo clean + +help: + @echo "Usage:" + @echo " make bindings Build all Rust + TS bindings for all crates" + @echo " make clean Remove build artifacts" + @echo " make help Show this help message" diff --git a/tangle-schema/Cargo.toml b/tangle-schema/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "radroots-tangle-schema" +version.workspace = true +edition.workspace = true +authors = ["Radroots Authors"] +rust-version.workspace = true +license.workspace = true +build = "build.rs" + +[lib] +crate-type = ["rlib"] + +[features] +default = [] + +[dependencies] +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true } +ts-rs = { workspace = true } diff --git a/tangle-schema/bindings/ts/package.json b/tangle-schema/bindings/ts/package.json @@ -0,0 +1,41 @@ +{ + "name": "@radroots/tangle-schema-bindings", + "version": "1.0.0", + "private": true, + "license": "AGPLv3", + "type": "module", + "main": "./dist/cjs/index.js", + "module": "./dist/esm/index.js", + "types": "./dist/types/index.d.ts", + "exports": { + ".": { + "types": "./dist/types/index.d.ts", + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js" + } + }, + "files": [ + "dist" + ], + "sideEffects": false, + "scripts": { + "build:esm": "tsc -p tsconfig.esm.json", + "build:cjs": "tsc -p tsconfig.cjs.json", + "build": "npm run build:esm && npm run build:cjs", + "prebuild": "npm run clean", + "clean": "rimraf dist", + "dev": "npm run watch", + "watch": "tsc -w" + }, + "devDependencies": { + "@radroots/dev": "*", + "@radroots/tsconfig": "*", + "rimraf": "^6.0.1" + }, + "dependencies": { + "@radroots/types-bindings": "*" + }, + "publishConfig": { + "access": "public" + } +} +\ No newline at end of file diff --git a/tangle-schema/bindings/ts/src/index.ts b/tangle-schema/bindings/ts/src/index.ts @@ -0,0 +1 @@ +export * from "./types.js"; diff --git a/tangle-schema/bindings/ts/src/types.ts b/tangle-schema/bindings/ts/src/types.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type ILogErrorFields = { error: string, message: string, stack_trace: string | null, cause: string | null, app_system: string, app_version: string, nostr_pubkey: string, data: string | null, }; + +export type ILogErrorFieldsFilter = { id?: string, created_at?: string, updated_at?: string, error?: string, message?: string, stack_trace?: string, cause?: string, app_system?: string, app_version?: string, nostr_pubkey?: string, data?: string, }; + +export type ILogErrorFieldsPartial = { error?: string | null, message?: string | null, stack_trace?: string | null, cause?: string | null, app_system?: string | null, app_version?: string | null, nostr_pubkey?: string | null, data?: string | null, }; + +export type LogError = { id: string, created_at: string, updated_at: string, error: string, message: string, stack_trace: string | null, cause: string | null, app_system: string, app_version: string, nostr_pubkey: string, data: string | null, }; + +export type LogErrorQueryBindValues = { id: string, } | { nostr_pubkey: string, }; diff --git a/tangle-schema/bindings/ts/tsconfig.cjs.json b/tangle-schema/bindings/ts/tsconfig.cjs.json @@ -0,0 +1,15 @@ +{ + "extends": "@radroots/tsconfig/tsconfig.esm.json", + "compilerOptions": { + "module": "CommonJS", + "moduleResolution": "Node", + "rootDir": "./src", + "outDir": "dist/cjs", + "declaration": false, + "declarationMap": false, + "emitDeclarationOnly": false, + "tsBuildInfoFile": "node_modules/.cache/tsc.utils-nostr.cjs.tsbuildinfo" + }, + "include": ["src"], + "exclude": ["node_modules", "dist"] +} diff --git a/tangle-schema/bindings/ts/tsconfig.esm.json b/tangle-schema/bindings/ts/tsconfig.esm.json @@ -0,0 +1,13 @@ +{ + "extends": "@radroots/tsconfig/tsconfig.esm.json", + "compilerOptions": { + "moduleResolution": "nodenext", + "rootDir": "./src", + "outDir": "dist/esm", + "declaration": true, + "declarationMap": true, + "declarationDir": "dist/types" + }, + "include": ["src"], + "exclude": ["node_modules", "dist"] +} diff --git a/tangle-schema/bindings/ts/tsconfig.json b/tangle-schema/bindings/ts/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "./tsconfig.esm.json" +} diff --git a/tangle-schema/build.rs b/tangle-schema/build.rs @@ -0,0 +1,11 @@ +use std::{fs, path::Path}; + +fn main() { + println!("cargo:rustc-env=TS_RS_EXPORT_DIR=./bindings/ts/src"); + let out_dir = Path::new("bindings/ts/src"); + if !out_dir.exists() { + fs::create_dir_all(out_dir).expect("create TS export dir"); + } + println!("cargo:rerun-if-changed=src"); + println!("cargo:rerun-if-changed=build.rs"); +} diff --git a/tangle-schema/src/lib.rs b/tangle-schema/src/lib.rs @@ -0,0 +1,2 @@ +pub mod tables; +pub use tables::*; diff --git a/tangle-schema/src/tables/log_error.rs b/tangle-schema/src/tables/log_error.rs @@ -0,0 +1,88 @@ +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use ts_rs::TS; + +#[derive(Serialize, Deserialize, TS)] +#[ts(export, export_to = "types.ts")] +pub struct LogError { + pub id: String, + pub created_at: String, + pub updated_at: String, + pub error: String, + pub message: String, + pub stack_trace: Option<String>, + pub cause: Option<String>, + pub app_system: String, + pub app_version: String, + pub nostr_pubkey: String, + pub data: Option<String>, +} + +#[derive(Clone, Deserialize, Serialize, TS)] +#[ts(export, export_to = "types.ts")] +pub struct ILogErrorFields { + pub error: String, + pub message: String, + pub stack_trace: Option<String>, + pub cause: Option<String>, + pub app_system: String, + pub app_version: String, + pub nostr_pubkey: String, + pub data: Option<String>, +} + +#[derive(Clone, Deserialize, Serialize, TS)] +#[ts(export, export_to = "types.ts")] +pub struct ILogErrorFieldsPartial { + #[ts(optional, type = "string | null")] + pub error: Option<Value>, + #[ts(optional, type = "string | null")] + pub message: Option<Value>, + #[ts(optional, type = "string | null")] + pub stack_trace: Option<Value>, + #[ts(optional, type = "string | null")] + pub cause: Option<Value>, + #[ts(optional, type = "string | null")] + pub app_system: Option<Value>, + #[ts(optional, type = "string | null")] + pub app_version: Option<Value>, + #[ts(optional, type = "string | null")] + pub nostr_pubkey: Option<Value>, + #[ts(optional, type = "string | null")] + pub data: Option<Value>, +} + +#[derive(Clone, Deserialize, Serialize, TS)] +#[ts(export, export_to = "types.ts")] +pub struct ILogErrorFieldsFilter { + #[ts(optional)] + pub id: Option<String>, + #[ts(optional)] + pub created_at: Option<String>, + #[ts(optional)] + pub updated_at: Option<String>, + #[ts(optional)] + pub error: Option<String>, + #[ts(optional)] + pub message: Option<String>, + #[ts(optional)] + pub stack_trace: Option<String>, + #[ts(optional)] + pub cause: Option<String>, + #[ts(optional)] + pub app_system: Option<String>, + #[ts(optional)] + pub app_version: Option<String>, + #[ts(optional)] + pub nostr_pubkey: Option<String>, + #[ts(optional)] + pub data: Option<String>, +} + +#[derive(Clone, Serialize, Deserialize, TS)] +#[serde(untagged)] +#[ts(export, export_to = "types.ts")] +pub enum LogErrorQueryBindValues { + Id { id: String }, + NostrPubkey { nostr_pubkey: String }, +} diff --git a/tangle-schema/src/tables/mod.rs b/tangle-schema/src/tables/mod.rs @@ -0,0 +1 @@ +pub mod log_error;