lib

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

commit 6148c0d35a84870c6aa9b7a94cee5da780540c16
parent 3fe5f98493474202efdf85b81e72d43388e8c1b5
Author: triesap <tyson@radroots.org>
Date:   Wed, 24 Jun 2026 07:38:11 +0000

dto: render events package roots

- Add dto_bindgen derives across source-owned event DTO structs and enums.

- Expand the events dto root registry to cover the generated package surface.

- Preserve core decimal and currency aliases through explicit manual descriptors.

- Encode approved optional, tuple, enum, and large-integer policies for events output.

Diffstat:
MCargo.lock | 39+++++++++++++++++++++++++++++++++++++++
MCargo.toml | 1+
Mcrates/events/Cargo.toml | 3++-
Mcrates/events/src/account.rs | 1+
Mcrates/events/src/app_data.rs | 1+
Mcrates/events/src/coop.rs | 3+++
Mcrates/events/src/document.rs | 2++
Mcrates/events/src/dto.rs | 1762++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mcrates/events/src/farm.rs | 6++++++
Mcrates/events/src/follow.rs | 2++
Mcrates/events/src/geochat.rs | 1+
Mcrates/events/src/gift_wrap.rs | 2++
Mcrates/events/src/job.rs | 12++++++++++++
Mcrates/events/src/job_feedback.rs | 1+
Mcrates/events/src/job_request.rs | 3+++
Mcrates/events/src/job_result.rs | 1+
Mcrates/events/src/list.rs | 2++
Mcrates/events/src/list_set.rs | 1+
Mcrates/events/src/listing.rs | 1+
Mcrates/events/src/message.rs | 2++
Mcrates/events/src/message_file.rs | 3+++
Mcrates/events/src/order.rs | 39++++++++++++++++++++++++++++++++++++---
Mcrates/events/src/order_economics.rs | 31+++++++++++++++++++++++++++++++
Mcrates/events/src/plot.rs | 3+++
Mcrates/events/src/profile.rs | 7+++++++
Mcrates/events/src/relay_document.rs | 1+
Mcrates/events/src/resource_area.rs | 3+++
Mcrates/events/src/resource_cap.rs | 1+
Mcrates/events/src/seal.rs | 1+
Mcrates/events/src/trade_validation.rs | 10++++++++++
30 files changed, 1936 insertions(+), 9 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -1500,6 +1500,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] +name = "dto_bindgen" +version = "0.1.0" +source = "git+https://github.com/triesap/dto_bindgen?rev=96ed6c691aacab31860828d25da2e0167b13d92c#96ed6c691aacab31860828d25da2e0167b13d92c" +dependencies = [ + "dto_bindgen_backend_python", + "dto_bindgen_backend_ts", + "dto_bindgen_core", + "dto_bindgen_macros", + "sha2", +] + +[[package]] +name = "dto_bindgen_backend_python" +version = "0.1.0" +source = "git+https://github.com/triesap/dto_bindgen?rev=96ed6c691aacab31860828d25da2e0167b13d92c#96ed6c691aacab31860828d25da2e0167b13d92c" +dependencies = [ + "dto_bindgen_core", +] + +[[package]] +name = "dto_bindgen_backend_ts" +version = "0.1.0" +source = "git+https://github.com/triesap/dto_bindgen?rev=96ed6c691aacab31860828d25da2e0167b13d92c#96ed6c691aacab31860828d25da2e0167b13d92c" +dependencies = [ + "dto_bindgen_core", +] + +[[package]] name = "dto_bindgen_core" version = "0.1.0" source = "git+https://github.com/triesap/dto_bindgen?rev=96ed6c691aacab31860828d25da2e0167b13d92c#96ed6c691aacab31860828d25da2e0167b13d92c" @@ -1514,6 +1542,16 @@ dependencies = [ ] [[package]] +name = "dto_bindgen_macros" +version = "0.1.0" +source = "git+https://github.com/triesap/dto_bindgen?rev=96ed6c691aacab31860828d25da2e0167b13d92c#96ed6c691aacab31860828d25da2e0167b13d92c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] name = "dynasm" version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4261,6 +4299,7 @@ dependencies = [ name = "radroots_events" version = "0.1.0-alpha.2" dependencies = [ + "dto_bindgen", "dto_bindgen_core", "hex", "radroots_core", diff --git a/Cargo.toml b/Cargo.toml @@ -58,6 +58,7 @@ homepage = "https://radroots.org" readme = "README" [workspace.dependencies] +dto_bindgen = { git = "https://github.com/triesap/dto_bindgen", rev = "96ed6c691aacab31860828d25da2e0167b13d92c", package = "dto_bindgen" } dto_bindgen_core = { git = "https://github.com/triesap/dto_bindgen", rev = "96ed6c691aacab31860828d25da2e0167b13d92c", package = "dto_bindgen_core" } radroots_core = { path = "crates/core", version = "0.1.0-alpha.2", default-features = false } radroots_events = { path = "crates/events", version = "0.1.0-alpha.2", default-features = false } diff --git a/crates/events/Cargo.toml b/crates/events/Cargo.toml @@ -14,11 +14,12 @@ readme = "README" [features] default = ["std", "serde"] -dto-bindgen = ["std", "serde", "dep:dto_bindgen_core", "radroots_core/dto-bindgen"] +dto-bindgen = ["std", "serde", "dep:dto_bindgen", "dep:dto_bindgen_core", "radroots_core/dto-bindgen"] std = ["radroots_core/std"] serde = ["dep:serde", "radroots_core/serde"] [dependencies] +dto_bindgen = { workspace = true, optional = true } dto_bindgen_core = { workspace = true, optional = true } radroots_core = { workspace = true, default-features = false } hex = { version = "0.4", default-features = false, features = ["alloc"] } diff --git a/crates/events/src/account.rs b/crates/events/src/account.rs @@ -5,6 +5,7 @@ use alloc::string::String; pub const KIND_ACCOUNT_CLAIM: u32 = KIND_ACCOUNT_CLAIM_EVENT; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsAccountClaim { diff --git a/crates/events/src/app_data.rs b/crates/events/src/app_data.rs @@ -7,6 +7,7 @@ use alloc::string::String; pub const KIND_APP_DATA: u32 = KIND_APP_DATA_EVENT; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsAppData { diff --git a/crates/events/src/coop.rs b/crates/events/src/coop.rs @@ -5,6 +5,7 @@ use crate::farm::RadrootsGcsLocation; #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsCoop { @@ -18,6 +19,7 @@ pub struct RadrootsCoop { pub tags: Option<Vec<String>>, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsCoopRef { @@ -25,6 +27,7 @@ pub struct RadrootsCoopRef { pub d_tag: String, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsCoopLocation { diff --git a/crates/events/src/document.rs b/crates/events/src/document.rs @@ -3,6 +3,7 @@ #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsDocumentSubject { @@ -10,6 +11,7 @@ pub struct RadrootsDocumentSubject { pub address: Option<String>, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsDocument { diff --git a/crates/events/src/dto.rs b/crates/events/src/dto.rs @@ -1,23 +1,208 @@ use dto_bindgen_core::{ - DescribeCtx, Dto, FieldDef, FieldPresence, IdentName, RootDescriptor, RustTypeId, SourceSpan, - StructDef, TargetFieldNames, TypeDef, TypeRef, WireFieldNames, + DescribeCtx, Dto, EnumDef, EnumRepr, FieldDef, FieldPresence, GenericParam, IdentName, IntRepr, + RootDescriptor, RustTypeId, SourceSpan, StructDef, TargetFieldNames, TypeDef, TypeRef, + VariantDef, VariantShape, WireFieldNames, }; +use radroots_core::RadrootsCoreDiscountValue; use crate::{ RadrootsNostrEvent, RadrootsNostrEventPtr, RadrootsNostrEventRef, - listing::{RadrootsListingImage, RadrootsListingImageSize, RadrootsListingProduct}, + account::RadrootsAccountClaim, + app_data::RadrootsAppData, + comment::RadrootsComment, + coop::{RadrootsCoop, RadrootsCoopLocation, RadrootsCoopRef}, + document::{RadrootsDocument, RadrootsDocumentSubject}, + farm::{ + RadrootsFarm, RadrootsFarmLocation, RadrootsFarmRef, RadrootsGcsLocation, + RadrootsGeoJsonPoint, RadrootsGeoJsonPolygon, + }, + follow::{RadrootsFollow, RadrootsFollowProfile}, + geochat::RadrootsGeoChat, + gift_wrap::{RadrootsGiftWrap, RadrootsGiftWrapRecipient}, + ids::{ + RadrootsDTag, RadrootsEventId, RadrootsInventoryBinId, RadrootsListingAddress, + RadrootsOrderId, RadrootsOrderQuoteId, RadrootsOrderRevisionId, RadrootsPublicKey, + }, + job::{JobFeedbackStatus, JobInputType, JobPaymentRequest}, + job_feedback::RadrootsJobFeedback, + job_request::{RadrootsJobInput, RadrootsJobParam, RadrootsJobRequest}, + job_result::RadrootsJobResult, + list::{RadrootsList, RadrootsListEntry}, + list_set::RadrootsListSet, + listing::{ + RadrootsListing, RadrootsListingAvailability, RadrootsListingBin, + RadrootsListingDeliveryMethod, RadrootsListingImage, RadrootsListingImageSize, + RadrootsListingLocation, RadrootsListingProduct, RadrootsListingStatus, + }, + message::{RadrootsMessage, RadrootsMessageRecipient}, + message_file::{RadrootsMessageFile, RadrootsMessageFileDimensions}, + order::{ + RadrootsCommercialDomain, RadrootsListingParseError, RadrootsOrderCancellation, + RadrootsOrderDecision, RadrootsOrderDecisionOutcome, RadrootsOrderEventType, + RadrootsOrderInventoryCommitment, RadrootsOrderRequest, RadrootsOrderRevisionDecision, + RadrootsOrderRevisionOutcome, RadrootsOrderRevisionProposal, + }, + order_economics::{ + RadrootsOrderEconomicActor, RadrootsOrderEconomicEffect, RadrootsOrderEconomicItem, + RadrootsOrderEconomicLine, RadrootsOrderEconomicLineKind, RadrootsOrderEconomicTotals, + RadrootsOrderEconomics, RadrootsOrderItem, RadrootsOrderPricingBasis, + }, + plot::{RadrootsPlot, RadrootsPlotLocation, RadrootsPlotRef}, + post::RadrootsPost, + profile::{RadrootsProfile, RadrootsProfileType}, + reaction::RadrootsReaction, + relay_document::RadrootsRelayDocument, + resource_area::{RadrootsResourceArea, RadrootsResourceAreaLocation, RadrootsResourceAreaRef}, + resource_cap::{RadrootsResourceHarvestCap, RadrootsResourceHarvestProduct}, + seal::RadrootsSeal, + trade_validation::{ + RadrootsTradeValidationListingError, RadrootsTradeValidationListingRequest, + RadrootsTradeValidationListingResult, + }, }; -pub fn dto_roots() -> [RootDescriptor; 5] { - [ +pub fn dto_roots() -> Vec<RootDescriptor> { + vec![ + RootDescriptor::new::<JobFeedbackStatus>(), + RootDescriptor::new::<JobInputType>(), + RootDescriptor::new::<JobPaymentRequest>(), + RootDescriptor::new::<RadrootsAccountClaim>(), + RootDescriptor::new::<RadrootsActiveTradeEnvelopeDto>(), + RootDescriptor::new::<RadrootsAppData>(), + RootDescriptor::new::<RadrootsComment>(), + RootDescriptor::new::<RadrootsCoop>(), + RootDescriptor::new::<RadrootsCoopLocation>(), + RootDescriptor::new::<RadrootsCoopRef>(), + RootDescriptor::new::<RadrootsDocument>(), + RootDescriptor::new::<RadrootsDocumentSubject>(), + RootDescriptor::new::<RadrootsFarm>(), + RootDescriptor::new::<RadrootsFarmLocation>(), + RootDescriptor::new::<RadrootsFarmRef>(), + RootDescriptor::new::<RadrootsFollow>(), + RootDescriptor::new::<RadrootsFollowProfile>(), + RootDescriptor::new::<RadrootsGcsLocation>(), + RootDescriptor::new::<RadrootsGeoChat>(), + RootDescriptor::new::<RadrootsGeoJsonPoint>(), + RootDescriptor::new::<RadrootsGeoJsonPolygon>(), + RootDescriptor::new::<RadrootsGiftWrap>(), + RootDescriptor::new::<RadrootsGiftWrapRecipient>(), + RootDescriptor::new::<RadrootsJobFeedback>(), + RootDescriptor::new::<RadrootsJobInput>(), + RootDescriptor::new::<RadrootsJobParam>(), + RootDescriptor::new::<RadrootsJobRequest>(), + RootDescriptor::new::<RadrootsJobResult>(), + RootDescriptor::new::<RadrootsList>(), + RootDescriptor::new::<RadrootsListEntry>(), + RootDescriptor::new::<RadrootsListSet>(), + RootDescriptor::new::<RadrootsListing>(), + RootDescriptor::new::<RadrootsListingAvailability>(), + RootDescriptor::new::<RadrootsListingBin>(), + RootDescriptor::new::<RadrootsListingDeliveryMethod>(), RootDescriptor::new::<RadrootsNostrEvent>(), RootDescriptor::new::<RadrootsNostrEventRef>(), RootDescriptor::new::<RadrootsNostrEventPtr>(), + RootDescriptor::new::<RadrootsListingLocation>(), RootDescriptor::new::<RadrootsListingProduct>(), + RootDescriptor::new::<RadrootsListingStatus>(), RootDescriptor::new::<RadrootsListingImage>(), + RootDescriptor::new::<RadrootsMessage>(), + RootDescriptor::new::<RadrootsMessageFile>(), + RootDescriptor::new::<RadrootsMessageFileDimensions>(), + RootDescriptor::new::<RadrootsMessageRecipient>(), + RootDescriptor::new::<RadrootsPlot>(), + RootDescriptor::new::<RadrootsPlotLocation>(), + RootDescriptor::new::<RadrootsPlotRef>(), + RootDescriptor::new::<RadrootsPost>(), + RootDescriptor::new::<RadrootsProfile>(), + RootDescriptor::new::<RadrootsProfileType>(), + RootDescriptor::new::<RadrootsReaction>(), + RootDescriptor::new::<RadrootsRelayDocument>(), + RootDescriptor::new::<RadrootsResourceArea>(), + RootDescriptor::new::<RadrootsResourceAreaLocation>(), + RootDescriptor::new::<RadrootsResourceAreaRef>(), + RootDescriptor::new::<RadrootsResourceHarvestCap>(), + RootDescriptor::new::<RadrootsResourceHarvestProduct>(), + RootDescriptor::new::<RadrootsSeal>(), + RootDescriptor::new::<RadrootsTradeAnswerDto>(), + RootDescriptor::new::<RadrootsTradeDiscountDecisionDto>(), + RootDescriptor::new::<RadrootsTradeDiscountOfferDto>(), + RootDescriptor::new::<RadrootsTradeDiscountRequestDto>(), + RootDescriptor::new::<RadrootsCommercialDomain>(), + RootDescriptor::new::<RadrootsOrderEconomicActor>(), + RootDescriptor::new::<RadrootsOrderEconomicEffect>(), + RootDescriptor::new::<RadrootsOrderEconomicLineKind>(), + RootDescriptor::new::<RadrootsTradeEnvelopeDto>(), + RootDescriptor::new::<RadrootsOrderInventoryCommitment>(), + RootDescriptor::new::<RadrootsTradeListingCancelDto>(), + RootDescriptor::new::<RadrootsListingParseError>(), + RootDescriptor::new::<RadrootsTradeValidationListingRequest>(), + RootDescriptor::new::<RadrootsTradeValidationListingResult>(), + RootDescriptor::new::<RadrootsTradeValidationListingError>(), + RootDescriptor::new::<RadrootsTradeMessagePayloadDto>(), + RootDescriptor::new::<RadrootsTradeMessageTypeDto>(), + RootDescriptor::new::<RadrootsOrderCancellation>(), + RootDescriptor::new::<RadrootsTradeOrderChangeDto>(), + RootDescriptor::new::<RadrootsOrderDecisionOutcome>(), + RootDescriptor::new::<RadrootsOrderDecision>(), + RootDescriptor::new::<RadrootsOrderEconomicItem>(), + RootDescriptor::new::<RadrootsOrderEconomicLine>(), + RootDescriptor::new::<RadrootsOrderEconomicTotals>(), + RootDescriptor::new::<RadrootsOrderEconomics>(), + RootDescriptor::new::<RadrootsOrderItem>(), + RootDescriptor::new::<RadrootsOrderRequest>(), + RootDescriptor::new::<RadrootsTradeOrderResponseDto>(), + RootDescriptor::new::<RadrootsTradeOrderRevisionDto>(), + RootDescriptor::new::<RadrootsOrderRevisionOutcome>(), + RootDescriptor::new::<RadrootsOrderRevisionDecision>(), + RootDescriptor::new::<RadrootsOrderRevisionProposal>(), + RootDescriptor::new::<RadrootsTradeOrderRevisionResponseDto>(), + RootDescriptor::new::<RadrootsTradeOrderStatusDto>(), + RootDescriptor::new::<RadrootsOrderPricingBasis>(), + RootDescriptor::new::<RadrootsTradeQuestionDto>(), + RootDescriptor::new::<RadrootsTradeTransportLaneDto>(), ] } +pub struct RadrootsActiveTradeEnvelopeDto; +pub struct RadrootsTradeAnswerDto; +pub struct RadrootsTradeDiscountDecisionDto; +pub struct RadrootsTradeDiscountOfferDto; +pub struct RadrootsTradeDiscountRequestDto; +pub struct RadrootsTradeEnvelopeDto; +pub struct RadrootsTradeListingCancelDto; +pub struct RadrootsTradeMessagePayloadDto; +pub struct RadrootsTradeMessageTypeDto; +pub struct RadrootsTradeOrderChangeDto; +pub struct RadrootsTradeOrderResponseDto; +pub struct RadrootsTradeOrderRevisionDto; +pub struct RadrootsTradeOrderRevisionResponseDto; +pub struct RadrootsTradeOrderStatusDto; +pub struct RadrootsTradeQuestionDto; +pub struct RadrootsTradeTransportLaneDto; + +macro_rules! string_dto { + ($($ty:ty),+ $(,)?) => { + $( + impl Dto for $ty { + fn describe(_ctx: &mut DescribeCtx) -> TypeRef { + TypeRef::String + } + } + )+ + }; +} + +string_dto!( + RadrootsDTag, + RadrootsEventId, + RadrootsInventoryBinId, + RadrootsListingAddress, + RadrootsOrderId, + RadrootsOrderQuoteId, + RadrootsOrderRevisionId, + RadrootsPublicKey, +); + impl Dto for RadrootsNostrEvent { fn describe(ctx: &mut DescribeCtx) -> TypeRef { let def = StructDef::new( @@ -223,6 +408,73 @@ impl Dto for RadrootsListingProduct { } } +impl Dto for RadrootsListingBin { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = StructDef::new( + "RadrootsListingBin", + "RadrootsListingBin", + span("crates/events/src/listing.rs", 101), + ) + .with_field(field( + "bin_id", + "bin_id", + RadrootsInventoryBinId::describe(ctx), + "crates/events/src/listing.rs", + 102, + )) + .with_field(field( + "quantity", + "quantity", + radroots_core::RadrootsCoreQuantity::describe(ctx), + "crates/events/src/listing.rs", + 103, + )) + .with_field(field( + "price_per_canonical_unit", + "price_per_canonical_unit", + radroots_core::RadrootsCoreQuantityPrice::describe(ctx), + "crates/events/src/listing.rs", + 104, + )) + .with_field(optional_nullable_field( + "display_amount", + "display_amount", + TypeRef::option(core_decimal(ctx)), + "crates/events/src/listing.rs", + 105, + )) + .with_field(optional_nullable_field( + "display_unit", + "display_unit", + <Option<radroots_core::RadrootsCoreUnit> as Dto>::describe(ctx), + "crates/events/src/listing.rs", + 106, + )) + .with_field(optional_nullable_field( + "display_label", + "display_label", + <Option<String> as Dto>::describe(ctx), + "crates/events/src/listing.rs", + 107, + )) + .with_field(optional_nullable_field( + "display_price", + "display_price", + <Option<radroots_core::RadrootsCoreMoney> as Dto>::describe(ctx), + "crates/events/src/listing.rs", + 108, + )) + .with_field(optional_nullable_field( + "display_price_unit", + "display_price_unit", + <Option<radroots_core::RadrootsCoreUnit> as Dto>::describe(ctx), + "crates/events/src/listing.rs", + 109, + )); + register(ctx, "RadrootsListingBin", TypeDef::Struct(def)) + } +} + impl Dto for RadrootsListingImageSize { fn describe(ctx: &mut DescribeCtx) -> TypeRef { let def = StructDef::new( @@ -274,10 +526,1510 @@ impl Dto for RadrootsListingImage { } } +impl Dto for RadrootsListingAvailability { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = EnumDef::new( + "RadrootsListingAvailability", + "RadrootsListingAvailability", + EnumRepr::Adjacent { + tag: "kind".to_owned(), + content: "amount".to_owned(), + }, + span("crates/events/src/listing.rs", 20), + ) + .with_variant(VariantDef::new( + "Window", + "window", + VariantShape::Struct(vec![ + optional_nullable_field( + "start", + "start", + <Option<u64> as Dto>::describe(ctx), + "crates/events/src/listing.rs", + 21, + ) + .with_int_repr(IntRepr::JsonNumberUnsafe), + optional_nullable_field( + "end", + "end", + <Option<u64> as Dto>::describe(ctx), + "crates/events/src/listing.rs", + 22, + ) + .with_int_repr(IntRepr::JsonNumberUnsafe), + ]), + span("crates/events/src/listing.rs", 21), + )) + .with_variant(VariantDef::new( + "Status", + "status", + VariantShape::Struct(vec![field( + "status", + "status", + RadrootsListingStatus::describe(ctx), + "crates/events/src/listing.rs", + 24, + )]), + span("crates/events/src/listing.rs", 24), + )); + register(ctx, "RadrootsListingAvailability", TypeDef::Enum(def)) + } +} + +impl Dto for RadrootsListingStatus { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = EnumDef::new( + "RadrootsListingStatus", + "RadrootsListingStatus", + EnumRepr::Adjacent { + tag: "kind".to_owned(), + content: "amount".to_owned(), + }, + span("crates/events/src/listing.rs", 36), + ) + .with_variant(VariantDef::new( + "Active", + "active", + VariantShape::Unit, + span("crates/events/src/listing.rs", 37), + )) + .with_variant(VariantDef::new( + "Sold", + "sold", + VariantShape::Unit, + span("crates/events/src/listing.rs", 38), + )) + .with_variant(VariantDef::new( + "Other", + "other", + VariantShape::Struct(vec![field( + "value", + "value", + String::describe(ctx), + "crates/events/src/listing.rs", + 39, + )]), + span("crates/events/src/listing.rs", 39), + )); + register(ctx, "RadrootsListingStatus", TypeDef::Enum(def)) + } +} + +impl Dto for RadrootsListingDeliveryMethod { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = EnumDef::new( + "RadrootsListingDeliveryMethod", + "RadrootsListingDeliveryMethod", + EnumRepr::Adjacent { + tag: "kind".to_owned(), + content: "amount".to_owned(), + }, + span("crates/events/src/listing.rs", 48), + ) + .with_variant(VariantDef::new( + "Pickup", + "pickup", + VariantShape::Unit, + span("crates/events/src/listing.rs", 49), + )) + .with_variant(VariantDef::new( + "LocalDelivery", + "local_delivery", + VariantShape::Unit, + span("crates/events/src/listing.rs", 50), + )) + .with_variant(VariantDef::new( + "Shipping", + "shipping", + VariantShape::Unit, + span("crates/events/src/listing.rs", 51), + )) + .with_variant(VariantDef::new( + "Other", + "other", + VariantShape::Struct(vec![field( + "method", + "method", + String::describe(ctx), + "crates/events/src/listing.rs", + 52, + )]), + span("crates/events/src/listing.rs", 52), + )); + register(ctx, "RadrootsListingDeliveryMethod", TypeDef::Enum(def)) + } +} + +impl Dto for RadrootsListing { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = StructDef::new( + "RadrootsListing", + "RadrootsListing", + span("crates/events/src/listing.rs", 57), + ) + .with_field(field( + "d_tag", + "d_tag", + RadrootsDTag::describe(ctx), + "crates/events/src/listing.rs", + 58, + )) + .with_field( + optional_nullable_field( + "published_at", + "published_at", + <Option<u64> as Dto>::describe(ctx), + "crates/events/src/listing.rs", + 63, + ) + .with_presence(FieldPresence::optional_nullable_skip_if_none()) + .with_int_repr(IntRepr::JsonNumberUnsafe), + ) + .with_field(field( + "farm", + "farm", + RadrootsFarmRef::describe(ctx), + "crates/events/src/listing.rs", + 68, + )) + .with_field(field( + "product", + "product", + RadrootsListingProduct::describe(ctx), + "crates/events/src/listing.rs", + 69, + )) + .with_field(field( + "primary_bin_id", + "primary_bin_id", + RadrootsInventoryBinId::describe(ctx), + "crates/events/src/listing.rs", + 70, + )) + .with_field(field( + "bins", + "bins", + <Vec<RadrootsListingBin> as Dto>::describe(ctx), + "crates/events/src/listing.rs", + 71, + )) + .with_field(optional_nullable_field( + "resource_area", + "resource_area", + <Option<RadrootsResourceAreaRef> as Dto>::describe(ctx), + "crates/events/src/listing.rs", + 72, + )) + .with_field(optional_nullable_field( + "plot", + "plot", + <Option<RadrootsPlotRef> as Dto>::describe(ctx), + "crates/events/src/listing.rs", + 73, + )) + .with_field(optional_nullable_field( + "discounts", + "discounts", + <Option<Vec<radroots_core::RadrootsCoreDiscount>> as Dto>::describe(ctx), + "crates/events/src/listing.rs", + 74, + )) + .with_field(optional_nullable_field( + "inventory_available", + "inventory_available", + TypeRef::option(core_decimal(ctx)), + "crates/events/src/listing.rs", + 75, + )) + .with_field(optional_nullable_field( + "availability", + "availability", + <Option<RadrootsListingAvailability> as Dto>::describe(ctx), + "crates/events/src/listing.rs", + 76, + )) + .with_field(optional_nullable_field( + "delivery_method", + "delivery_method", + <Option<RadrootsListingDeliveryMethod> as Dto>::describe(ctx), + "crates/events/src/listing.rs", + 77, + )) + .with_field(optional_nullable_field( + "location", + "location", + <Option<RadrootsListingLocation> as Dto>::describe(ctx), + "crates/events/src/listing.rs", + 78, + )) + .with_field(optional_nullable_field( + "images", + "images", + <Option<Vec<RadrootsListingImage>> as Dto>::describe(ctx), + "crates/events/src/listing.rs", + 79, + )); + register(ctx, "RadrootsListing", TypeDef::Struct(def)) + } +} + +impl Dto for RadrootsResourceHarvestCap { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = StructDef::new( + "RadrootsResourceHarvestCap", + "RadrootsResourceHarvestCap", + span("crates/events/src/resource_cap.rs", 20), + ) + .with_field(field( + "d_tag", + "d_tag", + String::describe(ctx), + "crates/events/src/resource_cap.rs", + 21, + )) + .with_field(field( + "resource_area", + "resource_area", + RadrootsResourceAreaRef::describe(ctx), + "crates/events/src/resource_cap.rs", + 22, + )) + .with_field(field( + "product", + "product", + RadrootsResourceHarvestProduct::describe(ctx), + "crates/events/src/resource_cap.rs", + 23, + )) + .with_field( + field( + "start", + "start", + u64::describe(ctx), + "crates/events/src/resource_cap.rs", + 24, + ) + .with_int_repr(IntRepr::NonJsonBigint), + ) + .with_field( + field( + "end", + "end", + u64::describe(ctx), + "crates/events/src/resource_cap.rs", + 25, + ) + .with_int_repr(IntRepr::NonJsonBigint), + ) + .with_field(field( + "cap_quantity", + "cap_quantity", + radroots_core::RadrootsCoreQuantity::describe(ctx), + "crates/events/src/resource_cap.rs", + 26, + )) + .with_field(optional_nullable_field( + "display_amount", + "display_amount", + TypeRef::option(core_decimal(ctx)), + "crates/events/src/resource_cap.rs", + 27, + )) + .with_field(optional_nullable_field( + "display_unit", + "display_unit", + <Option<radroots_core::RadrootsCoreUnit> as Dto>::describe(ctx), + "crates/events/src/resource_cap.rs", + 28, + )) + .with_field(optional_nullable_field( + "display_label", + "display_label", + <Option<String> as Dto>::describe(ctx), + "crates/events/src/resource_cap.rs", + 29, + )) + .with_field(optional_nullable_field( + "tags", + "tags", + <Option<Vec<String>> as Dto>::describe(ctx), + "crates/events/src/resource_cap.rs", + 30, + )); + register(ctx, "RadrootsResourceHarvestCap", TypeDef::Struct(def)) + } +} + +impl Dto for RadrootsComment { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let event_ref = RadrootsNostrEventRef::describe(ctx); + let def = StructDef::new( + "RadrootsComment", + "RadrootsComment", + span("crates/events/src/comment.rs", 8), + ) + .with_field(field( + "root", + "root", + event_ref, + "crates/events/src/comment.rs", + 9, + )) + .with_field(field( + "parent", + "parent", + RadrootsNostrEventRef::describe(ctx), + "crates/events/src/comment.rs", + 10, + )) + .with_field(field( + "content", + "content", + String::describe(ctx), + "crates/events/src/comment.rs", + 11, + )); + register(ctx, "RadrootsComment", TypeDef::Struct(def)) + } +} + +impl Dto for RadrootsReaction { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = StructDef::new( + "RadrootsReaction", + "RadrootsReaction", + span("crates/events/src/reaction.rs", 8), + ) + .with_field(field( + "root", + "root", + RadrootsNostrEventRef::describe(ctx), + "crates/events/src/reaction.rs", + 9, + )) + .with_field(field( + "content", + "content", + String::describe(ctx), + "crates/events/src/reaction.rs", + 10, + )); + register(ctx, "RadrootsReaction", TypeDef::Struct(def)) + } +} + +impl Dto for RadrootsPost { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = StructDef::new( + "RadrootsPost", + "RadrootsPost", + span("crates/events/src/post.rs", 11), + ) + .with_field(field( + "content", + "content", + String::describe(ctx), + "crates/events/src/post.rs", + 12, + )); + register(ctx, "RadrootsPost", TypeDef::Struct(def)) + } +} + +impl Dto for RadrootsListingParseError { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = EnumDef::new( + "RadrootsListingParseError", + "RadrootsTradeListingParseError", + EnumRepr::External, + span("crates/events/src/order.rs", 26), + ) + .with_variant(VariantDef::new( + "InvalidKind", + "InvalidKind", + VariantShape::Newtype(u32::describe(ctx)), + span("crates/events/src/order.rs", 27), + )) + .with_variant(VariantDef::new( + "MissingTag", + "MissingTag", + VariantShape::Newtype(String::describe(ctx)), + span("crates/events/src/order.rs", 28), + )) + .with_variant(VariantDef::new( + "InvalidTag", + "InvalidTag", + VariantShape::Newtype(String::describe(ctx)), + span("crates/events/src/order.rs", 29), + )) + .with_variant(VariantDef::new( + "InvalidNumber", + "InvalidNumber", + VariantShape::Newtype(String::describe(ctx)), + span("crates/events/src/order.rs", 30), + )) + .with_variant(VariantDef::new( + "InvalidUnit", + "InvalidUnit", + VariantShape::Unit, + span("crates/events/src/order.rs", 31), + )) + .with_variant(VariantDef::new( + "InvalidCurrency", + "InvalidCurrency", + VariantShape::Unit, + span("crates/events/src/order.rs", 32), + )) + .with_variant(VariantDef::new( + "InvalidJson", + "InvalidJson", + VariantShape::Newtype(String::describe(ctx)), + span("crates/events/src/order.rs", 33), + )) + .with_variant(VariantDef::new( + "InvalidDiscount", + "InvalidDiscount", + VariantShape::Newtype(String::describe(ctx)), + span("crates/events/src/order.rs", 34), + )); + register(ctx, "RadrootsListingParseError", TypeDef::Enum(def)) + } +} + +impl Dto for RadrootsTradeValidationListingError { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let parse_error = RadrootsListingParseError::describe(ctx); + let def = EnumDef::new( + "RadrootsTradeValidationListingError", + "RadrootsTradeListingValidationError", + EnumRepr::Adjacent { + tag: "kind".to_owned(), + content: "amount".to_owned(), + }, + span("crates/events/src/trade_validation.rs", 14), + ) + .with_variant(VariantDef::new( + "InvalidKind", + "invalid_kind", + VariantShape::Struct(vec![field( + "kind", + "kind", + u32::describe(ctx), + "crates/events/src/trade_validation.rs", + 15, + )]), + span("crates/events/src/trade_validation.rs", 15), + )) + .with_variant(unit_variant( + "MissingListingId", + "missing_listing_id", + "crates/events/src/trade_validation.rs", + 16, + )) + .with_variant(VariantDef::new( + "ListingEventNotFound", + "listing_event_not_found", + VariantShape::Struct(vec![field( + "listing_addr", + "listing_addr", + String::describe(ctx), + "crates/events/src/trade_validation.rs", + 17, + )]), + span("crates/events/src/trade_validation.rs", 17), + )) + .with_variant(VariantDef::new( + "ListingEventFetchFailed", + "listing_event_fetch_failed", + VariantShape::Struct(vec![field( + "listing_addr", + "listing_addr", + String::describe(ctx), + "crates/events/src/trade_validation.rs", + 18, + )]), + span("crates/events/src/trade_validation.rs", 18), + )) + .with_variant(VariantDef::new( + "ParseError", + "parse_error", + VariantShape::Struct(vec![field( + "error", + "error", + parse_error, + "crates/events/src/trade_validation.rs", + 19, + )]), + span("crates/events/src/trade_validation.rs", 19), + )) + .with_variant(unit_variant( + "InvalidSeller", + "invalid_seller", + "crates/events/src/trade_validation.rs", + 20, + )) + .with_variant(unit_variant( + "MissingFarmProfile", + "missing_farm_profile", + "crates/events/src/trade_validation.rs", + 21, + )) + .with_variant(unit_variant( + "MissingFarmRecord", + "missing_farm_record", + "crates/events/src/trade_validation.rs", + 22, + )) + .with_variant(unit_variant( + "MissingTitle", + "missing_title", + "crates/events/src/trade_validation.rs", + 23, + )) + .with_variant(unit_variant( + "MissingDescription", + "missing_description", + "crates/events/src/trade_validation.rs", + 24, + )) + .with_variant(unit_variant( + "MissingProductType", + "missing_product_type", + "crates/events/src/trade_validation.rs", + 25, + )) + .with_variant(unit_variant( + "MissingBins", + "missing_bins", + "crates/events/src/trade_validation.rs", + 26, + )) + .with_variant(unit_variant( + "MissingPrimaryBin", + "missing_primary_bin", + "crates/events/src/trade_validation.rs", + 27, + )) + .with_variant(unit_variant( + "InvalidBin", + "invalid_bin", + "crates/events/src/trade_validation.rs", + 28, + )) + .with_variant(unit_variant( + "MissingPrice", + "missing_price", + "crates/events/src/trade_validation.rs", + 29, + )) + .with_variant(unit_variant( + "InvalidPrice", + "invalid_price", + "crates/events/src/trade_validation.rs", + 30, + )) + .with_variant(unit_variant( + "MissingInventory", + "missing_inventory", + "crates/events/src/trade_validation.rs", + 31, + )) + .with_variant(unit_variant( + "InvalidInventory", + "invalid_inventory", + "crates/events/src/trade_validation.rs", + 32, + )) + .with_variant(unit_variant( + "MissingAvailability", + "missing_availability", + "crates/events/src/trade_validation.rs", + 33, + )) + .with_variant(unit_variant( + "MissingLocation", + "missing_location", + "crates/events/src/trade_validation.rs", + 34, + )) + .with_variant(unit_variant( + "MissingDeliveryMethod", + "missing_delivery_method", + "crates/events/src/trade_validation.rs", + 35, + )); + register( + ctx, + "RadrootsTradeValidationListingError", + TypeDef::Enum(def), + ) + } +} + +impl Dto for RadrootsOrderEconomicItem { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = StructDef::new( + "RadrootsOrderEconomicItem", + "RadrootsTradeOrderEconomicItem", + span("crates/events/src/order_economics.rs", 70), + ) + .with_field(field( + "bin_id", + "bin_id", + RadrootsInventoryBinId::describe(ctx), + "crates/events/src/order_economics.rs", + 71, + )) + .with_field(field( + "bin_count", + "bin_count", + u32::describe(ctx), + "crates/events/src/order_economics.rs", + 72, + )) + .with_field(field( + "quantity_amount", + "quantity_amount", + core_decimal(ctx), + "crates/events/src/order_economics.rs", + 73, + )) + .with_field(field( + "quantity_unit", + "quantity_unit", + radroots_core::RadrootsCoreUnit::describe(ctx), + "crates/events/src/order_economics.rs", + 74, + )) + .with_field(field( + "unit_price_amount", + "unit_price_amount", + core_decimal(ctx), + "crates/events/src/order_economics.rs", + 75, + )) + .with_field(field( + "unit_price_currency", + "unit_price_currency", + core_currency(ctx), + "crates/events/src/order_economics.rs", + 76, + )) + .with_field(field( + "line_subtotal", + "line_subtotal", + radroots_core::RadrootsCoreMoney::describe(ctx), + "crates/events/src/order_economics.rs", + 77, + )); + register(ctx, "RadrootsOrderEconomicItem", TypeDef::Struct(def)) + } +} + +impl Dto for RadrootsOrderEconomics { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = StructDef::new( + "RadrootsOrderEconomics", + "RadrootsTradeOrderEconomics", + span("crates/events/src/order_economics.rs", 119), + ) + .with_field(field( + "quote_id", + "quote_id", + RadrootsOrderQuoteId::describe(ctx), + "crates/events/src/order_economics.rs", + 120, + )) + .with_field(field( + "quote_version", + "quote_version", + u32::describe(ctx), + "crates/events/src/order_economics.rs", + 121, + )) + .with_field(field( + "pricing_basis", + "pricing_basis", + RadrootsOrderPricingBasis::describe(ctx), + "crates/events/src/order_economics.rs", + 122, + )) + .with_field(field( + "currency", + "currency", + core_currency(ctx), + "crates/events/src/order_economics.rs", + 123, + )) + .with_field(field( + "items", + "items", + <Vec<RadrootsOrderEconomicItem> as Dto>::describe(ctx), + "crates/events/src/order_economics.rs", + 124, + )) + .with_field(field( + "discounts", + "discounts", + <Vec<RadrootsOrderEconomicLine> as Dto>::describe(ctx), + "crates/events/src/order_economics.rs", + 125, + )) + .with_field(field( + "adjustments", + "adjustments", + <Vec<RadrootsOrderEconomicLine> as Dto>::describe(ctx), + "crates/events/src/order_economics.rs", + 126, + )) + .with_field(field( + "subtotal", + "subtotal", + radroots_core::RadrootsCoreMoney::describe(ctx), + "crates/events/src/order_economics.rs", + 127, + )) + .with_field(field( + "discount_total", + "discount_total", + radroots_core::RadrootsCoreMoney::describe(ctx), + "crates/events/src/order_economics.rs", + 128, + )) + .with_field(field( + "adjustment_total", + "adjustment_total", + radroots_core::RadrootsCoreMoney::describe(ctx), + "crates/events/src/order_economics.rs", + 129, + )) + .with_field(field( + "total", + "total", + radroots_core::RadrootsCoreMoney::describe(ctx), + "crates/events/src/order_economics.rs", + 130, + )); + register(ctx, "RadrootsOrderEconomics", TypeDef::Struct(def)) + } +} + +impl Dto for RadrootsOrderRevisionOutcome { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = EnumDef::new( + "RadrootsOrderRevisionOutcome", + "RadrootsTradeOrderRevisionDecision", + EnumRepr::Internal { + tag: "decision".to_owned(), + }, + span("crates/events/src/order.rs", 221), + ) + .with_variant(VariantDef::new( + "Accepted", + "accepted", + VariantShape::Unit, + span("crates/events/src/order.rs", 222), + )) + .with_variant(VariantDef::new( + "Declined", + "declined", + VariantShape::Struct(vec![field( + "reason", + "reason", + String::describe(ctx), + "crates/events/src/order.rs", + 223, + )]), + span("crates/events/src/order.rs", 223), + )); + register(ctx, "RadrootsOrderRevisionOutcome", TypeDef::Enum(def)) + } +} + +impl Dto for RadrootsActiveTradeEnvelopeDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = StructDef { + generics: vec![GenericParam::new("T")], + ..StructDef::new( + "RadrootsActiveTradeEnvelopeDto", + "RadrootsActiveTradeEnvelope", + span("crates/events/src/order.rs", 408), + ) + } + .with_field(field( + "version", + "version", + u16::describe(ctx), + "crates/events/src/order.rs", + 409, + )) + .with_field(field( + "domain", + "domain", + RadrootsCommercialDomain::describe(ctx), + "crates/events/src/order.rs", + 410, + )) + .with_field(field( + "message_type", + "type", + RadrootsOrderEventType::describe(ctx), + "crates/events/src/order.rs", + 412, + )) + .with_field(field( + "order_id", + "order_id", + String::describe(ctx), + "crates/events/src/order.rs", + 413, + )) + .with_field(field( + "listing_addr", + "listing_addr", + String::describe(ctx), + "crates/events/src/order.rs", + 414, + )) + .with_field(field( + "payload", + "payload", + TypeRef::GenericParam("T".to_owned()), + "crates/events/src/order.rs", + 415, + )); + register(ctx, "RadrootsActiveTradeEnvelopeDto", TypeDef::Struct(def)) + } +} + +impl Dto for RadrootsTradeEnvelopeDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = StructDef { + generics: vec![GenericParam::new("T")], + ..StructDef::new( + "RadrootsTradeEnvelopeDto", + "RadrootsTradeEnvelope", + span("crates/events/src/order.rs", 408), + ) + } + .with_field(field( + "version", + "version", + u16::describe(ctx), + "crates/events/src/order.rs", + 409, + )) + .with_field(field( + "domain", + "domain", + RadrootsCommercialDomain::describe(ctx), + "crates/events/src/order.rs", + 410, + )) + .with_field(field( + "message_type", + "type", + RadrootsTradeMessageTypeDto::describe(ctx), + "crates/events/src/order.rs", + 412, + )) + .with_field(optional_nullable_field( + "order_id", + "order_id", + <Option<String> as Dto>::describe(ctx), + "crates/events/src/order.rs", + 413, + )) + .with_field(field( + "listing_addr", + "listing_addr", + String::describe(ctx), + "crates/events/src/order.rs", + 414, + )) + .with_field(field( + "payload", + "payload", + TypeRef::GenericParam("T".to_owned()), + "crates/events/src/order.rs", + 415, + )); + register(ctx, "RadrootsTradeEnvelopeDto", TypeDef::Struct(def)) + } +} + +impl Dto for RadrootsTradeMessageTypeDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = EnumDef::new( + "RadrootsTradeMessageTypeDto", + "RadrootsTradeMessageType", + EnumRepr::External, + span("crates/events/src/order.rs", 408), + ) + .with_variant(unit_variant( + "ListingValidateRequest", + "listing_validate_request", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "ListingValidateResult", + "listing_validate_result", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "OrderRequest", + "order_request", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "OrderResponse", + "order_response", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "OrderRevision", + "order_revision", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "OrderRevisionAccept", + "order_revision_accept", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "OrderRevisionDecline", + "order_revision_decline", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "Question", + "question", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "Answer", + "answer", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "DiscountRequest", + "discount_request", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "DiscountOffer", + "discount_offer", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "DiscountAccept", + "discount_accept", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "DiscountDecline", + "discount_decline", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "Cancel", + "cancel", + "crates/events/src/order.rs", + 408, + )); + register(ctx, "RadrootsTradeMessageTypeDto", TypeDef::Enum(def)) + } +} + +impl Dto for RadrootsTradeTransportLaneDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = EnumDef::new( + "RadrootsTradeTransportLaneDto", + "RadrootsTradeTransportLane", + EnumRepr::External, + span("crates/events/src/order.rs", 408), + ) + .with_variant(unit_variant( + "Service", + "service", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "Public", + "public", + "crates/events/src/order.rs", + 408, + )); + register(ctx, "RadrootsTradeTransportLaneDto", TypeDef::Enum(def)) + } +} + +impl Dto for RadrootsTradeOrderStatusDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = EnumDef::new( + "RadrootsTradeOrderStatusDto", + "RadrootsTradeOrderStatus", + EnumRepr::External, + span("crates/events/src/order.rs", 408), + ) + .with_variant(unit_variant( + "Draft", + "draft", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "Validated", + "validated", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "Requested", + "requested", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "Questioned", + "questioned", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "Revised", + "revised", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "Accepted", + "accepted", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "Declined", + "declined", + "crates/events/src/order.rs", + 408, + )) + .with_variant(unit_variant( + "Cancelled", + "cancelled", + "crates/events/src/order.rs", + 408, + )); + register(ctx, "RadrootsTradeOrderStatusDto", TypeDef::Enum(def)) + } +} + +impl Dto for RadrootsTradeQuestionDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = StructDef::new( + "RadrootsTradeQuestionDto", + "RadrootsTradeQuestion", + span("crates/events/src/order.rs", 408), + ) + .with_field(field( + "question_id", + "question_id", + String::describe(ctx), + "crates/events/src/order.rs", + 408, + )); + register(ctx, "RadrootsTradeQuestionDto", TypeDef::Struct(def)) + } +} + +impl Dto for RadrootsTradeAnswerDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = StructDef::new( + "RadrootsTradeAnswerDto", + "RadrootsTradeAnswer", + span("crates/events/src/order.rs", 408), + ) + .with_field(field( + "question_id", + "question_id", + String::describe(ctx), + "crates/events/src/order.rs", + 408, + )); + register(ctx, "RadrootsTradeAnswerDto", TypeDef::Struct(def)) + } +} + +impl Dto for RadrootsTradeDiscountRequestDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = StructDef::new( + "RadrootsTradeDiscountRequestDto", + "RadrootsTradeDiscountRequest", + span("crates/events/src/order.rs", 408), + ) + .with_field(field( + "discount_id", + "discount_id", + String::describe(ctx), + "crates/events/src/order.rs", + 408, + )) + .with_field(field( + "value", + "value", + RadrootsCoreDiscountValue::describe(ctx), + "crates/events/src/order.rs", + 408, + )); + register(ctx, "RadrootsTradeDiscountRequestDto", TypeDef::Struct(def)) + } +} + +impl Dto for RadrootsTradeDiscountOfferDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = StructDef::new( + "RadrootsTradeDiscountOfferDto", + "RadrootsTradeDiscountOffer", + span("crates/events/src/order.rs", 408), + ) + .with_field(field( + "discount_id", + "discount_id", + String::describe(ctx), + "crates/events/src/order.rs", + 408, + )) + .with_field(field( + "value", + "value", + RadrootsCoreDiscountValue::describe(ctx), + "crates/events/src/order.rs", + 408, + )); + register(ctx, "RadrootsTradeDiscountOfferDto", TypeDef::Struct(def)) + } +} + +impl Dto for RadrootsTradeDiscountDecisionDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = EnumDef::new( + "RadrootsTradeDiscountDecisionDto", + "RadrootsTradeDiscountDecision", + EnumRepr::Adjacent { + tag: "kind".to_owned(), + content: "amount".to_owned(), + }, + span("crates/events/src/order.rs", 408), + ) + .with_variant(VariantDef::new( + "Accept", + "accept", + VariantShape::Struct(vec![field( + "value", + "value", + RadrootsCoreDiscountValue::describe(ctx), + "crates/events/src/order.rs", + 408, + )]), + span("crates/events/src/order.rs", 408), + )) + .with_variant(VariantDef::new( + "Decline", + "decline", + VariantShape::Struct(vec![optional_nullable_field( + "reason", + "reason", + <Option<String> as Dto>::describe(ctx), + "crates/events/src/order.rs", + 408, + )]), + span("crates/events/src/order.rs", 408), + )); + register(ctx, "RadrootsTradeDiscountDecisionDto", TypeDef::Enum(def)) + } +} + +impl Dto for RadrootsTradeListingCancelDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = StructDef::new( + "RadrootsTradeListingCancelDto", + "RadrootsTradeListingCancel", + span("crates/events/src/order.rs", 408), + ) + .with_field(optional_nullable_field( + "reason", + "reason", + <Option<String> as Dto>::describe(ctx), + "crates/events/src/order.rs", + 408, + )); + register(ctx, "RadrootsTradeListingCancelDto", TypeDef::Struct(def)) + } +} + +impl Dto for RadrootsTradeOrderResponseDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + accepted_reason_struct( + ctx, + "RadrootsTradeOrderResponseDto", + "RadrootsTradeOrderResponse", + ) + } +} + +impl Dto for RadrootsTradeOrderRevisionResponseDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + accepted_reason_struct( + ctx, + "RadrootsTradeOrderRevisionResponseDto", + "RadrootsTradeOrderRevisionResponse", + ) + } +} + +impl Dto for RadrootsTradeOrderRevisionDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = StructDef::new( + "RadrootsTradeOrderRevisionDto", + "RadrootsTradeOrderRevision", + span("crates/events/src/order.rs", 408), + ) + .with_field(field( + "revision_id", + "revision_id", + String::describe(ctx), + "crates/events/src/order.rs", + 408, + )) + .with_field(field( + "changes", + "changes", + <Vec<RadrootsTradeOrderChangeDto> as Dto>::describe(ctx), + "crates/events/src/order.rs", + 408, + )); + register(ctx, "RadrootsTradeOrderRevisionDto", TypeDef::Struct(def)) + } +} + +impl Dto for RadrootsTradeOrderChangeDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = EnumDef::new( + "RadrootsTradeOrderChangeDto", + "RadrootsTradeOrderChange", + EnumRepr::Adjacent { + tag: "kind".to_owned(), + content: "amount".to_owned(), + }, + span("crates/events/src/order.rs", 408), + ) + .with_variant(VariantDef::new( + "BinCount", + "bin_count", + VariantShape::Struct(vec![ + field( + "item_index", + "item_index", + u32::describe(ctx), + "crates/events/src/order.rs", + 408, + ), + field( + "bin_count", + "bin_count", + u32::describe(ctx), + "crates/events/src/order.rs", + 408, + ), + ]), + span("crates/events/src/order.rs", 408), + )) + .with_variant(VariantDef::new( + "ItemAdd", + "item_add", + VariantShape::Struct(vec![field( + "item", + "item", + RadrootsOrderItem::describe(ctx), + "crates/events/src/order.rs", + 408, + )]), + span("crates/events/src/order.rs", 408), + )) + .with_variant(VariantDef::new( + "ItemRemove", + "item_remove", + VariantShape::Struct(vec![field( + "item_index", + "item_index", + u32::describe(ctx), + "crates/events/src/order.rs", + 408, + )]), + span("crates/events/src/order.rs", 408), + )); + register(ctx, "RadrootsTradeOrderChangeDto", TypeDef::Enum(def)) + } +} + +impl Dto for RadrootsTradeMessagePayloadDto { + fn describe(ctx: &mut DescribeCtx) -> TypeRef { + let def = EnumDef::new( + "RadrootsTradeMessagePayloadDto", + "RadrootsTradeMessagePayload", + EnumRepr::Adjacent { + tag: "kind".to_owned(), + content: "amount".to_owned(), + }, + span("crates/events/src/order.rs", 408), + ) + .with_variant(newtype_variant( + "ListingValidateRequest", + "listing_validate_request", + RadrootsTradeValidationListingRequest::describe(ctx), + )) + .with_variant(newtype_variant( + "ListingValidateResult", + "listing_validate_result", + RadrootsTradeValidationListingResult::describe(ctx), + )) + .with_variant(newtype_variant( + "TradeOrderRequested", + "trade_order_requested", + RadrootsOrderRequest::describe(ctx), + )) + .with_variant(newtype_variant( + "OrderResponse", + "order_response", + RadrootsTradeOrderResponseDto::describe(ctx), + )) + .with_variant(newtype_variant( + "OrderRevision", + "order_revision", + RadrootsTradeOrderRevisionDto::describe(ctx), + )) + .with_variant(newtype_variant( + "OrderRevisionAccept", + "order_revision_accept", + RadrootsTradeOrderRevisionResponseDto::describe(ctx), + )) + .with_variant(newtype_variant( + "OrderRevisionDecline", + "order_revision_decline", + RadrootsTradeOrderRevisionResponseDto::describe(ctx), + )) + .with_variant(newtype_variant( + "Question", + "question", + RadrootsTradeQuestionDto::describe(ctx), + )) + .with_variant(newtype_variant( + "Answer", + "answer", + RadrootsTradeAnswerDto::describe(ctx), + )) + .with_variant(newtype_variant( + "DiscountRequest", + "discount_request", + RadrootsTradeDiscountRequestDto::describe(ctx), + )) + .with_variant(newtype_variant( + "DiscountOffer", + "discount_offer", + RadrootsTradeDiscountOfferDto::describe(ctx), + )) + .with_variant(newtype_variant( + "DiscountAccept", + "discount_accept", + RadrootsTradeDiscountDecisionDto::describe(ctx), + )) + .with_variant(newtype_variant( + "DiscountDecline", + "discount_decline", + RadrootsTradeDiscountDecisionDto::describe(ctx), + )) + .with_variant(newtype_variant( + "Cancel", + "cancel", + RadrootsTradeListingCancelDto::describe(ctx), + )); + register(ctx, "RadrootsTradeMessagePayloadDto", TypeDef::Enum(def)) + } +} + fn register(ctx: &mut DescribeCtx, rust_ident: &str, type_def: TypeDef) -> TypeRef { ctx.register_type(RustTypeId::new("radroots_events", rust_ident), type_def) } +fn core_decimal(ctx: &mut DescribeCtx) -> TypeRef { + external_core_alias(ctx, "RadrootsCoreDecimal") +} + +fn core_currency(ctx: &mut DescribeCtx) -> TypeRef { + external_core_alias(ctx, "RadrootsCoreCurrency") +} + +fn external_core_alias(ctx: &mut DescribeCtx, rust_ident: &str) -> TypeRef { + ctx.register_type( + RustTypeId::new("radroots_core", rust_ident), + TypeDef::Struct(StructDef::new( + rust_ident, + rust_ident, + span("crates/core/src/dto.rs", 1), + )), + ) +} + +fn accepted_reason_struct(ctx: &mut DescribeCtx, rust_ident: &str, export_name: &str) -> TypeRef { + let def = StructDef::new( + rust_ident, + export_name, + span("crates/events/src/order.rs", 408), + ) + .with_field(field( + "accepted", + "accepted", + bool::describe(ctx), + "crates/events/src/order.rs", + 408, + )) + .with_field(optional_nullable_field( + "reason", + "reason", + <Option<String> as Dto>::describe(ctx), + "crates/events/src/order.rs", + 408, + )); + register(ctx, rust_ident, TypeDef::Struct(def)) +} + +fn unit_variant(rust_name: &str, wire_name: &str, file: &str, line: u32) -> VariantDef { + VariantDef::new(rust_name, wire_name, VariantShape::Unit, span(file, line)) +} + +fn newtype_variant(rust_name: &str, wire_name: &str, ty: TypeRef) -> VariantDef { + VariantDef::new( + rust_name, + wire_name, + VariantShape::Newtype(ty), + span("crates/events/src/order.rs", 408), + ) +} + fn optional_nullable_field( rust_name: &str, wire_name: &str, diff --git a/crates/events/src/farm.rs b/crates/events/src/farm.rs @@ -1,6 +1,7 @@ #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsFarm { @@ -14,6 +15,7 @@ pub struct RadrootsFarm { pub tags: Option<Vec<String>>, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, Default)] pub struct RadrootsFarmRef { @@ -21,6 +23,7 @@ pub struct RadrootsFarmRef { pub d_tag: String, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsGeoJsonPoint { @@ -29,6 +32,7 @@ pub struct RadrootsGeoJsonPoint { pub coordinates: [f64; 2], } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsGeoJsonPolygon { @@ -37,6 +41,7 @@ pub struct RadrootsGeoJsonPolygon { pub coordinates: Vec<Vec<[f64; 2]>>, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsGcsLocation { @@ -61,6 +66,7 @@ pub struct RadrootsGcsLocation { pub gc_country_name: Option<String>, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsFarmLocation { diff --git a/crates/events/src/follow.rs b/crates/events/src/follow.rs @@ -1,12 +1,14 @@ #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsFollow { pub list: Vec<RadrootsFollowProfile>, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsFollowProfile { diff --git a/crates/events/src/geochat.rs b/crates/events/src/geochat.rs @@ -3,6 +3,7 @@ #[cfg(not(feature = "std"))] use alloc::string::String; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsGeoChat { diff --git a/crates/events/src/gift_wrap.rs b/crates/events/src/gift_wrap.rs @@ -3,6 +3,7 @@ #[cfg(not(feature = "std"))] use alloc::string::String; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsGiftWrap { @@ -11,6 +12,7 @@ pub struct RadrootsGiftWrap { pub expiration: Option<u32>, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsGiftWrapRecipient { diff --git a/crates/events/src/job.rs b/crates/events/src/job.rs @@ -1,27 +1,39 @@ #[cfg(not(feature = "std"))] use alloc::string::String; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] #[derive(Clone, Debug, PartialEq, Eq, Copy)] pub enum JobInputType { + #[cfg_attr(feature = "serde", serde(rename = "url"))] Url, + #[cfg_attr(feature = "serde", serde(rename = "event"))] Event, + #[cfg_attr(feature = "serde", serde(rename = "job"))] Job, + #[cfg_attr(feature = "serde", serde(rename = "text"))] Text, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] #[derive(Clone, Debug, PartialEq, Eq, Copy)] pub enum JobFeedbackStatus { + #[cfg_attr(feature = "serde", serde(rename = "payment_required"))] PaymentRequired, + #[cfg_attr(feature = "serde", serde(rename = "processing"))] Processing, + #[cfg_attr(feature = "serde", serde(rename = "error"))] Error, + #[cfg_attr(feature = "serde", serde(rename = "success"))] Success, + #[cfg_attr(feature = "serde", serde(rename = "partial"))] Partial, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct JobPaymentRequest { diff --git a/crates/events/src/job_feedback.rs b/crates/events/src/job_feedback.rs @@ -6,6 +6,7 @@ use crate::{ #[cfg(not(feature = "std"))] use alloc::string::String; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsJobFeedback { diff --git a/crates/events/src/job_request.rs b/crates/events/src/job_request.rs @@ -3,6 +3,7 @@ use crate::job::JobInputType; #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsJobInput { @@ -12,6 +13,7 @@ pub struct RadrootsJobInput { pub marker: Option<String>, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsJobParam { @@ -19,6 +21,7 @@ pub struct RadrootsJobParam { pub value: String, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsJobRequest { diff --git a/crates/events/src/job_result.rs b/crates/events/src/job_result.rs @@ -3,6 +3,7 @@ use crate::{RadrootsNostrEventPtr, job::JobPaymentRequest, job_request::Radroots #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsJobResult { diff --git a/crates/events/src/list.rs b/crates/events/src/list.rs @@ -1,6 +1,7 @@ #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsList { @@ -8,6 +9,7 @@ pub struct RadrootsList { pub entries: Vec<RadrootsListEntry>, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsListEntry { diff --git a/crates/events/src/list_set.rs b/crates/events/src/list_set.rs @@ -3,6 +3,7 @@ use crate::list::RadrootsListEntry; #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsListSet { diff --git a/crates/events/src/listing.rs b/crates/events/src/listing.rs @@ -109,6 +109,7 @@ pub struct RadrootsListingBin { pub display_price_unit: Option<RadrootsCoreUnit>, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsListingLocation { diff --git a/crates/events/src/message.rs b/crates/events/src/message.rs @@ -5,6 +5,7 @@ use crate::RadrootsNostrEventPtr; #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsMessage { @@ -14,6 +15,7 @@ pub struct RadrootsMessage { pub subject: Option<String>, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsMessageRecipient { diff --git a/crates/events/src/message_file.rs b/crates/events/src/message_file.rs @@ -6,6 +6,7 @@ use crate::message::RadrootsMessageRecipient; #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsMessageFile { @@ -19,6 +20,7 @@ pub struct RadrootsMessageFile { pub decryption_nonce: String, pub encrypted_hash: String, pub original_hash: Option<String>, + #[cfg_attr(feature = "dto-bindgen", dto(int_repr = "json_number_unsafe"))] pub size: Option<u64>, pub dimensions: Option<RadrootsMessageFileDimensions>, pub blurhash: Option<String>, @@ -26,6 +28,7 @@ pub struct RadrootsMessageFile { pub fallbacks: Vec<String>, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct RadrootsMessageFileDimensions { diff --git a/crates/events/src/order.rs b/crates/events/src/order.rs @@ -161,6 +161,8 @@ impl RadrootsOrderEconomics { } } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsTradeOrderRequested")))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsOrderRequest { @@ -184,6 +186,11 @@ impl RadrootsOrderRequest { } } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr( + feature = "dto-bindgen", + dto(ts(name = "RadrootsTradeOrderRevisionProposed")) +)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsOrderRevisionProposal { @@ -232,6 +239,11 @@ impl RadrootsOrderRevisionOutcome { } } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr( + feature = "dto-bindgen", + dto(ts(name = "RadrootsTradeOrderRevisionDecisionEvent")) +)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsOrderRevisionDecision { @@ -258,6 +270,11 @@ impl RadrootsOrderRevisionDecision { } } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr( + feature = "dto-bindgen", + dto(ts(name = "RadrootsTradeInventoryCommitment")) +)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsOrderInventoryCommitment { @@ -265,16 +282,18 @@ pub struct RadrootsOrderInventoryCommitment { pub bin_count: u32, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsTradeOrderDecision")))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case", tag = "decision"))] #[derive(Clone, Debug, PartialEq, Eq)] pub enum RadrootsOrderDecisionOutcome { + #[cfg_attr(feature = "serde", serde(rename = "accepted"))] Accepted { inventory_commitments: Vec<RadrootsOrderInventoryCommitment>, }, - Declined { - reason: String, - }, + #[cfg_attr(feature = "serde", serde(rename = "declined"))] + Declined { reason: String }, } impl RadrootsOrderDecisionOutcome { @@ -288,6 +307,11 @@ impl RadrootsOrderDecisionOutcome { } } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr( + feature = "dto-bindgen", + dto(ts(name = "RadrootsTradeOrderDecisionEvent")) +)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsOrderDecision { @@ -308,6 +332,8 @@ impl RadrootsOrderDecision { } } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsTradeOrderCancelled")))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsOrderCancellation { @@ -328,6 +354,8 @@ impl RadrootsOrderCancellation { } } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsTradeDomain")))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -336,6 +364,11 @@ pub enum RadrootsCommercialDomain { Listing, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr( + feature = "dto-bindgen", + dto(ts(name = "RadrootsActiveTradeMessageType")) +)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum RadrootsOrderEventType { diff --git a/crates/events/src/order_economics.rs b/crates/events/src/order_economics.rs @@ -9,6 +9,8 @@ use radroots_core::{ use crate::ids::{RadrootsInventoryBinId, RadrootsOrderQuoteId}; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsTradeOrderItem")))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsOrderItem { @@ -16,35 +18,54 @@ pub struct RadrootsOrderItem { pub bin_count: u32, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsTradePricingBasis")))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum RadrootsOrderPricingBasis { + #[cfg_attr(feature = "serde", serde(rename = "listing_event"))] ListingEvent, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr( + feature = "dto-bindgen", + dto(ts(name = "RadrootsTradeEconomicLineKind")) +)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum RadrootsOrderEconomicLineKind { + #[cfg_attr(feature = "serde", serde(rename = "listing_discount"))] ListingDiscount, + #[cfg_attr(feature = "serde", serde(rename = "basket_adjustment"))] BasketAdjustment, + #[cfg_attr(feature = "serde", serde(rename = "revision_adjustment"))] RevisionAdjustment, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsTradeEconomicActor")))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum RadrootsOrderEconomicActor { + #[cfg_attr(feature = "serde", serde(rename = "buyer"))] Buyer, + #[cfg_attr(feature = "serde", serde(rename = "seller"))] Seller, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsTradeEconomicEffect")))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum RadrootsOrderEconomicEffect { + #[cfg_attr(feature = "serde", serde(rename = "increase"))] Increase, + #[cfg_attr(feature = "serde", serde(rename = "decrease"))] Decrease, } @@ -60,6 +81,11 @@ pub struct RadrootsOrderEconomicItem { pub line_subtotal: RadrootsCoreMoney, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr( + feature = "dto-bindgen", + dto(ts(name = "RadrootsTradeOrderEconomicLine")) +)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsOrderEconomicLine { @@ -71,6 +97,11 @@ pub struct RadrootsOrderEconomicLine { pub reason: String, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr( + feature = "dto-bindgen", + dto(ts(name = "RadrootsTradeOrderEconomicTotals")) +)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsOrderEconomicTotals { diff --git a/crates/events/src/plot.rs b/crates/events/src/plot.rs @@ -3,6 +3,7 @@ use crate::farm::{RadrootsFarmRef, RadrootsGcsLocation}; #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsPlotRef { @@ -10,6 +11,7 @@ pub struct RadrootsPlotRef { pub d_tag: String, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsPlot { @@ -21,6 +23,7 @@ pub struct RadrootsPlot { pub tags: Option<Vec<String>>, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsPlotLocation { diff --git a/crates/events/src/profile.rs b/crates/events/src/profile.rs @@ -8,14 +8,20 @@ pub const RADROOTS_PROFILE_TYPE_TAG_COOP: &str = "radroots:type:coop"; pub const RADROOTS_PROFILE_TYPE_TAG_ANY: &str = "radroots:type:any"; pub const RADROOTS_PROFILE_TYPE_TAG_RADROOTSD: &str = "radroots:type:radrootsd"; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] #[derive(Clone, Debug, PartialEq, Eq, Copy)] pub enum RadrootsProfileType { + #[cfg_attr(feature = "serde", serde(rename = "individual"))] Individual, + #[cfg_attr(feature = "serde", serde(rename = "farm"))] Farm, + #[cfg_attr(feature = "serde", serde(rename = "coop"))] Coop, + #[cfg_attr(feature = "serde", serde(rename = "any"))] Any, + #[cfg_attr(feature = "serde", serde(rename = "radrootsd"))] Radrootsd, } @@ -40,6 +46,7 @@ pub fn radroots_profile_type_from_tag_value(value: &str) -> Option<RadrootsProfi } } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsProfile { diff --git a/crates/events/src/relay_document.rs b/crates/events/src/relay_document.rs @@ -1,6 +1,7 @@ #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsRelayDocument { diff --git a/crates/events/src/resource_area.rs b/crates/events/src/resource_area.rs @@ -5,6 +5,7 @@ use crate::farm::RadrootsGcsLocation; #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsResourceArea { @@ -15,6 +16,7 @@ pub struct RadrootsResourceArea { pub tags: Option<Vec<String>>, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsResourceAreaRef { @@ -22,6 +24,7 @@ pub struct RadrootsResourceAreaRef { pub d_tag: String, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsResourceAreaLocation { diff --git a/crates/events/src/resource_cap.rs b/crates/events/src/resource_cap.rs @@ -7,6 +7,7 @@ use crate::resource_area::RadrootsResourceAreaRef; #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsResourceHarvestProduct { diff --git a/crates/events/src/seal.rs b/crates/events/src/seal.rs @@ -3,6 +3,7 @@ #[cfg(not(feature = "std"))] use alloc::string::String; +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct RadrootsSeal { diff --git a/crates/events/src/trade_validation.rs b/crates/events/src/trade_validation.rs @@ -70,12 +70,22 @@ impl core::fmt::Display for RadrootsTradeValidationListingError { #[cfg(feature = "std")] impl std::error::Error for RadrootsTradeValidationListingError {} +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr( + feature = "dto-bindgen", + dto(ts(name = "RadrootsTradeListingValidateRequest")) +)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsTradeValidationListingRequest { pub listing_event: Option<RadrootsNostrEventPtr>, } +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr( + feature = "dto-bindgen", + dto(ts(name = "RadrootsTradeListingValidateResult")) +)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct RadrootsTradeValidationListingResult {