sdk

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

commit 87cf4ff726d7eee0f11a5eef5a8206f4960b6956
parent 25d556cc18d69229df5d688b4062d9e30d0e9d2f
Author: triesap <tyson@radroots.org>
Date:   Sat, 27 Jun 2026 20:55:04 +0000

trade: remove stale workflow bindings

- Delete SDK-local order status, message type, payload, and workflow message DTO roots.
- Use source-owned trade workflow state and events-owned order event type in trade bindings.
- Remove obsolete workflow projection counters and matching large-integer policies.
- Regenerate trade TypeScript bindings and harden generator fixture assertions.

Diffstat:
Mcrates/trade_bindings/src/dto.rs | 203++++---------------------------------------------------------------------------
Mcrates/trade_bindings/src/lib.rs | 59+++--------------------------------------------------------
Mpackages/trade-bindings/src/generated/types.ts | 22++++------------------
Mtools/xtask/src/dto_roots.rs | 50+++++++++++++++++++++++++++++++++++++++-----------
4 files changed, 55 insertions(+), 279 deletions(-)

diff --git a/crates/trade_bindings/src/dto.rs b/crates/trade_bindings/src/dto.rs @@ -3,16 +3,15 @@ use dto_bindgen_core::{ RustTypeId, SourceSpan, TargetFieldNames, TargetOverride, TypeDef, TypeRef, VariantDef, VariantShape, WireFieldNames, }; -use radroots_trade::listing::model::RadrootsTradeListingTotal; +use radroots_trade::{ + listing::model::RadrootsTradeListingTotal, workflow::RadrootsTradeWorkflowState, +}; pub fn dto_roots() -> Vec<RootDescriptor> { let mut roots = radroots_trade::dto::dto_roots() .into_iter() .collect::<Vec<_>>(); roots.extend([ - RootDescriptor::new::<RadrootsCommercialMessagePayload>(), - RootDescriptor::new::<RadrootsCommercialMessageType>(), - RootDescriptor::new::<RadrootsOrderStatus>(), RootDescriptor::new::<RadrootsTradeFacetCount>(), RootDescriptor::new::<RadrootsTradeListingBackofficeOverlay>(), RootDescriptor::new::<RadrootsTradeListingBackofficeQuery>(), @@ -36,7 +35,6 @@ pub fn dto_roots() -> Vec<RootDescriptor> { RootDescriptor::new::<RadrootsTradeOrderQuery>(), RootDescriptor::new::<RadrootsTradeOrderSort>(), RootDescriptor::new::<RadrootsTradeOrderSortField>(), - RootDescriptor::new::<RadrootsTradeOrderWorkflowMessage>(), RootDescriptor::new::<RadrootsTradeOrderWorkflowProjection>(), RootDescriptor::new::<RadrootsTradeReviewPriority>(), RootDescriptor::new::<RadrootsTradeReviewQueueEntry>(), @@ -85,158 +83,9 @@ imported_ts_type!(RadrootsListingProductImport, "RadrootsListingProduct"); imported_ts_type!(RadrootsNostrEventPtrImport, "RadrootsNostrEventPtr"); imported_ts_type!(RadrootsPlotRefImport, "RadrootsPlotRef"); imported_ts_type!(RadrootsResourceAreaRefImport, "RadrootsResourceAreaRef"); -imported_ts_type!(RadrootsOrderCancellationImport, "RadrootsOrderCancellation"); -imported_ts_type!(RadrootsOrderDecisionImport, "RadrootsOrderDecision"); imported_ts_type!(RadrootsOrderEconomicLineImport, "RadrootsOrderEconomicLine"); +imported_ts_type!(RadrootsOrderEventTypeImport, "RadrootsOrderEventType"); imported_ts_type!(RadrootsOrderItemImport, "RadrootsOrderItem"); -imported_ts_type!(RadrootsOrderRequestImport, "RadrootsOrderRequest"); -imported_ts_type!( - RadrootsOrderRevisionDecisionImport, - "RadrootsOrderRevisionDecision" -); -imported_ts_type!( - RadrootsOrderRevisionProposalImport, - "RadrootsOrderRevisionProposal" -); -imported_ts_type!( - RadrootsTradeListingValidateRequestImport, - "RadrootsTradeListingValidateRequest" -); -imported_ts_type!( - RadrootsTradeListingValidateResultImport, - "RadrootsTradeListingValidateResult" -); - -pub enum RadrootsCommercialMessagePayload { - ListingValidateRequest, - ListingValidateResult, - TradeOrderRequested, - OrderDecision, - OrderRevisionProposal, - OrderRevisionDecisionAccepted, - OrderRevisionDecisionDeclined, - Cancel, -} - -impl Dto for RadrootsCommercialMessagePayload { - fn describe(ctx: &mut DescribeCtx) -> TypeRef { - let def = EnumDef::new( - "RadrootsCommercialMessagePayload", - "RadrootsCommercialMessagePayload", - EnumRepr::External, - span("crates/trade_bindings/src/dto.rs", 97), - ) - .with_variant(payload_variant( - "ListingValidateRequest", - "listing_validate_request", - RadrootsTradeListingValidateRequestImport::describe(ctx), - "crates/trade_bindings/src/dto.rs", - 99, - )) - .with_variant(payload_variant( - "ListingValidateResult", - "listing_validate_result", - RadrootsTradeListingValidateResultImport::describe(ctx), - "crates/trade_bindings/src/dto.rs", - 100, - )) - .with_variant(payload_variant( - "TradeOrderRequested", - "trade_order_requested", - RadrootsOrderRequestImport::describe(ctx), - "crates/trade_bindings/src/dto.rs", - 101, - )) - .with_variant(payload_variant( - "OrderDecision", - "order_response", - RadrootsOrderDecisionImport::describe(ctx), - "crates/trade_bindings/src/dto.rs", - 102, - )) - .with_variant(payload_variant( - "OrderRevisionProposal", - "order_revision", - RadrootsOrderRevisionProposalImport::describe(ctx), - "crates/trade_bindings/src/dto.rs", - 103, - )) - .with_variant(payload_variant( - "OrderRevisionDecisionAccepted", - "order_revision_accept", - RadrootsOrderRevisionDecisionImport::describe(ctx), - "crates/trade_bindings/src/dto.rs", - 104, - )) - .with_variant(payload_variant( - "OrderRevisionDecisionDeclined", - "order_revision_decline", - RadrootsOrderRevisionDecisionImport::describe(ctx), - "crates/trade_bindings/src/dto.rs", - 105, - )) - .with_variant(payload_variant( - "Cancel", - "cancel", - RadrootsOrderCancellationImport::describe(ctx), - "crates/trade_bindings/src/dto.rs", - 106, - )); - register(ctx, "RadrootsCommercialMessagePayload", TypeDef::Enum(def)) - } -} - -#[derive(dto_bindgen::Dto)] -pub enum RadrootsCommercialMessageType { - #[serde(rename = "listing_validate_request")] - ListingValidateRequest, - #[serde(rename = "listing_validate_result")] - ListingValidateResult, - #[serde(rename = "order_request")] - OrderRequest, - #[serde(rename = "order_response")] - OrderResponse, - #[serde(rename = "order_revision")] - OrderRevision, - #[serde(rename = "order_revision_accept")] - OrderRevisionAccept, - #[serde(rename = "order_revision_decline")] - OrderRevisionDecline, - #[serde(rename = "question")] - Question, - #[serde(rename = "answer")] - Answer, - #[serde(rename = "discount_request")] - DiscountRequest, - #[serde(rename = "discount_offer")] - DiscountOffer, - #[serde(rename = "discount_accept")] - DiscountAccept, - #[serde(rename = "discount_decline")] - DiscountDecline, - #[serde(rename = "cancel")] - Cancel, -} - -#[derive(dto_bindgen::Dto)] -pub enum RadrootsOrderStatus { - #[serde(rename = "draft")] - Draft, - #[serde(rename = "validated")] - Validated, - #[serde(rename = "requested")] - Requested, - #[serde(rename = "questioned")] - Questioned, - #[serde(rename = "revised")] - Revised, - #[serde(rename = "accepted")] - Accepted, - #[serde(rename = "declined")] - Declined, - #[serde(rename = "cancelled")] - Cancelled, -} #[derive(dto_bindgen::Dto)] pub struct RadrootsTradeFacetCount { @@ -422,8 +271,8 @@ pub struct RadrootsTradeMarketplaceOrderSummary { pub listing_addr: String, pub buyer_pubkey: String, pub seller_pubkey: String, - pub status: RadrootsOrderStatus, - pub last_message_type: RadrootsCommercialMessageType, + pub status: RadrootsTradeWorkflowState, + pub last_message_type: RadrootsOrderEventTypeImport, pub item_count: u32, pub total_bin_count: u32, pub has_requested_discounts: bool, @@ -495,7 +344,7 @@ pub struct RadrootsTradeOrderQuery { pub listing_addr: Option<String>, pub buyer_pubkey: Option<String>, pub seller_pubkey: Option<String>, - pub status: Option<RadrootsOrderStatus>, + pub status: Option<RadrootsTradeWorkflowState>, } #[derive(dto_bindgen::Dto)] @@ -523,19 +372,6 @@ pub enum RadrootsTradeOrderSortField { } #[derive(dto_bindgen::Dto)] -pub struct RadrootsTradeOrderWorkflowMessage { - pub event_id: String, - pub actor_pubkey: String, - pub counterparty_pubkey: String, - pub listing_addr: String, - pub order_id: Option<String>, - pub listing_event: Option<RadrootsNostrEventPtrImport>, - pub root_event_id: Option<String>, - pub prev_event_id: Option<String>, - pub payload: RadrootsCommercialMessagePayload, -} - -#[derive(dto_bindgen::Dto)] pub struct RadrootsTradeOrderWorkflowProjection { pub order_id: String, pub listing_addr: String, @@ -543,7 +379,7 @@ pub struct RadrootsTradeOrderWorkflowProjection { pub seller_pubkey: String, pub items: Vec<RadrootsOrderItemImport>, pub requested_discounts: Option<Vec<RadrootsOrderEconomicLineImport>>, - pub status: RadrootsOrderStatus, + pub status: RadrootsTradeWorkflowState, pub listing_snapshot: Option<RadrootsNostrEventPtrImport>, pub root_event_id: String, pub last_event_id: String, @@ -552,15 +388,9 @@ pub struct RadrootsTradeOrderWorkflowProjection { pub accepted_discount: Option<RadrootsCoreDiscountValueImport>, pub last_reason: Option<String>, pub last_discount_decline_reason: Option<String>, - pub question_count: u32, - pub answer_count: u32, pub revision_count: u32, - pub discount_request_count: u32, - pub discount_offer_count: u32, - pub discount_accept_count: u32, - pub discount_decline_count: u32, pub cancellation_count: u32, - pub last_message_type: RadrootsCommercialMessageType, + pub last_message_type: RadrootsOrderEventTypeImport, pub last_actor_pubkey: String, } @@ -620,21 +450,6 @@ fn unit_variant(rust_name: &str, wire_name: &str, file: &str, line: u32) -> Vari VariantDef::new(rust_name, wire_name, VariantShape::Unit, span(file, line)) } -fn payload_variant( - rust_name: &str, - wire_name: &str, - ty: TypeRef, - file: &str, - line: u32, -) -> VariantDef { - VariantDef::new( - rust_name, - wire_name, - VariantShape::Newtype(ty), - span(file, line), - ) -} - fn field(rust_name: &str, wire_name: &str, ty: TypeRef, file: &str, line: u32) -> FieldDef { FieldDef::new( IdentName::new(rust_name), diff --git a/crates/trade_bindings/src/lib.rs b/crates/trade_bindings/src/lib.rs @@ -38,6 +38,7 @@ pub const TRADE_TYPE_INVENTORY: &[TradeTypeInventoryEntry] = &[ event_import("RadrootsListingProduct"), event_import("RadrootsListingPublicLocation"), event_import("RadrootsListingStatus"), + event_import("RadrootsOrderEventType"), local_shape("RadrootsTradeFacetCount"), source_root("RadrootsTradeListing"), local_shape("RadrootsTradeListingBackofficeOverlay"), @@ -54,8 +55,6 @@ pub const TRADE_TYPE_INVENTORY: &[TradeTypeInventoryEntry] = &[ source_root("RadrootsTradeListingTotal"), local_shape("RadrootsTradeMarketplaceListingSummary"), local_shape("RadrootsTradeMarketplaceOrderSummary"), - local_shape("RadrootsCommercialMessagePayload"), - local_shape("RadrootsCommercialMessageType"), local_shape("RadrootsTradeModerationFlag"), local_shape("RadrootsTradeModerationSeverity"), local_shape("RadrootsTradeModerationStatus"), @@ -66,8 +65,6 @@ pub const TRADE_TYPE_INVENTORY: &[TradeTypeInventoryEntry] = &[ local_shape("RadrootsTradeOrderQuery"), local_shape("RadrootsTradeOrderSort"), local_shape("RadrootsTradeOrderSortField"), - local_shape("RadrootsOrderStatus"), - local_shape("RadrootsTradeOrderWorkflowMessage"), local_shape("RadrootsTradeOrderWorkflowProjection"), local_shape("RadrootsTradeReviewPriority"), local_shape("RadrootsTradeReviewQueueEntry"), @@ -97,25 +94,7 @@ pub const TRADE_LARGE_INTEGER_POLICIES: &[TradeLargeIntegerPolicyEntry] = &[ "RadrootsTradeOrderBackofficeView", "open_moderation_flag_count", ), - json_number_safe_count("RadrootsTradeOrderWorkflowProjection", "question_count"), - json_number_safe_count("RadrootsTradeOrderWorkflowProjection", "answer_count"), json_number_safe_count("RadrootsTradeOrderWorkflowProjection", "revision_count"), - json_number_safe_count( - "RadrootsTradeOrderWorkflowProjection", - "discount_request_count", - ), - json_number_safe_count( - "RadrootsTradeOrderWorkflowProjection", - "discount_offer_count", - ), - json_number_safe_count( - "RadrootsTradeOrderWorkflowProjection", - "discount_accept_count", - ), - json_number_safe_count( - "RadrootsTradeOrderWorkflowProjection", - "discount_decline_count", - ), json_number_safe_count("RadrootsTradeOrderWorkflowProjection", "cancellation_count"), ]; @@ -186,6 +165,7 @@ mod tests { "RadrootsListingProduct", "RadrootsListingPublicLocation", "RadrootsListingStatus", + "RadrootsOrderEventType", "RadrootsTradeFacetCount", "RadrootsTradeListing", "RadrootsTradeListingBackofficeOverlay", @@ -202,8 +182,6 @@ mod tests { "RadrootsTradeListingTotal", "RadrootsTradeMarketplaceListingSummary", "RadrootsTradeMarketplaceOrderSummary", - "RadrootsCommercialMessagePayload", - "RadrootsCommercialMessageType", "RadrootsTradeModerationFlag", "RadrootsTradeModerationSeverity", "RadrootsTradeModerationStatus", @@ -214,8 +192,6 @@ mod tests { "RadrootsTradeOrderQuery", "RadrootsTradeOrderSort", "RadrootsTradeOrderSortField", - "RadrootsOrderStatus", - "RadrootsTradeOrderWorkflowMessage", "RadrootsTradeOrderWorkflowProjection", "RadrootsTradeReviewPriority", "RadrootsTradeReviewQueueEntry", @@ -237,6 +213,7 @@ mod tests { "RadrootsListingProduct", "RadrootsListingPublicLocation", "RadrootsListingStatus", + "RadrootsOrderEventType", ] { assert_eq!( disposition(export_name), @@ -331,41 +308,11 @@ mod tests { ), ( "RadrootsTradeOrderWorkflowProjection", - "question_count", - super::TradeLargeIntegerPolicy::JsonNumberSafeCount - ), - ( - "RadrootsTradeOrderWorkflowProjection", - "answer_count", - super::TradeLargeIntegerPolicy::JsonNumberSafeCount - ), - ( - "RadrootsTradeOrderWorkflowProjection", "revision_count", super::TradeLargeIntegerPolicy::JsonNumberSafeCount ), ( "RadrootsTradeOrderWorkflowProjection", - "discount_request_count", - super::TradeLargeIntegerPolicy::JsonNumberSafeCount - ), - ( - "RadrootsTradeOrderWorkflowProjection", - "discount_offer_count", - super::TradeLargeIntegerPolicy::JsonNumberSafeCount - ), - ( - "RadrootsTradeOrderWorkflowProjection", - "discount_accept_count", - super::TradeLargeIntegerPolicy::JsonNumberSafeCount - ), - ( - "RadrootsTradeOrderWorkflowProjection", - "discount_decline_count", - super::TradeLargeIntegerPolicy::JsonNumberSafeCount - ), - ( - "RadrootsTradeOrderWorkflowProjection", "cancellation_count", super::TradeLargeIntegerPolicy::JsonNumberSafeCount ), diff --git a/packages/trade-bindings/src/generated/types.ts b/packages/trade-bindings/src/generated/types.ts @@ -19,25 +19,13 @@ import type { RadrootsListingProduct, RadrootsListingPublicLocation, RadrootsNostrEventPtr, - RadrootsOrderCancellation, - RadrootsOrderDecision, RadrootsOrderEconomicLine, + RadrootsOrderEventType, RadrootsOrderItem, - RadrootsOrderRequest, - RadrootsOrderRevisionDecision, - RadrootsOrderRevisionProposal, RadrootsPlotRef, RadrootsResourceAreaRef, - RadrootsTradeListingValidateRequest, - RadrootsTradeListingValidateResult, } from "@radroots/events-bindings"; -export type RadrootsCommercialMessagePayload = { listing_validate_request: RadrootsTradeListingValidateRequest, } | { listing_validate_result: RadrootsTradeListingValidateResult, } | { trade_order_requested: RadrootsOrderRequest, } | { order_response: RadrootsOrderDecision, } | { order_revision: RadrootsOrderRevisionProposal, } | { order_revision_accept: RadrootsOrderRevisionDecision, } | { order_revision_decline: RadrootsOrderRevisionDecision, } | { cancel: RadrootsOrderCancellation, }; - -export type RadrootsCommercialMessageType = "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"; - -export type RadrootsOrderStatus = "draft" | "validated" | "requested" | "questioned" | "revised" | "accepted" | "declined" | "cancelled"; - export type RadrootsTradeFacetCount = { key: string, count: number, }; 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: RadrootsListingPublicLocation, delivery_method: RadrootsListingDeliveryMethod, listing: RadrootsListing, }; @@ -68,7 +56,7 @@ export type RadrootsTradeListingTotal = { price_amount: RadrootsCoreMoney, price 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: RadrootsOrderStatus, last_message_type: RadrootsCommercialMessageType, item_count: number, total_bin_count: number, has_requested_discounts: boolean, last_reason?: string | null, }; +export type RadrootsTradeMarketplaceOrderSummary = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, status: RadrootsTradeWorkflowState, last_message_type: RadrootsOrderEventType, item_count: number, total_bin_count: number, has_requested_discounts: boolean, last_reason?: string | null, }; export type RadrootsTradeModerationFlag = { code: string, severity: RadrootsTradeModerationSeverity, status: RadrootsTradeModerationStatus, source?: string | null, reason?: string | null, }; @@ -84,15 +72,13 @@ export type RadrootsTradeOrderBackofficeView = { order: RadrootsTradeOrderWorkfl export type RadrootsTradeOrderFacets = { buyer_pubkeys: Array<RadrootsTradeFacetCount>, seller_pubkeys: Array<RadrootsTradeFacetCount>, listing_addrs: Array<RadrootsTradeFacetCount>, statuses: Array<RadrootsTradeFacetCount>, }; -export type RadrootsTradeOrderQuery = { listing_addr?: string | null, buyer_pubkey?: string | null, seller_pubkey?: string | null, status?: RadrootsOrderStatus | null, }; +export type RadrootsTradeOrderQuery = { listing_addr?: string | null, buyer_pubkey?: string | null, seller_pubkey?: string | null, status?: RadrootsTradeWorkflowState | 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 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: RadrootsCommercialMessagePayload, }; - -export type RadrootsTradeOrderWorkflowProjection = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, items: Array<RadrootsOrderItem>, requested_discounts?: Array<RadrootsOrderEconomicLine> | null, status: RadrootsOrderStatus, 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_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, last_message_type: RadrootsCommercialMessageType, last_actor_pubkey: string, }; +export type RadrootsTradeOrderWorkflowProjection = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, items: Array<RadrootsOrderItem>, requested_discounts?: Array<RadrootsOrderEconomicLine> | null, status: RadrootsTradeWorkflowState, 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_reason?: string | null, last_discount_decline_reason?: string | null, revision_count: number, cancellation_count: number, last_message_type: RadrootsOrderEventType, last_actor_pubkey: string, }; export type RadrootsTradeReviewPriority = "low" | "normal" | "high" | "critical"; diff --git a/tools/xtask/src/dto_roots.rs b/tools/xtask/src/dto_roots.rs @@ -155,17 +155,11 @@ const TRADE_EXTERNAL_OVERRIDES: &[DtoExternalOverride] = &[ events_override("RadrootsListingPublicLocation"), events_override("RadrootsListingStatus"), events_override("RadrootsNostrEventPtr"), - events_override("RadrootsOrderCancellation"), - events_override("RadrootsOrderDecision"), events_override("RadrootsPlotRef"), events_override("RadrootsResourceAreaRef"), events_override("RadrootsOrderEconomicLine"), + events_override("RadrootsOrderEventType"), events_override("RadrootsOrderItem"), - events_override("RadrootsOrderRequest"), - events_override("RadrootsOrderRevisionDecision"), - events_override("RadrootsOrderRevisionProposal"), - events_override("RadrootsTradeListingValidateRequest"), - events_override("RadrootsTradeListingValidateResult"), ]; const TRADE_REQUIRED_EXTERNAL_PACKAGE_IMPORTS: &[&str] = @@ -630,9 +624,6 @@ mod tests { "RadrootsEventsIndexedIndexCheckpoint", ]; const TRADE_TYPE_INVENTORY: &[&str] = &[ - "RadrootsCommercialMessagePayload", - "RadrootsCommercialMessageType", - "RadrootsOrderStatus", "RadrootsTradeFacetCount", "RadrootsTradeListing", "RadrootsTradeListingBackofficeOverlay", @@ -659,7 +650,6 @@ mod tests { "RadrootsTradeOrderQuery", "RadrootsTradeOrderSort", "RadrootsTradeOrderSortField", - "RadrootsTradeOrderWorkflowMessage", "RadrootsTradeOrderWorkflowProjection", "RadrootsTradeReviewPriority", "RadrootsTradeReviewQueueEntry", @@ -922,12 +912,50 @@ mod tests { assert!(TRADE_BINDINGS_TYPES_TS.contains("from \"@radroots/core-bindings\"")); assert!(TRADE_BINDINGS_TYPES_TS.contains("from \"@radroots/events-bindings\"")); + let imports = imported_type_inventory(TRADE_BINDINGS_TYPES_TS); + assert!( + imports + .get("@radroots/events-bindings") + .is_some_and(|names| names.contains("RadrootsOrderEventType")) + ); + for duplicate in [ "export type RadrootsListing = ", "export type RadrootsFarmRef = ", + "export type RadrootsCommercialMessagePayload = ", + "export type RadrootsCommercialMessageType = ", + "export type RadrootsOrderStatus = ", + "export type RadrootsTradeOrderWorkflowMessage = ", ] { assert!(!TRADE_BINDINGS_TYPES_TS.contains(duplicate)); } + + let marketplace_order_summary = type_declaration( + TRADE_BINDINGS_TYPES_TS, + "RadrootsTradeMarketplaceOrderSummary", + ); + assert!(marketplace_order_summary.contains("status: RadrootsTradeWorkflowState")); + assert!(marketplace_order_summary.contains("last_message_type: RadrootsOrderEventType")); + + let order_query = type_declaration(TRADE_BINDINGS_TYPES_TS, "RadrootsTradeOrderQuery"); + assert!(order_query.contains("status?: RadrootsTradeWorkflowState | null")); + + let workflow_projection = type_declaration( + TRADE_BINDINGS_TYPES_TS, + "RadrootsTradeOrderWorkflowProjection", + ); + assert!(workflow_projection.contains("status: RadrootsTradeWorkflowState")); + assert!(workflow_projection.contains("last_message_type: RadrootsOrderEventType")); + for stale_counter in [ + "question_count", + "answer_count", + "discount_request_count", + "discount_offer_count", + "discount_accept_count", + "discount_decline_count", + ] { + assert!(!workflow_projection.contains(stale_counter)); + } } fn type_inventory(types_ts: &str) -> Vec<&str> {