@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
package/dist/esm/client.js
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { trackSummarySchema, podcastSummarySchema, episodeSummarySchema, } from './schema.js';
|
|
2
|
-
import { SyraApiError } from './errors.js';
|
|
3
|
-
/** Default base URL of the public Syra API. */
|
|
4
|
-
export const DEFAULT_SYRA_BASE_URL = 'https://api.syra.fm';
|
|
5
|
-
/** Default base URL of the Syra web app, used for deep links. */
|
|
6
|
-
export const DEFAULT_SYRA_WEB_BASE_URL = 'https://syra.fm';
|
|
7
|
-
/** Order used to pick the best available artwork variant when none is named. */
|
|
8
|
-
const ARTWORK_FALLBACK_ORDER = [
|
|
9
|
-
'original',
|
|
10
|
-
'xxlarge',
|
|
11
|
-
'xlarge',
|
|
12
|
-
'large',
|
|
13
|
-
'medium',
|
|
14
|
-
'small',
|
|
15
|
-
];
|
|
16
|
-
const OBJECT_ID_PATTERN = /^[a-f\d]{24}$/i;
|
|
17
|
-
/**
|
|
18
|
-
* Default episode page size, matching the backend's own default so the SDK's
|
|
19
|
-
* offset→page translation lines up with the server's pagination window.
|
|
20
|
-
*/
|
|
21
|
-
const DEFAULT_EPISODES_PAGE_SIZE = 20;
|
|
22
|
-
/** Read a finite number from an unknown response field, else a fallback. */
|
|
23
|
-
function numberOr(value, fallback) {
|
|
24
|
-
return typeof value === 'number' && Number.isFinite(value) ? value : fallback;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Create a headless client for the public Syra API. Public reads only — there
|
|
28
|
-
* is no authentication in this version.
|
|
29
|
-
*/
|
|
30
|
-
export function createSyraClient(options = {}) {
|
|
31
|
-
const baseURL = (options.baseURL ?? DEFAULT_SYRA_BASE_URL).replace(/\/+$/, '');
|
|
32
|
-
const webBaseURL = (options.webBaseURL ?? DEFAULT_SYRA_WEB_BASE_URL).replace(/\/+$/, '');
|
|
33
|
-
function resolveFetch() {
|
|
34
|
-
if (options.fetch) {
|
|
35
|
-
return options.fetch;
|
|
36
|
-
}
|
|
37
|
-
const globalFetch = globalThis.fetch;
|
|
38
|
-
if (typeof globalFetch === 'function') {
|
|
39
|
-
return globalFetch.bind(globalThis);
|
|
40
|
-
}
|
|
41
|
-
throw new Error('@syra.fm/sdk: no global fetch is available. Pass `fetch` in createSyraClient options, ' +
|
|
42
|
-
'or run on Node 18+, a browser, or React Native.');
|
|
43
|
-
}
|
|
44
|
-
async function getJson(path) {
|
|
45
|
-
const doFetch = resolveFetch();
|
|
46
|
-
const response = await doFetch(`${baseURL}${path}`, {
|
|
47
|
-
headers: { Accept: 'application/json' },
|
|
48
|
-
});
|
|
49
|
-
if (!response.ok) {
|
|
50
|
-
throw new SyraApiError(response.status, `Syra API request failed: ${response.status} ${response.statusText} (${path})`);
|
|
51
|
-
}
|
|
52
|
-
return response.json();
|
|
53
|
-
}
|
|
54
|
-
function resolveImageRef(ref) {
|
|
55
|
-
if (!ref) {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
if (/^https?:\/\//i.test(ref)) {
|
|
59
|
-
return ref;
|
|
60
|
-
}
|
|
61
|
-
if (ref.startsWith('/api/images/')) {
|
|
62
|
-
return `${baseURL}${ref}`;
|
|
63
|
-
}
|
|
64
|
-
if (OBJECT_ID_PATTERN.test(ref)) {
|
|
65
|
-
return `${baseURL}/api/images/${ref}`;
|
|
66
|
-
}
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
async searchTracks(query, searchOptions = {}) {
|
|
71
|
-
const params = new URLSearchParams({ q: query, category: 'tracks' });
|
|
72
|
-
if (typeof searchOptions.limit === 'number') {
|
|
73
|
-
params.set('limit', String(searchOptions.limit));
|
|
74
|
-
}
|
|
75
|
-
if (typeof searchOptions.offset === 'number') {
|
|
76
|
-
params.set('offset', String(searchOptions.offset));
|
|
77
|
-
}
|
|
78
|
-
const json = (await getJson(`/api/search?${params.toString()}`));
|
|
79
|
-
const rawTracks = Array.isArray(json?.results?.tracks) ? json.results.tracks : [];
|
|
80
|
-
const items = [];
|
|
81
|
-
for (const raw of rawTracks) {
|
|
82
|
-
// A single malformed catalog row must not fail the whole search.
|
|
83
|
-
const parsed = trackSummarySchema.safeParse(raw);
|
|
84
|
-
if (parsed.success && parsed.data.previewAvailable === true) {
|
|
85
|
-
items.push(parsed.data);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return {
|
|
89
|
-
items,
|
|
90
|
-
// `hasMore` is sourced from the backend's pagination over the FULL result
|
|
91
|
-
// set; the client-side preview filter above may shrink `items` below
|
|
92
|
-
// `limit`, but must NOT corrupt `hasMore` (else a page whose tail was
|
|
93
|
-
// filtered out would falsely report the end of the catalog).
|
|
94
|
-
hasMore: json?.hasMore === true,
|
|
95
|
-
limit: numberOr(json?.limit, searchOptions.limit ?? rawTracks.length),
|
|
96
|
-
offset: numberOr(json?.offset, searchOptions.offset ?? 0),
|
|
97
|
-
};
|
|
98
|
-
},
|
|
99
|
-
async getTrack(id) {
|
|
100
|
-
const json = await getJson(`/api/tracks/${encodeURIComponent(id)}`);
|
|
101
|
-
return trackSummarySchema.parse(json);
|
|
102
|
-
},
|
|
103
|
-
previewUrl(id, startSec = 0) {
|
|
104
|
-
const safeStart = Number.isFinite(startSec) ? Math.max(0, Math.trunc(startSec)) : 0;
|
|
105
|
-
return `${baseURL}/api/preview/${encodeURIComponent(id)}.mp3?start=${safeStart}`;
|
|
106
|
-
},
|
|
107
|
-
artworkUrl(source, size) {
|
|
108
|
-
if (typeof source === 'string') {
|
|
109
|
-
return resolveImageRef(source);
|
|
110
|
-
}
|
|
111
|
-
if (size && source.coverArtSizes) {
|
|
112
|
-
const resolved = resolveImageRef(source.coverArtSizes[size]?.url);
|
|
113
|
-
if (resolved) {
|
|
114
|
-
return resolved;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
const fromCoverArt = resolveImageRef(source.coverArt);
|
|
118
|
-
if (fromCoverArt) {
|
|
119
|
-
return fromCoverArt;
|
|
120
|
-
}
|
|
121
|
-
if (source.coverArtSizes) {
|
|
122
|
-
for (const key of ARTWORK_FALLBACK_ORDER) {
|
|
123
|
-
const resolved = resolveImageRef(source.coverArtSizes[key]?.url);
|
|
124
|
-
if (resolved) {
|
|
125
|
-
return resolved;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return undefined;
|
|
130
|
-
},
|
|
131
|
-
async searchPodcasts(query, searchOptions = {}) {
|
|
132
|
-
const params = new URLSearchParams({ q: query });
|
|
133
|
-
if (typeof searchOptions.limit === 'number') {
|
|
134
|
-
params.set('limit', String(searchOptions.limit));
|
|
135
|
-
}
|
|
136
|
-
if (typeof searchOptions.offset === 'number') {
|
|
137
|
-
params.set('offset', String(searchOptions.offset));
|
|
138
|
-
}
|
|
139
|
-
const json = (await getJson(`/api/podcasts/search?${params.toString()}`));
|
|
140
|
-
const rawPodcasts = Array.isArray(json?.data) ? json.data : [];
|
|
141
|
-
const items = [];
|
|
142
|
-
for (const raw of rawPodcasts) {
|
|
143
|
-
// A single malformed catalog row must not fail the whole search.
|
|
144
|
-
const parsed = podcastSummarySchema.safeParse(raw);
|
|
145
|
-
if (parsed.success) {
|
|
146
|
-
items.push(parsed.data);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
items,
|
|
151
|
-
// `hasMore` reflects the backend's pagination over the full result set.
|
|
152
|
-
hasMore: json?.hasMore === true,
|
|
153
|
-
limit: numberOr(json?.limit, searchOptions.limit ?? rawPodcasts.length),
|
|
154
|
-
offset: numberOr(json?.offset, searchOptions.offset ?? 0),
|
|
155
|
-
};
|
|
156
|
-
},
|
|
157
|
-
async getPodcast(id) {
|
|
158
|
-
const json = (await getJson(`/api/podcasts/${encodeURIComponent(id)}`));
|
|
159
|
-
return podcastSummarySchema.parse(json?.data?.podcast);
|
|
160
|
-
},
|
|
161
|
-
podcastUrl(id) {
|
|
162
|
-
return `${webBaseURL}/podcasts/${encodeURIComponent(id)}`;
|
|
163
|
-
},
|
|
164
|
-
podcastArtworkUrl(source, size) {
|
|
165
|
-
if (size && source.imageSizes) {
|
|
166
|
-
const resolved = resolveImageRef(source.imageSizes[size]?.url);
|
|
167
|
-
if (resolved) {
|
|
168
|
-
return resolved;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
const fromImage = resolveImageRef(source.image);
|
|
172
|
-
if (fromImage) {
|
|
173
|
-
return fromImage;
|
|
174
|
-
}
|
|
175
|
-
if (source.imageSizes) {
|
|
176
|
-
for (const key of ARTWORK_FALLBACK_ORDER) {
|
|
177
|
-
const resolved = resolveImageRef(source.imageSizes[key]?.url);
|
|
178
|
-
if (resolved) {
|
|
179
|
-
return resolved;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return resolveImageRef(source.imageSourceUrl);
|
|
184
|
-
},
|
|
185
|
-
async getPodcastEpisodes(podcastId, listOptions = {}) {
|
|
186
|
-
// The endpoint paginates by 1-based `page`; translate the SDK's uniform
|
|
187
|
-
// offset-based paging into it. `limit` must be concrete (unlike search,
|
|
188
|
-
// which can omit it) because the page number is derived from it.
|
|
189
|
-
const limit = listOptions.limit ?? DEFAULT_EPISODES_PAGE_SIZE;
|
|
190
|
-
const offset = listOptions.offset ?? 0;
|
|
191
|
-
const page = Math.floor(offset / limit) + 1;
|
|
192
|
-
const json = (await getJson(`/api/podcasts/${encodeURIComponent(podcastId)}/episodes?page=${page}&limit=${limit}`));
|
|
193
|
-
const rawEpisodes = Array.isArray(json?.data) ? json.data : [];
|
|
194
|
-
const items = [];
|
|
195
|
-
for (const raw of rawEpisodes) {
|
|
196
|
-
// A single malformed episode row must not fail the whole listing.
|
|
197
|
-
const parsed = episodeSummarySchema.safeParse(raw);
|
|
198
|
-
if (parsed.success) {
|
|
199
|
-
items.push(parsed.data);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
// `total` is the backend's full count over the show; derive `hasMore` from
|
|
203
|
-
// it rather than `items.length`, which the schema/enclosure filter above may
|
|
204
|
-
// shrink below `limit` on a page that is NOT the last one. Absent a count,
|
|
205
|
-
// fall back to what we have (this page ends the listing).
|
|
206
|
-
const total = numberOr(json?.total, offset + items.length);
|
|
207
|
-
return {
|
|
208
|
-
items,
|
|
209
|
-
hasMore: page * limit < total,
|
|
210
|
-
limit,
|
|
211
|
-
offset,
|
|
212
|
-
};
|
|
213
|
-
},
|
|
214
|
-
async getEpisode(episodeId) {
|
|
215
|
-
const json = (await getJson(`/api/episodes/${encodeURIComponent(episodeId)}`));
|
|
216
|
-
return episodeSummarySchema.parse(json?.data?.episode);
|
|
217
|
-
},
|
|
218
|
-
episodeImageUrl(source, size) {
|
|
219
|
-
if (size && source.imageSizes) {
|
|
220
|
-
const resolved = resolveImageRef(source.imageSizes[size]?.url);
|
|
221
|
-
if (resolved) {
|
|
222
|
-
return resolved;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
const fromImage = resolveImageRef(source.image);
|
|
226
|
-
if (fromImage) {
|
|
227
|
-
return fromImage;
|
|
228
|
-
}
|
|
229
|
-
if (source.imageSizes) {
|
|
230
|
-
for (const key of ARTWORK_FALLBACK_ORDER) {
|
|
231
|
-
const resolved = resolveImageRef(source.imageSizes[key]?.url);
|
|
232
|
-
if (resolved) {
|
|
233
|
-
return resolved;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return resolveImageRef(source.imageSourceUrl);
|
|
238
|
-
},
|
|
239
|
-
};
|
|
240
|
-
}
|
package/dist/esm/errors.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error thrown when the Syra API returns a non-2xx response.
|
|
3
|
-
*/
|
|
4
|
-
export class SyraApiError extends Error {
|
|
5
|
-
constructor(status, message) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = 'SyraApiError';
|
|
8
|
-
this.status = status;
|
|
9
|
-
// Restore the prototype chain when targeting ES5-ish runtimes.
|
|
10
|
-
Object.setPrototypeOf(this, SyraApiError.prototype);
|
|
11
|
-
}
|
|
12
|
-
}
|
package/dist/esm/index.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { createSyraClient, DEFAULT_SYRA_BASE_URL, DEFAULT_SYRA_WEB_BASE_URL, } from './client.js';
|
|
2
|
-
export { trackSummarySchema, podcastSummarySchema, episodeSummarySchema, coverArtSizesSchema, coverArtVariantSchema, } from './schema.js';
|
|
3
|
-
export { SyraApiError } from './errors.js';
|
package/dist/esm/package.json
DELETED