@saavn-labs/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.
Files changed (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +339 -0
  3. package/dist/core/models/album.d.ts +32 -0
  4. package/dist/core/models/album.js +1 -0
  5. package/dist/core/models/artist.d.ts +61 -0
  6. package/dist/core/models/artist.js +1 -0
  7. package/dist/core/models/index.d.ts +4 -0
  8. package/dist/core/models/index.js +4 -0
  9. package/dist/core/models/playlist.d.ts +35 -0
  10. package/dist/core/models/playlist.js +1 -0
  11. package/dist/core/models/song.d.ts +52 -0
  12. package/dist/core/models/song.js +1 -0
  13. package/dist/core/modules/album.module.d.ts +82 -0
  14. package/dist/core/modules/album.module.js +74 -0
  15. package/dist/core/modules/artist.module.d.ts +97 -0
  16. package/dist/core/modules/artist.module.js +49 -0
  17. package/dist/core/modules/extras.module.d.ts +385 -0
  18. package/dist/core/modules/extras.module.js +64 -0
  19. package/dist/core/modules/playlist.module.d.ts +79 -0
  20. package/dist/core/modules/playlist.module.js +74 -0
  21. package/dist/core/modules/song.module.d.ts +91 -0
  22. package/dist/core/modules/song.module.js +97 -0
  23. package/dist/helpers/errors.d.ts +25 -0
  24. package/dist/helpers/errors.js +84 -0
  25. package/dist/helpers/experimental/stream-urls/index.d.ts +20 -0
  26. package/dist/helpers/experimental/stream-urls/index.js +33 -0
  27. package/dist/helpers/experimental/stream-urls/stream-urls.edge.d.ts +4 -0
  28. package/dist/helpers/experimental/stream-urls/stream-urls.edge.js +38 -0
  29. package/dist/helpers/experimental/stream-urls/stream-urls.node.d.ts +4 -0
  30. package/dist/helpers/experimental/stream-urls/stream-urls.node.js +27 -0
  31. package/dist/helpers/fetch.d.ts +38 -0
  32. package/dist/helpers/fetch.js +38 -0
  33. package/dist/helpers/utils.d.ts +13 -0
  34. package/dist/helpers/utils.js +58 -0
  35. package/dist/index.d.ts +10 -0
  36. package/dist/index.js +8 -0
  37. package/dist/saavn/common-mapper.d.ts +77 -0
  38. package/dist/saavn/common-mapper.js +348 -0
  39. package/dist/saavn/entities/album.entity.d.ts +151 -0
  40. package/dist/saavn/entities/album.entity.js +25 -0
  41. package/dist/saavn/entities/artist.entity.d.ts +274 -0
  42. package/dist/saavn/entities/artist.entity.js +49 -0
  43. package/dist/saavn/entities/base.d.ts +117 -0
  44. package/dist/saavn/entities/base.js +71 -0
  45. package/dist/saavn/entities/extras.d.ts +102 -0
  46. package/dist/saavn/entities/extras.js +43 -0
  47. package/dist/saavn/entities/index.d.ts +6 -0
  48. package/dist/saavn/entities/index.js +6 -0
  49. package/dist/saavn/entities/playlist.entity.d.ts +143 -0
  50. package/dist/saavn/entities/playlist.entity.js +55 -0
  51. package/dist/saavn/entities/show.entity.d.ts +14 -0
  52. package/dist/saavn/entities/show.entity.js +14 -0
  53. package/dist/saavn/entities/song.entity.d.ts +142 -0
  54. package/dist/saavn/entities/song.entity.js +48 -0
  55. package/dist/saavn/operations/get-details/index.d.ts +755 -0
  56. package/dist/saavn/operations/get-details/index.js +34 -0
  57. package/dist/saavn/operations/get-details/mapper.ops.d.ts +35 -0
  58. package/dist/saavn/operations/get-details/mapper.ops.js +55 -0
  59. package/dist/saavn/operations/get-details/schema.ops.d.ts +706 -0
  60. package/dist/saavn/operations/get-details/schema.ops.js +49 -0
  61. package/dist/saavn/operations/get-reco/index.d.ts +144 -0
  62. package/dist/saavn/operations/get-reco/index.js +19 -0
  63. package/dist/saavn/operations/get-reco/mapper.ops.d.ts +36 -0
  64. package/dist/saavn/operations/get-reco/mapper.ops.js +43 -0
  65. package/dist/saavn/operations/get-reco/schema.ops.d.ts +103 -0
  66. package/dist/saavn/operations/get-reco/schema.ops.js +28 -0
  67. package/dist/saavn/operations/get-trending/index.d.ts +288 -0
  68. package/dist/saavn/operations/get-trending/index.js +24 -0
  69. package/dist/saavn/operations/get-trending/mapper.ops.d.ts +13 -0
  70. package/dist/saavn/operations/get-trending/mapper.ops.js +134 -0
  71. package/dist/saavn/operations/get-trending/schema.ops.d.ts +272 -0
  72. package/dist/saavn/operations/get-trending/schema.ops.js +34 -0
  73. package/dist/saavn/operations/index.d.ts +6 -0
  74. package/dist/saavn/operations/index.js +6 -0
  75. package/dist/saavn/operations/search-results/index.d.ts +790 -0
  76. package/dist/saavn/operations/search-results/index.js +29 -0
  77. package/dist/saavn/operations/search-results/mapper.ops.d.ts +413 -0
  78. package/dist/saavn/operations/search-results/mapper.ops.js +80 -0
  79. package/dist/saavn/operations/search-results/schema.ops.d.ts +366 -0
  80. package/dist/saavn/operations/search-results/schema.ops.js +101 -0
  81. package/dist/saavn/operations/web-api/index.d.ts +604 -0
  82. package/dist/saavn/operations/web-api/index.js +29 -0
  83. package/dist/saavn/operations/web-api/mapper.ops.d.ts +11 -0
  84. package/dist/saavn/operations/web-api/mapper.ops.js +23 -0
  85. package/dist/saavn/operations/web-api/schema.ops.d.ts +582 -0
  86. package/dist/saavn/operations/web-api/schema.ops.js +50 -0
  87. package/dist/saavn/operations/web-radio/index.d.ts +181 -0
  88. package/dist/saavn/operations/web-radio/index.js +19 -0
  89. package/dist/saavn/operations/web-radio/mapper.ops.d.ts +14 -0
  90. package/dist/saavn/operations/web-radio/mapper.ops.js +35 -0
  91. package/dist/saavn/operations/web-radio/schema.ops.d.ts +162 -0
  92. package/dist/saavn/operations/web-radio/schema.ops.js +56 -0
  93. package/dist/saavn/primitives/enums.d.ts +17 -0
  94. package/dist/saavn/primitives/enums.js +4 -0
  95. package/dist/saavn/primitives/string.d.ts +5 -0
  96. package/dist/saavn/primitives/string.js +22 -0
  97. package/dist/saavn/run-operation.d.ts +12 -0
  98. package/dist/saavn/run-operation.js +39 -0
  99. package/dist/schemas/index.d.ts +2188 -0
  100. package/dist/schemas/index.js +14 -0
  101. package/dist/types.d.ts +24 -0
  102. package/dist/types.js +1 -0
  103. package/package.json +82 -0
@@ -0,0 +1,58 @@
1
+ /**
2
+ * General utilities for @saavn-labs/sdk
3
+ * @module utils
4
+ * @internal
5
+ */
6
+ const DEFAULT_USER_AGENTS = [
7
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
8
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
9
+ 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
10
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0',
11
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15',
12
+ ];
13
+ export function pickUserAgent(custom) {
14
+ const agents = Array.isArray(custom) && custom.length > 0 ? custom : DEFAULT_USER_AGENTS;
15
+ return agents[Math.floor(Math.random() * agents.length)];
16
+ }
17
+ /**
18
+ * Extract entity type and token from a JioSaavn share URL
19
+ * @param permaLink - JioSaavn share URL or token
20
+ * @returns Extracted token object or undefined if invalid
21
+ */
22
+ export function extractPermalinkToken(permaLink) {
23
+ if (!permaLink || typeof permaLink !== 'string')
24
+ return undefined;
25
+ let url;
26
+ try {
27
+ url = permaLink.startsWith('http')
28
+ ? new URL(permaLink)
29
+ : new URL(permaLink, 'https://www.jiosaavn.com');
30
+ }
31
+ catch {
32
+ return undefined;
33
+ }
34
+ const segments = url.pathname.split('/').filter(Boolean);
35
+ if (segments.length < 2)
36
+ return undefined;
37
+ const token = segments.at(-1);
38
+ if (!token)
39
+ return undefined;
40
+ const root = segments[0] === 's' ? segments[1] : segments[0];
41
+ switch (root) {
42
+ case 'song':
43
+ return { type: 'song', token };
44
+ case 'album':
45
+ return { type: 'album', token };
46
+ case 'artist':
47
+ return { type: 'artist', token };
48
+ case 'label':
49
+ return { type: 'label', token };
50
+ case 'playlist':
51
+ case 'featured':
52
+ return { type: 'playlist', token };
53
+ case 'show':
54
+ return { type: 'show', token };
55
+ default:
56
+ return undefined;
57
+ }
58
+ }
@@ -0,0 +1,10 @@
1
+ export { ArtistModule as Artist } from './core/modules/artist.module';
2
+ export { AlbumModule as Album } from './core/modules/album.module';
3
+ export { SongModule as Song } from './core/modules/song.module';
4
+ export { PlaylistModule as Playlist } from './core/modules/playlist.module';
5
+ export { ExtrasModule as Extras } from './core/modules/extras.module';
6
+ export { SDKError } from './helpers/errors';
7
+ export type { SDKErrorCode } from './helpers/errors';
8
+ export * from './core/models';
9
+ export { schemas, type Schemas } from './schemas';
10
+ export type { EntityType, ClientConfig, Image, SaavnPermalinkToken, } from './types';
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export { ArtistModule as Artist } from './core/modules/artist.module';
2
+ export { AlbumModule as Album } from './core/modules/album.module';
3
+ export { SongModule as Song } from './core/modules/song.module';
4
+ export { PlaylistModule as Playlist } from './core/modules/playlist.module';
5
+ export { ExtrasModule as Extras } from './core/modules/extras.module';
6
+ export { SDKError } from './helpers/errors';
7
+ export * from './core/models';
8
+ export { schemas } from './schemas';
@@ -0,0 +1,77 @@
1
+ import { z } from 'zod';
2
+ import type { Image } from '../types';
3
+ import type { Album, Artist, Playlist, Song } from '../core/models';
4
+ import type { SaavnArtistBase } from '../saavn/entities/base';
5
+ import type { SaavnAlbumEntity, SaavnArtistEntity, SaavnPlaylistEntity, SaavnSongEntity } from '../saavn/entities';
6
+ import type { SaavnAlbumEdgeCase, SaavnPlaylistEdgeCase } from '../saavn/entities/extras';
7
+ export declare function parseImageUrls(imageUrl?: string): Image[];
8
+ export declare function mapArtistBase(artist: z.infer<typeof SaavnArtistBase>): Artist;
9
+ export declare function mapAlbumEdgeCase(data: z.infer<typeof SaavnAlbumEdgeCase>): Album;
10
+ export declare function mapAlbum(data: z.infer<typeof SaavnAlbumEntity>): Album;
11
+ export declare function mapArtist(data: z.infer<typeof SaavnArtistEntity>): Artist;
12
+ export declare function mapPlaylistEdgeCase(data: z.infer<typeof SaavnPlaylistEdgeCase>): Playlist;
13
+ export declare function mapPlaylist(data: z.infer<typeof SaavnPlaylistEntity>): Playlist;
14
+ export declare function mapSong(song: z.infer<typeof SaavnSongEntity>): Song;
15
+ export declare function mapSearchAllBase(item: any): {
16
+ id: any;
17
+ type: "song";
18
+ title: any;
19
+ subtitle: any;
20
+ description: any;
21
+ url: any;
22
+ images: Image[];
23
+ flags: {
24
+ isExplicit: boolean;
25
+ isRadioPresent?: undefined;
26
+ };
27
+ name?: undefined;
28
+ } | {
29
+ id: any;
30
+ type: "album";
31
+ title: any;
32
+ subtitle: any;
33
+ description: any;
34
+ url: any;
35
+ images: Image[];
36
+ flags: {
37
+ isExplicit: boolean;
38
+ isRadioPresent?: undefined;
39
+ };
40
+ name?: undefined;
41
+ } | {
42
+ id: any;
43
+ type: "artist";
44
+ name: any;
45
+ url: any;
46
+ images: Image[];
47
+ flags: {
48
+ isRadioPresent: any;
49
+ isExplicit?: undefined;
50
+ };
51
+ title?: undefined;
52
+ subtitle?: undefined;
53
+ description?: undefined;
54
+ } | {
55
+ id: any;
56
+ type: "playlist";
57
+ title: any;
58
+ subtitle: any;
59
+ description: any;
60
+ url: any;
61
+ images: Image[];
62
+ flags: {
63
+ isExplicit: boolean;
64
+ isRadioPresent?: undefined;
65
+ };
66
+ name?: undefined;
67
+ } | {
68
+ id: any;
69
+ type: "show";
70
+ title: any;
71
+ subtitle: any;
72
+ description: any;
73
+ url: any;
74
+ images: Image[];
75
+ flags?: undefined;
76
+ name?: undefined;
77
+ } | null;
@@ -0,0 +1,348 @@
1
+ import { z } from 'zod';
2
+ export function parseImageUrls(imageUrl) {
3
+ if (!imageUrl)
4
+ return [];
5
+ const resolutions = [
6
+ '50x50',
7
+ '150x150',
8
+ '500x500',
9
+ ];
10
+ return resolutions.map((resolution) => ({
11
+ url: imageUrl.replace(/150x150/, resolution),
12
+ resolution,
13
+ }));
14
+ }
15
+ export function mapArtistBase(artist) {
16
+ return {
17
+ id: artist.id,
18
+ type: 'artist',
19
+ name: artist.name,
20
+ url: artist.perma_url,
21
+ images: parseImageUrls(artist.image),
22
+ };
23
+ }
24
+ function parseBio(bio) {
25
+ if (typeof bio !== 'string')
26
+ return undefined;
27
+ const trimmed = bio.trim();
28
+ if (!trimmed)
29
+ return undefined;
30
+ try {
31
+ const parsed = JSON.parse(trimmed);
32
+ if (!Array.isArray(parsed))
33
+ return undefined;
34
+ const items = parsed
35
+ .map((item) => {
36
+ if (!item || typeof item !== 'object')
37
+ return null;
38
+ const text = typeof item.text === 'string' && item.text.trim()
39
+ ? item.text.trim()
40
+ : null;
41
+ if (!text)
42
+ return null;
43
+ const title = typeof item.title === 'string' && item.title.trim()
44
+ ? item.title.trim()
45
+ : undefined;
46
+ const sequence = typeof item.sequence === 'number' ? item.sequence : undefined;
47
+ return { text, title, sequence };
48
+ })
49
+ .filter((x) => x !== null);
50
+ return items.length > 0 ? items : undefined;
51
+ }
52
+ catch {
53
+ return undefined;
54
+ }
55
+ }
56
+ export function mapAlbumEdgeCase(data) {
57
+ return {
58
+ id: data.id,
59
+ type: 'album',
60
+ title: data.title,
61
+ subtitle: data.subtitle,
62
+ description: data.header_desc,
63
+ url: data.perma_url,
64
+ images: parseImageUrls(data.image),
65
+ language: data.language,
66
+ year: parseInt(data.year, 10),
67
+ stats: {
68
+ playCount: parseInt(data.play_count, 10),
69
+ songCount: data.more_info?.song_count
70
+ ? parseInt(data.more_info.song_count, 10)
71
+ : undefined,
72
+ },
73
+ flags: {
74
+ isExplicit: data.explicit_content === '1',
75
+ },
76
+ artists: {
77
+ primary: data.more_info?.artistMap?.primary_artists?.map(mapArtistBase),
78
+ featured: data.more_info?.artistMap?.featured_artists?.map(mapArtistBase),
79
+ all: data.more_info?.artistMap?.artists?.map(mapArtistBase),
80
+ },
81
+ };
82
+ }
83
+ export function mapAlbum(data) {
84
+ return {
85
+ id: data.id,
86
+ type: 'album',
87
+ title: data.title,
88
+ subtitle: data.subtitle,
89
+ description: data.header_desc,
90
+ url: data.perma_url,
91
+ images: parseImageUrls(data.image),
92
+ language: data.language,
93
+ year: parseInt(data.year, 10),
94
+ stats: {
95
+ playCount: parseInt(data.play_count, 10),
96
+ songCount: parseInt(data.more_info.song_count, 10),
97
+ },
98
+ flags: {
99
+ isExplicit: data.explicit_content === '1',
100
+ isDolby: data.more_info.is_dolby_content,
101
+ },
102
+ artists: {
103
+ primary: data.more_info.artistMap.primary_artists?.map(mapArtistBase),
104
+ featured: data.more_info.artistMap.featured_artists?.map(mapArtistBase),
105
+ all: data.more_info.artistMap.artists?.map(mapArtistBase),
106
+ },
107
+ songs: data.list?.map(mapSong),
108
+ meta: {
109
+ copyright: data.more_info?.copyright_text,
110
+ labelUrl: data.more_info?.label_url,
111
+ },
112
+ };
113
+ }
114
+ export function mapArtist(data) {
115
+ return {
116
+ id: data.artistId,
117
+ type: 'artist',
118
+ name: data.name,
119
+ subtitle: data.subtitle,
120
+ url: data.wiki ? data.wiki : '',
121
+ images: parseImageUrls(data.image),
122
+ stats: {
123
+ followerCount: data.follower_count
124
+ ? parseInt(data.follower_count, 10)
125
+ : undefined,
126
+ fanCount: data.fan_count ? parseInt(data.fan_count, 10) : undefined,
127
+ },
128
+ flags: {
129
+ isVerified: data.isVerified,
130
+ isRadioPresent: data.isRadioPresent,
131
+ },
132
+ language: {
133
+ primary: data.dominantLanguage,
134
+ available: data.availableLanguages,
135
+ },
136
+ profile: {
137
+ bio: parseBio(data.bio),
138
+ dob: data.dob || undefined,
139
+ },
140
+ links: {
141
+ saavn: {
142
+ overview: data.urls?.overview,
143
+ albums: data.urls?.albums,
144
+ songs: data.urls?.songs,
145
+ bio: data.urls?.bio,
146
+ comments: data.urls?.comments,
147
+ },
148
+ social: {
149
+ wiki: data.wiki || undefined,
150
+ facebook: data.fb || undefined,
151
+ twitter: data.twitter || undefined,
152
+ },
153
+ },
154
+ songs: {
155
+ top: data.topSongs?.map(mapSong),
156
+ },
157
+ albums: {
158
+ top: data.topAlbums?.map(mapAlbumEdgeCase),
159
+ singles: data.singles?.map(mapAlbumEdgeCase),
160
+ latest: data.latest_release?.map((album) => mapAlbumEdgeCase(album)),
161
+ },
162
+ playlists: {
163
+ dedicated: data.dedicated_artist_playlist?.map(mapPlaylistEdgeCase),
164
+ featured: data.featured_artist_playlist?.map(mapPlaylistEdgeCase),
165
+ },
166
+ };
167
+ }
168
+ export function mapPlaylistEdgeCase(data) {
169
+ return {
170
+ id: data.id,
171
+ type: 'playlist',
172
+ title: data.title,
173
+ subtitle: data.subtitle,
174
+ url: data.perma_url,
175
+ images: parseImageUrls(data.image),
176
+ stats: {
177
+ followerCount: data.more_info?.follower_count
178
+ ? parseInt(data.more_info.follower_count, 10)
179
+ : undefined,
180
+ fanCount: data.more_info?.fan_count
181
+ ? parseInt(data.more_info.fan_count, 10)
182
+ : undefined,
183
+ },
184
+ flags: {
185
+ isExplicit: data.explicit_content === '1',
186
+ isDolby: data.more_info?.is_dolby_content ?? undefined,
187
+ },
188
+ meta: {
189
+ language: data.more_info?.language,
190
+ },
191
+ };
192
+ }
193
+ export function mapPlaylist(data) {
194
+ return {
195
+ id: data.id,
196
+ type: 'playlist',
197
+ title: data.title,
198
+ subtitle: data.subtitle,
199
+ description: data.header_desc,
200
+ url: data.perma_url,
201
+ images: parseImageUrls(data.image),
202
+ stats: {
203
+ songCount: data.list_count ? parseInt(data.list_count, 10) : undefined,
204
+ followerCount: data.more_info?.follower_count
205
+ ? parseInt(data.more_info.follower_count, 10)
206
+ : undefined,
207
+ fanCount: data.more_info?.fan_count
208
+ ? parseInt(data.more_info.fan_count, 10)
209
+ : undefined,
210
+ },
211
+ flags: {
212
+ isExplicit: data.explicit_content === '1',
213
+ isDolby: data.more_info?.is_dolby_content,
214
+ isFollowed: data.more_info?.is_followed === 'true',
215
+ },
216
+ songs: data.list?.map(mapSong),
217
+ artists: data.more_info?.artists?.map(mapArtistBase),
218
+ owner: {
219
+ id: data.more_info?.uid,
220
+ name: [data.more_info?.firstname, data.more_info?.lastname]
221
+ .filter(Boolean)
222
+ .join(' ') || undefined,
223
+ },
224
+ meta: {
225
+ playlistType: data.more_info?.playlist_type,
226
+ language: data.language,
227
+ lastUpdated: data.more_info?.last_updated
228
+ ? parseInt(data.more_info.last_updated, 10)
229
+ : undefined,
230
+ },
231
+ };
232
+ }
233
+ export function mapSong(song) {
234
+ return {
235
+ id: song.id,
236
+ type: 'song',
237
+ title: song.title,
238
+ subtitle: song.subtitle,
239
+ url: song.perma_url,
240
+ images: parseImageUrls(song.image),
241
+ album: {
242
+ id: song.more_info?.album_id,
243
+ title: song.more_info?.album,
244
+ url: song.more_info?.album_url,
245
+ },
246
+ artists: {
247
+ primary: song.more_info.artistMap.primary_artists?.map(mapArtistBase),
248
+ featured: song.more_info.artistMap.featured_artists?.map(mapArtistBase),
249
+ all: song.more_info.artistMap.artists?.map(mapArtistBase),
250
+ },
251
+ duration: parseInt(song.more_info.duration, 10),
252
+ language: song.language,
253
+ year: parseInt(song.year, 10),
254
+ stats: {
255
+ playCount: typeof song.play_count === 'string'
256
+ ? parseInt(song.play_count, 10)
257
+ : song.play_count,
258
+ },
259
+ flags: {
260
+ isExplicit: song.explicit_content === '1',
261
+ hasLyrics: song.more_info?.has_lyrics === 'true',
262
+ isDolby: song.more_info.is_dolby_content,
263
+ },
264
+ lyrics: {
265
+ id: song.more_info?.lyrics_id,
266
+ snippet: song.more_info?.lyrics_snippet,
267
+ },
268
+ media: {
269
+ encryptedUrl: song.more_info?.encrypted_media_url,
270
+ previewUrl: song.more_info?.vlink,
271
+ },
272
+ meta: {
273
+ copyright: song.more_info?.copyright_text,
274
+ label: {
275
+ id: song.more_info?.label_id || undefined,
276
+ name: song.more_info?.label,
277
+ url: song.more_info?.label_url,
278
+ },
279
+ releaseDate: song.more_info?.release_date || undefined,
280
+ },
281
+ };
282
+ }
283
+ export function mapSearchAllBase(item) {
284
+ switch (item.type) {
285
+ case 'song':
286
+ return {
287
+ id: item.id,
288
+ type: 'song',
289
+ title: item.title,
290
+ subtitle: item.subtitle,
291
+ description: item.description,
292
+ url: item.perma_url,
293
+ images: parseImageUrls(item.image),
294
+ flags: {
295
+ isExplicit: item.explicit_content === '1',
296
+ },
297
+ };
298
+ case 'album':
299
+ return {
300
+ id: item.id,
301
+ type: 'album',
302
+ title: item.title,
303
+ subtitle: item.subtitle,
304
+ description: item.description,
305
+ url: item.perma_url,
306
+ images: parseImageUrls(item.image),
307
+ flags: {
308
+ isExplicit: item.explicit_content === '1',
309
+ },
310
+ };
311
+ case 'artist':
312
+ return {
313
+ id: item.id,
314
+ type: 'artist',
315
+ name: item.title,
316
+ url: item.perma_url,
317
+ images: parseImageUrls(item.image),
318
+ flags: {
319
+ isRadioPresent: item.isRadioPresent,
320
+ },
321
+ };
322
+ case 'playlist':
323
+ return {
324
+ id: item.id,
325
+ type: 'playlist',
326
+ title: item.title,
327
+ subtitle: item.subtitle,
328
+ description: item.description,
329
+ url: item.perma_url,
330
+ images: parseImageUrls(item.image),
331
+ flags: {
332
+ isExplicit: item.explicit_content === '1',
333
+ },
334
+ };
335
+ case 'show':
336
+ return {
337
+ id: item.id,
338
+ type: 'show',
339
+ title: item.title,
340
+ subtitle: item.subtitle,
341
+ description: item.description,
342
+ url: item.perma_url,
343
+ images: parseImageUrls(item.image),
344
+ };
345
+ default:
346
+ return null;
347
+ }
348
+ }
@@ -0,0 +1,151 @@
1
+ import { z } from 'zod';
2
+ export declare const SaavnAlbumEntity: z.ZodLazy<z.ZodObject<{
3
+ id: z.ZodString;
4
+ title: z.ZodString;
5
+ subtitle: z.ZodString;
6
+ type: z.ZodLiteral<"album">;
7
+ image: z.ZodString;
8
+ perma_url: z.ZodString;
9
+ explicit_content: z.ZodString;
10
+ header_desc: z.ZodString;
11
+ play_count: z.ZodString;
12
+ language: z.ZodString;
13
+ year: z.ZodString;
14
+ list_count: z.ZodString;
15
+ list_type: z.ZodLiteral<"song">;
16
+ list: z.ZodArray<z.ZodLazy<z.ZodObject<{
17
+ id: z.ZodString;
18
+ title: z.ZodString;
19
+ subtitle: z.ZodString;
20
+ type: z.ZodLiteral<"song">;
21
+ perma_url: z.ZodString;
22
+ image: z.ZodString;
23
+ explicit_content: z.ZodString;
24
+ header_desc: z.ZodString;
25
+ language: z.ZodString;
26
+ year: z.ZodString;
27
+ play_count: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
28
+ more_info: z.ZodObject<{
29
+ music: z.ZodString;
30
+ album_id: z.ZodString;
31
+ album: z.ZodString;
32
+ label: z.ZodString;
33
+ label_id: z.ZodNullable<z.ZodString>;
34
+ origin: z.ZodString;
35
+ is_dolby_content: z.ZodBoolean;
36
+ encrypted_media_url: z.ZodString;
37
+ encrypted_drm_media_url: z.ZodString;
38
+ album_url: z.ZodString;
39
+ duration: z.ZodString;
40
+ has_lyrics: z.ZodString;
41
+ lyrics_snippet: z.ZodString;
42
+ lyrics_id: z.ZodOptional<z.ZodString>;
43
+ copyright_text: z.ZodString;
44
+ release_date: z.ZodNullable<z.ZodString>;
45
+ label_url: z.ZodOptional<z.ZodString>;
46
+ vcode: z.ZodOptional<z.ZodString>;
47
+ vlink: z.ZodOptional<z.ZodString>;
48
+ artistMap: z.ZodLazy<z.ZodObject<{
49
+ primary_artists: z.ZodArray<z.ZodObject<{
50
+ id: z.ZodString;
51
+ name: z.ZodString;
52
+ role: z.ZodString;
53
+ image: z.ZodString;
54
+ type: z.ZodLiteral<"artist">;
55
+ perma_url: z.ZodString;
56
+ }, z.core.$loose>>;
57
+ featured_artists: z.ZodArray<z.ZodObject<{
58
+ id: z.ZodString;
59
+ name: z.ZodString;
60
+ role: z.ZodString;
61
+ image: z.ZodString;
62
+ type: z.ZodLiteral<"artist">;
63
+ perma_url: z.ZodString;
64
+ }, z.core.$loose>>;
65
+ artists: z.ZodArray<z.ZodObject<{
66
+ id: z.ZodString;
67
+ name: z.ZodString;
68
+ role: z.ZodString;
69
+ image: z.ZodString;
70
+ type: z.ZodLiteral<"artist">;
71
+ perma_url: z.ZodString;
72
+ }, z.core.$loose>>;
73
+ }, z.core.$loose>>;
74
+ }, z.core.$loose>;
75
+ }, z.core.$loose>>>;
76
+ more_info: z.ZodObject<{
77
+ song_count: z.ZodString;
78
+ copyright_text: z.ZodString;
79
+ is_dolby_content: z.ZodBoolean;
80
+ label_url: z.ZodString;
81
+ artistMap: z.ZodObject<{
82
+ primary_artists: z.ZodArray<z.ZodObject<{
83
+ id: z.ZodString;
84
+ name: z.ZodString;
85
+ role: z.ZodString;
86
+ image: z.ZodString;
87
+ type: z.ZodLiteral<"artist">;
88
+ perma_url: z.ZodString;
89
+ }, z.core.$loose>>;
90
+ featured_artists: z.ZodArray<z.ZodObject<{
91
+ id: z.ZodString;
92
+ name: z.ZodString;
93
+ role: z.ZodString;
94
+ image: z.ZodString;
95
+ type: z.ZodLiteral<"artist">;
96
+ perma_url: z.ZodString;
97
+ }, z.core.$loose>>;
98
+ artists: z.ZodArray<z.ZodObject<{
99
+ id: z.ZodString;
100
+ name: z.ZodString;
101
+ role: z.ZodString;
102
+ image: z.ZodString;
103
+ type: z.ZodLiteral<"artist">;
104
+ perma_url: z.ZodString;
105
+ }, z.core.$loose>>;
106
+ }, z.core.$loose>;
107
+ }, z.core.$loose>;
108
+ }, z.core.$loose>>;
109
+ export declare const SaavnTrendingAlbum: z.ZodObject<{
110
+ id: z.ZodString;
111
+ title: z.ZodString;
112
+ subtitle: z.ZodString;
113
+ header_desc: z.ZodString;
114
+ perma_url: z.ZodString;
115
+ image: z.ZodString;
116
+ language: z.ZodString;
117
+ year: z.ZodString;
118
+ play_count: z.ZodString;
119
+ explicit_content: z.ZodString;
120
+ type: z.ZodLiteral<"album">;
121
+ more_info: z.ZodObject<{
122
+ release_date: z.ZodString;
123
+ song_count: z.ZodString;
124
+ artistMap: z.ZodObject<{
125
+ primary_artists: z.ZodArray<z.ZodObject<{
126
+ id: z.ZodString;
127
+ name: z.ZodString;
128
+ role: z.ZodString;
129
+ image: z.ZodString;
130
+ type: z.ZodLiteral<"artist">;
131
+ perma_url: z.ZodString;
132
+ }, z.core.$loose>>;
133
+ featured_artists: z.ZodArray<z.ZodObject<{
134
+ id: z.ZodString;
135
+ name: z.ZodString;
136
+ role: z.ZodString;
137
+ image: z.ZodString;
138
+ type: z.ZodLiteral<"artist">;
139
+ perma_url: z.ZodString;
140
+ }, z.core.$loose>>;
141
+ artists: z.ZodArray<z.ZodObject<{
142
+ id: z.ZodString;
143
+ name: z.ZodString;
144
+ role: z.ZodString;
145
+ image: z.ZodString;
146
+ type: z.ZodLiteral<"artist">;
147
+ perma_url: z.ZodString;
148
+ }, z.core.$loose>>;
149
+ }, z.core.$loose>;
150
+ }, z.core.$loose>;
151
+ }, z.core.$loose>;
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+ import { SaavnAlbumBase, SaavnArtistMap, SaavnTrendingBase } from './base';
3
+ import { SaavnSongEntity } from './song.entity';
4
+ export const SaavnAlbumEntity = z.lazy(() => SaavnAlbumBase.extend({
5
+ language: z.string(),
6
+ year: z.string(),
7
+ list_count: z.string(),
8
+ list_type: z.literal('song'),
9
+ list: z.array(z.lazy(() => SaavnSongEntity)),
10
+ more_info: z.looseObject({
11
+ song_count: z.string(),
12
+ copyright_text: z.string(),
13
+ is_dolby_content: z.boolean(),
14
+ label_url: z.string(),
15
+ artistMap: SaavnArtistMap,
16
+ }),
17
+ }));
18
+ export const SaavnTrendingAlbum = SaavnTrendingBase.extend({
19
+ type: z.literal('album'),
20
+ more_info: z.looseObject({
21
+ release_date: z.string(),
22
+ song_count: z.string(),
23
+ artistMap: SaavnArtistMap,
24
+ }),
25
+ });