sdk

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

commit 43a9aa2f44c2e4308079e6f06ffa2c8d817ad146
parent 707b579cb60fbd3de67b4d017fbd25255d1952d8
Author: triesap <tyson@radroots.org>
Date:   Thu, 11 Jun 2026 06:25:01 -0700

feat(trade-bindings): generate trade package

Diffstat:
MCargo.lock | 1+
Mcrates/trade_bindings/src/lib.rs | 15+++++++++++++++
Mcrates/xtask/Cargo.toml | 1+
Mcrates/xtask/src/output.rs | 33+++++++++++++++++++++++++++++++++
Apackages/trade-bindings/src/generated/sdk-manifest.json | 6++++++
Apackages/trade-bindings/src/generated/types.ts | 114+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpackages/trade-bindings/src/index.ts | 2+-
7 files changed, 171 insertions(+), 1 deletion(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -685,6 +685,7 @@ dependencies = [ "radroots_events_indexed_bindings", "radroots_identity_bindings", "radroots_replica_db_schema_bindings", + "radroots_trade_bindings", "radroots_types_bindings", "serde_json", ] diff --git a/crates/trade_bindings/src/lib.rs b/crates/trade_bindings/src/lib.rs @@ -1 +1,16 @@ pub use radroots_trade as upstream; + +pub const TYPES_TS: &str = + include_str!("../../../testdata/baseline/current-radroots-generated/trade/types.ts"); + +#[cfg(test)] +mod tests { + use super::TYPES_TS; + + #[test] + fn preserves_trade_type_exports() { + assert!(TYPES_TS.contains("export type RadrootsTradeListingTotal")); + assert!(TYPES_TS.contains("export type RadrootsTradeOrderWorkflowProjection")); + assert!(TYPES_TS.contains("export type RadrootsTradeMarketplaceOrderSummary")); + } +} diff --git a/crates/xtask/Cargo.toml b/crates/xtask/Cargo.toml @@ -19,4 +19,5 @@ radroots_events_indexed_bindings = { path = "../events_indexed_bindings" } radroots_identity_bindings = { path = "../identity_bindings" } radroots_replica_db_schema_bindings = { path = "../replica_db_schema_bindings" } radroots_types_bindings = { path = "../types_bindings" } +radroots_trade_bindings = { path = "../trade_bindings" } serde_json = "1" diff --git a/crates/xtask/src/output.rs b/crates/xtask/src/output.rs @@ -92,6 +92,13 @@ pub fn package_outputs() -> Vec<PackageOutput> { kinds_ts: None, }, PackageOutput { + spec: spec_by_key("trade"), + types_ts: Some(radroots_trade_bindings::TYPES_TS), + types_imports_ts: Some(TRADE_TYPES_IMPORTS_TS), + constants_ts: None, + kinds_ts: None, + }, + PackageOutput { spec: spec_by_key("types"), types_ts: Some(radroots_types_bindings::TYPES_TS), types_imports_ts: None, @@ -136,6 +143,31 @@ const REPLICA_DB_SCHEMA_TYPES_IMPORTS_TS: &str = r#"import type { "#; +const TRADE_TYPES_IMPORTS_TS: &str = r#"import type { + RadrootsCoreCurrency, + RadrootsCoreDecimal, + RadrootsCoreDiscount, + RadrootsCoreDiscountValue, + RadrootsCoreMoney, + RadrootsCoreQuantity, + RadrootsCoreQuantityPrice, + RadrootsCoreUnit, +} from "@radroots/core-bindings"; +import type { + RadrootsListingImage, + RadrootsNostrEventPtr, + RadrootsPlotRef, + RadrootsResourceAreaRef, + RadrootsTradeFulfillmentStatus, + RadrootsTradeMessagePayload, + RadrootsTradeOrderEconomicLine, + RadrootsTradeOrderItem, +} from "@radroots/events-bindings"; + +type bool = boolean; + +"#; + fn render_manifest(spec: PackageSpec) -> String { let mut value = package_manifest(spec); value["generated"] = serde_json::Value::Bool(true); @@ -196,6 +228,7 @@ mod tests { assert!(package_names.contains(&"@radroots/events-indexed-bindings")); assert!(package_names.contains(&"@radroots/identity-bindings")); assert!(package_names.contains(&"@radroots/replica-db-schema-bindings")); + assert!(package_names.contains(&"@radroots/trade-bindings")); assert!(package_names.contains(&"@radroots/types-bindings")); } } diff --git a/packages/trade-bindings/src/generated/sdk-manifest.json b/packages/trade-bindings/src/generated/sdk-manifest.json @@ -0,0 +1,6 @@ +{ + "crate": "radroots_trade_bindings", + "generated": true, + "generator": "radroots_sdk_xtask", + "package": "@radroots/trade-bindings" +} diff --git a/packages/trade-bindings/src/generated/types.ts b/packages/trade-bindings/src/generated/types.ts @@ -0,0 +1,114 @@ +// @generated by cargo xtask generate ts +// Do not edit by hand. +import type { + RadrootsCoreCurrency, + RadrootsCoreDecimal, + RadrootsCoreDiscount, + RadrootsCoreDiscountValue, + RadrootsCoreMoney, + RadrootsCoreQuantity, + RadrootsCoreQuantityPrice, + RadrootsCoreUnit, +} from "@radroots/core-bindings"; +import type { + RadrootsListingImage, + RadrootsNostrEventPtr, + RadrootsPlotRef, + RadrootsResourceAreaRef, + RadrootsTradeFulfillmentStatus, + RadrootsTradeMessagePayload, + RadrootsTradeOrderEconomicLine, + RadrootsTradeOrderItem, +} from "@radroots/events-bindings"; + +type bool = boolean; + +export type RadrootsFarmRef = { pubkey: string, d_tag: string, }; + +export type RadrootsListing = { d_tag: string, farm: RadrootsFarmRef, product: RadrootsListingProduct, primary_bin_id: string, bins: Array<RadrootsListingBin>, resource_area?: RadrootsResourceAreaRef | null, plot?: RadrootsPlotRef | null, discounts?: RadrootsCoreDiscount[] | null, inventory_available?: RadrootsCoreDecimal | null, availability?: RadrootsListingAvailability | null, delivery_method?: RadrootsListingDeliveryMethod | null, location?: RadrootsListingLocation | null, images?: RadrootsListingImage[] | null, }; + +export type RadrootsListingAvailability = { "kind": "window", "amount": { start?: number | null, end?: number | null, } } | { "kind": "status", "amount": { status: RadrootsListingStatus, } }; + +export type RadrootsListingBin = { bin_id: string, quantity: RadrootsCoreQuantity, price_per_canonical_unit: RadrootsCoreQuantityPrice, display_amount?: RadrootsCoreDecimal | null, display_unit?: RadrootsCoreUnit | null, display_label?: string | null, display_price?: RadrootsCoreMoney | null, display_price_unit?: RadrootsCoreUnit | null, }; + +export type RadrootsListingDeliveryMethod = { "kind": "pickup" } | { "kind": "local_delivery" } | { "kind": "shipping" } | { "kind": "other", "amount": { method: string, } }; + +export type RadrootsListingLocation = { primary: string, city?: string | null, region?: string | null, country?: string | null, lat?: number | null, lng?: number | null, geohash?: string | null, }; + +export type RadrootsListingProduct = { key: string, title: string, category: string, summary?: string | null, process?: string | null, lot?: string | null, location?: string | null, profile?: string | null, year?: string | null, }; + +export type RadrootsListingStatus = { "kind": "active" } | { "kind": "sold" } | { "kind": "other", "amount": { value: string, } }; + +export type RadrootsTradeFacetCount = { key: string, count: number, }; + +export type RadrootsTradeFulfillmentException = { code: string, severity: RadrootsTradeFulfillmentExceptionSeverity, status: RadrootsTradeFulfillmentExceptionStatus, source?: string | null, notes?: string | null, }; + +export type RadrootsTradeFulfillmentExceptionSeverity = "notice" | "warning" | "blocking"; + +export type RadrootsTradeFulfillmentExceptionStatus = "open" | "monitoring" | "resolved"; + +export type RadrootsTradeListing = { listing_id: string, listing_addr: string, seller_pubkey: string, title: string, description: string, product_type: string, primary_bin_id: string, bin_quantity: RadrootsCoreQuantity, unit: RadrootsCoreUnit, unit_price: RadrootsCoreMoney, inventory_available: RadrootsCoreDecimal, availability: RadrootsListingAvailability, location: RadrootsListingLocation, delivery_method: RadrootsListingDeliveryMethod, listing: RadrootsListing, }; + +export type RadrootsTradeListingBackofficeOverlay = { listing_addr: string, review_queue?: RadrootsTradeReviewQueueEntry | null, moderation_flags: RadrootsTradeModerationFlag[], }; + +export type RadrootsTradeListingBackofficeQuery = { listing: RadrootsTradeListingQuery, requires_review?: boolean | null, has_open_moderation_flags?: boolean | null, }; + +export type RadrootsTradeListingBackofficeView = { listing: RadrootsTradeListingProjection, marketplace?: RadrootsTradeMarketplaceListingSummary | null, overlay?: RadrootsTradeListingBackofficeOverlay | null, requires_review: boolean, open_moderation_flag_count: number, }; + +export type RadrootsTradeListingBinProjection = { bin: RadrootsListingBin, one_bin_total: RadrootsTradeListingTotal, }; + +export type RadrootsTradeListingFacets = { seller_pubkeys: RadrootsTradeFacetCount[], farm_pubkeys: RadrootsTradeFacetCount[], farm_ids: RadrootsTradeFacetCount[], product_keys: RadrootsTradeFacetCount[], product_categories: RadrootsTradeFacetCount[], listing_statuses: RadrootsTradeFacetCount[], }; + +export type RadrootsTradeListingMarketStatus = "unknown" | "window" | "active" | "sold" | { "other": { value: string, } }; + +export type RadrootsTradeListingProjection = { listing_addr: string, seller_pubkey: string, listing_id: string, farm: RadrootsFarmRef, product: RadrootsListingProduct, primary_bin_id: string, bins: RadrootsTradeListingBinProjection[], resource_area?: RadrootsResourceAreaRef | null, plot?: RadrootsPlotRef | null, discounts?: RadrootsCoreDiscount[] | null, inventory_available?: RadrootsCoreDecimal | null, availability?: RadrootsListingAvailability | null, delivery_method?: RadrootsListingDeliveryMethod | null, location?: RadrootsListingLocation | null, images?: RadrootsListingImage[] | null, order_count: number, open_order_count: number, terminal_order_count: number, }; + +export type RadrootsTradeListingQuery = { seller_pubkey?: string | null, farm_pubkey?: string | null, farm_id?: string | null, product_key?: string | null, product_category?: string | null, listing_status?: RadrootsTradeListingMarketStatus | null, }; + +export type RadrootsTradeListingSort = { field: RadrootsTradeListingSortField, direction: RadrootsTradeSortDirection, }; + +export type RadrootsTradeListingSortField = "listing_addr" | "product_title" | "product_category" | "seller_pubkey" | "inventory_available" | "open_order_count" | "total_order_count"; + +export type RadrootsTradeListingSubtotal = { price_amount: RadrootsCoreMoney, price_currency: RadrootsCoreCurrency, quantity_amount: RadrootsCoreDecimal, quantity_unit: RadrootsCoreUnit, }; + +export type RadrootsTradeListingTotal = { price_amount: RadrootsCoreMoney, price_currency: RadrootsCoreCurrency, quantity_amount: RadrootsCoreDecimal, quantity_unit: RadrootsCoreUnit, }; + +export type RadrootsTradeMarketplaceListingSummary = { listing_addr: string, seller_pubkey: string, farm_pubkey: string, farm_id: string, product_key: string, product_title: string, product_category: string, product_summary?: string | null, listing_status: RadrootsTradeListingMarketStatus, location_primary?: string | null, inventory_available?: RadrootsCoreDecimal | null, primary_bin_id: string, primary_bin_label?: string | null, primary_bin_total: RadrootsTradeListingTotal, order_count: number, open_order_count: number, terminal_order_count: number, }; + +export type RadrootsTradeMarketplaceOrderSummary = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, status: RadrootsTradeOrderStatus, last_message_type: RadrootsTradeMessageType, item_count: number, total_bin_count: number, has_requested_discounts: boolean, last_reason?: string | null, }; + +export type RadrootsTradeMessageType = "listing_validate_request" | "listing_validate_result" | "order_request" | "order_response" | "order_revision" | "order_revision_accept" | "order_revision_decline" | "question" | "answer" | "discount_request" | "discount_offer" | "discount_accept" | "discount_decline" | "cancel" | "fulfillment_update" | "receipt"; + +export type RadrootsTradeModerationFlag = { code: string, severity: RadrootsTradeModerationSeverity, status: RadrootsTradeModerationStatus, source?: string | null, reason?: string | null, }; + +export type RadrootsTradeModerationSeverity = "notice" | "warning" | "block"; + +export type RadrootsTradeModerationStatus = "open" | "snoozed" | "resolved"; + +export type RadrootsTradeOrderBackofficeOverlay = { order_id: string, review_queue?: RadrootsTradeReviewQueueEntry | null, moderation_flags: RadrootsTradeModerationFlag[], fulfillment_exceptions: RadrootsTradeFulfillmentException[], }; + +export type RadrootsTradeOrderBackofficeQuery = { order: RadrootsTradeOrderQuery, requires_review?: boolean | null, has_open_moderation_flags?: boolean | null, has_open_fulfillment_exceptions?: boolean | null, }; + +export type RadrootsTradeOrderBackofficeView = { order: RadrootsTradeOrderWorkflowProjection, marketplace: RadrootsTradeMarketplaceOrderSummary, overlay?: RadrootsTradeOrderBackofficeOverlay | null, requires_review: boolean, open_moderation_flag_count: number, open_fulfillment_exception_count: number, }; + +export type RadrootsTradeOrderFacets = { buyer_pubkeys: RadrootsTradeFacetCount[], seller_pubkeys: RadrootsTradeFacetCount[], listing_addrs: RadrootsTradeFacetCount[], statuses: RadrootsTradeFacetCount[], }; + +export type RadrootsTradeOrderQuery = { listing_addr?: string | null, buyer_pubkey?: string | null, seller_pubkey?: string | null, status?: RadrootsTradeOrderStatus | null, }; + +export type RadrootsTradeOrderSort = { field: RadrootsTradeOrderSortField, direction: RadrootsTradeSortDirection, }; + +export type RadrootsTradeOrderSortField = "order_id" | "listing_addr" | "buyer_pubkey" | "seller_pubkey" | "status" | "last_message_type" | "total_bin_count"; + +export type RadrootsTradeOrderStatus = "draft" | "validated" | "requested" | "questioned" | "revised" | "accepted" | "declined" | "cancelled" | "fulfilled" | "completed"; + +export type RadrootsTradeOrderWorkflowMessage = { event_id: string, actor_pubkey: string, counterparty_pubkey: string, listing_addr: string, order_id?: string | null, listing_event?: RadrootsNostrEventPtr | null, root_event_id?: string | null, prev_event_id?: string | null, payload: RadrootsTradeMessagePayload, }; + +export type RadrootsTradeOrderWorkflowProjection = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, items: RadrootsTradeOrderItem[], requested_discounts?: RadrootsTradeOrderEconomicLine[] | null, status: RadrootsTradeOrderStatus, listing_snapshot?: RadrootsNostrEventPtr | null, root_event_id: string, last_event_id: string, last_discount_request?: RadrootsCoreDiscountValue | null, last_discount_offer?: RadrootsCoreDiscountValue | null, accepted_discount?: RadrootsCoreDiscountValue | null, last_fulfillment_status?: RadrootsTradeFulfillmentStatus | null, receipt_acknowledged?: bool | null, receipt_at?: number | null, last_reason?: string | null, last_discount_decline_reason?: string | null, question_count: number, answer_count: number, revision_count: number, discount_request_count: number, discount_offer_count: number, discount_accept_count: number, discount_decline_count: number, cancellation_count: number, fulfillment_update_count: number, receipt_count: number, last_message_type: RadrootsTradeMessageType, last_actor_pubkey: string, }; + +export type RadrootsTradeReviewPriority = "low" | "normal" | "high" | "critical"; + +export type RadrootsTradeReviewQueueEntry = { queue: string, priority: RadrootsTradeReviewPriority, status: RadrootsTradeReviewStatus, assigned_operator?: string | null, reason?: string | null, }; + +export type RadrootsTradeReviewStatus = "queued" | "in_progress" | "blocked" | "resolved"; + +export type RadrootsTradeSortDirection = "asc" | "desc"; diff --git a/packages/trade-bindings/src/index.ts b/packages/trade-bindings/src/index.ts @@ -1 +1 @@ -export {}; +export * from "./generated/types.js";