@techcake/broadcake-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,350 @@
1
+ interface Station {
2
+ id: string;
3
+ name: string;
4
+ slug: string;
5
+ timezone: string;
6
+ listen_url: string | null;
7
+ }
8
+ interface StationStream {
9
+ name: string;
10
+ url: string;
11
+ format: string | null;
12
+ bitrate: number | null;
13
+ is_default: boolean;
14
+ }
15
+ interface StationSocialLink {
16
+ platform: string;
17
+ url: string;
18
+ }
19
+ interface StationDetail extends Station {
20
+ broadcast_day_start: string;
21
+ streams: StationStream[];
22
+ social_links: StationSocialLink[];
23
+ }
24
+ interface Genre {
25
+ name: string;
26
+ slug: string;
27
+ }
28
+ interface SlotPresenter {
29
+ name: string;
30
+ role: string;
31
+ pronouns: string | null;
32
+ }
33
+ interface ScheduleSlot {
34
+ slot_start: string;
35
+ slot_end: string;
36
+ show_name: string | null;
37
+ show_slug: string | null;
38
+ show_description: string | null;
39
+ show_tagline: string | null;
40
+ is_repeat: boolean;
41
+ repeat_label: string | null;
42
+ source: string;
43
+ override_type: string | null;
44
+ auto_cancel_reason: string | null;
45
+ event_name: string | null;
46
+ event_slug: string | null;
47
+ genres: Genre[];
48
+ presenters: SlotPresenter[];
49
+ schedule_rule_id: string | null;
50
+ override_id: string | null;
51
+ }
52
+ interface WeekScheduleDay {
53
+ date: string;
54
+ slots: ScheduleSlot[];
55
+ error?: string;
56
+ }
57
+ interface WeekSchedule {
58
+ station: string;
59
+ timezone: string;
60
+ from: string;
61
+ to: string;
62
+ days: WeekScheduleDay[];
63
+ }
64
+ interface NowPlaying {
65
+ station: string;
66
+ now: ScheduleSlot | null;
67
+ next: ScheduleSlot | null;
68
+ }
69
+ interface ShowPresenter {
70
+ id: string;
71
+ slug: string;
72
+ display_name: string;
73
+ /** Included in show detail responses only. */
74
+ pronouns?: string | null;
75
+ /** Included in show detail responses only. */
76
+ bio?: string | null;
77
+ /** Included in show detail responses only. */
78
+ avatar_url?: string | null;
79
+ /** Included in show detail responses only. */
80
+ role?: string;
81
+ }
82
+ interface ShowGenre {
83
+ id: string;
84
+ name: string;
85
+ slug: string;
86
+ }
87
+ interface Show {
88
+ id: string;
89
+ name: string;
90
+ slug: string;
91
+ description: string | null;
92
+ is_active: boolean;
93
+ presenters: ShowPresenter[];
94
+ genres: ShowGenre[];
95
+ }
96
+ interface PresenterShow {
97
+ id: string;
98
+ name: string;
99
+ slug: string;
100
+ /** Included in presenter detail responses only. */
101
+ description?: string | null;
102
+ /** Included in presenter detail responses only. */
103
+ is_active?: boolean;
104
+ }
105
+ interface Presenter {
106
+ id: string;
107
+ display_name: string;
108
+ slug: string;
109
+ pronouns: string | null;
110
+ bio: string | null;
111
+ avatar_url: string | null;
112
+ is_active: boolean;
113
+ shows: PresenterShow[];
114
+ }
115
+ interface ArchiveLink {
116
+ id: string;
117
+ url: string;
118
+ label: string;
119
+ link_type: string;
120
+ }
121
+ interface ArchiveShow {
122
+ id: string;
123
+ name: string;
124
+ slug: string;
125
+ }
126
+ interface ArchiveEvent {
127
+ id: string;
128
+ name: string;
129
+ slug: string;
130
+ }
131
+ interface Archive {
132
+ id: string;
133
+ title: string;
134
+ aired_date: string;
135
+ description: string | null;
136
+ cover_url: string | null;
137
+ is_published: boolean;
138
+ archive_links: ArchiveLink[];
139
+ }
140
+ interface StationArchive extends Archive {
141
+ show: ArchiveShow | null;
142
+ event: ArchiveEvent | null;
143
+ }
144
+ interface ArchivePage {
145
+ data: Archive[];
146
+ next_cursor: string | null;
147
+ }
148
+ interface StationArchivePage {
149
+ data: StationArchive[];
150
+ next_cursor: string | null;
151
+ count: number;
152
+ }
153
+ interface EventShow {
154
+ id: string;
155
+ name: string;
156
+ slug: string;
157
+ }
158
+ interface EventSegmentPresenter {
159
+ id: string;
160
+ display_name: string;
161
+ slug: string;
162
+ role: string;
163
+ }
164
+ interface EventSegment {
165
+ id: string;
166
+ show_date: string;
167
+ start_time: string;
168
+ end_time: string;
169
+ display_order: number;
170
+ show: EventShow | null;
171
+ custom_name: string | null;
172
+ presenters: EventSegmentPresenter[];
173
+ }
174
+ interface Event {
175
+ id: string;
176
+ name: string;
177
+ slug: string;
178
+ description: string | null;
179
+ cover_url: string | null;
180
+ start_at: string;
181
+ end_at: string;
182
+ shows: EventShow[];
183
+ }
184
+ interface EventDetail {
185
+ id: string;
186
+ name: string;
187
+ slug: string;
188
+ description: string | null;
189
+ cover_url: string | null;
190
+ start_at: string;
191
+ end_at: string;
192
+ shows: EventSegment[];
193
+ }
194
+ interface ShowScheduleSlot {
195
+ day_of_week: number;
196
+ day_name: string;
197
+ start_time: string;
198
+ end_time: string;
199
+ is_repeat: boolean;
200
+ repeat_label: string | null;
201
+ recurrence_weeks: number;
202
+ effective_from: string;
203
+ effective_until: string | null;
204
+ }
205
+ interface ShowSchedule {
206
+ show: {
207
+ id: string;
208
+ name: string;
209
+ slug: string;
210
+ };
211
+ slots: ShowScheduleSlot[];
212
+ }
213
+ interface TodaySchedule {
214
+ station: string;
215
+ timezone: string;
216
+ date: string;
217
+ slots: ScheduleSlot[];
218
+ }
219
+ interface FormField {
220
+ id: string;
221
+ type: string;
222
+ label: string;
223
+ description?: string;
224
+ placeholder?: string;
225
+ required: boolean;
226
+ options?: string[];
227
+ default_value?: string;
228
+ min?: number;
229
+ max?: number;
230
+ }
231
+ interface FormConnectedData {
232
+ genres?: {
233
+ id: string;
234
+ name: string;
235
+ slug: string;
236
+ }[];
237
+ shows?: {
238
+ id: string;
239
+ name: string;
240
+ slug: string;
241
+ }[];
242
+ presenters?: {
243
+ id: string;
244
+ display_name: string;
245
+ slug: string;
246
+ }[];
247
+ }
248
+ type FormAvailability = 'open' | 'closed' | 'scheduled' | 'full' | 'unpublished';
249
+ /** Form summary returned by the list endpoint (no fields). */
250
+ interface Form {
251
+ id: string;
252
+ name: string;
253
+ slug: string;
254
+ description: string | null;
255
+ success_message: string | null;
256
+ success_redirect_url: string | null;
257
+ closed_message: string | null;
258
+ availability: FormAvailability;
259
+ }
260
+ /** Full form detail returned by the detail endpoint (includes fields + connected data). */
261
+ interface FormDetail extends Form {
262
+ fields: FormField[];
263
+ connected: FormConnectedData;
264
+ }
265
+ interface FormSubmitResult {
266
+ success: boolean;
267
+ error?: string;
268
+ field_errors?: Record<string, string>;
269
+ }
270
+ interface BroadcakeOptions {
271
+ baseUrl?: string;
272
+ }
273
+ interface ScheduleRangeOptions {
274
+ from: string;
275
+ to?: string;
276
+ }
277
+ interface ArchiveListOptions {
278
+ show?: string;
279
+ cursor?: string;
280
+ offset?: number;
281
+ limit?: number;
282
+ }
283
+ interface ShowArchiveListOptions {
284
+ cursor?: string;
285
+ limit?: number;
286
+ }
287
+ interface SubscribeOptions {
288
+ interval?: number;
289
+ }
290
+
291
+ type NowPlayingCallback = (data: NowPlaying) => void;
292
+ type Unsubscribe = () => void;
293
+
294
+ type NowPlayingFn = {
295
+ (): Promise<NowPlaying>;
296
+ subscribe: (callback: NowPlayingCallback, options?: SubscribeOptions) => Unsubscribe;
297
+ };
298
+ declare class Broadcake {
299
+ private readonly stationSlug;
300
+ private readonly baseUrl;
301
+ /** Fetch current now-playing data, or subscribe for polling updates. */
302
+ readonly nowPlaying: NowPlayingFn;
303
+ constructor(stationSlug: string, options?: BroadcakeOptions);
304
+ private request;
305
+ private post;
306
+ private stationPath;
307
+ /** List all stations. */
308
+ stations(): Promise<Station[]>;
309
+ /** Get this station's details. */
310
+ station(): Promise<StationDetail>;
311
+ /** Get the schedule for a single day. */
312
+ schedule(date: string): Promise<ScheduleSlot[]>;
313
+ /** Get the schedule for a date range (defaults to 7 days if `to` is omitted). */
314
+ schedule(range: ScheduleRangeOptions): Promise<WeekSchedule>;
315
+ /** Get today's schedule (auto-resolves date in station timezone). */
316
+ scheduleToday(): Promise<TodaySchedule>;
317
+ /** List all shows. */
318
+ shows(): Promise<Show[]>;
319
+ /** Get a show by slug. */
320
+ show(showSlug: string): Promise<Show>;
321
+ /** Get a show's recurring schedule slots (when it airs). */
322
+ showSchedule(showSlug: string): Promise<ShowSchedule>;
323
+ /** List all presenters. */
324
+ presenters(): Promise<Presenter[]>;
325
+ /** Get a presenter by slug. */
326
+ presenter(presenterSlug: string): Promise<Presenter>;
327
+ /** List station-wide archives (paginated). */
328
+ archives(options?: ArchiveListOptions): Promise<StationArchivePage>;
329
+ /** List archives for a specific show (cursor-paginated). */
330
+ showArchives(showSlug: string, options?: ShowArchiveListOptions): Promise<ArchivePage>;
331
+ /** List upcoming events. */
332
+ events(): Promise<Event[]>;
333
+ /** Get an event by slug (includes segments and presenters). */
334
+ event(eventSlug: string): Promise<EventDetail>;
335
+ /** List all published forms. */
336
+ forms(): Promise<Form[]>;
337
+ /** Get a form by slug (includes connected data for genre/show/presenter fields). */
338
+ form(formSlug: string): Promise<FormDetail>;
339
+ /** Submit data to a form. */
340
+ submitForm(formSlug: string, data: Record<string, unknown>): Promise<FormSubmitResult>;
341
+ }
342
+
343
+ declare class BroadcakeError extends Error {
344
+ readonly status: number;
345
+ readonly endpoint: string;
346
+ readonly body: unknown;
347
+ constructor(status: number, message: string, endpoint: string, body?: unknown);
348
+ }
349
+
350
+ export { type Archive, type ArchiveEvent, type ArchiveLink, type ArchiveListOptions, type ArchivePage, type ArchiveShow, Broadcake, BroadcakeError, type BroadcakeOptions, type Event, type EventDetail, type EventSegment, type EventSegmentPresenter, type EventShow, type Form, type FormAvailability, type FormConnectedData, type FormDetail, type FormField, type FormSubmitResult, type Genre, type NowPlaying, type NowPlayingCallback, type Presenter, type PresenterShow, type ScheduleRangeOptions, type ScheduleSlot, type Show, type ShowArchiveListOptions, type ShowGenre, type ShowPresenter, type ShowSchedule, type ShowScheduleSlot, type SlotPresenter, type Station, type StationArchive, type StationArchivePage, type StationDetail, type StationSocialLink, type StationStream, type SubscribeOptions, type TodaySchedule, type Unsubscribe, type WeekSchedule, type WeekScheduleDay };
@@ -0,0 +1,350 @@
1
+ interface Station {
2
+ id: string;
3
+ name: string;
4
+ slug: string;
5
+ timezone: string;
6
+ listen_url: string | null;
7
+ }
8
+ interface StationStream {
9
+ name: string;
10
+ url: string;
11
+ format: string | null;
12
+ bitrate: number | null;
13
+ is_default: boolean;
14
+ }
15
+ interface StationSocialLink {
16
+ platform: string;
17
+ url: string;
18
+ }
19
+ interface StationDetail extends Station {
20
+ broadcast_day_start: string;
21
+ streams: StationStream[];
22
+ social_links: StationSocialLink[];
23
+ }
24
+ interface Genre {
25
+ name: string;
26
+ slug: string;
27
+ }
28
+ interface SlotPresenter {
29
+ name: string;
30
+ role: string;
31
+ pronouns: string | null;
32
+ }
33
+ interface ScheduleSlot {
34
+ slot_start: string;
35
+ slot_end: string;
36
+ show_name: string | null;
37
+ show_slug: string | null;
38
+ show_description: string | null;
39
+ show_tagline: string | null;
40
+ is_repeat: boolean;
41
+ repeat_label: string | null;
42
+ source: string;
43
+ override_type: string | null;
44
+ auto_cancel_reason: string | null;
45
+ event_name: string | null;
46
+ event_slug: string | null;
47
+ genres: Genre[];
48
+ presenters: SlotPresenter[];
49
+ schedule_rule_id: string | null;
50
+ override_id: string | null;
51
+ }
52
+ interface WeekScheduleDay {
53
+ date: string;
54
+ slots: ScheduleSlot[];
55
+ error?: string;
56
+ }
57
+ interface WeekSchedule {
58
+ station: string;
59
+ timezone: string;
60
+ from: string;
61
+ to: string;
62
+ days: WeekScheduleDay[];
63
+ }
64
+ interface NowPlaying {
65
+ station: string;
66
+ now: ScheduleSlot | null;
67
+ next: ScheduleSlot | null;
68
+ }
69
+ interface ShowPresenter {
70
+ id: string;
71
+ slug: string;
72
+ display_name: string;
73
+ /** Included in show detail responses only. */
74
+ pronouns?: string | null;
75
+ /** Included in show detail responses only. */
76
+ bio?: string | null;
77
+ /** Included in show detail responses only. */
78
+ avatar_url?: string | null;
79
+ /** Included in show detail responses only. */
80
+ role?: string;
81
+ }
82
+ interface ShowGenre {
83
+ id: string;
84
+ name: string;
85
+ slug: string;
86
+ }
87
+ interface Show {
88
+ id: string;
89
+ name: string;
90
+ slug: string;
91
+ description: string | null;
92
+ is_active: boolean;
93
+ presenters: ShowPresenter[];
94
+ genres: ShowGenre[];
95
+ }
96
+ interface PresenterShow {
97
+ id: string;
98
+ name: string;
99
+ slug: string;
100
+ /** Included in presenter detail responses only. */
101
+ description?: string | null;
102
+ /** Included in presenter detail responses only. */
103
+ is_active?: boolean;
104
+ }
105
+ interface Presenter {
106
+ id: string;
107
+ display_name: string;
108
+ slug: string;
109
+ pronouns: string | null;
110
+ bio: string | null;
111
+ avatar_url: string | null;
112
+ is_active: boolean;
113
+ shows: PresenterShow[];
114
+ }
115
+ interface ArchiveLink {
116
+ id: string;
117
+ url: string;
118
+ label: string;
119
+ link_type: string;
120
+ }
121
+ interface ArchiveShow {
122
+ id: string;
123
+ name: string;
124
+ slug: string;
125
+ }
126
+ interface ArchiveEvent {
127
+ id: string;
128
+ name: string;
129
+ slug: string;
130
+ }
131
+ interface Archive {
132
+ id: string;
133
+ title: string;
134
+ aired_date: string;
135
+ description: string | null;
136
+ cover_url: string | null;
137
+ is_published: boolean;
138
+ archive_links: ArchiveLink[];
139
+ }
140
+ interface StationArchive extends Archive {
141
+ show: ArchiveShow | null;
142
+ event: ArchiveEvent | null;
143
+ }
144
+ interface ArchivePage {
145
+ data: Archive[];
146
+ next_cursor: string | null;
147
+ }
148
+ interface StationArchivePage {
149
+ data: StationArchive[];
150
+ next_cursor: string | null;
151
+ count: number;
152
+ }
153
+ interface EventShow {
154
+ id: string;
155
+ name: string;
156
+ slug: string;
157
+ }
158
+ interface EventSegmentPresenter {
159
+ id: string;
160
+ display_name: string;
161
+ slug: string;
162
+ role: string;
163
+ }
164
+ interface EventSegment {
165
+ id: string;
166
+ show_date: string;
167
+ start_time: string;
168
+ end_time: string;
169
+ display_order: number;
170
+ show: EventShow | null;
171
+ custom_name: string | null;
172
+ presenters: EventSegmentPresenter[];
173
+ }
174
+ interface Event {
175
+ id: string;
176
+ name: string;
177
+ slug: string;
178
+ description: string | null;
179
+ cover_url: string | null;
180
+ start_at: string;
181
+ end_at: string;
182
+ shows: EventShow[];
183
+ }
184
+ interface EventDetail {
185
+ id: string;
186
+ name: string;
187
+ slug: string;
188
+ description: string | null;
189
+ cover_url: string | null;
190
+ start_at: string;
191
+ end_at: string;
192
+ shows: EventSegment[];
193
+ }
194
+ interface ShowScheduleSlot {
195
+ day_of_week: number;
196
+ day_name: string;
197
+ start_time: string;
198
+ end_time: string;
199
+ is_repeat: boolean;
200
+ repeat_label: string | null;
201
+ recurrence_weeks: number;
202
+ effective_from: string;
203
+ effective_until: string | null;
204
+ }
205
+ interface ShowSchedule {
206
+ show: {
207
+ id: string;
208
+ name: string;
209
+ slug: string;
210
+ };
211
+ slots: ShowScheduleSlot[];
212
+ }
213
+ interface TodaySchedule {
214
+ station: string;
215
+ timezone: string;
216
+ date: string;
217
+ slots: ScheduleSlot[];
218
+ }
219
+ interface FormField {
220
+ id: string;
221
+ type: string;
222
+ label: string;
223
+ description?: string;
224
+ placeholder?: string;
225
+ required: boolean;
226
+ options?: string[];
227
+ default_value?: string;
228
+ min?: number;
229
+ max?: number;
230
+ }
231
+ interface FormConnectedData {
232
+ genres?: {
233
+ id: string;
234
+ name: string;
235
+ slug: string;
236
+ }[];
237
+ shows?: {
238
+ id: string;
239
+ name: string;
240
+ slug: string;
241
+ }[];
242
+ presenters?: {
243
+ id: string;
244
+ display_name: string;
245
+ slug: string;
246
+ }[];
247
+ }
248
+ type FormAvailability = 'open' | 'closed' | 'scheduled' | 'full' | 'unpublished';
249
+ /** Form summary returned by the list endpoint (no fields). */
250
+ interface Form {
251
+ id: string;
252
+ name: string;
253
+ slug: string;
254
+ description: string | null;
255
+ success_message: string | null;
256
+ success_redirect_url: string | null;
257
+ closed_message: string | null;
258
+ availability: FormAvailability;
259
+ }
260
+ /** Full form detail returned by the detail endpoint (includes fields + connected data). */
261
+ interface FormDetail extends Form {
262
+ fields: FormField[];
263
+ connected: FormConnectedData;
264
+ }
265
+ interface FormSubmitResult {
266
+ success: boolean;
267
+ error?: string;
268
+ field_errors?: Record<string, string>;
269
+ }
270
+ interface BroadcakeOptions {
271
+ baseUrl?: string;
272
+ }
273
+ interface ScheduleRangeOptions {
274
+ from: string;
275
+ to?: string;
276
+ }
277
+ interface ArchiveListOptions {
278
+ show?: string;
279
+ cursor?: string;
280
+ offset?: number;
281
+ limit?: number;
282
+ }
283
+ interface ShowArchiveListOptions {
284
+ cursor?: string;
285
+ limit?: number;
286
+ }
287
+ interface SubscribeOptions {
288
+ interval?: number;
289
+ }
290
+
291
+ type NowPlayingCallback = (data: NowPlaying) => void;
292
+ type Unsubscribe = () => void;
293
+
294
+ type NowPlayingFn = {
295
+ (): Promise<NowPlaying>;
296
+ subscribe: (callback: NowPlayingCallback, options?: SubscribeOptions) => Unsubscribe;
297
+ };
298
+ declare class Broadcake {
299
+ private readonly stationSlug;
300
+ private readonly baseUrl;
301
+ /** Fetch current now-playing data, or subscribe for polling updates. */
302
+ readonly nowPlaying: NowPlayingFn;
303
+ constructor(stationSlug: string, options?: BroadcakeOptions);
304
+ private request;
305
+ private post;
306
+ private stationPath;
307
+ /** List all stations. */
308
+ stations(): Promise<Station[]>;
309
+ /** Get this station's details. */
310
+ station(): Promise<StationDetail>;
311
+ /** Get the schedule for a single day. */
312
+ schedule(date: string): Promise<ScheduleSlot[]>;
313
+ /** Get the schedule for a date range (defaults to 7 days if `to` is omitted). */
314
+ schedule(range: ScheduleRangeOptions): Promise<WeekSchedule>;
315
+ /** Get today's schedule (auto-resolves date in station timezone). */
316
+ scheduleToday(): Promise<TodaySchedule>;
317
+ /** List all shows. */
318
+ shows(): Promise<Show[]>;
319
+ /** Get a show by slug. */
320
+ show(showSlug: string): Promise<Show>;
321
+ /** Get a show's recurring schedule slots (when it airs). */
322
+ showSchedule(showSlug: string): Promise<ShowSchedule>;
323
+ /** List all presenters. */
324
+ presenters(): Promise<Presenter[]>;
325
+ /** Get a presenter by slug. */
326
+ presenter(presenterSlug: string): Promise<Presenter>;
327
+ /** List station-wide archives (paginated). */
328
+ archives(options?: ArchiveListOptions): Promise<StationArchivePage>;
329
+ /** List archives for a specific show (cursor-paginated). */
330
+ showArchives(showSlug: string, options?: ShowArchiveListOptions): Promise<ArchivePage>;
331
+ /** List upcoming events. */
332
+ events(): Promise<Event[]>;
333
+ /** Get an event by slug (includes segments and presenters). */
334
+ event(eventSlug: string): Promise<EventDetail>;
335
+ /** List all published forms. */
336
+ forms(): Promise<Form[]>;
337
+ /** Get a form by slug (includes connected data for genre/show/presenter fields). */
338
+ form(formSlug: string): Promise<FormDetail>;
339
+ /** Submit data to a form. */
340
+ submitForm(formSlug: string, data: Record<string, unknown>): Promise<FormSubmitResult>;
341
+ }
342
+
343
+ declare class BroadcakeError extends Error {
344
+ readonly status: number;
345
+ readonly endpoint: string;
346
+ readonly body: unknown;
347
+ constructor(status: number, message: string, endpoint: string, body?: unknown);
348
+ }
349
+
350
+ export { type Archive, type ArchiveEvent, type ArchiveLink, type ArchiveListOptions, type ArchivePage, type ArchiveShow, Broadcake, BroadcakeError, type BroadcakeOptions, type Event, type EventDetail, type EventSegment, type EventSegmentPresenter, type EventShow, type Form, type FormAvailability, type FormConnectedData, type FormDetail, type FormField, type FormSubmitResult, type Genre, type NowPlaying, type NowPlayingCallback, type Presenter, type PresenterShow, type ScheduleRangeOptions, type ScheduleSlot, type Show, type ShowArchiveListOptions, type ShowGenre, type ShowPresenter, type ShowSchedule, type ShowScheduleSlot, type SlotPresenter, type Station, type StationArchive, type StationArchivePage, type StationDetail, type StationSocialLink, type StationStream, type SubscribeOptions, type TodaySchedule, type Unsubscribe, type WeekSchedule, type WeekScheduleDay };