commit 2b1abc86f020fa1a33656e0a7fd298ad6956f654
parent f2f14a5901d602adf08526cf0777ec1cafb641df
Author: triesap <tyson@radroots.org>
Date: Tue, 14 Jul 2026 10:47:19 +0000
event: expose sealed event DTO roots
- add source-owned wire, envelope, signed, and verified signed event DTO roots
- name the generated envelope TypeScript surface as RadrootsEventEnvelopeDto
- include event DTO and envelope sources in dto-bindgen root discovery
- refresh generated event DTO root descriptors
Diffstat:
5 files changed, 77 insertions(+), 1 deletion(-)
diff --git a/crates/event/src/dto.rs b/crates/event/src/dto.rs
@@ -1,3 +1,62 @@
+use crate::RadrootsEventEnvelope;
+
+#[derive(dto_bindgen::Dto)]
+#[dto(export)]
+pub struct RadrootsNip01EventWireDto {
+ pub id: String,
+ pub pubkey: String,
+ #[dto(int = "json_number")]
+ pub created_at: u64,
+ pub kind: u32,
+ pub tags: Vec<Vec<String>>,
+ pub content: String,
+ pub sig: String,
+ pub extra: RadrootsNip01EventExtraDto,
+}
+
+#[derive(dto_bindgen::Dto)]
+#[dto(export)]
+#[dto(as = "string_enum")]
+pub enum RadrootsSignedEventVerificationStateDto {
+ #[dto(rename = "id_verified")]
+ IdVerified,
+}
+
+#[derive(dto_bindgen::Dto)]
+#[dto(export)]
+#[dto(as = "string_enum")]
+pub enum RadrootsVerifiedSignedEventVerificationStateDto {
+ #[dto(rename = "signature_verified")]
+ SignatureVerified,
+}
+
+#[derive(dto_bindgen::Dto)]
+#[dto(export)]
+pub struct RadrootsSignedEventDto {
+ pub state: RadrootsSignedEventVerificationStateDto,
+ pub envelope: RadrootsEventEnvelope,
+ pub wire: RadrootsNip01EventWireDto,
+ pub raw_json: String,
+}
+
+#[derive(dto_bindgen::Dto)]
+#[dto(export)]
+pub struct RadrootsVerifiedSignedEventDto {
+ pub state: RadrootsVerifiedSignedEventVerificationStateDto,
+ pub signed_event: RadrootsSignedEventDto,
+}
+
+pub struct RadrootsNip01EventExtraDto;
+
+impl dto_bindgen::Dto for RadrootsNip01EventExtraDto {
+ fn describe(_ctx: &mut dto_bindgen::__private::DescribeCtx) -> dto_bindgen::__private::TypeRef {
+ dto_bindgen::__private::TypeRef::Override(dto_bindgen::__private::TargetOverride::new(
+ dto_bindgen::__private::BackendId::TypeScript,
+ "{ [key: string]: unknown }",
+ ))
+ }
+}
+
#[path = "generated/dto_roots.rs"]
mod generated_roots;
@@ -20,6 +79,9 @@ mod tests {
let export_names = registry_export_names(®istry);
assert!(export_names.contains("RadrootsEventEnvelope"));
+ assert!(export_names.contains("RadrootsNip01EventWireDto"));
+ assert!(export_names.contains("RadrootsSignedEventDto"));
+ assert!(export_names.contains("RadrootsVerifiedSignedEventDto"));
assert!(export_names.contains("RadrootsListingImageSize"));
}
diff --git a/crates/event/src/envelope.rs b/crates/event/src/envelope.rs
@@ -296,10 +296,12 @@ pub struct RadrootsEventEnvelopeParts {
)]
#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
#[cfg_attr(feature = "dto-bindgen", dto(export))]
+#[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsEventEnvelopeDto")))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct RadrootsEventEnvelope {
id: RadrootsEventId,
author: RadrootsPublicKey,
+ #[cfg_attr(feature = "dto-bindgen", dto(int = "json_number"))]
created_at: RadrootsEventTimestamp,
kind: RadrootsEventKind,
tags: RadrootsEventTags,
diff --git a/crates/event/src/follow.rs b/crates/event/src/follow.rs
@@ -20,6 +20,7 @@ pub struct RadrootsFollow {
)]
#[derive(Clone, Debug)]
pub struct RadrootsFollowProfile {
+ #[cfg_attr(feature = "dto-bindgen", dto(int = "json_number"))]
pub published_at: u64,
pub public_key: String,
pub relay_url: Option<String>,
diff --git a/crates/event/src/generated/dto_roots.rs b/crates/event/src/generated/dto_roots.rs
@@ -3,7 +3,6 @@
pub fn dto_bindgen_roots() -> ::std::vec::Vec<::dto_bindgen::export::RootDescriptor> {
::std::vec![
- ::dto_bindgen::export::RootDescriptor::new::<crate::RadrootsEventEnvelope>(),
::dto_bindgen::export::RootDescriptor::new::<crate::RadrootsEventPtr>(),
::dto_bindgen::export::RootDescriptor::new::<crate::RadrootsEventRef>(),
::dto_bindgen::export::RootDescriptor::new::<crate::account::RadrootsAccountClaim>(),
@@ -14,6 +13,16 @@ pub fn dto_bindgen_roots() -> ::std::vec::Vec<::dto_bindgen::export::RootDescrip
::dto_bindgen::export::RootDescriptor::new::<crate::coop::RadrootsCoopRef>(),
::dto_bindgen::export::RootDescriptor::new::<crate::document::RadrootsDocument>(),
::dto_bindgen::export::RootDescriptor::new::<crate::document::RadrootsDocumentSubject>(),
+ ::dto_bindgen::export::RootDescriptor::new::<crate::dto::RadrootsNip01EventWireDto>(),
+ ::dto_bindgen::export::RootDescriptor::new::<crate::dto::RadrootsSignedEventDto>(),
+ ::dto_bindgen::export::RootDescriptor::new::<
+ crate::dto::RadrootsSignedEventVerificationStateDto,
+ >(),
+ ::dto_bindgen::export::RootDescriptor::new::<crate::dto::RadrootsVerifiedSignedEventDto>(),
+ ::dto_bindgen::export::RootDescriptor::new::<
+ crate::dto::RadrootsVerifiedSignedEventVerificationStateDto,
+ >(),
+ ::dto_bindgen::export::RootDescriptor::new::<crate::envelope::RadrootsEventEnvelope>(),
::dto_bindgen::export::RootDescriptor::new::<crate::farm::RadrootsFarm>(),
::dto_bindgen::export::RootDescriptor::new::<crate::farm::RadrootsFarmPublicLocation>(),
::dto_bindgen::export::RootDescriptor::new::<crate::farm::RadrootsFarmRef>(),
diff --git a/dto_bindgen.toml b/dto_bindgen.toml
@@ -60,6 +60,8 @@ source_files = [
"crates/event/src/comment.rs",
"crates/event/src/coop.rs",
"crates/event/src/document.rs",
+ "crates/event/src/dto.rs",
+ "crates/event/src/envelope.rs",
"crates/event/src/farm.rs",
"crates/event/src/follow.rs",
"crates/event/src/gcs.rs",