sdk

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

commit 4136534a7a66413ff0e362615b15e23d649a2600
parent 8f306d2f61397891e37ebd04bd00fa8245ec5471
Author: triesap <tyson@radroots.org>
Date:   Thu, 11 Jun 2026 14:12:07 -0700

refactor: align event bindings

Diffstat:
MCargo.lock | 1+
Mcrates/binding_model/src/lib.rs | 20+++++++++++++++-----
Mcrates/events_bindings/Cargo.toml | 1+
Mcrates/events_bindings/src/lib.rs | 23+++++++++++++----------
Acrates/events_bindings/src/model.rs | 1545+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dcrates/events_bindings/src/typescript/constants.ts | 3---
Dcrates/events_bindings/src/typescript/kinds.ts | 87-------------------------------------------------------------------------------
Dcrates/events_bindings/src/typescript/types.ts | 221-------------------------------------------------------------------------------
Mcrates/xtask/src/output.rs | 8+++++---
Mpackages/events-bindings/src/generated/types.ts | 42+++++++++++++++++++++---------------------
Mpackages/identity-bindings/src/generated/constants.ts | 2--
11 files changed, 1601 insertions(+), 352 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -597,6 +597,7 @@ name = "radroots_events_bindings" version = "0.1.0" dependencies = [ "radroots_events", + "radroots_sdk_binding_model", ] [[package]] diff --git a/crates/binding_model/src/lib.rs b/crates/binding_model/src/lib.rs @@ -9,11 +9,14 @@ impl TsModule { } pub fn render(&self) -> String { - self.declarations - .iter() - .map(TsDeclaration::render) - .collect::<Vec<_>>() - .join("\n\n") + let mut rendered = String::new(); + for (index, declaration) in self.declarations.iter().enumerate() { + if index > 0 { + rendered.push_str(render_separator(&self.declarations[index - 1], declaration)); + } + rendered.push_str(&declaration.render()); + } + rendered } } @@ -34,6 +37,13 @@ impl TsDeclaration { } } +fn render_separator(previous: &TsDeclaration, current: &TsDeclaration) -> &'static str { + match (previous, current) { + (TsDeclaration::Const(_), TsDeclaration::Const(_)) => "\n", + _ => "\n\n", + } +} + #[derive(Clone, Debug, Eq, PartialEq)] pub struct TsTypeAlias { name: String, diff --git a/crates/events_bindings/Cargo.toml b/crates/events_bindings/Cargo.toml @@ -9,4 +9,5 @@ homepage.workspace = true publish = false [dependencies] +radroots_sdk_binding_model = { path = "../binding_model" } radroots_events = { workspace = true } diff --git a/crates/events_bindings/src/lib.rs b/crates/events_bindings/src/lib.rs @@ -1,24 +1,27 @@ pub use radroots_events as upstream; -pub const TYPES_TS: &str = include_str!("typescript/types.ts"); -pub const CONSTANTS_TS: &str = include_str!("typescript/constants.ts"); -pub const KINDS_TS: &str = include_str!("typescript/kinds.ts"); +mod model; + +pub use model::{constants_module, kinds_module, types_module}; #[cfg(test)] mod tests { - use super::{CONSTANTS_TS, KINDS_TS, TYPES_TS}; + use super::{constants_module, kinds_module, types_module}; #[test] fn preserves_event_type_exports() { - assert!(TYPES_TS.contains("export type RadrootsListing")); - assert!(TYPES_TS.contains("export type RadrootsJobInput")); - assert!(TYPES_TS.contains("export type RadrootsTradeOrderRequested")); + let rendered = types_module().render(); + assert!(rendered.contains("export type RadrootsListing")); + assert!(rendered.contains("export type RadrootsJobInput")); + assert!(rendered.contains("export type RadrootsTradeOrderRequested")); } #[test] fn preserves_event_constant_exports() { - assert!(CONSTANTS_TS.contains("RADROOTS_LISTING_PRODUCT_TAG_KEYS")); - assert!(KINDS_TS.contains("KIND_LISTING")); - assert!(KINDS_TS.contains("KIND_TRADE_LISTING_ORDER_REQ")); + let constants = constants_module().render(); + let kinds = kinds_module().render(); + assert!(constants.contains("RADROOTS_LISTING_PRODUCT_TAG_KEYS")); + assert!(kinds.contains("KIND_LISTING")); + assert!(kinds.contains("KIND_TRADE_LISTING_ORDER_REQ")); } } diff --git a/crates/events_bindings/src/model.rs b/crates/events_bindings/src/model.rs @@ -0,0 +1,1545 @@ +use radroots_sdk_binding_model::{self as ts, TsValue}; + +pub fn types_module() -> ts::TsModule { + ts::module(vec![ + ts::type_alias( + "JobFeedbackStatus", + ts::union(vec![ + ts::string_literal("payment_required"), + ts::string_literal("processing"), + ts::string_literal("error"), + ts::string_literal("success"), + ts::string_literal("partial"), + ]), + ), + ts::type_alias( + "JobInputType", + ts::union(vec![ + ts::string_literal("url"), + ts::string_literal("event"), + ts::string_literal("job"), + ts::string_literal("text"), + ]), + ), + ts::type_alias( + "JobPaymentRequest", + ts::object(vec![ + ts::field("amount_sat", ts::number()), + ts::optional_field("bolt11", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsAccountClaim", + ts::object(vec![ + ts::field("username", ts::string()), + ts::field("pubkey", ts::string()), + ts::optional_field("nip05", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias_params( + "RadrootsActiveTradeEnvelope", + &["T"], + ts::object(vec![ + ts::field("version", ts::number()), + ts::field("domain", ts::reference("RadrootsTradeDomain")), + ts::field("type", ts::reference("RadrootsActiveTradeMessageType")), + ts::field("order_id", ts::string()), + ts::field("listing_addr", ts::string()), + ts::field("payload", ts::reference("T")), + ]), + ), + ts::type_alias( + "RadrootsActiveTradeFulfillmentState", + ts::union(vec![ + ts::string_literal("accepted_not_fulfilled"), + ts::string_literal("preparing"), + ts::string_literal("ready_for_pickup"), + ts::string_literal("out_for_delivery"), + ts::string_literal("delivered"), + ts::string_literal("seller_cancelled"), + ]), + ), + ts::type_alias( + "RadrootsActiveTradeMessageType", + ts::union(vec![ + ts::string_literal("TradeOrderRequested"), + ts::string_literal("TradeOrderDecision"), + ts::string_literal("TradeOrderRevisionProposed"), + ts::string_literal("TradeOrderRevisionDecision"), + ts::string_literal("TradeOrderCancelled"), + ts::string_literal("TradeFulfillmentUpdated"), + ts::string_literal("TradeBuyerReceipt"), + ts::string_literal("TradePaymentRecorded"), + ts::string_literal("TradeSettlementDecision"), + ]), + ), + ts::type_alias( + "RadrootsAppData", + ts::object(vec![ + ts::field("d_tag", ts::string()), + ts::field("content", ts::string()), + ]), + ), + ts::type_alias( + "RadrootsComment", + ts::object(vec![ + ts::field("root", ts::reference("RadrootsNostrEventRef")), + ts::field("parent", ts::reference("RadrootsNostrEventRef")), + ts::field("content", ts::string()), + ]), + ), + ts::type_alias( + "RadrootsCoop", + ts::object(vec![ + ts::field("d_tag", ts::string()), + ts::field("name", ts::string()), + ts::optional_field("about", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("website", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("picture", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("banner", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field( + "location", + ts::union(vec![ts::reference("RadrootsCoopLocation"), ts::null()]), + ), + ts::optional_field("tags", ts::union(vec![ts::array(ts::string()), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsCoopLocation", + ts::object(vec![ + ts::optional_field("primary", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("city", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("region", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("country", ts::union(vec![ts::string(), ts::null()])), + ts::field("gcs", ts::reference("RadrootsGcsLocation")), + ]), + ), + ts::type_alias( + "RadrootsCoopRef", + ts::object(vec![ + ts::field("pubkey", ts::string()), + ts::field("d_tag", ts::string()), + ]), + ), + ts::type_alias( + "RadrootsDocument", + ts::object(vec![ + ts::field("d_tag", ts::string()), + ts::field("doc_type", ts::string()), + ts::field("title", ts::string()), + ts::field("version", ts::string()), + ts::optional_field("summary", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("effective_at", ts::union(vec![ts::number(), ts::null()])), + ts::optional_field("body_markdown", ts::union(vec![ts::string(), ts::null()])), + ts::field("subject", ts::reference("RadrootsDocumentSubject")), + ts::optional_field("tags", ts::union(vec![ts::array(ts::string()), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsDocumentSubject", + ts::object(vec![ + ts::field("pubkey", ts::string()), + ts::optional_field("address", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsFarm", + ts::object(vec![ + ts::field("d_tag", ts::string()), + ts::field("name", ts::string()), + ts::optional_field("about", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("website", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("picture", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("banner", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field( + "location", + ts::union(vec![ts::reference("RadrootsFarmLocation"), ts::null()]), + ), + ts::optional_field("tags", ts::union(vec![ts::array(ts::string()), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsFarmLocation", + ts::object(vec![ + ts::optional_field("primary", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("city", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("region", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("country", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field( + "gcs", + ts::union(vec![ts::reference("RadrootsGcsLocation"), ts::null()]), + ), + ]), + ), + ts::type_alias( + "RadrootsFarmRef", + ts::object(vec![ + ts::field("pubkey", ts::string()), + ts::field("d_tag", ts::string()), + ]), + ), + ts::type_alias( + "RadrootsFollow", + ts::object(vec![ts::field( + "list", + ts::array(ts::reference("RadrootsFollowProfile")), + )]), + ), + ts::type_alias( + "RadrootsFollowProfile", + ts::object(vec![ + ts::field("published_at", ts::number()), + ts::field("public_key", ts::string()), + ts::optional_field("relay_url", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("contact_name", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsGcsLocation", + ts::object(vec![ + ts::field("lat", ts::number()), + ts::field("lng", ts::number()), + ts::field("geohash", ts::string()), + ts::field("point", ts::reference("RadrootsGeoJsonPoint")), + ts::field("polygon", ts::reference("RadrootsGeoJsonPolygon")), + ts::optional_field("accuracy", ts::union(vec![ts::number(), ts::null()])), + ts::optional_field("altitude", ts::union(vec![ts::number(), ts::null()])), + ts::optional_field("tag_0", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("label", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("area", ts::union(vec![ts::number(), ts::null()])), + ts::optional_field("elevation", ts::union(vec![ts::number(), ts::null()])), + ts::optional_field("soil", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("climate", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("gc_id", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("gc_name", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("gc_admin1_id", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("gc_admin1_name", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("gc_country_id", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("gc_country_name", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsGeoChat", + ts::object(vec![ + ts::field("geohash", ts::string()), + ts::field("content", ts::string()), + ts::optional_field("nickname", ts::union(vec![ts::string(), ts::null()])), + ts::field("teleported", ts::boolean()), + ]), + ), + ts::type_alias( + "RadrootsGeoJsonPoint", + ts::object(vec![ + ts::field("type", ts::string()), + ts::field("coordinates", ts::tuple(vec![ts::number(), ts::number()])), + ]), + ), + ts::type_alias( + "RadrootsGeoJsonPolygon", + ts::object(vec![ + ts::field("type", ts::string()), + ts::field( + "coordinates", + ts::array(ts::array(ts::tuple(vec![ts::number(), ts::number()]))), + ), + ]), + ), + ts::type_alias( + "RadrootsGiftWrap", + ts::object(vec![ + ts::field("recipient", ts::reference("RadrootsGiftWrapRecipient")), + ts::field("content", ts::string()), + ts::optional_field("expiration", ts::union(vec![ts::number(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsGiftWrapRecipient", + ts::object(vec![ + ts::field("public_key", ts::string()), + ts::optional_field("relay_url", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsJobFeedback", + ts::object(vec![ + ts::field("kind", ts::number()), + ts::field("status", ts::reference("JobFeedbackStatus")), + ts::optional_field("extra_info", ts::union(vec![ts::string(), ts::null()])), + ts::field("request_event", ts::reference("RadrootsNostrEventPtr")), + ts::optional_field("customer_pubkey", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field( + "payment", + ts::union(vec![ts::reference("JobPaymentRequest"), ts::null()]), + ), + ts::optional_field("content", ts::union(vec![ts::string(), ts::null()])), + ts::field("encrypted", ts::boolean()), + ]), + ), + ts::type_alias( + "RadrootsJobInput", + ts::object(vec![ + ts::field("data", ts::string()), + ts::field("input_type", ts::reference("JobInputType")), + ts::optional_field("relay", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("marker", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsJobParam", + ts::object(vec![ + ts::field("key", ts::string()), + ts::field("value", ts::string()), + ]), + ), + ts::type_alias( + "RadrootsJobRequest", + ts::object(vec![ + ts::field("kind", ts::number()), + ts::field("inputs", ts::array(ts::reference("RadrootsJobInput"))), + ts::optional_field("output", ts::union(vec![ts::string(), ts::null()])), + ts::field("params", ts::array(ts::reference("RadrootsJobParam"))), + ts::optional_field("bid_sat", ts::union(vec![ts::number(), ts::null()])), + ts::field("relays", ts::array(ts::string())), + ts::field("providers", ts::array(ts::string())), + ts::field("topics", ts::array(ts::string())), + ts::field("encrypted", ts::boolean()), + ]), + ), + ts::type_alias( + "RadrootsJobResult", + ts::object(vec![ + ts::field("kind", ts::number()), + ts::field("request_event", ts::reference("RadrootsNostrEventPtr")), + ts::optional_field("request_json", ts::union(vec![ts::string(), ts::null()])), + ts::field("inputs", ts::array(ts::reference("RadrootsJobInput"))), + ts::optional_field("customer_pubkey", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field( + "payment", + ts::union(vec![ts::reference("JobPaymentRequest"), ts::null()]), + ), + ts::optional_field("content", ts::union(vec![ts::string(), ts::null()])), + ts::field("encrypted", ts::boolean()), + ]), + ), + ts::type_alias( + "RadrootsList", + ts::object(vec![ + ts::field("content", ts::string()), + ts::field("entries", ts::array(ts::reference("RadrootsListEntry"))), + ]), + ), + ts::type_alias( + "RadrootsListEntry", + ts::object(vec![ + ts::field("tag", ts::string()), + ts::field("values", ts::array(ts::string())), + ]), + ), + ts::type_alias( + "RadrootsListSet", + ts::object(vec![ + ts::field("d_tag", ts::string()), + ts::field("content", ts::string()), + ts::field("entries", ts::array(ts::reference("RadrootsListEntry"))), + ts::optional_field("title", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("description", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("image", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsListing", + ts::object(vec![ + ts::field("d_tag", ts::string()), + ts::field("farm", ts::reference("RadrootsFarmRef")), + ts::field("product", ts::reference("RadrootsListingProduct")), + ts::field("primary_bin_id", ts::string()), + ts::field("bins", ts::array(ts::reference("RadrootsListingBin"))), + ts::optional_field( + "resource_area", + ts::union(vec![ts::reference("RadrootsResourceAreaRef"), ts::null()]), + ), + ts::optional_field( + "plot", + ts::union(vec![ts::reference("RadrootsPlotRef"), ts::null()]), + ), + ts::optional_field( + "discounts", + ts::union(vec![ + ts::array(ts::reference("RadrootsCoreDiscount")), + ts::null(), + ]), + ), + ts::optional_field( + "inventory_available", + ts::union(vec![ts::reference("RadrootsCoreDecimal"), ts::null()]), + ), + ts::optional_field( + "availability", + ts::union(vec![ + ts::reference("RadrootsListingAvailability"), + ts::null(), + ]), + ), + ts::optional_field( + "delivery_method", + ts::union(vec![ + ts::reference("RadrootsListingDeliveryMethod"), + ts::null(), + ]), + ), + ts::optional_field( + "location", + ts::union(vec![ts::reference("RadrootsListingLocation"), ts::null()]), + ), + ts::optional_field( + "images", + ts::union(vec![ + ts::array(ts::reference("RadrootsListingImage")), + ts::null(), + ]), + ), + ]), + ), + ts::type_alias( + "RadrootsListingAvailability", + ts::union(vec![ + ts::object(vec![ + ts::field("kind", ts::string_literal("window")), + ts::field( + "amount", + ts::object(vec![ + ts::optional_field("start", ts::union(vec![ts::number(), ts::null()])), + ts::optional_field("end", ts::union(vec![ts::number(), ts::null()])), + ]), + ), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("status")), + ts::field( + "amount", + ts::object(vec![ts::field( + "status", + ts::reference("RadrootsListingStatus"), + )]), + ), + ]), + ]), + ), + ts::type_alias( + "RadrootsListingBin", + ts::object(vec![ + ts::field("bin_id", ts::string()), + ts::field("quantity", ts::reference("RadrootsCoreQuantity")), + ts::field( + "price_per_canonical_unit", + ts::reference("RadrootsCoreQuantityPrice"), + ), + ts::optional_field( + "display_amount", + ts::union(vec![ts::reference("RadrootsCoreDecimal"), ts::null()]), + ), + ts::optional_field( + "display_unit", + ts::union(vec![ts::reference("RadrootsCoreUnit"), ts::null()]), + ), + ts::optional_field("display_label", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field( + "display_price", + ts::union(vec![ts::reference("RadrootsCoreMoney"), ts::null()]), + ), + ts::optional_field( + "display_price_unit", + ts::union(vec![ts::reference("RadrootsCoreUnit"), ts::null()]), + ), + ]), + ), + ts::type_alias( + "RadrootsListingDeliveryMethod", + ts::union(vec![ + ts::object(vec![ts::field("kind", ts::string_literal("pickup"))]), + ts::object(vec![ts::field( + "kind", + ts::string_literal("local_delivery"), + )]), + ts::object(vec![ts::field("kind", ts::string_literal("shipping"))]), + ts::object(vec![ + ts::field("kind", ts::string_literal("other")), + ts::field( + "amount", + ts::object(vec![ts::field("method", ts::string())]), + ), + ]), + ]), + ), + ts::type_alias( + "RadrootsListingImage", + ts::object(vec![ + ts::field("url", ts::string()), + ts::optional_field( + "size", + ts::union(vec![ts::reference("RadrootsListingImageSize"), ts::null()]), + ), + ]), + ), + ts::type_alias( + "RadrootsListingImageSize", + ts::object(vec![ + ts::field("w", ts::number()), + ts::field("h", ts::number()), + ]), + ), + ts::type_alias( + "RadrootsListingLocation", + ts::object(vec![ + ts::field("primary", ts::string()), + ts::optional_field("city", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("region", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("country", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("lat", ts::union(vec![ts::number(), ts::null()])), + ts::optional_field("lng", ts::union(vec![ts::number(), ts::null()])), + ts::optional_field("geohash", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsListingProduct", + ts::object(vec![ + ts::field("key", ts::string()), + ts::field("title", ts::string()), + ts::field("category", ts::string()), + ts::optional_field("summary", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("process", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("lot", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("location", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("profile", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("year", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsListingProductTagKeys", + ts::readonly_tuple(vec![ + ts::string_literal("key"), + ts::string_literal("title"), + ts::string_literal("category"), + ts::string_literal("summary"), + ts::string_literal("process"), + ts::string_literal("lot"), + ts::string_literal("location"), + ts::string_literal("profile"), + ts::string_literal("year"), + ]), + ), + ts::type_alias( + "RadrootsListingStatus", + ts::union(vec![ + ts::object(vec![ts::field("kind", ts::string_literal("active"))]), + ts::object(vec![ts::field("kind", ts::string_literal("sold"))]), + ts::object(vec![ + ts::field("kind", ts::string_literal("other")), + ts::field("amount", ts::object(vec![ts::field("value", ts::string())])), + ]), + ]), + ), + ts::type_alias( + "RadrootsMessage", + ts::object(vec![ + ts::field( + "recipients", + ts::array(ts::reference("RadrootsMessageRecipient")), + ), + ts::field("content", ts::string()), + ts::optional_field( + "reply_to", + ts::union(vec![ts::reference("RadrootsNostrEventPtr"), ts::null()]), + ), + ts::optional_field("subject", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsMessageFile", + ts::object(vec![ + ts::field( + "recipients", + ts::array(ts::reference("RadrootsMessageRecipient")), + ), + ts::field("file_url", ts::string()), + ts::optional_field( + "reply_to", + ts::union(vec![ts::reference("RadrootsNostrEventPtr"), ts::null()]), + ), + ts::optional_field("subject", ts::union(vec![ts::string(), ts::null()])), + ts::field("file_type", ts::string()), + ts::field("encryption_algorithm", ts::string()), + ts::field("decryption_key", ts::string()), + ts::field("decryption_nonce", ts::string()), + ts::field("encrypted_hash", ts::string()), + ts::optional_field("original_hash", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("size", ts::union(vec![ts::number(), ts::null()])), + ts::optional_field( + "dimensions", + ts::union(vec![ + ts::reference("RadrootsMessageFileDimensions"), + ts::null(), + ]), + ), + ts::optional_field("blurhash", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("thumb", ts::union(vec![ts::string(), ts::null()])), + ts::field("fallbacks", ts::array(ts::string())), + ]), + ), + ts::type_alias( + "RadrootsMessageFileDimensions", + ts::object(vec![ + ts::field("w", ts::number()), + ts::field("h", ts::number()), + ]), + ), + ts::type_alias( + "RadrootsMessageRecipient", + ts::object(vec![ + ts::field("public_key", ts::string()), + ts::optional_field("relay_url", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsNostrEvent", + ts::object(vec![ + ts::field("id", ts::string()), + ts::field("author", ts::string()), + ts::field("created_at", ts::number()), + ts::field("kind", ts::number()), + ts::field("tags", ts::array(ts::array(ts::string()))), + ts::field("content", ts::string()), + ts::field("sig", ts::string()), + ]), + ), + ts::type_alias( + "RadrootsNostrEventPtr", + ts::object(vec![ + ts::field("id", ts::string()), + ts::optional_field("relays", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsNostrEventRef", + ts::object(vec![ + ts::field("id", ts::string()), + ts::field("author", ts::string()), + ts::field("kind", ts::number()), + ts::optional_field("d_tag", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field( + "relays", + ts::union(vec![ts::array(ts::string()), ts::null()]), + ), + ]), + ), + ts::type_alias( + "RadrootsPlot", + ts::object(vec![ + ts::field("d_tag", ts::string()), + ts::field("farm", ts::reference("RadrootsFarmRef")), + ts::field("name", ts::string()), + ts::optional_field("about", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field( + "location", + ts::union(vec![ts::reference("RadrootsPlotLocation"), ts::null()]), + ), + ts::optional_field("tags", ts::union(vec![ts::array(ts::string()), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsPlotLocation", + ts::object(vec![ + ts::optional_field("primary", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("city", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("region", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("country", ts::union(vec![ts::string(), ts::null()])), + ts::field("gcs", ts::reference("RadrootsGcsLocation")), + ]), + ), + ts::type_alias( + "RadrootsPlotRef", + ts::object(vec![ + ts::field("pubkey", ts::string()), + ts::field("d_tag", ts::string()), + ]), + ), + ts::type_alias( + "RadrootsPost", + ts::object(vec![ts::field("content", ts::string())]), + ), + ts::type_alias( + "RadrootsProfile", + ts::object(vec![ + ts::field("name", ts::string()), + ts::optional_field("display_name", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("nip05", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("about", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("website", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("picture", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("banner", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("lud06", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("lud16", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("bot", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsProfileType", + ts::union(vec![ + ts::string_literal("individual"), + ts::string_literal("farm"), + ts::string_literal("coop"), + ts::string_literal("any"), + ts::string_literal("radrootsd"), + ]), + ), + ts::type_alias( + "RadrootsReaction", + ts::object(vec![ + ts::field("root", ts::reference("RadrootsNostrEventRef")), + ts::field("content", ts::string()), + ]), + ), + ts::type_alias( + "RadrootsRelayDocument", + ts::object(vec![ + ts::optional_field("name", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("description", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("pubkey", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("contact", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field( + "supported_nips", + ts::union(vec![ts::array(ts::number()), ts::null()]), + ), + ts::optional_field("software", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("version", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsResourceArea", + ts::object(vec![ + ts::field("d_tag", ts::string()), + ts::field("name", ts::string()), + ts::optional_field("about", ts::union(vec![ts::string(), ts::null()])), + ts::field("location", ts::reference("RadrootsResourceAreaLocation")), + ts::optional_field("tags", ts::union(vec![ts::array(ts::string()), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsResourceAreaLocation", + ts::object(vec![ + ts::optional_field("primary", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("city", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("region", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("country", ts::union(vec![ts::string(), ts::null()])), + ts::field("gcs", ts::reference("RadrootsGcsLocation")), + ]), + ), + ts::type_alias( + "RadrootsResourceAreaRef", + ts::object(vec![ + ts::field("pubkey", ts::string()), + ts::field("d_tag", ts::string()), + ]), + ), + ts::type_alias( + "RadrootsResourceHarvestCap", + ts::object(vec![ + ts::field("d_tag", ts::string()), + ts::field("resource_area", ts::reference("RadrootsResourceAreaRef")), + ts::field("product", ts::reference("RadrootsResourceHarvestProduct")), + ts::field("start", ts::bigint()), + ts::field("end", ts::bigint()), + ts::field("cap_quantity", ts::reference("RadrootsCoreQuantity")), + ts::optional_field( + "display_amount", + ts::union(vec![ts::reference("RadrootsCoreDecimal"), ts::null()]), + ), + ts::optional_field( + "display_unit", + ts::union(vec![ts::reference("RadrootsCoreUnit"), ts::null()]), + ), + ts::optional_field("display_label", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("tags", ts::union(vec![ts::array(ts::string()), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsResourceHarvestProduct", + ts::object(vec![ + ts::field("key", ts::string()), + ts::optional_field("category", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsSeal", + ts::object(vec![ts::field("content", ts::string())]), + ), + ts::type_alias( + "RadrootsTradeAnswer", + ts::object(vec![ts::field("question_id", ts::string())]), + ), + ts::type_alias( + "RadrootsTradeBuyerReceipt", + ts::object(vec![ + ts::field("order_id", ts::string()), + ts::field("listing_addr", ts::string()), + ts::field("buyer_pubkey", ts::string()), + ts::field("seller_pubkey", ts::string()), + ts::field("received", ts::boolean()), + ts::optional_field("issue", ts::union(vec![ts::string(), ts::null()])), + ts::field("received_at", ts::bigint()), + ]), + ), + ts::type_alias( + "RadrootsTradeDiscountDecision", + ts::union(vec![ + ts::object(vec![ + ts::field("kind", ts::string_literal("accept")), + ts::field( + "amount", + ts::object(vec![ts::field( + "value", + ts::reference("RadrootsCoreDiscountValue"), + )]), + ), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("decline")), + ts::field( + "amount", + ts::object(vec![ts::optional_field( + "reason", + ts::union(vec![ts::string(), ts::null()]), + )]), + ), + ]), + ]), + ), + ts::type_alias( + "RadrootsTradeDiscountOffer", + ts::object(vec![ + ts::field("discount_id", ts::string()), + ts::field("value", ts::reference("RadrootsCoreDiscountValue")), + ]), + ), + ts::type_alias( + "RadrootsTradeDiscountRequest", + ts::object(vec![ + ts::field("discount_id", ts::string()), + ts::field("value", ts::reference("RadrootsCoreDiscountValue")), + ]), + ), + ts::type_alias("RadrootsTradeDomain", ts::string_literal("trade:listing")), + ts::type_alias( + "RadrootsTradeEconomicActor", + ts::union(vec![ + ts::string_literal("buyer"), + ts::string_literal("seller"), + ]), + ), + ts::type_alias( + "RadrootsTradeEconomicEffect", + ts::union(vec![ + ts::string_literal("increase"), + ts::string_literal("decrease"), + ]), + ), + ts::type_alias( + "RadrootsTradeEconomicLineKind", + ts::union(vec![ + ts::string_literal("listing_discount"), + ts::string_literal("basket_adjustment"), + ts::string_literal("revision_adjustment"), + ]), + ), + ts::type_alias_params( + "RadrootsTradeEnvelope", + &["T"], + ts::object(vec![ + ts::field("version", ts::number()), + ts::field("domain", ts::reference("RadrootsTradeDomain")), + ts::field("type", ts::reference("RadrootsTradeMessageType")), + ts::optional_field("order_id", ts::union(vec![ts::string(), ts::null()])), + ts::field("listing_addr", ts::string()), + ts::field("payload", ts::reference("T")), + ]), + ), + ts::type_alias( + "RadrootsTradeFulfillmentStatus", + ts::union(vec![ + ts::object(vec![ts::field("kind", ts::string_literal("preparing"))]), + ts::object(vec![ts::field("kind", ts::string_literal("shipped"))]), + ts::object(vec![ts::field( + "kind", + ts::string_literal("ready_for_pickup"), + )]), + ts::object(vec![ts::field("kind", ts::string_literal("delivered"))]), + ts::object(vec![ts::field("kind", ts::string_literal("cancelled"))]), + ]), + ), + ts::type_alias( + "RadrootsTradeFulfillmentUpdate", + ts::object(vec![ts::field( + "status", + ts::reference("RadrootsTradeFulfillmentStatus"), + )]), + ), + ts::type_alias( + "RadrootsTradeFulfillmentUpdated", + ts::object(vec![ + ts::field("order_id", ts::string()), + ts::field("listing_addr", ts::string()), + ts::field("buyer_pubkey", ts::string()), + ts::field("seller_pubkey", ts::string()), + ts::field( + "status", + ts::reference("RadrootsActiveTradeFulfillmentState"), + ), + ]), + ), + ts::type_alias( + "RadrootsTradeInventoryCommitment", + ts::object(vec![ + ts::field("bin_id", ts::string()), + ts::field("bin_count", ts::number()), + ]), + ), + ts::type_alias( + "RadrootsTradeListingCancel", + ts::object(vec![ts::optional_field( + "reason", + ts::union(vec![ts::string(), ts::null()]), + )]), + ), + ts::type_alias( + "RadrootsTradeListingParseError", + ts::union(vec![ + ts::object(vec![ts::field("InvalidKind", ts::number())]), + ts::object(vec![ts::field("MissingTag", ts::string())]), + ts::object(vec![ts::field("InvalidTag", ts::string())]), + ts::object(vec![ts::field("InvalidNumber", ts::string())]), + ts::string_literal("InvalidUnit"), + ts::string_literal("InvalidCurrency"), + ts::object(vec![ts::field("InvalidJson", ts::string())]), + ts::object(vec![ts::field("InvalidDiscount", ts::string())]), + ]), + ), + ts::type_alias( + "RadrootsTradeListingValidateRequest", + ts::object(vec![ts::optional_field( + "listing_event", + ts::union(vec![ts::reference("RadrootsNostrEventPtr"), ts::null()]), + )]), + ), + ts::type_alias( + "RadrootsTradeListingValidateResult", + ts::object(vec![ + ts::field("valid", ts::boolean()), + ts::field( + "errors", + ts::array(ts::reference("RadrootsTradeListingValidationError")), + ), + ]), + ), + ts::type_alias( + "RadrootsTradeListingValidationError", + ts::union(vec![ + ts::object(vec![ + ts::field("kind", ts::string_literal("invalid_kind")), + ts::field("amount", ts::object(vec![ts::field("kind", ts::number())])), + ]), + ts::object(vec![ts::field( + "kind", + ts::string_literal("missing_listing_id"), + )]), + ts::object(vec![ + ts::field("kind", ts::string_literal("listing_event_not_found")), + ts::field( + "amount", + ts::object(vec![ts::field("listing_addr", ts::string())]), + ), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("listing_event_fetch_failed")), + ts::field( + "amount", + ts::object(vec![ts::field("listing_addr", ts::string())]), + ), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("parse_error")), + ts::field( + "amount", + ts::object(vec![ts::field( + "error", + ts::reference("RadrootsTradeListingParseError"), + )]), + ), + ]), + ts::object(vec![ts::field( + "kind", + ts::string_literal("invalid_seller"), + )]), + ts::object(vec![ts::field( + "kind", + ts::string_literal("missing_farm_profile"), + )]), + ts::object(vec![ts::field( + "kind", + ts::string_literal("missing_farm_record"), + )]), + ts::object(vec![ts::field("kind", ts::string_literal("missing_title"))]), + ts::object(vec![ts::field( + "kind", + ts::string_literal("missing_description"), + )]), + ts::object(vec![ts::field( + "kind", + ts::string_literal("missing_product_type"), + )]), + ts::object(vec![ts::field("kind", ts::string_literal("missing_bins"))]), + ts::object(vec![ts::field( + "kind", + ts::string_literal("missing_primary_bin"), + )]), + ts::object(vec![ts::field("kind", ts::string_literal("invalid_bin"))]), + ts::object(vec![ts::field("kind", ts::string_literal("missing_price"))]), + ts::object(vec![ts::field("kind", ts::string_literal("invalid_price"))]), + ts::object(vec![ts::field( + "kind", + ts::string_literal("missing_inventory"), + )]), + ts::object(vec![ts::field( + "kind", + ts::string_literal("invalid_inventory"), + )]), + ts::object(vec![ts::field( + "kind", + ts::string_literal("missing_availability"), + )]), + ts::object(vec![ts::field( + "kind", + ts::string_literal("missing_location"), + )]), + ts::object(vec![ts::field( + "kind", + ts::string_literal("missing_delivery_method"), + )]), + ]), + ), + ts::type_alias( + "RadrootsTradeMessagePayload", + ts::union(vec![ + ts::object(vec![ + ts::field("kind", ts::string_literal("listing_validate_request")), + ts::field( + "amount", + ts::reference("RadrootsTradeListingValidateRequest"), + ), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("listing_validate_result")), + ts::field( + "amount", + ts::reference("RadrootsTradeListingValidateResult"), + ), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("trade_order_requested")), + ts::field("amount", ts::reference("RadrootsTradeOrderRequested")), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("order_response")), + ts::field("amount", ts::reference("RadrootsTradeOrderResponse")), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("order_revision")), + ts::field("amount", ts::reference("RadrootsTradeOrderRevision")), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("order_revision_accept")), + ts::field( + "amount", + ts::reference("RadrootsTradeOrderRevisionResponse"), + ), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("order_revision_decline")), + ts::field( + "amount", + ts::reference("RadrootsTradeOrderRevisionResponse"), + ), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("question")), + ts::field("amount", ts::reference("RadrootsTradeQuestion")), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("answer")), + ts::field("amount", ts::reference("RadrootsTradeAnswer")), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("discount_request")), + ts::field("amount", ts::reference("RadrootsTradeDiscountRequest")), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("discount_offer")), + ts::field("amount", ts::reference("RadrootsTradeDiscountOffer")), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("discount_accept")), + ts::field("amount", ts::reference("RadrootsTradeDiscountDecision")), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("discount_decline")), + ts::field("amount", ts::reference("RadrootsTradeDiscountDecision")), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("cancel")), + ts::field("amount", ts::reference("RadrootsTradeListingCancel")), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("fulfillment_update")), + ts::field("amount", ts::reference("RadrootsTradeFulfillmentUpdate")), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("receipt")), + ts::field("amount", ts::reference("RadrootsTradeReceipt")), + ]), + ]), + ), + ts::type_alias( + "RadrootsTradeMessageType", + ts::union(vec![ + ts::string_literal("listing_validate_request"), + ts::string_literal("listing_validate_result"), + ts::string_literal("order_request"), + ts::string_literal("order_response"), + ts::string_literal("order_revision"), + ts::string_literal("order_revision_accept"), + ts::string_literal("order_revision_decline"), + ts::string_literal("question"), + ts::string_literal("answer"), + ts::string_literal("discount_request"), + ts::string_literal("discount_offer"), + ts::string_literal("discount_accept"), + ts::string_literal("discount_decline"), + ts::string_literal("cancel"), + ts::string_literal("fulfillment_update"), + ts::string_literal("receipt"), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderCancelled", + ts::object(vec![ + ts::field("order_id", ts::string()), + ts::field("listing_addr", ts::string()), + ts::field("buyer_pubkey", ts::string()), + ts::field("seller_pubkey", ts::string()), + ts::field("reason", ts::string()), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderChange", + ts::union(vec![ + ts::object(vec![ + ts::field("kind", ts::string_literal("bin_count")), + ts::field( + "amount", + ts::object(vec![ + ts::field("item_index", ts::number()), + ts::field("bin_count", ts::number()), + ]), + ), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("item_add")), + ts::field( + "amount", + ts::object(vec![ts::field( + "item", + ts::reference("RadrootsTradeOrderItem"), + )]), + ), + ]), + ts::object(vec![ + ts::field("kind", ts::string_literal("item_remove")), + ts::field( + "amount", + ts::object(vec![ts::field("item_index", ts::number())]), + ), + ]), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderDecision", + ts::union(vec![ + ts::object(vec![ + ts::field("decision", ts::string_literal("accepted")), + ts::field( + "inventory_commitments", + ts::array(ts::reference("RadrootsTradeInventoryCommitment")), + ), + ]), + ts::object(vec![ + ts::field("decision", ts::string_literal("declined")), + ts::field("reason", ts::string()), + ]), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderDecisionEvent", + ts::object(vec![ + ts::field("order_id", ts::string()), + ts::field("listing_addr", ts::string()), + ts::field("buyer_pubkey", ts::string()), + ts::field("seller_pubkey", ts::string()), + ts::field("decision", ts::reference("RadrootsTradeOrderDecision")), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderEconomicItem", + ts::object(vec![ + ts::field("bin_id", ts::string()), + ts::field("bin_count", ts::number()), + ts::field("quantity_amount", ts::reference("RadrootsCoreDecimal")), + ts::field("quantity_unit", ts::reference("RadrootsCoreUnit")), + ts::field("unit_price_amount", ts::reference("RadrootsCoreDecimal")), + ts::field("unit_price_currency", ts::reference("RadrootsCoreCurrency")), + ts::field("line_subtotal", ts::reference("RadrootsCoreMoney")), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderEconomicLine", + ts::object(vec![ + ts::field("id", ts::string()), + ts::field("kind", ts::reference("RadrootsTradeEconomicLineKind")), + ts::field("actor", ts::reference("RadrootsTradeEconomicActor")), + ts::field("effect", ts::reference("RadrootsTradeEconomicEffect")), + ts::field("amount", ts::reference("RadrootsCoreMoney")), + ts::field("reason", ts::string()), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderEconomicTotals", + ts::object(vec![ + ts::field("subtotal", ts::reference("RadrootsCoreMoney")), + ts::field("discount_total", ts::reference("RadrootsCoreMoney")), + ts::field("adjustment_total", ts::reference("RadrootsCoreMoney")), + ts::field("total", ts::reference("RadrootsCoreMoney")), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderEconomics", + ts::object(vec![ + ts::field("quote_id", ts::string()), + ts::field("quote_version", ts::number()), + ts::field("pricing_basis", ts::reference("RadrootsTradePricingBasis")), + ts::field("currency", ts::reference("RadrootsCoreCurrency")), + ts::field( + "items", + ts::array(ts::reference("RadrootsTradeOrderEconomicItem")), + ), + ts::field( + "discounts", + ts::array(ts::reference("RadrootsTradeOrderEconomicLine")), + ), + ts::field( + "adjustments", + ts::array(ts::reference("RadrootsTradeOrderEconomicLine")), + ), + ts::field("subtotal", ts::reference("RadrootsCoreMoney")), + ts::field("discount_total", ts::reference("RadrootsCoreMoney")), + ts::field("adjustment_total", ts::reference("RadrootsCoreMoney")), + ts::field("total", ts::reference("RadrootsCoreMoney")), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderItem", + ts::object(vec![ + ts::field("bin_id", ts::string()), + ts::field("bin_count", ts::number()), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderRequested", + ts::object(vec![ + ts::field("order_id", ts::string()), + ts::field("listing_addr", ts::string()), + ts::field("buyer_pubkey", ts::string()), + ts::field("seller_pubkey", ts::string()), + ts::field("items", ts::array(ts::reference("RadrootsTradeOrderItem"))), + ts::field("economics", ts::reference("RadrootsTradeOrderEconomics")), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderResponse", + ts::object(vec![ + ts::field("accepted", ts::boolean()), + ts::optional_field("reason", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderRevision", + ts::object(vec![ + ts::field("revision_id", ts::string()), + ts::field( + "changes", + ts::array(ts::reference("RadrootsTradeOrderChange")), + ), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderRevisionDecision", + ts::union(vec![ + ts::object(vec![ts::field("decision", ts::string_literal("accepted"))]), + ts::object(vec![ + ts::field("decision", ts::string_literal("declined")), + ts::field("reason", ts::string()), + ]), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderRevisionDecisionEvent", + ts::object(vec![ + ts::field("revision_id", ts::string()), + ts::field("order_id", ts::string()), + ts::field("listing_addr", ts::string()), + ts::field("buyer_pubkey", ts::string()), + ts::field("seller_pubkey", ts::string()), + ts::field("root_event_id", ts::string()), + ts::field("prev_event_id", ts::string()), + ts::field( + "decision", + ts::reference("RadrootsTradeOrderRevisionDecision"), + ), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderRevisionProposed", + ts::object(vec![ + ts::field("revision_id", ts::string()), + ts::field("order_id", ts::string()), + ts::field("listing_addr", ts::string()), + ts::field("buyer_pubkey", ts::string()), + ts::field("seller_pubkey", ts::string()), + ts::field("root_event_id", ts::string()), + ts::field("prev_event_id", ts::string()), + ts::field("items", ts::array(ts::reference("RadrootsTradeOrderItem"))), + ts::field("economics", ts::reference("RadrootsTradeOrderEconomics")), + ts::field("reason", ts::string()), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderRevisionResponse", + ts::object(vec![ + ts::field("accepted", ts::boolean()), + ts::optional_field("reason", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsTradeOrderStatus", + ts::union(vec![ + ts::string_literal("draft"), + ts::string_literal("validated"), + ts::string_literal("requested"), + ts::string_literal("questioned"), + ts::string_literal("revised"), + ts::string_literal("accepted"), + ts::string_literal("declined"), + ts::string_literal("cancelled"), + ts::string_literal("fulfilled"), + ts::string_literal("completed"), + ]), + ), + ts::type_alias( + "RadrootsTradePaymentMethod", + ts::union(vec![ + ts::string_literal("cash"), + ts::string_literal("manual_transfer"), + ts::string_literal("other"), + ]), + ), + ts::type_alias( + "RadrootsTradePaymentRecorded", + ts::object(vec![ + ts::field("order_id", ts::string()), + ts::field("listing_addr", ts::string()), + ts::field("buyer_pubkey", ts::string()), + ts::field("seller_pubkey", ts::string()), + ts::field("root_event_id", ts::string()), + ts::field("previous_event_id", ts::string()), + ts::field("agreement_event_id", ts::string()), + ts::field("quote_id", ts::string()), + ts::field("quote_version", ts::number()), + ts::field("economics_digest", ts::string()), + ts::field("amount", ts::reference("RadrootsCoreDecimal")), + ts::field("currency", ts::reference("RadrootsCoreCurrency")), + ts::field("method", ts::reference("RadrootsTradePaymentMethod")), + ts::optional_field("reference", ts::union(vec![ts::string(), ts::null()])), + ts::optional_field("paid_at", ts::union(vec![ts::number(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsTradePricingBasis", + ts::string_literal("listing_event"), + ), + ts::type_alias( + "RadrootsTradeQuestion", + ts::object(vec![ts::field("question_id", ts::string())]), + ), + ts::type_alias( + "RadrootsTradeReceipt", + ts::object(vec![ + ts::field("acknowledged", ts::boolean()), + ts::field("at", ts::bigint()), + ]), + ), + ts::type_alias( + "RadrootsTradeSettlementDecision", + ts::union(vec![ + ts::string_literal("accepted"), + ts::string_literal("rejected"), + ]), + ), + ts::type_alias( + "RadrootsTradeSettlementDecisionEvent", + ts::object(vec![ + ts::field("order_id", ts::string()), + ts::field("listing_addr", ts::string()), + ts::field("seller_pubkey", ts::string()), + ts::field("buyer_pubkey", ts::string()), + ts::field("root_event_id", ts::string()), + ts::field("previous_event_id", ts::string()), + ts::field("agreement_event_id", ts::string()), + ts::field("payment_event_id", ts::string()), + ts::field("quote_id", ts::string()), + ts::field("quote_version", ts::number()), + ts::field("economics_digest", ts::string()), + ts::field("amount", ts::reference("RadrootsCoreDecimal")), + ts::field("currency", ts::reference("RadrootsCoreCurrency")), + ts::field("decision", ts::reference("RadrootsTradeSettlementDecision")), + ts::optional_field("reason", ts::union(vec![ts::string(), ts::null()])), + ]), + ), + ts::type_alias( + "RadrootsTradeTransportLane", + ts::union(vec![ + ts::string_literal("service"), + ts::string_literal("public"), + ]), + ), + ]) +} + +pub fn constants_module() -> ts::TsModule { + ts::module(vec![ + ts::import_type(&["RadrootsListingProductTagKeys"], "./types.js"), + ts::const_decl( + "RADROOTS_LISTING_PRODUCT_TAG_KEYS", + Some(ts::reference("RadrootsListingProductTagKeys")), + TsValue::Array(vec![ + TsValue::String("key".to_owned()), + TsValue::String("title".to_owned()), + TsValue::String("category".to_owned()), + TsValue::String("summary".to_owned()), + TsValue::String("process".to_owned()), + TsValue::String("lot".to_owned()), + TsValue::String("location".to_owned()), + TsValue::String("profile".to_owned()), + TsValue::String("year".to_owned()), + ]), + ), + ]) +} + +pub fn kinds_module() -> ts::TsModule { + ts::module(vec![ + ts::const_number("KIND_PROFILE", 0), + ts::const_number("KIND_POST", 1), + ts::const_number("KIND_FOLLOW", 3), + ts::const_number("KIND_REACTION", 7), + ts::const_number("KIND_SEAL", 13), + ts::const_number("KIND_MESSAGE", 14), + ts::const_number("KIND_MESSAGE_FILE", 15), + ts::const_number("KIND_GIFT_WRAP", 1059), + ts::const_number("KIND_COMMENT", 1111), + ts::const_number("KIND_GEOCHAT", 20000), + ts::const_number("KIND_LIST_MUTE", 10000), + ts::const_number("KIND_LIST_PINNED_NOTES", 10001), + ts::const_number("KIND_LIST_READ_WRITE_RELAYS", 10002), + ts::const_number("KIND_LIST_BOOKMARKS", 10003), + ts::const_number("KIND_LIST_COMMUNITIES", 10004), + ts::const_number("KIND_LIST_PUBLIC_CHATS", 10005), + ts::const_number("KIND_LIST_BLOCKED_RELAYS", 10006), + ts::const_number("KIND_LIST_SEARCH_RELAYS", 10007), + ts::const_number("KIND_LIST_SIMPLE_GROUPS", 10009), + ts::const_number("KIND_LIST_RELAY_FEEDS", 10012), + ts::const_number("KIND_LIST_INTERESTS", 10015), + ts::const_number("KIND_LIST_MEDIA_FOLLOWS", 10020), + ts::const_number("KIND_LIST_EMOJIS", 10030), + ts::const_number("KIND_LIST_DM_RELAYS", 10050), + ts::const_number("KIND_LIST_GOOD_WIKI_AUTHORS", 10101), + ts::const_number("KIND_LIST_GOOD_WIKI_RELAYS", 10102), + ts::const_number("KIND_LIST_SET_FOLLOW", 30000), + ts::const_number("KIND_LIST_SET_GENERIC", 30001), + ts::const_number("KIND_LIST_SET_RELAY", 30002), + ts::const_number("KIND_LIST_SET_BOOKMARK", 30003), + ts::const_number("KIND_LIST_SET_CURATION", 30004), + ts::const_number("KIND_LIST_SET_VIDEO", 30005), + ts::const_number("KIND_LIST_SET_PICTURE", 30006), + ts::const_number("KIND_LIST_SET_KIND_MUTE", 30007), + ts::const_number("KIND_LIST_SET_INTEREST", 30015), + ts::const_number("KIND_LIST_SET_EMOJI", 30030), + ts::const_number("KIND_LIST_SET_RELEASE_ARTIFACT", 30063), + ts::const_number("KIND_LIST_SET_APP_CURATION", 30267), + ts::const_number("KIND_LIST_SET_CALENDAR", 31924), + ts::const_number("KIND_LIST_SET_STARTER_PACK", 39089), + ts::const_number("KIND_LIST_SET_MEDIA_STARTER_PACK", 39092), + ts::const_number("KIND_FARM", 30340), + ts::const_number("KIND_PLOT", 30350), + ts::const_number("KIND_COOP", 30360), + ts::const_number("KIND_DOCUMENT", 30361), + ts::const_number("KIND_RESOURCE_AREA", 30370), + ts::const_number("KIND_RESOURCE_HARVEST_CAP", 30371), + ts::const_number("KIND_ACCOUNT_CLAIM", 30380), + ts::const_number("KIND_APP_DATA", 30078), + ts::const_number("KIND_LISTING", 30402), + ts::const_number("KIND_APPLICATION_HANDLER", 31990), + ts::const_number("KIND_TRADE_LISTING_VALIDATE_REQ", 5321), + ts::const_number("KIND_TRADE_LISTING_VALIDATE_RES", 6321), + ts::const_number("KIND_WORKER_TRADE_TRANSITION_PROOF_REQ", 5322), + ts::const_number("KIND_WORKER_TRADE_TRANSITION_PROOF_RES", 6322), + ts::const_number("KIND_TRADE_ORDER_REQUEST", 3422), + ts::const_number("KIND_TRADE_ORDER_RESPONSE", 3423), + ts::const_number("KIND_TRADE_ORDER_DECISION", 3423), + ts::const_number("KIND_TRADE_ORDER_REVISION", 3424), + ts::const_number("KIND_TRADE_ORDER_REVISION_RESPONSE", 3425), + ts::const_number("KIND_TRADE_QUESTION", 3426), + ts::const_number("KIND_TRADE_ANSWER", 3427), + ts::const_number("KIND_TRADE_DISCOUNT_REQUEST", 3428), + ts::const_number("KIND_TRADE_DISCOUNT_OFFER", 3429), + ts::const_number("KIND_TRADE_DISCOUNT_ACCEPT", 3430), + ts::const_number("KIND_TRADE_FORBIDDEN_3431", 3431), + ts::const_number("KIND_TRADE_CANCEL", 3432), + ts::const_number("KIND_TRADE_FULFILLMENT_UPDATE", 3433), + ts::const_number("KIND_TRADE_RECEIPT", 3434), + ts::const_number("KIND_TRADE_VALIDATION_RECEIPT", 3440), + ts::const_number("KIND_TRADE_LISTING_ORDER_REQ", 3422), + ts::const_number("KIND_TRADE_LISTING_ORDER_RES", 3423), + ts::const_number("KIND_TRADE_LISTING_ORDER_REVISION_REQ", 3424), + ts::const_number("KIND_TRADE_LISTING_ORDER_REVISION_RES", 3425), + ts::const_number("KIND_TRADE_LISTING_QUESTION_REQ", 3426), + ts::const_number("KIND_TRADE_LISTING_ANSWER_RES", 3427), + ts::const_number("KIND_TRADE_LISTING_DISCOUNT_REQ", 3428), + ts::const_number("KIND_TRADE_LISTING_DISCOUNT_OFFER_RES", 3429), + ts::const_number("KIND_TRADE_LISTING_DISCOUNT_ACCEPT_REQ", 3430), + ts::const_number("KIND_TRADE_LISTING_CANCEL_REQ", 3432), + ts::const_number("KIND_TRADE_LISTING_FULFILLMENT_UPDATE_REQ", 3433), + ts::const_number("KIND_TRADE_LISTING_RECEIPT_REQ", 3434), + ts::const_number("KIND_JOB_REQUEST_MIN", 5000), + ts::const_number("KIND_JOB_REQUEST_MAX", 5999), + ts::const_number("KIND_JOB_RESULT_MIN", 6000), + ts::const_number("KIND_JOB_RESULT_MAX", 6999), + ts::const_number("KIND_JOB_FEEDBACK", 7000), + ]) +} diff --git a/crates/events_bindings/src/typescript/constants.ts b/crates/events_bindings/src/typescript/constants.ts @@ -1,3 +0,0 @@ -import type { RadrootsListingProductTagKeys } from "./types.js"; - -export const RADROOTS_LISTING_PRODUCT_TAG_KEYS: RadrootsListingProductTagKeys = ["key", "title", "category", "summary", "process", "lot", "location", "profile", "year"]; diff --git a/crates/events_bindings/src/typescript/kinds.ts b/crates/events_bindings/src/typescript/kinds.ts @@ -1,87 +0,0 @@ -export const KIND_PROFILE = 0; -export const KIND_POST = 1; -export const KIND_FOLLOW = 3; -export const KIND_REACTION = 7; -export const KIND_SEAL = 13; -export const KIND_MESSAGE = 14; -export const KIND_MESSAGE_FILE = 15; -export const KIND_GIFT_WRAP = 1059; -export const KIND_COMMENT = 1111; -export const KIND_GEOCHAT = 20000; -export const KIND_LIST_MUTE = 10000; -export const KIND_LIST_PINNED_NOTES = 10001; -export const KIND_LIST_READ_WRITE_RELAYS = 10002; -export const KIND_LIST_BOOKMARKS = 10003; -export const KIND_LIST_COMMUNITIES = 10004; -export const KIND_LIST_PUBLIC_CHATS = 10005; -export const KIND_LIST_BLOCKED_RELAYS = 10006; -export const KIND_LIST_SEARCH_RELAYS = 10007; -export const KIND_LIST_SIMPLE_GROUPS = 10009; -export const KIND_LIST_RELAY_FEEDS = 10012; -export const KIND_LIST_INTERESTS = 10015; -export const KIND_LIST_MEDIA_FOLLOWS = 10020; -export const KIND_LIST_EMOJIS = 10030; -export const KIND_LIST_DM_RELAYS = 10050; -export const KIND_LIST_GOOD_WIKI_AUTHORS = 10101; -export const KIND_LIST_GOOD_WIKI_RELAYS = 10102; -export const KIND_LIST_SET_FOLLOW = 30000; -export const KIND_LIST_SET_GENERIC = 30001; -export const KIND_LIST_SET_RELAY = 30002; -export const KIND_LIST_SET_BOOKMARK = 30003; -export const KIND_LIST_SET_CURATION = 30004; -export const KIND_LIST_SET_VIDEO = 30005; -export const KIND_LIST_SET_PICTURE = 30006; -export const KIND_LIST_SET_KIND_MUTE = 30007; -export const KIND_LIST_SET_INTEREST = 30015; -export const KIND_LIST_SET_EMOJI = 30030; -export const KIND_LIST_SET_RELEASE_ARTIFACT = 30063; -export const KIND_LIST_SET_APP_CURATION = 30267; -export const KIND_LIST_SET_CALENDAR = 31924; -export const KIND_LIST_SET_STARTER_PACK = 39089; -export const KIND_LIST_SET_MEDIA_STARTER_PACK = 39092; -export const KIND_FARM = 30340; -export const KIND_PLOT = 30350; -export const KIND_COOP = 30360; -export const KIND_DOCUMENT = 30361; -export const KIND_RESOURCE_AREA = 30370; -export const KIND_RESOURCE_HARVEST_CAP = 30371; -export const KIND_ACCOUNT_CLAIM = 30380; -export const KIND_APP_DATA = 30078; -export const KIND_LISTING = 30402; -export const KIND_APPLICATION_HANDLER = 31990; -export const KIND_TRADE_LISTING_VALIDATE_REQ = 5321; -export const KIND_TRADE_LISTING_VALIDATE_RES = 6321; -export const KIND_WORKER_TRADE_TRANSITION_PROOF_REQ = 5322; -export const KIND_WORKER_TRADE_TRANSITION_PROOF_RES = 6322; -export const KIND_TRADE_ORDER_REQUEST = 3422; -export const KIND_TRADE_ORDER_RESPONSE = 3423; -export const KIND_TRADE_ORDER_DECISION = 3423; -export const KIND_TRADE_ORDER_REVISION = 3424; -export const KIND_TRADE_ORDER_REVISION_RESPONSE = 3425; -export const KIND_TRADE_QUESTION = 3426; -export const KIND_TRADE_ANSWER = 3427; -export const KIND_TRADE_DISCOUNT_REQUEST = 3428; -export const KIND_TRADE_DISCOUNT_OFFER = 3429; -export const KIND_TRADE_DISCOUNT_ACCEPT = 3430; -export const KIND_TRADE_FORBIDDEN_3431 = 3431; -export const KIND_TRADE_CANCEL = 3432; -export const KIND_TRADE_FULFILLMENT_UPDATE = 3433; -export const KIND_TRADE_RECEIPT = 3434; -export const KIND_TRADE_VALIDATION_RECEIPT = 3440; -export const KIND_TRADE_LISTING_ORDER_REQ = 3422; -export const KIND_TRADE_LISTING_ORDER_RES = 3423; -export const KIND_TRADE_LISTING_ORDER_REVISION_REQ = 3424; -export const KIND_TRADE_LISTING_ORDER_REVISION_RES = 3425; -export const KIND_TRADE_LISTING_QUESTION_REQ = 3426; -export const KIND_TRADE_LISTING_ANSWER_RES = 3427; -export const KIND_TRADE_LISTING_DISCOUNT_REQ = 3428; -export const KIND_TRADE_LISTING_DISCOUNT_OFFER_RES = 3429; -export const KIND_TRADE_LISTING_DISCOUNT_ACCEPT_REQ = 3430; -export const KIND_TRADE_LISTING_CANCEL_REQ = 3432; -export const KIND_TRADE_LISTING_FULFILLMENT_UPDATE_REQ = 3433; -export const KIND_TRADE_LISTING_RECEIPT_REQ = 3434; -export const KIND_JOB_REQUEST_MIN = 5000; -export const KIND_JOB_REQUEST_MAX = 5999; -export const KIND_JOB_RESULT_MIN = 6000; -export const KIND_JOB_RESULT_MAX = 6999; -export const KIND_JOB_FEEDBACK = 7000; diff --git a/crates/events_bindings/src/typescript/types.ts b/crates/events_bindings/src/typescript/types.ts @@ -1,221 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -export type JobFeedbackStatus = "payment_required" | "processing" | "error" | "success" | "partial"; - -export type JobInputType = "url" | "event" | "job" | "text"; - -export type JobPaymentRequest = { amount_sat: number, bolt11?: string | null, }; - -export type RadrootsAccountClaim = { username: string, pubkey: string, nip05?: string | null, }; - -export type RadrootsActiveTradeEnvelope<T> = { version: number, domain: RadrootsTradeDomain, type: RadrootsActiveTradeMessageType, order_id: string, listing_addr: string, payload: T, }; - -export type RadrootsActiveTradeFulfillmentState = "accepted_not_fulfilled" | "preparing" | "ready_for_pickup" | "out_for_delivery" | "delivered" | "seller_cancelled"; - -export type RadrootsActiveTradeMessageType = "TradeOrderRequested" | "TradeOrderDecision" | "TradeOrderRevisionProposed" | "TradeOrderRevisionDecision" | "TradeOrderCancelled" | "TradeFulfillmentUpdated" | "TradeBuyerReceipt" | "TradePaymentRecorded" | "TradeSettlementDecision"; - -export type RadrootsAppData = { d_tag: string, content: string, }; - -export type RadrootsComment = { root: RadrootsNostrEventRef, parent: RadrootsNostrEventRef, content: string, }; - -export type RadrootsCoop = { d_tag: string, name: string, about?: string | null, website?: string | null, picture?: string | null, banner?: string | null, location?: RadrootsCoopLocation | null, tags?: string[] | null, }; - -export type RadrootsCoopLocation = { primary?: string | null, city?: string | null, region?: string | null, country?: string | null, gcs: RadrootsGcsLocation, }; - -export type RadrootsCoopRef = { pubkey: string, d_tag: string, }; - -export type RadrootsDocument = { d_tag: string, doc_type: string, title: string, version: string, summary?: string | null, effective_at?: number | null, body_markdown?: string | null, subject: RadrootsDocumentSubject, tags?: string[] | null, }; - -export type RadrootsDocumentSubject = { pubkey: string, address?: string | null, }; - -export type RadrootsFarm = { d_tag: string, name: string, about?: string | null, website?: string | null, picture?: string | null, banner?: string | null, location?: RadrootsFarmLocation | null, tags?: string[] | null, }; - -export type RadrootsFarmLocation = { primary?: string | null, city?: string | null, region?: string | null, country?: string | null, gcs?: RadrootsGcsLocation | null, }; - -export type RadrootsFarmRef = { pubkey: string, d_tag: string, }; - -export type RadrootsFollow = { list: Array<RadrootsFollowProfile>, }; - -export type RadrootsFollowProfile = { published_at: number, public_key: string, relay_url?: string | null, contact_name?: string | null, }; - -export type RadrootsGcsLocation = { lat: number, lng: number, geohash: string, point: RadrootsGeoJsonPoint, polygon: RadrootsGeoJsonPolygon, accuracy?: number | null, altitude?: number | null, tag_0?: string | null, label?: string | null, area?: number | null, elevation?: number | null, soil?: string | null, climate?: string | null, gc_id?: string | null, gc_name?: string | null, gc_admin1_id?: string | null, gc_admin1_name?: string | null, gc_country_id?: string | null, gc_country_name?: string | null, }; - -export type RadrootsGeoChat = { geohash: string, content: string, nickname?: string | null, teleported: boolean, }; - -export type RadrootsGeoJsonPoint = { type: string, coordinates: [number, number], }; - -export type RadrootsGeoJsonPolygon = { type: string, coordinates: Array<Array<[number, number]>>, }; - -export type RadrootsGiftWrap = { recipient: RadrootsGiftWrapRecipient, content: string, expiration?: number | null, }; - -export type RadrootsGiftWrapRecipient = { public_key: string, relay_url?: string | null, }; - -export type RadrootsJobFeedback = { kind: number, status: JobFeedbackStatus, extra_info?: string | null, request_event: RadrootsNostrEventPtr, customer_pubkey?: string | null, payment?: JobPaymentRequest | null, content?: string | null, encrypted: boolean, }; - -export type RadrootsJobInput = { data: string, input_type: JobInputType, relay?: string | null, marker?: string | null, }; - -export type RadrootsJobParam = { key: string, value: string, }; - -export type RadrootsJobRequest = { kind: number, inputs: Array<RadrootsJobInput>, output?: string | null, params: Array<RadrootsJobParam>, bid_sat?: number | null, relays: Array<string>, providers: Array<string>, topics: Array<string>, encrypted: boolean, }; - -export type RadrootsJobResult = { kind: number, request_event: RadrootsNostrEventPtr, request_json?: string | null, inputs: Array<RadrootsJobInput>, customer_pubkey?: string | null, payment?: JobPaymentRequest | null, content?: string | null, encrypted: boolean, }; - -export type RadrootsList = { content: string, entries: Array<RadrootsListEntry>, }; - -export type RadrootsListEntry = { tag: string, values: Array<string>, }; - -export type RadrootsListSet = { d_tag: string, content: string, entries: Array<RadrootsListEntry>, title?: string | null, description?: string | null, image?: string | null, }; - -export type RadrootsListing = { d_tag: string, farm: RadrootsFarmRef, product: RadrootsListingProduct, primary_bin_id: string, bins: Array<RadrootsListingBin>, resource_area?: RadrootsResourceAreaRef | null, plot?: RadrootsPlotRef | null, discounts?: RadrootsCoreDiscount[] | null, inventory_available?: RadrootsCoreDecimal | null, availability?: RadrootsListingAvailability | null, delivery_method?: RadrootsListingDeliveryMethod | null, location?: RadrootsListingLocation | null, images?: RadrootsListingImage[] | null, }; - -export type RadrootsListingAvailability = { "kind": "window", "amount": { start?: number | null, end?: number | null, } } | { "kind": "status", "amount": { status: RadrootsListingStatus, } }; - -export type RadrootsListingBin = { bin_id: string, quantity: RadrootsCoreQuantity, price_per_canonical_unit: RadrootsCoreQuantityPrice, display_amount?: RadrootsCoreDecimal | null, display_unit?: RadrootsCoreUnit | null, display_label?: string | null, display_price?: RadrootsCoreMoney | null, display_price_unit?: RadrootsCoreUnit | null, }; - -export type RadrootsListingDeliveryMethod = { "kind": "pickup" } | { "kind": "local_delivery" } | { "kind": "shipping" } | { "kind": "other", "amount": { method: string, } }; - -export type RadrootsListingImage = { url: string, size?: RadrootsListingImageSize | null, }; - -export type RadrootsListingImageSize = { w: number, h: number, }; - -export type RadrootsListingLocation = { primary: string, city?: string | null, region?: string | null, country?: string | null, lat?: number | null, lng?: number | null, geohash?: string | null, }; - -export type RadrootsListingProduct = { key: string, title: string, category: string, summary?: string | null, process?: string | null, lot?: string | null, location?: string | null, profile?: string | null, year?: string | null, }; - -export type RadrootsListingProductTagKeys = readonly ["key", "title", "category", "summary", "process", "lot", "location", "profile", "year"]; - -export type RadrootsListingStatus = { "kind": "active" } | { "kind": "sold" } | { "kind": "other", "amount": { value: string, } }; - -export type RadrootsMessage = { recipients: Array<RadrootsMessageRecipient>, content: string, reply_to?: RadrootsNostrEventPtr | null, subject?: string | null, }; - -export type RadrootsMessageFile = { recipients: Array<RadrootsMessageRecipient>, file_url: string, reply_to?: RadrootsNostrEventPtr | null, subject?: string | null, file_type: string, encryption_algorithm: string, decryption_key: string, decryption_nonce: string, encrypted_hash: string, original_hash?: string | null, size?: number | null, dimensions?: RadrootsMessageFileDimensions | null, blurhash?: string | null, thumb?: string | null, fallbacks: Array<string>, }; - -export type RadrootsMessageFileDimensions = { w: number, h: number, }; - -export type RadrootsMessageRecipient = { public_key: string, relay_url?: string | null, }; - -export type RadrootsNostrEvent = { id: string, author: string, created_at: number, kind: number, tags: Array<Array<string>>, content: string, sig: string, }; - -export type RadrootsNostrEventPtr = { id: string, relays?: string | null, }; - -export type RadrootsNostrEventRef = { id: string, author: string, kind: number, d_tag?: string | null, relays?: string[] | null, }; - -export type RadrootsPlot = { d_tag: string, farm: RadrootsFarmRef, name: string, about?: string | null, location?: RadrootsPlotLocation | null, tags?: string[] | null, }; - -export type RadrootsPlotLocation = { primary?: string | null, city?: string | null, region?: string | null, country?: string | null, gcs: RadrootsGcsLocation, }; - -export type RadrootsPlotRef = { pubkey: string, d_tag: string, }; - -export type RadrootsPost = { content: string, }; - -export type RadrootsProfile = { name: string, display_name?: string | null, nip05?: string | null, about?: string | null, website?: string | null, picture?: string | null, banner?: string | null, lud06?: string | null, lud16?: string | null, bot?: string | null, }; - -export type RadrootsProfileType = "individual" | "farm" | "coop" | "any" | "radrootsd"; - -export type RadrootsReaction = { root: RadrootsNostrEventRef, content: string, }; - -export type RadrootsRelayDocument = { name?: string | null, description?: string | null, pubkey?: string | null, contact?: string | null, supported_nips?: number[] | null, software?: string | null, version?: string | null, }; - -export type RadrootsResourceArea = { d_tag: string, name: string, about?: string | null, location: RadrootsResourceAreaLocation, tags?: string[] | null, }; - -export type RadrootsResourceAreaLocation = { primary?: string | null, city?: string | null, region?: string | null, country?: string | null, gcs: RadrootsGcsLocation, }; - -export type RadrootsResourceAreaRef = { pubkey: string, d_tag: string, }; - -export type RadrootsResourceHarvestCap = { d_tag: string, resource_area: RadrootsResourceAreaRef, product: RadrootsResourceHarvestProduct, start: bigint, end: bigint, cap_quantity: RadrootsCoreQuantity, display_amount?: RadrootsCoreDecimal | null, display_unit?: RadrootsCoreUnit | null, display_label?: string | null, tags?: string[] | null, }; - -export type RadrootsResourceHarvestProduct = { key: string, category?: string | null, }; - -export type RadrootsSeal = { content: string, }; - -export type RadrootsTradeAnswer = { question_id: string, }; - -export type RadrootsTradeBuyerReceipt = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, received: boolean, issue?: string | null, received_at: bigint, }; - -export type RadrootsTradeDiscountDecision = { "kind": "accept", "amount": { value: RadrootsCoreDiscountValue, } } | { "kind": "decline", "amount": { reason?: string | null, } }; - -export type RadrootsTradeDiscountOffer = { discount_id: string, value: RadrootsCoreDiscountValue, }; - -export type RadrootsTradeDiscountRequest = { discount_id: string, value: RadrootsCoreDiscountValue, }; - -export type RadrootsTradeDomain = "trade:listing"; - -export type RadrootsTradeEconomicActor = "buyer" | "seller"; - -export type RadrootsTradeEconomicEffect = "increase" | "decrease"; - -export type RadrootsTradeEconomicLineKind = "listing_discount" | "basket_adjustment" | "revision_adjustment"; - -export type RadrootsTradeEnvelope<T> = { version: number, domain: RadrootsTradeDomain, type: RadrootsTradeMessageType, order_id?: string | null, listing_addr: string, payload: T, }; - -export type RadrootsTradeFulfillmentStatus = { "kind": "preparing" } | { "kind": "shipped" } | { "kind": "ready_for_pickup" } | { "kind": "delivered" } | { "kind": "cancelled" }; - -export type RadrootsTradeFulfillmentUpdate = { status: RadrootsTradeFulfillmentStatus, }; - -export type RadrootsTradeFulfillmentUpdated = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, status: RadrootsActiveTradeFulfillmentState, }; - -export type RadrootsTradeInventoryCommitment = { bin_id: string, bin_count: number, }; - -export type RadrootsTradeListingCancel = { reason?: string | null, }; - -export type RadrootsTradeListingParseError = { "InvalidKind": number } | { "MissingTag": string } | { "InvalidTag": string } | { "InvalidNumber": string } | "InvalidUnit" | "InvalidCurrency" | { "InvalidJson": string } | { "InvalidDiscount": string }; - -export type RadrootsTradeListingValidateRequest = { listing_event?: RadrootsNostrEventPtr | null, }; - -export type RadrootsTradeListingValidateResult = { valid: boolean, errors: RadrootsTradeListingValidationError[], }; - -export type RadrootsTradeListingValidationError = { "kind": "invalid_kind", "amount": { kind: number, } } | { "kind": "missing_listing_id" } | { "kind": "listing_event_not_found", "amount": { listing_addr: string, } } | { "kind": "listing_event_fetch_failed", "amount": { listing_addr: string, } } | { "kind": "parse_error", "amount": { error: RadrootsTradeListingParseError, } } | { "kind": "invalid_seller" } | { "kind": "missing_farm_profile" } | { "kind": "missing_farm_record" } | { "kind": "missing_title" } | { "kind": "missing_description" } | { "kind": "missing_product_type" } | { "kind": "missing_bins" } | { "kind": "missing_primary_bin" } | { "kind": "invalid_bin" } | { "kind": "missing_price" } | { "kind": "invalid_price" } | { "kind": "missing_inventory" } | { "kind": "invalid_inventory" } | { "kind": "missing_availability" } | { "kind": "missing_location" } | { "kind": "missing_delivery_method" }; - -export type RadrootsTradeMessagePayload = { "kind": "listing_validate_request", "amount": RadrootsTradeListingValidateRequest } | { "kind": "listing_validate_result", "amount": RadrootsTradeListingValidateResult } | { "kind": "trade_order_requested", "amount": RadrootsTradeOrderRequested } | { "kind": "order_response", "amount": RadrootsTradeOrderResponse } | { "kind": "order_revision", "amount": RadrootsTradeOrderRevision } | { "kind": "order_revision_accept", "amount": RadrootsTradeOrderRevisionResponse } | { "kind": "order_revision_decline", "amount": RadrootsTradeOrderRevisionResponse } | { "kind": "question", "amount": RadrootsTradeQuestion } | { "kind": "answer", "amount": RadrootsTradeAnswer } | { "kind": "discount_request", "amount": RadrootsTradeDiscountRequest } | { "kind": "discount_offer", "amount": RadrootsTradeDiscountOffer } | { "kind": "discount_accept", "amount": RadrootsTradeDiscountDecision } | { "kind": "discount_decline", "amount": RadrootsTradeDiscountDecision } | { "kind": "cancel", "amount": RadrootsTradeListingCancel } | { "kind": "fulfillment_update", "amount": RadrootsTradeFulfillmentUpdate } | { "kind": "receipt", "amount": RadrootsTradeReceipt }; - -export type RadrootsTradeMessageType = "listing_validate_request" | "listing_validate_result" | "order_request" | "order_response" | "order_revision" | "order_revision_accept" | "order_revision_decline" | "question" | "answer" | "discount_request" | "discount_offer" | "discount_accept" | "discount_decline" | "cancel" | "fulfillment_update" | "receipt"; - -export type RadrootsTradeOrderCancelled = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, reason: string, }; - -export type RadrootsTradeOrderChange = { "kind": "bin_count", "amount": { item_index: number, bin_count: number, } } | { "kind": "item_add", "amount": { item: RadrootsTradeOrderItem, } } | { "kind": "item_remove", "amount": { item_index: number, } }; - -export type RadrootsTradeOrderDecision = { "decision": "accepted", inventory_commitments: Array<RadrootsTradeInventoryCommitment>, } | { "decision": "declined", reason: string, }; - -export type RadrootsTradeOrderDecisionEvent = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, decision: RadrootsTradeOrderDecision, }; - -export type RadrootsTradeOrderEconomicItem = { bin_id: string, bin_count: number, quantity_amount: RadrootsCoreDecimal, quantity_unit: RadrootsCoreUnit, unit_price_amount: RadrootsCoreDecimal, unit_price_currency: RadrootsCoreCurrency, line_subtotal: RadrootsCoreMoney, }; - -export type RadrootsTradeOrderEconomicLine = { id: string, kind: RadrootsTradeEconomicLineKind, actor: RadrootsTradeEconomicActor, effect: RadrootsTradeEconomicEffect, amount: RadrootsCoreMoney, reason: string, }; - -export type RadrootsTradeOrderEconomicTotals = { subtotal: RadrootsCoreMoney, discount_total: RadrootsCoreMoney, adjustment_total: RadrootsCoreMoney, total: RadrootsCoreMoney, }; - -export type RadrootsTradeOrderEconomics = { quote_id: string, quote_version: number, pricing_basis: RadrootsTradePricingBasis, currency: RadrootsCoreCurrency, items: Array<RadrootsTradeOrderEconomicItem>, discounts: Array<RadrootsTradeOrderEconomicLine>, adjustments: Array<RadrootsTradeOrderEconomicLine>, subtotal: RadrootsCoreMoney, discount_total: RadrootsCoreMoney, adjustment_total: RadrootsCoreMoney, total: RadrootsCoreMoney, }; - -export type RadrootsTradeOrderItem = { bin_id: string, bin_count: number, }; - -export type RadrootsTradeOrderRequested = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, items: Array<RadrootsTradeOrderItem>, economics: RadrootsTradeOrderEconomics, }; - -export type RadrootsTradeOrderResponse = { accepted: boolean, reason?: string | null, }; - -export type RadrootsTradeOrderRevision = { revision_id: string, changes: Array<RadrootsTradeOrderChange>, }; - -export type RadrootsTradeOrderRevisionDecision = { "decision": "accepted" } | { "decision": "declined", reason: string, }; - -export type RadrootsTradeOrderRevisionDecisionEvent = { revision_id: string, order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, root_event_id: string, prev_event_id: string, decision: RadrootsTradeOrderRevisionDecision, }; - -export type RadrootsTradeOrderRevisionProposed = { revision_id: string, order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, root_event_id: string, prev_event_id: string, items: Array<RadrootsTradeOrderItem>, economics: RadrootsTradeOrderEconomics, reason: string, }; - -export type RadrootsTradeOrderRevisionResponse = { accepted: boolean, reason?: string | null, }; - -export type RadrootsTradeOrderStatus = "draft" | "validated" | "requested" | "questioned" | "revised" | "accepted" | "declined" | "cancelled" | "fulfilled" | "completed"; - -export type RadrootsTradePaymentMethod = "cash" | "manual_transfer" | "other"; - -export type RadrootsTradePaymentRecorded = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, root_event_id: string, previous_event_id: string, agreement_event_id: string, quote_id: string, quote_version: number, economics_digest: string, amount: RadrootsCoreDecimal, currency: RadrootsCoreCurrency, method: RadrootsTradePaymentMethod, reference?: string | null, paid_at?: number | null, }; - -export type RadrootsTradePricingBasis = "listing_event"; - -export type RadrootsTradeQuestion = { question_id: string, }; - -export type RadrootsTradeReceipt = { acknowledged: boolean, at: bigint, }; - -export type RadrootsTradeSettlementDecision = "accepted" | "rejected"; - -export type RadrootsTradeSettlementDecisionEvent = { order_id: string, listing_addr: string, seller_pubkey: string, buyer_pubkey: string, root_event_id: string, previous_event_id: string, agreement_event_id: string, payment_event_id: string, quote_id: string, quote_version: number, economics_digest: string, amount: RadrootsCoreDecimal, currency: RadrootsCoreCurrency, decision: RadrootsTradeSettlementDecision, reason?: string | null, }; - -export type RadrootsTradeTransportLane = "service" | "public"; diff --git a/crates/xtask/src/output.rs b/crates/xtask/src/output.rs @@ -85,10 +85,12 @@ pub fn package_outputs() -> Vec<PackageOutput> { }, PackageOutput { spec: spec_by_key("events"), - types_ts: Some(TsSource::text(radroots_events_bindings::TYPES_TS)), + types_ts: Some(TsSource::Module(radroots_events_bindings::types_module())), types_imports_ts: Some(EVENTS_TYPES_IMPORTS_TS), - constants_ts: Some(TsSource::text(radroots_events_bindings::CONSTANTS_TS)), - kinds_ts: Some(TsSource::text(radroots_events_bindings::KINDS_TS)), + constants_ts: Some(TsSource::Module( + radroots_events_bindings::constants_module(), + )), + kinds_ts: Some(TsSource::Module(radroots_events_bindings::kinds_module())), }, PackageOutput { spec: spec_by_key("events_indexed"), diff --git a/packages/events-bindings/src/generated/types.ts b/packages/events-bindings/src/generated/types.ts @@ -29,17 +29,17 @@ export type RadrootsAppData = { d_tag: string, content: string, }; export type RadrootsComment = { root: RadrootsNostrEventRef, parent: RadrootsNostrEventRef, content: string, }; -export type RadrootsCoop = { d_tag: string, name: string, about?: string | null, website?: string | null, picture?: string | null, banner?: string | null, location?: RadrootsCoopLocation | null, tags?: string[] | null, }; +export type RadrootsCoop = { d_tag: string, name: string, about?: string | null, website?: string | null, picture?: string | null, banner?: string | null, location?: RadrootsCoopLocation | null, tags?: Array<string> | null, }; export type RadrootsCoopLocation = { primary?: string | null, city?: string | null, region?: string | null, country?: string | null, gcs: RadrootsGcsLocation, }; export type RadrootsCoopRef = { pubkey: string, d_tag: string, }; -export type RadrootsDocument = { d_tag: string, doc_type: string, title: string, version: string, summary?: string | null, effective_at?: number | null, body_markdown?: string | null, subject: RadrootsDocumentSubject, tags?: string[] | null, }; +export type RadrootsDocument = { d_tag: string, doc_type: string, title: string, version: string, summary?: string | null, effective_at?: number | null, body_markdown?: string | null, subject: RadrootsDocumentSubject, tags?: Array<string> | null, }; export type RadrootsDocumentSubject = { pubkey: string, address?: string | null, }; -export type RadrootsFarm = { d_tag: string, name: string, about?: string | null, website?: string | null, picture?: string | null, banner?: string | null, location?: RadrootsFarmLocation | null, tags?: string[] | null, }; +export type RadrootsFarm = { d_tag: string, name: string, about?: string | null, website?: string | null, picture?: string | null, banner?: string | null, location?: RadrootsFarmLocation | null, tags?: Array<string> | null, }; export type RadrootsFarmLocation = { primary?: string | null, city?: string | null, region?: string | null, country?: string | null, gcs?: RadrootsGcsLocation | null, }; @@ -77,13 +77,13 @@ export type RadrootsListEntry = { tag: string, values: Array<string>, }; export type RadrootsListSet = { d_tag: string, content: string, entries: Array<RadrootsListEntry>, title?: string | null, description?: string | null, image?: string | null, }; -export type RadrootsListing = { d_tag: string, farm: RadrootsFarmRef, product: RadrootsListingProduct, primary_bin_id: string, bins: Array<RadrootsListingBin>, resource_area?: RadrootsResourceAreaRef | null, plot?: RadrootsPlotRef | null, discounts?: RadrootsCoreDiscount[] | null, inventory_available?: RadrootsCoreDecimal | null, availability?: RadrootsListingAvailability | null, delivery_method?: RadrootsListingDeliveryMethod | null, location?: RadrootsListingLocation | null, images?: RadrootsListingImage[] | null, }; +export type RadrootsListing = { d_tag: string, farm: RadrootsFarmRef, product: RadrootsListingProduct, primary_bin_id: string, bins: Array<RadrootsListingBin>, resource_area?: RadrootsResourceAreaRef | null, plot?: RadrootsPlotRef | null, discounts?: Array<RadrootsCoreDiscount> | null, inventory_available?: RadrootsCoreDecimal | null, availability?: RadrootsListingAvailability | null, delivery_method?: RadrootsListingDeliveryMethod | null, location?: RadrootsListingLocation | null, images?: Array<RadrootsListingImage> | null, }; -export type RadrootsListingAvailability = { "kind": "window", "amount": { start?: number | null, end?: number | null, } } | { "kind": "status", "amount": { status: RadrootsListingStatus, } }; +export type RadrootsListingAvailability = { kind: "window", amount: { start?: number | null, end?: number | null, }, } | { kind: "status", amount: { status: RadrootsListingStatus, }, }; export type RadrootsListingBin = { bin_id: string, quantity: RadrootsCoreQuantity, price_per_canonical_unit: RadrootsCoreQuantityPrice, display_amount?: RadrootsCoreDecimal | null, display_unit?: RadrootsCoreUnit | null, display_label?: string | null, display_price?: RadrootsCoreMoney | null, display_price_unit?: RadrootsCoreUnit | null, }; -export type RadrootsListingDeliveryMethod = { "kind": "pickup" } | { "kind": "local_delivery" } | { "kind": "shipping" } | { "kind": "other", "amount": { method: string, } }; +export type RadrootsListingDeliveryMethod = { kind: "pickup", } | { kind: "local_delivery", } | { kind: "shipping", } | { kind: "other", amount: { method: string, }, }; export type RadrootsListingImage = { url: string, size?: RadrootsListingImageSize | null, }; @@ -95,7 +95,7 @@ export type RadrootsListingProduct = { key: string, title: string, category: str export type RadrootsListingProductTagKeys = readonly ["key", "title", "category", "summary", "process", "lot", "location", "profile", "year"]; -export type RadrootsListingStatus = { "kind": "active" } | { "kind": "sold" } | { "kind": "other", "amount": { value: string, } }; +export type RadrootsListingStatus = { kind: "active", } | { kind: "sold", } | { kind: "other", amount: { value: string, }, }; export type RadrootsMessage = { recipients: Array<RadrootsMessageRecipient>, content: string, reply_to?: RadrootsNostrEventPtr | null, subject?: string | null, }; @@ -109,9 +109,9 @@ export type RadrootsNostrEvent = { id: string, author: string, created_at: numbe export type RadrootsNostrEventPtr = { id: string, relays?: string | null, }; -export type RadrootsNostrEventRef = { id: string, author: string, kind: number, d_tag?: string | null, relays?: string[] | null, }; +export type RadrootsNostrEventRef = { id: string, author: string, kind: number, d_tag?: string | null, relays?: Array<string> | null, }; -export type RadrootsPlot = { d_tag: string, farm: RadrootsFarmRef, name: string, about?: string | null, location?: RadrootsPlotLocation | null, tags?: string[] | null, }; +export type RadrootsPlot = { d_tag: string, farm: RadrootsFarmRef, name: string, about?: string | null, location?: RadrootsPlotLocation | null, tags?: Array<string> | null, }; export type RadrootsPlotLocation = { primary?: string | null, city?: string | null, region?: string | null, country?: string | null, gcs: RadrootsGcsLocation, }; @@ -125,15 +125,15 @@ export type RadrootsProfileType = "individual" | "farm" | "coop" | "any" | "radr export type RadrootsReaction = { root: RadrootsNostrEventRef, content: string, }; -export type RadrootsRelayDocument = { name?: string | null, description?: string | null, pubkey?: string | null, contact?: string | null, supported_nips?: number[] | null, software?: string | null, version?: string | null, }; +export type RadrootsRelayDocument = { name?: string | null, description?: string | null, pubkey?: string | null, contact?: string | null, supported_nips?: Array<number> | null, software?: string | null, version?: string | null, }; -export type RadrootsResourceArea = { d_tag: string, name: string, about?: string | null, location: RadrootsResourceAreaLocation, tags?: string[] | null, }; +export type RadrootsResourceArea = { d_tag: string, name: string, about?: string | null, location: RadrootsResourceAreaLocation, tags?: Array<string> | null, }; export type RadrootsResourceAreaLocation = { primary?: string | null, city?: string | null, region?: string | null, country?: string | null, gcs: RadrootsGcsLocation, }; export type RadrootsResourceAreaRef = { pubkey: string, d_tag: string, }; -export type RadrootsResourceHarvestCap = { d_tag: string, resource_area: RadrootsResourceAreaRef, product: RadrootsResourceHarvestProduct, start: bigint, end: bigint, cap_quantity: RadrootsCoreQuantity, display_amount?: RadrootsCoreDecimal | null, display_unit?: RadrootsCoreUnit | null, display_label?: string | null, tags?: string[] | null, }; +export type RadrootsResourceHarvestCap = { d_tag: string, resource_area: RadrootsResourceAreaRef, product: RadrootsResourceHarvestProduct, start: bigint, end: bigint, cap_quantity: RadrootsCoreQuantity, display_amount?: RadrootsCoreDecimal | null, display_unit?: RadrootsCoreUnit | null, display_label?: string | null, tags?: Array<string> | null, }; export type RadrootsResourceHarvestProduct = { key: string, category?: string | null, }; @@ -143,7 +143,7 @@ export type RadrootsTradeAnswer = { question_id: string, }; export type RadrootsTradeBuyerReceipt = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, received: boolean, issue?: string | null, received_at: bigint, }; -export type RadrootsTradeDiscountDecision = { "kind": "accept", "amount": { value: RadrootsCoreDiscountValue, } } | { "kind": "decline", "amount": { reason?: string | null, } }; +export type RadrootsTradeDiscountDecision = { kind: "accept", amount: { value: RadrootsCoreDiscountValue, }, } | { kind: "decline", amount: { reason?: string | null, }, }; export type RadrootsTradeDiscountOffer = { discount_id: string, value: RadrootsCoreDiscountValue, }; @@ -159,7 +159,7 @@ export type RadrootsTradeEconomicLineKind = "listing_discount" | "basket_adjustm export type RadrootsTradeEnvelope<T> = { version: number, domain: RadrootsTradeDomain, type: RadrootsTradeMessageType, order_id?: string | null, listing_addr: string, payload: T, }; -export type RadrootsTradeFulfillmentStatus = { "kind": "preparing" } | { "kind": "shipped" } | { "kind": "ready_for_pickup" } | { "kind": "delivered" } | { "kind": "cancelled" }; +export type RadrootsTradeFulfillmentStatus = { kind: "preparing", } | { kind: "shipped", } | { kind: "ready_for_pickup", } | { kind: "delivered", } | { kind: "cancelled", }; export type RadrootsTradeFulfillmentUpdate = { status: RadrootsTradeFulfillmentStatus, }; @@ -169,23 +169,23 @@ export type RadrootsTradeInventoryCommitment = { bin_id: string, bin_count: numb export type RadrootsTradeListingCancel = { reason?: string | null, }; -export type RadrootsTradeListingParseError = { "InvalidKind": number } | { "MissingTag": string } | { "InvalidTag": string } | { "InvalidNumber": string } | "InvalidUnit" | "InvalidCurrency" | { "InvalidJson": string } | { "InvalidDiscount": string }; +export type RadrootsTradeListingParseError = { InvalidKind: number, } | { MissingTag: string, } | { InvalidTag: string, } | { InvalidNumber: string, } | "InvalidUnit" | "InvalidCurrency" | { InvalidJson: string, } | { InvalidDiscount: string, }; export type RadrootsTradeListingValidateRequest = { listing_event?: RadrootsNostrEventPtr | null, }; -export type RadrootsTradeListingValidateResult = { valid: boolean, errors: RadrootsTradeListingValidationError[], }; +export type RadrootsTradeListingValidateResult = { valid: boolean, errors: Array<RadrootsTradeListingValidationError>, }; -export type RadrootsTradeListingValidationError = { "kind": "invalid_kind", "amount": { kind: number, } } | { "kind": "missing_listing_id" } | { "kind": "listing_event_not_found", "amount": { listing_addr: string, } } | { "kind": "listing_event_fetch_failed", "amount": { listing_addr: string, } } | { "kind": "parse_error", "amount": { error: RadrootsTradeListingParseError, } } | { "kind": "invalid_seller" } | { "kind": "missing_farm_profile" } | { "kind": "missing_farm_record" } | { "kind": "missing_title" } | { "kind": "missing_description" } | { "kind": "missing_product_type" } | { "kind": "missing_bins" } | { "kind": "missing_primary_bin" } | { "kind": "invalid_bin" } | { "kind": "missing_price" } | { "kind": "invalid_price" } | { "kind": "missing_inventory" } | { "kind": "invalid_inventory" } | { "kind": "missing_availability" } | { "kind": "missing_location" } | { "kind": "missing_delivery_method" }; +export type RadrootsTradeListingValidationError = { kind: "invalid_kind", amount: { kind: number, }, } | { kind: "missing_listing_id", } | { kind: "listing_event_not_found", amount: { listing_addr: string, }, } | { kind: "listing_event_fetch_failed", amount: { listing_addr: string, }, } | { kind: "parse_error", amount: { error: RadrootsTradeListingParseError, }, } | { kind: "invalid_seller", } | { kind: "missing_farm_profile", } | { kind: "missing_farm_record", } | { kind: "missing_title", } | { kind: "missing_description", } | { kind: "missing_product_type", } | { kind: "missing_bins", } | { kind: "missing_primary_bin", } | { kind: "invalid_bin", } | { kind: "missing_price", } | { kind: "invalid_price", } | { kind: "missing_inventory", } | { kind: "invalid_inventory", } | { kind: "missing_availability", } | { kind: "missing_location", } | { kind: "missing_delivery_method", }; -export type RadrootsTradeMessagePayload = { "kind": "listing_validate_request", "amount": RadrootsTradeListingValidateRequest } | { "kind": "listing_validate_result", "amount": RadrootsTradeListingValidateResult } | { "kind": "trade_order_requested", "amount": RadrootsTradeOrderRequested } | { "kind": "order_response", "amount": RadrootsTradeOrderResponse } | { "kind": "order_revision", "amount": RadrootsTradeOrderRevision } | { "kind": "order_revision_accept", "amount": RadrootsTradeOrderRevisionResponse } | { "kind": "order_revision_decline", "amount": RadrootsTradeOrderRevisionResponse } | { "kind": "question", "amount": RadrootsTradeQuestion } | { "kind": "answer", "amount": RadrootsTradeAnswer } | { "kind": "discount_request", "amount": RadrootsTradeDiscountRequest } | { "kind": "discount_offer", "amount": RadrootsTradeDiscountOffer } | { "kind": "discount_accept", "amount": RadrootsTradeDiscountDecision } | { "kind": "discount_decline", "amount": RadrootsTradeDiscountDecision } | { "kind": "cancel", "amount": RadrootsTradeListingCancel } | { "kind": "fulfillment_update", "amount": RadrootsTradeFulfillmentUpdate } | { "kind": "receipt", "amount": RadrootsTradeReceipt }; +export type RadrootsTradeMessagePayload = { kind: "listing_validate_request", amount: RadrootsTradeListingValidateRequest, } | { kind: "listing_validate_result", amount: RadrootsTradeListingValidateResult, } | { kind: "trade_order_requested", amount: RadrootsTradeOrderRequested, } | { kind: "order_response", amount: RadrootsTradeOrderResponse, } | { kind: "order_revision", amount: RadrootsTradeOrderRevision, } | { kind: "order_revision_accept", amount: RadrootsTradeOrderRevisionResponse, } | { kind: "order_revision_decline", amount: RadrootsTradeOrderRevisionResponse, } | { kind: "question", amount: RadrootsTradeQuestion, } | { kind: "answer", amount: RadrootsTradeAnswer, } | { kind: "discount_request", amount: RadrootsTradeDiscountRequest, } | { kind: "discount_offer", amount: RadrootsTradeDiscountOffer, } | { kind: "discount_accept", amount: RadrootsTradeDiscountDecision, } | { kind: "discount_decline", amount: RadrootsTradeDiscountDecision, } | { kind: "cancel", amount: RadrootsTradeListingCancel, } | { kind: "fulfillment_update", amount: RadrootsTradeFulfillmentUpdate, } | { kind: "receipt", amount: RadrootsTradeReceipt, }; export type RadrootsTradeMessageType = "listing_validate_request" | "listing_validate_result" | "order_request" | "order_response" | "order_revision" | "order_revision_accept" | "order_revision_decline" | "question" | "answer" | "discount_request" | "discount_offer" | "discount_accept" | "discount_decline" | "cancel" | "fulfillment_update" | "receipt"; export type RadrootsTradeOrderCancelled = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, reason: string, }; -export type RadrootsTradeOrderChange = { "kind": "bin_count", "amount": { item_index: number, bin_count: number, } } | { "kind": "item_add", "amount": { item: RadrootsTradeOrderItem, } } | { "kind": "item_remove", "amount": { item_index: number, } }; +export type RadrootsTradeOrderChange = { kind: "bin_count", amount: { item_index: number, bin_count: number, }, } | { kind: "item_add", amount: { item: RadrootsTradeOrderItem, }, } | { kind: "item_remove", amount: { item_index: number, }, }; -export type RadrootsTradeOrderDecision = { "decision": "accepted", inventory_commitments: Array<RadrootsTradeInventoryCommitment>, } | { "decision": "declined", reason: string, }; +export type RadrootsTradeOrderDecision = { decision: "accepted", inventory_commitments: Array<RadrootsTradeInventoryCommitment>, } | { decision: "declined", reason: string, }; export type RadrootsTradeOrderDecisionEvent = { order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, decision: RadrootsTradeOrderDecision, }; @@ -205,7 +205,7 @@ export type RadrootsTradeOrderResponse = { accepted: boolean, reason?: string | export type RadrootsTradeOrderRevision = { revision_id: string, changes: Array<RadrootsTradeOrderChange>, }; -export type RadrootsTradeOrderRevisionDecision = { "decision": "accepted" } | { "decision": "declined", reason: string, }; +export type RadrootsTradeOrderRevisionDecision = { decision: "accepted", } | { decision: "declined", reason: string, }; export type RadrootsTradeOrderRevisionDecisionEvent = { revision_id: string, order_id: string, listing_addr: string, buyer_pubkey: string, seller_pubkey: string, root_event_id: string, prev_event_id: string, decision: RadrootsTradeOrderRevisionDecision, }; diff --git a/packages/identity-bindings/src/generated/constants.ts b/packages/identity-bindings/src/generated/constants.ts @@ -1,7 +1,5 @@ // @generated by cargo xtask generate ts // Do not edit by hand. export const RADROOTS_USERNAME_MIN_LEN = 3; - export const RADROOTS_USERNAME_MAX_LEN = 30; - export const RADROOTS_USERNAME_REGEX = "^(?!.*\\.\\.)(?!\\.)(?!.*\\.$)[a-z0-9._-]{3,30}$";