sdk

Radroots SDK and bindings
git clone https://radroots.dev/git/sdk.git
Log | Files | Refs | README

commit 536636a0fc5d10b541edba5cdeb9a7fcf8705993
parent 67fc0bf8adf131904f70c6cd45e115b734bd9932
Author: triesap <tyson@radroots.org>
Date:   Wed, 24 Jun 2026 06:32:26 +0000

dto: render core bindings from source roots

Diffstat:
MCargo.lock | 1-
Mpackages/core-bindings/src/generated/types.ts | 14+++++++-------
Mtools/xtask/Cargo.toml | 1-
Mtools/xtask/src/check.rs | 2+-
Mtools/xtask/src/dto_roots.rs | 15+++++++++++++++
Mtools/xtask/src/generate.rs | 2+-
Mtools/xtask/src/output.rs | 10++++++----
7 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -2049,7 +2049,6 @@ version = "0.1.0" dependencies = [ "dto_bindgen_core", "radroots_core", - "radroots_core_bindings", "radroots_events", "radroots_events_bindings", "radroots_events_indexed_bindings", diff --git a/packages/core-bindings/src/generated/types.ts b/packages/core-bindings/src/generated/types.ts @@ -4,22 +4,22 @@ export type RadrootsCoreCurrency = string; export type RadrootsCoreDecimal = string; -export type RadrootsCoreDiscount = { scope: RadrootsCoreDiscountScope, threshold: RadrootsCoreDiscountThreshold, value: RadrootsCoreDiscountValue, }; - export type RadrootsCoreDiscountScope = "bin" | "order_total"; -export type RadrootsCoreDiscountThreshold = { kind: "bin_count", amount: { bin_id: string, min: number, }, } | { kind: "order_quantity", amount: { min: RadrootsCoreQuantity, }, }; +export type RadrootsCoreUnit = "each" | "kg" | "g" | "oz" | "lb" | "l" | "ml"; -export type RadrootsCoreDiscountValue = { kind: "money_per_bin", amount: RadrootsCoreMoney, } | { kind: "percent", amount: RadrootsCorePercent, }; +export type RadrootsCoreQuantity = { amount: string, unit: RadrootsCoreUnit, label?: string | null, }; + +export type RadrootsCoreDiscountThreshold = { kind: "bin_count", amount: { bin_id: string, min: number, }, } | { kind: "order_quantity", amount: { min: RadrootsCoreQuantity, }, }; export type RadrootsCoreMoney = { amount: string, currency: string, }; export type RadrootsCorePercent = { value: string, }; -export type RadrootsCoreQuantity = { amount: string, unit: RadrootsCoreUnit, label: string | null, }; +export type RadrootsCoreDiscountValue = { kind: "money_per_bin", amount: RadrootsCoreMoney, } | { kind: "percent", amount: RadrootsCorePercent, }; -export type RadrootsCoreQuantityPrice = { amount: RadrootsCoreMoney, quantity: RadrootsCoreQuantity, }; +export type RadrootsCoreDiscount = { scope: RadrootsCoreDiscountScope, threshold: RadrootsCoreDiscountThreshold, value: RadrootsCoreDiscountValue, }; -export type RadrootsCoreUnit = "each" | "kg" | "g" | "oz" | "lb" | "l" | "ml"; +export type RadrootsCoreQuantityPrice = { amount: RadrootsCoreMoney, quantity: RadrootsCoreQuantity, }; export type RadrootsCoreUnitDimension = "count" | "mass" | "volume"; diff --git a/tools/xtask/Cargo.toml b/tools/xtask/Cargo.toml @@ -16,7 +16,6 @@ path = "src/main.rs" dto_bindgen_core = { workspace = true } radroots_sdk_binding_model = { path = "../../crates/binding_model" } radroots_core = { workspace = true, features = ["dto-bindgen"] } -radroots_core_bindings = { path = "../../crates/core_bindings" } radroots_events = { workspace = true, features = ["dto-bindgen"] } radroots_events_bindings = { path = "../../crates/events_bindings" } radroots_events_indexed_bindings = { path = "../../crates/events_indexed_bindings" } diff --git a/tools/xtask/src/check.rs b/tools/xtask/src/check.rs @@ -28,7 +28,7 @@ pub fn check() -> Result<(), String> { for spec in wasm_package_specs() { check_wasm_package_surface(&root, *spec)?; } - for output in package_outputs() { + for output in package_outputs()? { for expected in output.files() { let path = root .join(output.spec.package_dir) diff --git a/tools/xtask/src/dto_roots.rs b/tools/xtask/src/dto_roots.rs @@ -1,5 +1,7 @@ use dto_bindgen_core::{Registry, RootDescriptor, build_registry}; +use crate::dto_render::{DtoRegistryRenderOptions, DtoTypesModule, render_registry_types}; + #[derive(Clone, Copy, Debug)] pub struct DtoPackageRootSet { pub package_key: &'static str, @@ -103,6 +105,19 @@ pub fn package_root_set(package_key: &str) -> Option<&'static DtoPackageRootSet> .find(|root_set| root_set.package_key == package_key) } +pub fn core_types_module() -> Result<DtoTypesModule, String> { + let root_set = package_root_set("core").ok_or_else(|| "missing core DTO roots".to_owned())?; + let rendered = + render_registry_types(&root_set.registry(), &DtoRegistryRenderOptions::default())?; + Ok(DtoTypesModule::new( + rendered.imports_ts().unwrap_or_default(), + format!( + "export type RadrootsCoreCurrency = string;\n\nexport type RadrootsCoreDecimal = string;\n\n{}", + rendered.body_ts() + ), + )) +} + fn core_roots() -> Vec<RootDescriptor> { radroots_core::dto::dto_roots().into_iter().collect() } diff --git a/tools/xtask/src/generate.rs b/tools/xtask/src/generate.rs @@ -3,7 +3,7 @@ use crate::{fs::workspace_root, output::package_outputs, package_matrix::validat pub fn generate_ts() -> Result<(), String> { validate_package_matrix()?; let root = workspace_root()?; - for output in package_outputs() { + for output in package_outputs()? { for generated_file in output.files() { let path = root .join(output.spec.package_dir) diff --git a/tools/xtask/src/output.rs b/tools/xtask/src/output.rs @@ -1,5 +1,6 @@ use crate::{ dto_render::DtoTypesModule, + dto_roots, manifest::manifest_file_name, manifest::package_manifest, package_matrix::{PackageSpec, package_specs}, @@ -76,11 +77,11 @@ impl PackageOutput { } } -pub fn package_outputs() -> Vec<PackageOutput> { - vec![ +pub fn package_outputs() -> Result<Vec<PackageOutput>, String> { + Ok(vec![ PackageOutput { spec: spec_by_key("core"), - types_ts: Some(TsSource::Module(radroots_core_bindings::types_module())), + types_ts: Some(TsSource::DtoRegistry(dto_roots::core_types_module()?)), types_imports_ts: None, constants_ts: None, kinds_ts: None, @@ -135,7 +136,7 @@ pub fn package_outputs() -> Vec<PackageOutput> { constants_ts: None, kinds_ts: None, }, - ] + ]) } fn spec_by_key(key: &str) -> PackageSpec { @@ -277,6 +278,7 @@ mod tests { #[test] fn includes_core_and_types_outputs() { let package_names = package_outputs() + .expect("package outputs") .into_iter() .map(|output| output.spec.package_name) .collect::<Vec<_>>();