From 6aea9456fb00c0b722432171378aa0d536d595cc Mon Sep 17 00:00:00 2001 From: Drew Volz Date: Fri, 24 Jan 2025 00:47:57 -0800 Subject: [PATCH] add bindings and ts export macros to stream types --- ccc-types/bindings/index.d.ts | 20 ++++++++++++++++++++ ccc-types/src/streams.rs | 11 +++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/ccc-types/bindings/index.d.ts b/ccc-types/bindings/index.d.ts index 3f60048..6974fe3 100644 --- a/ccc-types/bindings/index.d.ts +++ b/ccc-types/bindings/index.d.ts @@ -249,6 +249,26 @@ export interface Schedule { isPhysicallyOpen: boolean | null; } +export type Stream = { + starttime: string; + location: string; + eid: any; + performer: string; + subtitle: string; + poster: string; + player: string; + status: string; + category: string; + hptitle: string; + categoryTextcolor: string; + categoryColor: string; + thumb: string; + title: string; + iframesrc: string; +}; + +export type StreamResponse = { results: Array }; + export interface TransitColors { bar: string; dot: string; diff --git a/ccc-types/src/streams.rs b/ccc-types/src/streams.rs index 658ebda..9bacefa 100644 --- a/ccc-types/src/streams.rs +++ b/ccc-types/src/streams.rs @@ -1,11 +1,16 @@ use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; +use ts_rs::TS; -#[derive(Debug, Serialize, Deserialize)] +#[derive(Serialize, Deserialize, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export, rename = "Stream")] pub struct StreamEntry { + #[ts(type = "string")] pub starttime: DateTime, pub location: String, + #[ts(type = "any")] pub eid: serde_json::Value, pub performer: String, pub subtitle: String, @@ -21,7 +26,9 @@ pub struct StreamEntry { pub iframesrc: String, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Serialize, Deserialize, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export)] pub struct StreamResponse { pub results: Vec, }