@syra.fm/sdk 0.4.0 → 0.5.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.
- package/lib/commonjs/client.js +268 -0
- package/lib/commonjs/client.js.map +1 -0
- package/lib/commonjs/errors.js +22 -0
- package/lib/commonjs/errors.js.map +1 -0
- package/lib/commonjs/index.js +63 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/index.native.js +28 -0
- package/lib/commonjs/index.native.js.map +1 -0
- package/lib/commonjs/live/assets/icons/spaces-icon.js +42 -0
- package/lib/commonjs/live/assets/icons/spaces-icon.js.map +1 -0
- package/lib/commonjs/live/assets/icons/syra-icon.js +43 -0
- package/lib/commonjs/live/assets/icons/syra-icon.js.map +1 -0
- package/lib/commonjs/live/components/AnimatedPulse.js +38 -0
- package/lib/commonjs/live/components/AnimatedPulse.js.map +1 -0
- package/lib/commonjs/live/components/AnimatedSpeakerRing.js +90 -0
- package/lib/commonjs/live/components/AnimatedSpeakerRing.js.map +1 -0
- package/lib/commonjs/live/components/CreateRoomSheet.js +688 -0
- package/lib/commonjs/live/components/CreateRoomSheet.js.map +1 -0
- package/lib/commonjs/live/components/InsightsPanel.js +333 -0
- package/lib/commonjs/live/components/InsightsPanel.js.map +1 -0
- package/lib/commonjs/live/components/LiveRoomSheet.js +1195 -0
- package/lib/commonjs/live/components/LiveRoomSheet.js.map +1 -0
- package/lib/commonjs/live/components/MiniRoomBar.js +161 -0
- package/lib/commonjs/live/components/MiniRoomBar.js.map +1 -0
- package/lib/commonjs/live/components/PanelHeader.js +57 -0
- package/lib/commonjs/live/components/PanelHeader.js.map +1 -0
- package/lib/commonjs/live/components/PodcastStreamPicker.js +1190 -0
- package/lib/commonjs/live/components/PodcastStreamPicker.js.map +1 -0
- package/lib/commonjs/live/components/RecordingCard.js +192 -0
- package/lib/commonjs/live/components/RecordingCard.js.map +1 -0
- package/lib/commonjs/live/components/RecordingsPanel.js +304 -0
- package/lib/commonjs/live/components/RecordingsPanel.js.map +1 -0
- package/lib/commonjs/live/components/RoomCard.js +553 -0
- package/lib/commonjs/live/components/RoomCard.js.map +1 -0
- package/lib/commonjs/live/components/StreamConfigModal.js +656 -0
- package/lib/commonjs/live/components/StreamConfigModal.js.map +1 -0
- package/lib/commonjs/live/components/StreamConfigPanel.js +822 -0
- package/lib/commonjs/live/components/StreamConfigPanel.js.map +1 -0
- package/lib/commonjs/live/context/LiveConfigContext.js +46 -0
- package/lib/commonjs/live/context/LiveConfigContext.js.map +1 -0
- package/lib/commonjs/live/context/LiveRoomContext.js +195 -0
- package/lib/commonjs/live/context/LiveRoomContext.js.map +1 -0
- package/lib/commonjs/live/hooks/useActiveSpeakers.js +35 -0
- package/lib/commonjs/live/hooks/useActiveSpeakers.js.map +1 -0
- package/lib/commonjs/live/hooks/useRoomAudio.js +129 -0
- package/lib/commonjs/live/hooks/useRoomAudio.js.map +1 -0
- package/lib/commonjs/live/hooks/useRoomConnection.js +177 -0
- package/lib/commonjs/live/hooks/useRoomConnection.js.map +1 -0
- package/lib/commonjs/live/hooks/useRoomManager.js +37 -0
- package/lib/commonjs/live/hooks/useRoomManager.js.map +1 -0
- package/lib/commonjs/live/hooks/useRoomUsers.js +52 -0
- package/lib/commonjs/live/hooks/useRoomUsers.js.map +1 -0
- package/lib/commonjs/live/index.js +310 -0
- package/lib/commonjs/live/index.js.map +1 -0
- package/lib/commonjs/live/services/livekitService.js +20 -0
- package/lib/commonjs/live/services/livekitService.js.map +1 -0
- package/lib/commonjs/live/services/spaceSocketService.js +181 -0
- package/lib/commonjs/live/services/spaceSocketService.js.map +1 -0
- package/lib/commonjs/live/services/spacesService.js +642 -0
- package/lib/commonjs/live/services/spacesService.js.map +1 -0
- package/lib/commonjs/live/types.js +6 -0
- package/lib/commonjs/live/types.js.map +1 -0
- package/lib/commonjs/live/validation.js +238 -0
- package/lib/commonjs/live/validation.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/{dist/cjs → lib/commonjs}/schema.js +55 -47
- package/lib/commonjs/schema.js.map +1 -0
- package/lib/module/client.js +264 -0
- package/lib/module/client.js.map +1 -0
- package/lib/module/errors.js +17 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/index.native.js +5 -0
- package/lib/module/index.native.js.map +1 -0
- package/lib/module/live/assets/icons/spaces-icon.js +34 -0
- package/lib/module/live/assets/icons/spaces-icon.js.map +1 -0
- package/lib/module/live/assets/icons/syra-icon.js +36 -0
- package/lib/module/live/assets/icons/syra-icon.js.map +1 -0
- package/lib/module/live/components/AnimatedPulse.js +33 -0
- package/lib/module/live/components/AnimatedPulse.js.map +1 -0
- package/lib/module/live/components/AnimatedSpeakerRing.js +85 -0
- package/lib/module/live/components/AnimatedSpeakerRing.js.map +1 -0
- package/lib/module/live/components/CreateRoomSheet.js +682 -0
- package/lib/module/live/components/CreateRoomSheet.js.map +1 -0
- package/lib/module/live/components/InsightsPanel.js +327 -0
- package/lib/module/live/components/InsightsPanel.js.map +1 -0
- package/lib/module/live/components/LiveRoomSheet.js +1189 -0
- package/lib/module/live/components/LiveRoomSheet.js.map +1 -0
- package/lib/module/live/components/MiniRoomBar.js +154 -0
- package/lib/module/live/components/MiniRoomBar.js.map +1 -0
- package/lib/module/live/components/PanelHeader.js +52 -0
- package/lib/module/live/components/PanelHeader.js.map +1 -0
- package/lib/module/live/components/PodcastStreamPicker.js +1183 -0
- package/lib/module/live/components/PodcastStreamPicker.js.map +1 -0
- package/lib/module/live/components/RecordingCard.js +187 -0
- package/lib/module/live/components/RecordingCard.js.map +1 -0
- package/lib/module/live/components/RecordingsPanel.js +298 -0
- package/lib/module/live/components/RecordingsPanel.js.map +1 -0
- package/lib/module/live/components/RoomCard.js +548 -0
- package/lib/module/live/components/RoomCard.js.map +1 -0
- package/lib/module/live/components/StreamConfigModal.js +650 -0
- package/lib/module/live/components/StreamConfigModal.js.map +1 -0
- package/lib/module/live/components/StreamConfigPanel.js +816 -0
- package/lib/module/live/components/StreamConfigPanel.js.map +1 -0
- package/lib/module/live/context/LiveConfigContext.js +40 -0
- package/lib/module/live/context/LiveConfigContext.js.map +1 -0
- package/lib/module/live/context/LiveRoomContext.js +189 -0
- package/lib/module/live/context/LiveRoomContext.js.map +1 -0
- package/lib/module/live/hooks/useActiveSpeakers.js +31 -0
- package/lib/module/live/hooks/useActiveSpeakers.js.map +1 -0
- package/lib/module/live/hooks/useRoomAudio.js +125 -0
- package/lib/module/live/hooks/useRoomAudio.js.map +1 -0
- package/lib/module/live/hooks/useRoomConnection.js +173 -0
- package/lib/module/live/hooks/useRoomConnection.js.map +1 -0
- package/lib/module/live/hooks/useRoomManager.js +32 -0
- package/lib/module/live/hooks/useRoomManager.js.map +1 -0
- package/lib/module/live/hooks/useRoomUsers.js +46 -0
- package/lib/module/live/hooks/useRoomUsers.js.map +1 -0
- package/lib/module/live/index.js +38 -0
- package/lib/module/live/index.js.map +1 -0
- package/lib/module/live/services/livekitService.js +16 -0
- package/lib/module/live/services/livekitService.js.map +1 -0
- package/lib/module/live/services/spaceSocketService.js +176 -0
- package/lib/module/live/services/spaceSocketService.js.map +1 -0
- package/lib/module/live/services/spacesService.js +639 -0
- package/lib/module/live/services/spacesService.js.map +1 -0
- package/lib/module/live/types.js +4 -0
- package/lib/module/live/types.js.map +1 -0
- package/lib/module/live/validation.js +229 -0
- package/lib/module/live/validation.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/{dist/esm → lib/module}/schema.js +47 -39
- package/lib/module/schema.js.map +1 -0
- package/{dist/types → lib/typescript/commonjs}/client.d.ts +1 -0
- package/lib/typescript/commonjs/client.d.ts.map +1 -0
- package/{dist/types → lib/typescript/commonjs}/errors.d.ts +1 -0
- package/lib/typescript/commonjs/errors.d.ts.map +1 -0
- package/{dist/types → lib/typescript/commonjs}/index.d.ts +1 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.native.d.ts +3 -0
- package/lib/typescript/commonjs/index.native.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/assets/icons/spaces-icon.d.ts +13 -0
- package/lib/typescript/commonjs/live/assets/icons/spaces-icon.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/assets/icons/syra-icon.d.ts +13 -0
- package/lib/typescript/commonjs/live/assets/icons/syra-icon.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/components/AnimatedPulse.d.ts +8 -0
- package/lib/typescript/commonjs/live/components/AnimatedPulse.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/components/AnimatedSpeakerRing.d.ts +10 -0
- package/lib/typescript/commonjs/live/components/AnimatedSpeakerRing.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/components/CreateRoomSheet.d.ts +26 -0
- package/lib/typescript/commonjs/live/components/CreateRoomSheet.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/components/InsightsPanel.d.ts +11 -0
- package/lib/typescript/commonjs/live/components/InsightsPanel.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/components/LiveRoomSheet.d.ts +11 -0
- package/lib/typescript/commonjs/live/components/LiveRoomSheet.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/components/MiniRoomBar.d.ts +15 -0
- package/lib/typescript/commonjs/live/components/MiniRoomBar.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/components/PanelHeader.d.ts +10 -0
- package/lib/typescript/commonjs/live/components/PanelHeader.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/components/PodcastStreamPicker.d.ts +54 -0
- package/lib/typescript/commonjs/live/components/PodcastStreamPicker.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/components/RecordingCard.d.ts +11 -0
- package/lib/typescript/commonjs/live/components/RecordingCard.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/components/RecordingsPanel.d.ts +12 -0
- package/lib/typescript/commonjs/live/components/RecordingsPanel.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/components/RoomCard.d.ts +38 -0
- package/lib/typescript/commonjs/live/components/RoomCard.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/components/StreamConfigModal.d.ts +11 -0
- package/lib/typescript/commonjs/live/components/StreamConfigModal.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/components/StreamConfigPanel.d.ts +13 -0
- package/lib/typescript/commonjs/live/components/StreamConfigPanel.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/context/LiveConfigContext.d.ts +78 -0
- package/lib/typescript/commonjs/live/context/LiveConfigContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/context/LiveRoomContext.d.ts +12 -0
- package/lib/typescript/commonjs/live/context/LiveRoomContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/hooks/useActiveSpeakers.d.ts +3 -0
- package/lib/typescript/commonjs/live/hooks/useActiveSpeakers.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/hooks/useRoomAudio.d.ts +16 -0
- package/lib/typescript/commonjs/live/hooks/useRoomAudio.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/hooks/useRoomConnection.d.ts +29 -0
- package/lib/typescript/commonjs/live/hooks/useRoomConnection.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/hooks/useRoomManager.d.ts +11 -0
- package/lib/typescript/commonjs/live/hooks/useRoomManager.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/hooks/useRoomUsers.d.ts +5 -0
- package/lib/typescript/commonjs/live/hooks/useRoomUsers.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/index.d.ts +24 -0
- package/lib/typescript/commonjs/live/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/services/livekitService.d.ts +7 -0
- package/lib/typescript/commonjs/live/services/livekitService.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/services/spaceSocketService.d.ts +69 -0
- package/lib/typescript/commonjs/live/services/spaceSocketService.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/services/spacesService.d.ts +181 -0
- package/lib/typescript/commonjs/live/services/spacesService.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/types.d.ts +100 -0
- package/lib/typescript/commonjs/live/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/live/validation.d.ts +658 -0
- package/lib/typescript/commonjs/live/validation.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/{dist/types → lib/typescript/commonjs}/schema.d.ts +1 -0
- package/lib/typescript/commonjs/schema.d.ts.map +1 -0
- package/lib/typescript/module/client.d.ts +141 -0
- package/lib/typescript/module/client.d.ts.map +1 -0
- package/lib/typescript/module/errors.d.ts +9 -0
- package/lib/typescript/module/errors.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +6 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/index.native.d.ts +3 -0
- package/lib/typescript/module/index.native.d.ts.map +1 -0
- package/lib/typescript/module/live/assets/icons/spaces-icon.d.ts +13 -0
- package/lib/typescript/module/live/assets/icons/spaces-icon.d.ts.map +1 -0
- package/lib/typescript/module/live/assets/icons/syra-icon.d.ts +13 -0
- package/lib/typescript/module/live/assets/icons/syra-icon.d.ts.map +1 -0
- package/lib/typescript/module/live/components/AnimatedPulse.d.ts +8 -0
- package/lib/typescript/module/live/components/AnimatedPulse.d.ts.map +1 -0
- package/lib/typescript/module/live/components/AnimatedSpeakerRing.d.ts +10 -0
- package/lib/typescript/module/live/components/AnimatedSpeakerRing.d.ts.map +1 -0
- package/lib/typescript/module/live/components/CreateRoomSheet.d.ts +26 -0
- package/lib/typescript/module/live/components/CreateRoomSheet.d.ts.map +1 -0
- package/lib/typescript/module/live/components/InsightsPanel.d.ts +11 -0
- package/lib/typescript/module/live/components/InsightsPanel.d.ts.map +1 -0
- package/lib/typescript/module/live/components/LiveRoomSheet.d.ts +11 -0
- package/lib/typescript/module/live/components/LiveRoomSheet.d.ts.map +1 -0
- package/lib/typescript/module/live/components/MiniRoomBar.d.ts +15 -0
- package/lib/typescript/module/live/components/MiniRoomBar.d.ts.map +1 -0
- package/lib/typescript/module/live/components/PanelHeader.d.ts +10 -0
- package/lib/typescript/module/live/components/PanelHeader.d.ts.map +1 -0
- package/lib/typescript/module/live/components/PodcastStreamPicker.d.ts +54 -0
- package/lib/typescript/module/live/components/PodcastStreamPicker.d.ts.map +1 -0
- package/lib/typescript/module/live/components/RecordingCard.d.ts +11 -0
- package/lib/typescript/module/live/components/RecordingCard.d.ts.map +1 -0
- package/lib/typescript/module/live/components/RecordingsPanel.d.ts +12 -0
- package/lib/typescript/module/live/components/RecordingsPanel.d.ts.map +1 -0
- package/lib/typescript/module/live/components/RoomCard.d.ts +38 -0
- package/lib/typescript/module/live/components/RoomCard.d.ts.map +1 -0
- package/lib/typescript/module/live/components/StreamConfigModal.d.ts +11 -0
- package/lib/typescript/module/live/components/StreamConfigModal.d.ts.map +1 -0
- package/lib/typescript/module/live/components/StreamConfigPanel.d.ts +13 -0
- package/lib/typescript/module/live/components/StreamConfigPanel.d.ts.map +1 -0
- package/lib/typescript/module/live/context/LiveConfigContext.d.ts +78 -0
- package/lib/typescript/module/live/context/LiveConfigContext.d.ts.map +1 -0
- package/lib/typescript/module/live/context/LiveRoomContext.d.ts +12 -0
- package/lib/typescript/module/live/context/LiveRoomContext.d.ts.map +1 -0
- package/lib/typescript/module/live/hooks/useActiveSpeakers.d.ts +3 -0
- package/lib/typescript/module/live/hooks/useActiveSpeakers.d.ts.map +1 -0
- package/lib/typescript/module/live/hooks/useRoomAudio.d.ts +16 -0
- package/lib/typescript/module/live/hooks/useRoomAudio.d.ts.map +1 -0
- package/lib/typescript/module/live/hooks/useRoomConnection.d.ts +29 -0
- package/lib/typescript/module/live/hooks/useRoomConnection.d.ts.map +1 -0
- package/lib/typescript/module/live/hooks/useRoomManager.d.ts +11 -0
- package/lib/typescript/module/live/hooks/useRoomManager.d.ts.map +1 -0
- package/lib/typescript/module/live/hooks/useRoomUsers.d.ts +5 -0
- package/lib/typescript/module/live/hooks/useRoomUsers.d.ts.map +1 -0
- package/lib/typescript/module/live/index.d.ts +24 -0
- package/lib/typescript/module/live/index.d.ts.map +1 -0
- package/lib/typescript/module/live/services/livekitService.d.ts +7 -0
- package/lib/typescript/module/live/services/livekitService.d.ts.map +1 -0
- package/lib/typescript/module/live/services/spaceSocketService.d.ts +69 -0
- package/lib/typescript/module/live/services/spaceSocketService.d.ts.map +1 -0
- package/lib/typescript/module/live/services/spacesService.d.ts +181 -0
- package/lib/typescript/module/live/services/spacesService.d.ts.map +1 -0
- package/lib/typescript/module/live/types.d.ts +100 -0
- package/lib/typescript/module/live/types.d.ts.map +1 -0
- package/lib/typescript/module/live/validation.d.ts +658 -0
- package/lib/typescript/module/live/validation.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/schema.d.ts +1072 -0
- package/lib/typescript/module/schema.d.ts.map +1 -0
- package/package.json +133 -21
- package/src/index.native.ts +2 -0
- package/src/live/assets/icons/spaces-icon.tsx +15 -0
- package/src/live/assets/icons/syra-icon.tsx +13 -0
- package/src/live/assets/sounds/intro.mp3 +0 -0
- package/src/live/components/AnimatedPulse.tsx +52 -0
- package/src/live/components/AnimatedSpeakerRing.tsx +101 -0
- package/src/live/components/CreateRoomSheet.tsx +654 -0
- package/src/live/components/InsightsPanel.tsx +202 -0
- package/src/live/components/LiveRoomSheet.tsx +969 -0
- package/src/live/components/MiniRoomBar.tsx +166 -0
- package/src/live/components/PanelHeader.tsx +36 -0
- package/src/live/components/PodcastStreamPicker.tsx +1155 -0
- package/src/live/components/RecordingCard.tsx +154 -0
- package/src/live/components/RecordingsPanel.tsx +251 -0
- package/src/live/components/RoomCard.tsx +494 -0
- package/src/live/components/StreamConfigModal.tsx +600 -0
- package/src/live/components/StreamConfigPanel.tsx +729 -0
- package/src/live/context/LiveConfigContext.tsx +96 -0
- package/src/live/context/LiveRoomContext.tsx +235 -0
- package/src/live/hooks/useActiveSpeakers.ts +39 -0
- package/src/live/hooks/useRoomAudio.ts +103 -0
- package/src/live/hooks/useRoomConnection.ts +162 -0
- package/src/live/hooks/useRoomManager.ts +17 -0
- package/src/live/hooks/useRoomUsers.ts +52 -0
- package/src/live/index.ts +92 -0
- package/src/live/services/livekitService.ts +11 -0
- package/src/live/services/spaceSocketService.ts +136 -0
- package/src/live/services/spacesService.ts +692 -0
- package/src/live/types.ts +119 -0
- package/src/live/validation.ts +279 -0
- package/dist/cjs/client.js +0 -244
- package/dist/cjs/errors.js +0 -16
- package/dist/cjs/index.js +0 -15
- package/dist/cjs/package.json +0 -3
- package/dist/esm/client.js +0 -240
- package/dist/esm/errors.js +0 -12
- package/dist/esm/index.js +0 -3
- package/dist/esm/package.json +0 -3
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { RoomParticipant } from './validation';
|
|
2
|
+
|
|
3
|
+
export type {
|
|
4
|
+
Room,
|
|
5
|
+
RoomParticipant,
|
|
6
|
+
Recording,
|
|
7
|
+
House,
|
|
8
|
+
HouseMember,
|
|
9
|
+
Series,
|
|
10
|
+
SeriesEpisode,
|
|
11
|
+
Recurrence,
|
|
12
|
+
RoomTemplate,
|
|
13
|
+
RoomAttachment,
|
|
14
|
+
} from './validation';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The "now playing" stream surfaced in the live room. Derived from the
|
|
18
|
+
* `room:stream:started` socket payload (and the room's persisted stream fields);
|
|
19
|
+
* it is NOT parsed through zod, so it stays a plain structural type rather than
|
|
20
|
+
* `z.infer<typeof ZStreamInfo>`. `startedAt` / `durationSec` are present for
|
|
21
|
+
* length-known streams (e.g. a podcast episode) and drive the progress bar;
|
|
22
|
+
* manual URL/RTMP streams omit them and render no progress UI.
|
|
23
|
+
*/
|
|
24
|
+
export interface StreamInfo {
|
|
25
|
+
title?: string;
|
|
26
|
+
image?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
/** ISO timestamp when the current stream began. */
|
|
29
|
+
startedAt?: string;
|
|
30
|
+
/** Total length of the current stream in seconds, when known. */
|
|
31
|
+
durationSec?: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ParticipantsUpdateData {
|
|
35
|
+
roomId: string;
|
|
36
|
+
participants: RoomParticipant[];
|
|
37
|
+
count: number;
|
|
38
|
+
timestamp: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface MuteUpdateData {
|
|
42
|
+
userId: string;
|
|
43
|
+
isMuted: boolean;
|
|
44
|
+
timestamp: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface SpeakerRequestData {
|
|
48
|
+
roomId: string;
|
|
49
|
+
userId: string;
|
|
50
|
+
timestamp: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface RecordingStateData {
|
|
54
|
+
roomId: string;
|
|
55
|
+
recordingId: string;
|
|
56
|
+
reason?: 'manual' | 'max_duration' | 'room_ended' | 'room_stopped';
|
|
57
|
+
timestamp: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface RoomAttachmentData {
|
|
61
|
+
roomId: string;
|
|
62
|
+
title: string;
|
|
63
|
+
status?: 'scheduled' | 'live' | 'ended';
|
|
64
|
+
type?: 'talk' | 'stage' | 'broadcast';
|
|
65
|
+
topic?: string;
|
|
66
|
+
host?: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface UserEntity {
|
|
70
|
+
id: string;
|
|
71
|
+
username?: string;
|
|
72
|
+
name?: { displayName?: string; full?: string; first?: string; last?: string } | string;
|
|
73
|
+
handle?: string;
|
|
74
|
+
// Adapts the Oxy SDK `User.avatar` (`string | null`): the API projects avatar
|
|
75
|
+
// from a nullable column, so `null` is a legitimate value at this boundary.
|
|
76
|
+
avatar?: string | null;
|
|
77
|
+
verified?: boolean;
|
|
78
|
+
bio?: string;
|
|
79
|
+
displayName?: string;
|
|
80
|
+
createdAt?: string;
|
|
81
|
+
[key: string]: unknown;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface LiveTheme {
|
|
85
|
+
isDark?: boolean;
|
|
86
|
+
colors: {
|
|
87
|
+
text: string;
|
|
88
|
+
textSecondary: string;
|
|
89
|
+
background: string;
|
|
90
|
+
backgroundSecondary: string;
|
|
91
|
+
card: string;
|
|
92
|
+
border: string;
|
|
93
|
+
primary: string;
|
|
94
|
+
[key: string]: string;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface HttpRequestConfig {
|
|
99
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
100
|
+
[key: string]: unknown;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The HTTP client the engine consumes. Deliberately shaped to match an Oxy
|
|
105
|
+
* `oxyServices.createLinkedClient(...).client` as-is: every method resolves to
|
|
106
|
+
* the PARSED RESPONSE BODY directly (not a `{ data }` envelope). Consumers pass
|
|
107
|
+
* that Oxy client straight through — no per-app adapter.
|
|
108
|
+
*/
|
|
109
|
+
export interface HttpClient {
|
|
110
|
+
get: (url: string, config?: HttpRequestConfig) => Promise<Record<string, unknown>>;
|
|
111
|
+
post: (url: string, data?: Record<string, unknown> | FormData, config?: HttpRequestConfig) => Promise<Record<string, unknown>>;
|
|
112
|
+
patch: (url: string, data?: Record<string, unknown>, config?: HttpRequestConfig) => Promise<Record<string, unknown>>;
|
|
113
|
+
delete: (url: string, config?: HttpRequestConfig) => Promise<Record<string, unknown>>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface FileDownloadService {
|
|
117
|
+
getFileDownloadUrl?(fileId: string, variant?: string, expiresIn?: number): string;
|
|
118
|
+
getFileDownloadUrlAsync?(fileId: string, variant?: string, expiresIn?: number): Promise<string>;
|
|
119
|
+
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// --- Podcast queue ---
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* One podcast episode queued behind the current stream. `episodeId` is the
|
|
7
|
+
* opaque Syra episode handle; `syraPodcastId` (when present) identifies its show.
|
|
8
|
+
* The playable audio URL is never carried here — it is resolved server-side at
|
|
9
|
+
* play-time.
|
|
10
|
+
*/
|
|
11
|
+
export const ZPodcastQueueItem = z.object({
|
|
12
|
+
syraPodcastId: z.string().optional(),
|
|
13
|
+
episodeId: z.string(),
|
|
14
|
+
}).passthrough();
|
|
15
|
+
|
|
16
|
+
export type PodcastQueueItem = z.infer<typeof ZPodcastQueueItem>;
|
|
17
|
+
|
|
18
|
+
// --- Room (replaces Space) ---
|
|
19
|
+
|
|
20
|
+
export const ZRoom = z.object({
|
|
21
|
+
_id: z.string(),
|
|
22
|
+
id: z.string().optional(),
|
|
23
|
+
title: z.string(),
|
|
24
|
+
description: z.string().nullish(),
|
|
25
|
+
|
|
26
|
+
// Ownership
|
|
27
|
+
ownerType: z.enum(['profile', 'house', 'agora']).default('profile'),
|
|
28
|
+
host: z.string(),
|
|
29
|
+
houseId: z.string().optional().nullable(),
|
|
30
|
+
createdByAdmin: z.string().optional().nullable(),
|
|
31
|
+
|
|
32
|
+
// Classification
|
|
33
|
+
type: z.enum(['talk', 'stage', 'broadcast']).default('talk'),
|
|
34
|
+
broadcastKind: z.enum(['user', 'agora']).optional().nullable(),
|
|
35
|
+
|
|
36
|
+
// Lifecycle
|
|
37
|
+
status: z.enum(['scheduled', 'live', 'ended']),
|
|
38
|
+
scheduledStart: z.string().nullish(),
|
|
39
|
+
startedAt: z.string().nullish(),
|
|
40
|
+
endedAt: z.string().nullish(),
|
|
41
|
+
|
|
42
|
+
// Participation
|
|
43
|
+
speakerPermission: z.enum(['everyone', 'followers', 'invited']).nullish(),
|
|
44
|
+
participants: z.array(z.string()).default([]),
|
|
45
|
+
speakers: z.array(z.string()).default([]),
|
|
46
|
+
maxParticipants: z.number().default(100),
|
|
47
|
+
|
|
48
|
+
// Content
|
|
49
|
+
topic: z.string().nullish(),
|
|
50
|
+
tags: z.array(z.string()).optional(),
|
|
51
|
+
archived: z.boolean().optional().default(false),
|
|
52
|
+
seriesId: z.string().nullish(),
|
|
53
|
+
|
|
54
|
+
// Stats
|
|
55
|
+
stats: z.object({
|
|
56
|
+
peakListeners: z.number(),
|
|
57
|
+
totalJoined: z.number(),
|
|
58
|
+
}).optional(),
|
|
59
|
+
|
|
60
|
+
// Streaming
|
|
61
|
+
activeIngressId: z.string().nullish(),
|
|
62
|
+
activeStreamUrl: z.string().nullish(),
|
|
63
|
+
streamTitle: z.string().nullish(),
|
|
64
|
+
streamImage: z.string().nullish(),
|
|
65
|
+
streamDescription: z.string().nullish(),
|
|
66
|
+
rtmpUrl: z.string().nullish(),
|
|
67
|
+
rtmpStreamKey: z.string().nullish(),
|
|
68
|
+
// Stream progress + podcast lifecycle (shared contract with the backend).
|
|
69
|
+
// `streamStartedAt` is an ISO timestamp; `streamDurationSec` is the current
|
|
70
|
+
// stream's total length in seconds when known (e.g. a podcast episode);
|
|
71
|
+
// `podcastQueue` holds the episodes queued behind the current one.
|
|
72
|
+
streamStartedAt: z.string().nullish(),
|
|
73
|
+
streamDurationSec: z.number().nullish(),
|
|
74
|
+
podcastQueue: z.array(ZPodcastQueueItem).nullish(),
|
|
75
|
+
|
|
76
|
+
// Recording
|
|
77
|
+
recordingEnabled: z.boolean().optional().default(true),
|
|
78
|
+
recordingEgressId: z.string().nullish(),
|
|
79
|
+
|
|
80
|
+
createdAt: z.string(),
|
|
81
|
+
}).passthrough();
|
|
82
|
+
|
|
83
|
+
export type Room = z.infer<typeof ZRoom>;
|
|
84
|
+
|
|
85
|
+
// --- Room Participant ---
|
|
86
|
+
|
|
87
|
+
export const ZRoomParticipant = z.object({
|
|
88
|
+
userId: z.string(),
|
|
89
|
+
role: z.enum(['host', 'speaker', 'listener']),
|
|
90
|
+
isMuted: z.boolean(),
|
|
91
|
+
joinedAt: z.string(),
|
|
92
|
+
}).passthrough();
|
|
93
|
+
|
|
94
|
+
export type RoomParticipant = z.infer<typeof ZRoomParticipant>;
|
|
95
|
+
|
|
96
|
+
// --- House ---
|
|
97
|
+
|
|
98
|
+
export const ZHouseMember = z.object({
|
|
99
|
+
userId: z.string(),
|
|
100
|
+
role: z.enum(['owner', 'admin', 'host', 'member']),
|
|
101
|
+
joinedAt: z.string(),
|
|
102
|
+
}).passthrough();
|
|
103
|
+
|
|
104
|
+
export type HouseMember = z.infer<typeof ZHouseMember>;
|
|
105
|
+
|
|
106
|
+
export const ZHouse = z.object({
|
|
107
|
+
_id: z.string(),
|
|
108
|
+
id: z.string().optional(),
|
|
109
|
+
name: z.string(),
|
|
110
|
+
description: z.string().optional(),
|
|
111
|
+
avatar: z.string().optional().nullable(),
|
|
112
|
+
coverImage: z.string().optional().nullable(),
|
|
113
|
+
members: z.array(ZHouseMember).default([]),
|
|
114
|
+
createdBy: z.string(),
|
|
115
|
+
isPublic: z.boolean().default(true),
|
|
116
|
+
tags: z.array(z.string()).optional(),
|
|
117
|
+
createdAt: z.string(),
|
|
118
|
+
}).passthrough();
|
|
119
|
+
|
|
120
|
+
export type House = z.infer<typeof ZHouse>;
|
|
121
|
+
|
|
122
|
+
// --- Series ---
|
|
123
|
+
|
|
124
|
+
export const ZRecurrence = z.object({
|
|
125
|
+
type: z.enum(['daily', 'weekly', 'biweekly', 'monthly']),
|
|
126
|
+
dayOfWeek: z.number().min(0).max(6).optional(),
|
|
127
|
+
dayOfMonth: z.number().min(1).max(31).optional(),
|
|
128
|
+
time: z.string().regex(/^\d{2}:\d{2}$/),
|
|
129
|
+
timezone: z.string().default('UTC'),
|
|
130
|
+
}).passthrough();
|
|
131
|
+
|
|
132
|
+
export type Recurrence = z.infer<typeof ZRecurrence>;
|
|
133
|
+
|
|
134
|
+
export const ZRoomTemplate = z.object({
|
|
135
|
+
titlePattern: z.string(),
|
|
136
|
+
type: z.enum(['talk', 'stage', 'broadcast']).default('talk'),
|
|
137
|
+
description: z.string().optional(),
|
|
138
|
+
maxParticipants: z.number().default(100),
|
|
139
|
+
speakerPermission: z.enum(['everyone', 'followers', 'invited']).default('invited'),
|
|
140
|
+
tags: z.array(z.string()).optional(),
|
|
141
|
+
}).passthrough();
|
|
142
|
+
|
|
143
|
+
export type RoomTemplate = z.infer<typeof ZRoomTemplate>;
|
|
144
|
+
|
|
145
|
+
export const ZSeriesEpisode = z.object({
|
|
146
|
+
roomId: z.string(),
|
|
147
|
+
scheduledStart: z.string(),
|
|
148
|
+
episodeNumber: z.number(),
|
|
149
|
+
}).passthrough();
|
|
150
|
+
|
|
151
|
+
export type SeriesEpisode = z.infer<typeof ZSeriesEpisode>;
|
|
152
|
+
|
|
153
|
+
export const ZSeries = z.object({
|
|
154
|
+
_id: z.string(),
|
|
155
|
+
id: z.string().optional(),
|
|
156
|
+
title: z.string(),
|
|
157
|
+
description: z.string().optional(),
|
|
158
|
+
coverImage: z.string().optional().nullable(),
|
|
159
|
+
houseId: z.string().optional().nullable(),
|
|
160
|
+
createdBy: z.string(),
|
|
161
|
+
recurrence: ZRecurrence,
|
|
162
|
+
roomTemplate: ZRoomTemplate,
|
|
163
|
+
episodes: z.array(ZSeriesEpisode).default([]),
|
|
164
|
+
nextEpisodeNumber: z.number().default(1),
|
|
165
|
+
isActive: z.boolean().default(true),
|
|
166
|
+
createdAt: z.string(),
|
|
167
|
+
}).passthrough();
|
|
168
|
+
|
|
169
|
+
export type Series = z.infer<typeof ZSeries>;
|
|
170
|
+
|
|
171
|
+
// --- Recording ---
|
|
172
|
+
|
|
173
|
+
export const ZRecording = z.object({
|
|
174
|
+
_id: z.string(),
|
|
175
|
+
roomId: z.string(),
|
|
176
|
+
roomTitle: z.string(),
|
|
177
|
+
host: z.string(),
|
|
178
|
+
status: z.enum(['recording', 'processing', 'ready', 'failed', 'deleted']),
|
|
179
|
+
egressId: z.string(),
|
|
180
|
+
objectKey: z.string(),
|
|
181
|
+
fileSize: z.number().nullish(),
|
|
182
|
+
durationMs: z.number().nullish(),
|
|
183
|
+
startedAt: z.string(),
|
|
184
|
+
stoppedAt: z.string().nullish(),
|
|
185
|
+
access: z.enum(['public', 'participants']).default('public'),
|
|
186
|
+
participantIds: z.array(z.string()).default([]),
|
|
187
|
+
expiresAt: z.string(),
|
|
188
|
+
createdAt: z.string(),
|
|
189
|
+
}).passthrough();
|
|
190
|
+
|
|
191
|
+
export type Recording = z.infer<typeof ZRecording>;
|
|
192
|
+
|
|
193
|
+
// --- Stream responses ---
|
|
194
|
+
|
|
195
|
+
export const ZStartStreamResponse = z.object({
|
|
196
|
+
ingressId: z.string(),
|
|
197
|
+
url: z.string(),
|
|
198
|
+
}).passthrough();
|
|
199
|
+
|
|
200
|
+
export const ZGenerateStreamKeyResponse = z.object({
|
|
201
|
+
rtmpUrl: z.string(),
|
|
202
|
+
streamKey: z.string(),
|
|
203
|
+
}).passthrough();
|
|
204
|
+
|
|
205
|
+
export const ZStreamInfo = z.object({
|
|
206
|
+
title: z.string().optional(),
|
|
207
|
+
image: z.string().optional(),
|
|
208
|
+
description: z.string().optional(),
|
|
209
|
+
}).passthrough();
|
|
210
|
+
|
|
211
|
+
export type StreamInfo = z.infer<typeof ZStreamInfo>;
|
|
212
|
+
|
|
213
|
+
// --- Room attachment for posts ---
|
|
214
|
+
|
|
215
|
+
export const ZRoomAttachment = z.object({
|
|
216
|
+
roomId: z.string(),
|
|
217
|
+
title: z.string(),
|
|
218
|
+
status: z.enum(['scheduled', 'live', 'ended']).optional(),
|
|
219
|
+
type: z.enum(['talk', 'stage', 'broadcast']).optional(),
|
|
220
|
+
topic: z.string().optional(),
|
|
221
|
+
host: z.string().optional(),
|
|
222
|
+
}).passthrough();
|
|
223
|
+
|
|
224
|
+
export type RoomAttachment = z.infer<typeof ZRoomAttachment>;
|
|
225
|
+
|
|
226
|
+
// --- Validators ---
|
|
227
|
+
|
|
228
|
+
export function validateRoom(data: unknown): Room | null {
|
|
229
|
+
const result = ZRoom.safeParse(data);
|
|
230
|
+
if (result.success) return result.data;
|
|
231
|
+
console.warn('[live] Invalid Room:', result.error.issues[0]);
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function validateRooms(items: unknown[]): Room[] {
|
|
236
|
+
if (!Array.isArray(items)) return [];
|
|
237
|
+
const valid: Room[] = [];
|
|
238
|
+
for (const item of items) {
|
|
239
|
+
const parsed = ZRoom.safeParse(item);
|
|
240
|
+
if (parsed.success) {
|
|
241
|
+
valid.push(parsed.data);
|
|
242
|
+
} else {
|
|
243
|
+
console.warn('[live] Dropping invalid room:', parsed.error.issues[0]);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return valid;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function validateHouse(data: unknown): House | null {
|
|
250
|
+
const result = ZHouse.safeParse(data);
|
|
251
|
+
if (result.success) return result.data;
|
|
252
|
+
console.warn('[live] Invalid House:', result.error.issues[0]);
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function validateRecording(data: unknown): Recording | null {
|
|
257
|
+
const result = ZRecording.safeParse(data);
|
|
258
|
+
if (result.success) return result.data;
|
|
259
|
+
console.warn('[live] Invalid Recording:', result.error.issues[0]);
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export function validateRecordings(items: unknown[]): Recording[] {
|
|
264
|
+
if (!Array.isArray(items)) return [];
|
|
265
|
+
const valid: Recording[] = [];
|
|
266
|
+
for (const item of items) {
|
|
267
|
+
const parsed = ZRecording.safeParse(item);
|
|
268
|
+
if (parsed.success) valid.push(parsed.data);
|
|
269
|
+
}
|
|
270
|
+
return valid;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export function validateSeries(data: unknown): Series | null {
|
|
274
|
+
const result = ZSeries.safeParse(data);
|
|
275
|
+
if (result.success) return result.data;
|
|
276
|
+
console.warn('[live] Invalid Series:', result.error.issues[0]);
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
|
package/dist/cjs/client.js
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_SYRA_WEB_BASE_URL = exports.DEFAULT_SYRA_BASE_URL = void 0;
|
|
4
|
-
exports.createSyraClient = createSyraClient;
|
|
5
|
-
const schema_1 = require("./schema");
|
|
6
|
-
const errors_1 = require("./errors");
|
|
7
|
-
/** Default base URL of the public Syra API. */
|
|
8
|
-
exports.DEFAULT_SYRA_BASE_URL = 'https://api.syra.fm';
|
|
9
|
-
/** Default base URL of the Syra web app, used for deep links. */
|
|
10
|
-
exports.DEFAULT_SYRA_WEB_BASE_URL = 'https://syra.fm';
|
|
11
|
-
/** Order used to pick the best available artwork variant when none is named. */
|
|
12
|
-
const ARTWORK_FALLBACK_ORDER = [
|
|
13
|
-
'original',
|
|
14
|
-
'xxlarge',
|
|
15
|
-
'xlarge',
|
|
16
|
-
'large',
|
|
17
|
-
'medium',
|
|
18
|
-
'small',
|
|
19
|
-
];
|
|
20
|
-
const OBJECT_ID_PATTERN = /^[a-f\d]{24}$/i;
|
|
21
|
-
/**
|
|
22
|
-
* Default episode page size, matching the backend's own default so the SDK's
|
|
23
|
-
* offset→page translation lines up with the server's pagination window.
|
|
24
|
-
*/
|
|
25
|
-
const DEFAULT_EPISODES_PAGE_SIZE = 20;
|
|
26
|
-
/** Read a finite number from an unknown response field, else a fallback. */
|
|
27
|
-
function numberOr(value, fallback) {
|
|
28
|
-
return typeof value === 'number' && Number.isFinite(value) ? value : fallback;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Create a headless client for the public Syra API. Public reads only — there
|
|
32
|
-
* is no authentication in this version.
|
|
33
|
-
*/
|
|
34
|
-
function createSyraClient(options = {}) {
|
|
35
|
-
const baseURL = (options.baseURL ?? exports.DEFAULT_SYRA_BASE_URL).replace(/\/+$/, '');
|
|
36
|
-
const webBaseURL = (options.webBaseURL ?? exports.DEFAULT_SYRA_WEB_BASE_URL).replace(/\/+$/, '');
|
|
37
|
-
function resolveFetch() {
|
|
38
|
-
if (options.fetch) {
|
|
39
|
-
return options.fetch;
|
|
40
|
-
}
|
|
41
|
-
const globalFetch = globalThis.fetch;
|
|
42
|
-
if (typeof globalFetch === 'function') {
|
|
43
|
-
return globalFetch.bind(globalThis);
|
|
44
|
-
}
|
|
45
|
-
throw new Error('@syra.fm/sdk: no global fetch is available. Pass `fetch` in createSyraClient options, ' +
|
|
46
|
-
'or run on Node 18+, a browser, or React Native.');
|
|
47
|
-
}
|
|
48
|
-
async function getJson(path) {
|
|
49
|
-
const doFetch = resolveFetch();
|
|
50
|
-
const response = await doFetch(`${baseURL}${path}`, {
|
|
51
|
-
headers: { Accept: 'application/json' },
|
|
52
|
-
});
|
|
53
|
-
if (!response.ok) {
|
|
54
|
-
throw new errors_1.SyraApiError(response.status, `Syra API request failed: ${response.status} ${response.statusText} (${path})`);
|
|
55
|
-
}
|
|
56
|
-
return response.json();
|
|
57
|
-
}
|
|
58
|
-
function resolveImageRef(ref) {
|
|
59
|
-
if (!ref) {
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
if (/^https?:\/\//i.test(ref)) {
|
|
63
|
-
return ref;
|
|
64
|
-
}
|
|
65
|
-
if (ref.startsWith('/api/images/')) {
|
|
66
|
-
return `${baseURL}${ref}`;
|
|
67
|
-
}
|
|
68
|
-
if (OBJECT_ID_PATTERN.test(ref)) {
|
|
69
|
-
return `${baseURL}/api/images/${ref}`;
|
|
70
|
-
}
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
async searchTracks(query, searchOptions = {}) {
|
|
75
|
-
const params = new URLSearchParams({ q: query, category: 'tracks' });
|
|
76
|
-
if (typeof searchOptions.limit === 'number') {
|
|
77
|
-
params.set('limit', String(searchOptions.limit));
|
|
78
|
-
}
|
|
79
|
-
if (typeof searchOptions.offset === 'number') {
|
|
80
|
-
params.set('offset', String(searchOptions.offset));
|
|
81
|
-
}
|
|
82
|
-
const json = (await getJson(`/api/search?${params.toString()}`));
|
|
83
|
-
const rawTracks = Array.isArray(json?.results?.tracks) ? json.results.tracks : [];
|
|
84
|
-
const items = [];
|
|
85
|
-
for (const raw of rawTracks) {
|
|
86
|
-
// A single malformed catalog row must not fail the whole search.
|
|
87
|
-
const parsed = schema_1.trackSummarySchema.safeParse(raw);
|
|
88
|
-
if (parsed.success && parsed.data.previewAvailable === true) {
|
|
89
|
-
items.push(parsed.data);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
items,
|
|
94
|
-
// `hasMore` is sourced from the backend's pagination over the FULL result
|
|
95
|
-
// set; the client-side preview filter above may shrink `items` below
|
|
96
|
-
// `limit`, but must NOT corrupt `hasMore` (else a page whose tail was
|
|
97
|
-
// filtered out would falsely report the end of the catalog).
|
|
98
|
-
hasMore: json?.hasMore === true,
|
|
99
|
-
limit: numberOr(json?.limit, searchOptions.limit ?? rawTracks.length),
|
|
100
|
-
offset: numberOr(json?.offset, searchOptions.offset ?? 0),
|
|
101
|
-
};
|
|
102
|
-
},
|
|
103
|
-
async getTrack(id) {
|
|
104
|
-
const json = await getJson(`/api/tracks/${encodeURIComponent(id)}`);
|
|
105
|
-
return schema_1.trackSummarySchema.parse(json);
|
|
106
|
-
},
|
|
107
|
-
previewUrl(id, startSec = 0) {
|
|
108
|
-
const safeStart = Number.isFinite(startSec) ? Math.max(0, Math.trunc(startSec)) : 0;
|
|
109
|
-
return `${baseURL}/api/preview/${encodeURIComponent(id)}.mp3?start=${safeStart}`;
|
|
110
|
-
},
|
|
111
|
-
artworkUrl(source, size) {
|
|
112
|
-
if (typeof source === 'string') {
|
|
113
|
-
return resolveImageRef(source);
|
|
114
|
-
}
|
|
115
|
-
if (size && source.coverArtSizes) {
|
|
116
|
-
const resolved = resolveImageRef(source.coverArtSizes[size]?.url);
|
|
117
|
-
if (resolved) {
|
|
118
|
-
return resolved;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
const fromCoverArt = resolveImageRef(source.coverArt);
|
|
122
|
-
if (fromCoverArt) {
|
|
123
|
-
return fromCoverArt;
|
|
124
|
-
}
|
|
125
|
-
if (source.coverArtSizes) {
|
|
126
|
-
for (const key of ARTWORK_FALLBACK_ORDER) {
|
|
127
|
-
const resolved = resolveImageRef(source.coverArtSizes[key]?.url);
|
|
128
|
-
if (resolved) {
|
|
129
|
-
return resolved;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return undefined;
|
|
134
|
-
},
|
|
135
|
-
async searchPodcasts(query, searchOptions = {}) {
|
|
136
|
-
const params = new URLSearchParams({ q: query });
|
|
137
|
-
if (typeof searchOptions.limit === 'number') {
|
|
138
|
-
params.set('limit', String(searchOptions.limit));
|
|
139
|
-
}
|
|
140
|
-
if (typeof searchOptions.offset === 'number') {
|
|
141
|
-
params.set('offset', String(searchOptions.offset));
|
|
142
|
-
}
|
|
143
|
-
const json = (await getJson(`/api/podcasts/search?${params.toString()}`));
|
|
144
|
-
const rawPodcasts = Array.isArray(json?.data) ? json.data : [];
|
|
145
|
-
const items = [];
|
|
146
|
-
for (const raw of rawPodcasts) {
|
|
147
|
-
// A single malformed catalog row must not fail the whole search.
|
|
148
|
-
const parsed = schema_1.podcastSummarySchema.safeParse(raw);
|
|
149
|
-
if (parsed.success) {
|
|
150
|
-
items.push(parsed.data);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return {
|
|
154
|
-
items,
|
|
155
|
-
// `hasMore` reflects the backend's pagination over the full result set.
|
|
156
|
-
hasMore: json?.hasMore === true,
|
|
157
|
-
limit: numberOr(json?.limit, searchOptions.limit ?? rawPodcasts.length),
|
|
158
|
-
offset: numberOr(json?.offset, searchOptions.offset ?? 0),
|
|
159
|
-
};
|
|
160
|
-
},
|
|
161
|
-
async getPodcast(id) {
|
|
162
|
-
const json = (await getJson(`/api/podcasts/${encodeURIComponent(id)}`));
|
|
163
|
-
return schema_1.podcastSummarySchema.parse(json?.data?.podcast);
|
|
164
|
-
},
|
|
165
|
-
podcastUrl(id) {
|
|
166
|
-
return `${webBaseURL}/podcasts/${encodeURIComponent(id)}`;
|
|
167
|
-
},
|
|
168
|
-
podcastArtworkUrl(source, size) {
|
|
169
|
-
if (size && source.imageSizes) {
|
|
170
|
-
const resolved = resolveImageRef(source.imageSizes[size]?.url);
|
|
171
|
-
if (resolved) {
|
|
172
|
-
return resolved;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
const fromImage = resolveImageRef(source.image);
|
|
176
|
-
if (fromImage) {
|
|
177
|
-
return fromImage;
|
|
178
|
-
}
|
|
179
|
-
if (source.imageSizes) {
|
|
180
|
-
for (const key of ARTWORK_FALLBACK_ORDER) {
|
|
181
|
-
const resolved = resolveImageRef(source.imageSizes[key]?.url);
|
|
182
|
-
if (resolved) {
|
|
183
|
-
return resolved;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return resolveImageRef(source.imageSourceUrl);
|
|
188
|
-
},
|
|
189
|
-
async getPodcastEpisodes(podcastId, listOptions = {}) {
|
|
190
|
-
// The endpoint paginates by 1-based `page`; translate the SDK's uniform
|
|
191
|
-
// offset-based paging into it. `limit` must be concrete (unlike search,
|
|
192
|
-
// which can omit it) because the page number is derived from it.
|
|
193
|
-
const limit = listOptions.limit ?? DEFAULT_EPISODES_PAGE_SIZE;
|
|
194
|
-
const offset = listOptions.offset ?? 0;
|
|
195
|
-
const page = Math.floor(offset / limit) + 1;
|
|
196
|
-
const json = (await getJson(`/api/podcasts/${encodeURIComponent(podcastId)}/episodes?page=${page}&limit=${limit}`));
|
|
197
|
-
const rawEpisodes = Array.isArray(json?.data) ? json.data : [];
|
|
198
|
-
const items = [];
|
|
199
|
-
for (const raw of rawEpisodes) {
|
|
200
|
-
// A single malformed episode row must not fail the whole listing.
|
|
201
|
-
const parsed = schema_1.episodeSummarySchema.safeParse(raw);
|
|
202
|
-
if (parsed.success) {
|
|
203
|
-
items.push(parsed.data);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
// `total` is the backend's full count over the show; derive `hasMore` from
|
|
207
|
-
// it rather than `items.length`, which the schema/enclosure filter above may
|
|
208
|
-
// shrink below `limit` on a page that is NOT the last one. Absent a count,
|
|
209
|
-
// fall back to what we have (this page ends the listing).
|
|
210
|
-
const total = numberOr(json?.total, offset + items.length);
|
|
211
|
-
return {
|
|
212
|
-
items,
|
|
213
|
-
hasMore: page * limit < total,
|
|
214
|
-
limit,
|
|
215
|
-
offset,
|
|
216
|
-
};
|
|
217
|
-
},
|
|
218
|
-
async getEpisode(episodeId) {
|
|
219
|
-
const json = (await getJson(`/api/episodes/${encodeURIComponent(episodeId)}`));
|
|
220
|
-
return schema_1.episodeSummarySchema.parse(json?.data?.episode);
|
|
221
|
-
},
|
|
222
|
-
episodeImageUrl(source, size) {
|
|
223
|
-
if (size && source.imageSizes) {
|
|
224
|
-
const resolved = resolveImageRef(source.imageSizes[size]?.url);
|
|
225
|
-
if (resolved) {
|
|
226
|
-
return resolved;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
const fromImage = resolveImageRef(source.image);
|
|
230
|
-
if (fromImage) {
|
|
231
|
-
return fromImage;
|
|
232
|
-
}
|
|
233
|
-
if (source.imageSizes) {
|
|
234
|
-
for (const key of ARTWORK_FALLBACK_ORDER) {
|
|
235
|
-
const resolved = resolveImageRef(source.imageSizes[key]?.url);
|
|
236
|
-
if (resolved) {
|
|
237
|
-
return resolved;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
return resolveImageRef(source.imageSourceUrl);
|
|
242
|
-
},
|
|
243
|
-
};
|
|
244
|
-
}
|
package/dist/cjs/errors.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SyraApiError = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Error thrown when the Syra API returns a non-2xx response.
|
|
6
|
-
*/
|
|
7
|
-
class SyraApiError extends Error {
|
|
8
|
-
constructor(status, message) {
|
|
9
|
-
super(message);
|
|
10
|
-
this.name = 'SyraApiError';
|
|
11
|
-
this.status = status;
|
|
12
|
-
// Restore the prototype chain when targeting ES5-ish runtimes.
|
|
13
|
-
Object.setPrototypeOf(this, SyraApiError.prototype);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.SyraApiError = SyraApiError;
|
package/dist/cjs/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SyraApiError = exports.coverArtVariantSchema = exports.coverArtSizesSchema = exports.episodeSummarySchema = exports.podcastSummarySchema = exports.trackSummarySchema = exports.DEFAULT_SYRA_WEB_BASE_URL = exports.DEFAULT_SYRA_BASE_URL = exports.createSyraClient = void 0;
|
|
4
|
-
var client_1 = require("./client");
|
|
5
|
-
Object.defineProperty(exports, "createSyraClient", { enumerable: true, get: function () { return client_1.createSyraClient; } });
|
|
6
|
-
Object.defineProperty(exports, "DEFAULT_SYRA_BASE_URL", { enumerable: true, get: function () { return client_1.DEFAULT_SYRA_BASE_URL; } });
|
|
7
|
-
Object.defineProperty(exports, "DEFAULT_SYRA_WEB_BASE_URL", { enumerable: true, get: function () { return client_1.DEFAULT_SYRA_WEB_BASE_URL; } });
|
|
8
|
-
var schema_1 = require("./schema");
|
|
9
|
-
Object.defineProperty(exports, "trackSummarySchema", { enumerable: true, get: function () { return schema_1.trackSummarySchema; } });
|
|
10
|
-
Object.defineProperty(exports, "podcastSummarySchema", { enumerable: true, get: function () { return schema_1.podcastSummarySchema; } });
|
|
11
|
-
Object.defineProperty(exports, "episodeSummarySchema", { enumerable: true, get: function () { return schema_1.episodeSummarySchema; } });
|
|
12
|
-
Object.defineProperty(exports, "coverArtSizesSchema", { enumerable: true, get: function () { return schema_1.coverArtSizesSchema; } });
|
|
13
|
-
Object.defineProperty(exports, "coverArtVariantSchema", { enumerable: true, get: function () { return schema_1.coverArtVariantSchema; } });
|
|
14
|
-
var errors_1 = require("./errors");
|
|
15
|
-
Object.defineProperty(exports, "SyraApiError", { enumerable: true, get: function () { return errors_1.SyraApiError; } });
|
package/dist/cjs/package.json
DELETED