lib

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

commit 321518045908b13eb534d951ee6461a447054e2e
parent 307a428e6005a7fd6ba1f351136097bff694ad9e
Author: triesap <tyson@radroots.org>
Date:   Fri, 26 Dec 2025 03:43:21 +0000

events: add app_data event index and TS bindings


- Add app_data module with KIND_APP_DATA constant
- Define RadrootsAppData and metadata/index structs in Rust
- Export new app_data types via ts-rs to types.ts
- Extend TypeScript bindings with app_data event index types

Diffstat:
Mevents/bindings/ts/src/types.ts | 6++++++
Aevents/src/app_data.rs | 40++++++++++++++++++++++++++++++++++++++++
Mevents/src/lib.rs | 1+
3 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/events/bindings/ts/src/types.ts b/events/bindings/ts/src/types.ts @@ -8,6 +8,12 @@ export type JobInputType = "url" | "event" | "job" | "text"; export type JobPaymentRequest = { amount_sat: number, bolt11?: string | null, }; +export type RadrootsAppData = { d_tag: string, content: string, }; + +export type RadrootsAppDataEventIndex = { event: RadrootsNostrEvent, metadata: RadrootsAppDataEventMetadata, }; + +export type RadrootsAppDataEventMetadata = { id: string, author: string, published_at: number, kind: number, app_data: RadrootsAppData, }; + export type RadrootsComment = { root: RadrootsNostrEventRef, parent: RadrootsNostrEventRef, content: string, }; export type RadrootsCommentEventIndex = { event: RadrootsNostrEvent, metadata: RadrootsCommentEventMetadata, }; diff --git a/events/src/app_data.rs b/events/src/app_data.rs @@ -0,0 +1,40 @@ +#![forbid(unsafe_code)] + +use crate::RadrootsNostrEvent; +#[cfg(feature = "ts-rs")] +use ts_rs::TS; + +#[cfg(not(feature = "std"))] +use alloc::string::String; + +pub const KIND_APP_DATA: u32 = 30078; + +#[cfg_attr(feature = "ts-rs", derive(TS))] +#[cfg_attr(feature = "ts-rs", ts(export, export_to = "types.ts"))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(Clone, Debug)] +pub struct RadrootsAppDataEventIndex { + pub event: RadrootsNostrEvent, + pub metadata: RadrootsAppDataEventMetadata, +} + +#[cfg_attr(feature = "ts-rs", derive(TS))] +#[cfg_attr(feature = "ts-rs", ts(export, export_to = "types.ts"))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(Clone, Debug)] +pub struct RadrootsAppDataEventMetadata { + pub id: String, + pub author: String, + pub published_at: u32, + pub kind: u32, + pub app_data: RadrootsAppData, +} + +#[cfg_attr(feature = "ts-rs", derive(TS))] +#[cfg_attr(feature = "ts-rs", ts(export, export_to = "types.ts"))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(Clone, Debug)] +pub struct RadrootsAppData { + pub d_tag: String, + pub content: String, +} diff --git a/events/src/lib.rs b/events/src/lib.rs @@ -17,6 +17,7 @@ pub mod job_request; pub mod job_result; pub mod kinds; pub mod listing; +pub mod app_data; pub mod post; pub mod profile; pub mod reaction;