Skip to content

Commit

Permalink
add bindings and ts export macros to stream types
Browse files Browse the repository at this point in the history
  • Loading branch information
drewvolz committed Jan 24, 2025
1 parent 6b2c5b6 commit 6aea945
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
20 changes: 20 additions & 0 deletions ccc-types/bindings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Stream> };

export interface TransitColors {
bar: string;
dot: string;
Expand Down
11 changes: 9 additions & 2 deletions ccc-types/src/streams.rs
Original file line number Diff line number Diff line change
@@ -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<Utc>,
pub location: String,
#[ts(type = "any")]
pub eid: serde_json::Value,
pub performer: String,
pub subtitle: String,
Expand All @@ -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<StreamEntry>,
}

0 comments on commit 6aea945

Please sign in to comment.