@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,74 @@
1
+ import { SaavnGetDetails, SaavnGetReco, SaavnGetTrending, SaavnSearchResults, SaavnWebAPI, } from '../../saavn/operations';
2
+ import { runOperation } from '../../saavn/run-operation';
3
+ import { extractPermalinkToken } from '../../helpers/utils';
4
+ import { SDKError } from '../../helpers/errors';
5
+ /**
6
+ * Fetch an album by Saavn ID.
7
+ *
8
+ * @param params - Parameters object
9
+ * @param params.albumId - Saavn album ID
10
+ * @returns Normalized album object
11
+ */
12
+ function getById({ albumId }) {
13
+ return runOperation(SaavnGetDetails.album, { albumid: albumId });
14
+ }
15
+ /**
16
+ * Fetch an album by permalink.
17
+ *
18
+ * @param params - Parameters object
19
+ * @param params.permalink - Album permalink string
20
+ * @returns Normalized album object
21
+ */
22
+ function getByPermalink({ permalink }) {
23
+ const { token, type } = extractPermalinkToken(permalink) ?? {};
24
+ if (!token || type !== 'album') {
25
+ throw new SDKError('INVALID_PARAMS', 'Invalid permalink provided');
26
+ }
27
+ return runOperation(SaavnWebAPI.album, { token, type: 'album' });
28
+ }
29
+ /**
30
+ * Fetch album recommendations by Saavn ID.
31
+ *
32
+ * @param params - Parameters object
33
+ * @param params.albumId - Saavn album ID
34
+ * @returns List of recommended albums
35
+ */
36
+ function getRecommendations({ albumId }) {
37
+ return runOperation(SaavnGetReco.albums, { albumid: albumId });
38
+ }
39
+ /**
40
+ * Get trending albums by language.
41
+ *
42
+ * @param params - Parameters object
43
+ * @param params.language - Language code
44
+ * @returns List of trending albums
45
+ */
46
+ function getTrending({ language }) {
47
+ return runOperation(SaavnGetTrending.albums, {
48
+ entity_language: language,
49
+ entity_type: 'album',
50
+ });
51
+ }
52
+ /**
53
+ * Search for albums by query.
54
+ *
55
+ * @param params - Parameters object
56
+ * @param params.query - Search query string
57
+ * @param params.limit - Number of results to return (default: 10)
58
+ * @param params.offset - Offset for pagination (default: 1)
59
+ * @returns List of matching albums
60
+ */
61
+ function search({ query, limit = 20, offset = 1, }) {
62
+ return runOperation(SaavnSearchResults.albums, {
63
+ q: query,
64
+ p: String(offset),
65
+ n: String(limit),
66
+ });
67
+ }
68
+ export const AlbumModule = {
69
+ getById,
70
+ getByPermalink,
71
+ getRecommendations,
72
+ getTrending,
73
+ search,
74
+ };
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Fetch an artist by Saavn ID.
3
+ *
4
+ * @param params - Parameters object
5
+ * @param params.artistId - Saavn artist ID
6
+ * @returns Normalized artist object
7
+ */
8
+ declare function getById({ artistId }: {
9
+ artistId: string;
10
+ }): Promise<import("../models").Artist>;
11
+ /**
12
+ * Fetch an artist by permalink.
13
+ *
14
+ * @param params - Parameters object
15
+ * @param params.permalink - Artist permalink string
16
+ * @returns Normalized artist object
17
+ */
18
+ declare function getByPermalink({ permalink }: {
19
+ permalink: string;
20
+ }): Promise<import("../models").Artist>;
21
+ /**
22
+ * Search for artists by query.
23
+ *
24
+ * @param params - Parameters object
25
+ * @param params.query - Search query string
26
+ * @param params.limit - Number of results to return (default: 10)
27
+ * @param params.offset - Offset for pagination (default: 1)
28
+ * @returns List of matching artists
29
+ */
30
+ declare function search({ query, limit, offset, }: {
31
+ query: string;
32
+ limit?: number;
33
+ offset?: number;
34
+ }): Promise<{
35
+ total: number;
36
+ start: number;
37
+ results: {
38
+ flags: {
39
+ isRadioPresent: boolean;
40
+ isFollowed: boolean;
41
+ };
42
+ id: string;
43
+ type: "artist";
44
+ name: string;
45
+ subtitle?: string;
46
+ url: string;
47
+ images: import("../..").Image[];
48
+ stats?: {
49
+ followerCount?: number;
50
+ fanCount?: number;
51
+ };
52
+ language?: {
53
+ primary?: string;
54
+ available?: string[];
55
+ };
56
+ profile?: {
57
+ bio?: import("../models").BioSection[];
58
+ dob?: string;
59
+ };
60
+ links?: {
61
+ saavn?: {
62
+ overview?: string;
63
+ albums?: string;
64
+ songs?: string;
65
+ bio?: string;
66
+ comments?: string;
67
+ };
68
+ social?: {
69
+ wiki?: string;
70
+ facebook?: string;
71
+ twitter?: string;
72
+ };
73
+ };
74
+ songs?: {
75
+ top?: import("../models").Song[];
76
+ latest?: import("../models").Song[];
77
+ };
78
+ albums?: {
79
+ top?: import("../models").Album[];
80
+ singles?: import("../models").Album[];
81
+ latest?: import("../models").Album[];
82
+ };
83
+ playlists?: {
84
+ dedicated?: import("../models").Playlist[];
85
+ featured?: import("../models").Playlist[];
86
+ };
87
+ related?: {
88
+ similar?: import("../models").Artist[];
89
+ };
90
+ }[];
91
+ }>;
92
+ export declare const ArtistModule: {
93
+ getById: typeof getById;
94
+ getByPermalink: typeof getByPermalink;
95
+ search: typeof search;
96
+ };
97
+ export {};
@@ -0,0 +1,49 @@
1
+ import { SaavnGetDetails, SaavnSearchResults, SaavnWebAPI, } from '../../saavn/operations';
2
+ import { runOperation } from '../../saavn/run-operation';
3
+ import { extractPermalinkToken } from '../../helpers/utils';
4
+ import { SDKError } from '../../helpers/errors';
5
+ /**
6
+ * Fetch an artist by Saavn ID.
7
+ *
8
+ * @param params - Parameters object
9
+ * @param params.artistId - Saavn artist ID
10
+ * @returns Normalized artist object
11
+ */
12
+ function getById({ artistId }) {
13
+ return runOperation(SaavnGetDetails.artist, { artistId });
14
+ }
15
+ /**
16
+ * Fetch an artist by permalink.
17
+ *
18
+ * @param params - Parameters object
19
+ * @param params.permalink - Artist permalink string
20
+ * @returns Normalized artist object
21
+ */
22
+ function getByPermalink({ permalink }) {
23
+ const { token, type } = extractPermalinkToken(permalink) ?? {};
24
+ if (!token || type !== 'artist') {
25
+ throw new SDKError('INVALID_PARAMS', 'Invalid permalink provided');
26
+ }
27
+ return runOperation(SaavnWebAPI.artist, { token, type: 'artist' });
28
+ }
29
+ /**
30
+ * Search for artists by query.
31
+ *
32
+ * @param params - Parameters object
33
+ * @param params.query - Search query string
34
+ * @param params.limit - Number of results to return (default: 10)
35
+ * @param params.offset - Offset for pagination (default: 1)
36
+ * @returns List of matching artists
37
+ */
38
+ function search({ query, limit = 20, offset = 1, }) {
39
+ return runOperation(SaavnSearchResults.artists, {
40
+ q: query,
41
+ p: String(offset),
42
+ n: String(limit),
43
+ });
44
+ }
45
+ export const ArtistModule = {
46
+ getById,
47
+ getByPermalink,
48
+ search,
49
+ };
@@ -0,0 +1,385 @@
1
+ export declare function stringArrayToJSONStringArray(value: readonly string[]): string;
2
+ /**
3
+ * Search all entities by query.
4
+ *
5
+ * @param params - Parameters object
6
+ * @param params.query - Search query string
7
+ * @returns List of matching entities
8
+ */
9
+ declare function searchAll({ query }: {
10
+ query: string;
11
+ }): Promise<{
12
+ albums: {
13
+ position: number;
14
+ data: ({
15
+ id: any;
16
+ type: "song";
17
+ title: any;
18
+ subtitle: any;
19
+ description: any;
20
+ url: any;
21
+ images: import("../..").Image[];
22
+ flags: {
23
+ isExplicit: boolean;
24
+ isRadioPresent?: undefined;
25
+ };
26
+ name?: undefined;
27
+ } | {
28
+ id: any;
29
+ type: "album";
30
+ title: any;
31
+ subtitle: any;
32
+ description: any;
33
+ url: any;
34
+ images: import("../..").Image[];
35
+ flags: {
36
+ isExplicit: boolean;
37
+ isRadioPresent?: undefined;
38
+ };
39
+ name?: undefined;
40
+ } | {
41
+ id: any;
42
+ type: "artist";
43
+ name: any;
44
+ url: any;
45
+ images: import("../..").Image[];
46
+ flags: {
47
+ isRadioPresent: any;
48
+ isExplicit?: undefined;
49
+ };
50
+ title?: undefined;
51
+ subtitle?: undefined;
52
+ description?: undefined;
53
+ } | {
54
+ id: any;
55
+ type: "playlist";
56
+ title: any;
57
+ subtitle: any;
58
+ description: any;
59
+ url: any;
60
+ images: import("../..").Image[];
61
+ flags: {
62
+ isExplicit: boolean;
63
+ isRadioPresent?: undefined;
64
+ };
65
+ name?: undefined;
66
+ } | {
67
+ id: any;
68
+ type: "show";
69
+ title: any;
70
+ subtitle: any;
71
+ description: any;
72
+ url: any;
73
+ images: import("../..").Image[];
74
+ flags?: undefined;
75
+ name?: undefined;
76
+ } | null)[];
77
+ };
78
+ artists: {
79
+ position: number;
80
+ data: ({
81
+ id: any;
82
+ type: "song";
83
+ title: any;
84
+ subtitle: any;
85
+ description: any;
86
+ url: any;
87
+ images: import("../..").Image[];
88
+ flags: {
89
+ isExplicit: boolean;
90
+ isRadioPresent?: undefined;
91
+ };
92
+ name?: undefined;
93
+ } | {
94
+ id: any;
95
+ type: "album";
96
+ title: any;
97
+ subtitle: any;
98
+ description: any;
99
+ url: any;
100
+ images: import("../..").Image[];
101
+ flags: {
102
+ isExplicit: boolean;
103
+ isRadioPresent?: undefined;
104
+ };
105
+ name?: undefined;
106
+ } | {
107
+ id: any;
108
+ type: "artist";
109
+ name: any;
110
+ url: any;
111
+ images: import("../..").Image[];
112
+ flags: {
113
+ isRadioPresent: any;
114
+ isExplicit?: undefined;
115
+ };
116
+ title?: undefined;
117
+ subtitle?: undefined;
118
+ description?: undefined;
119
+ } | {
120
+ id: any;
121
+ type: "playlist";
122
+ title: any;
123
+ subtitle: any;
124
+ description: any;
125
+ url: any;
126
+ images: import("../..").Image[];
127
+ flags: {
128
+ isExplicit: boolean;
129
+ isRadioPresent?: undefined;
130
+ };
131
+ name?: undefined;
132
+ } | {
133
+ id: any;
134
+ type: "show";
135
+ title: any;
136
+ subtitle: any;
137
+ description: any;
138
+ url: any;
139
+ images: import("../..").Image[];
140
+ flags?: undefined;
141
+ name?: undefined;
142
+ } | null)[];
143
+ };
144
+ playlists: {
145
+ position: number;
146
+ data: ({
147
+ id: any;
148
+ type: "song";
149
+ title: any;
150
+ subtitle: any;
151
+ description: any;
152
+ url: any;
153
+ images: import("../..").Image[];
154
+ flags: {
155
+ isExplicit: boolean;
156
+ isRadioPresent?: undefined;
157
+ };
158
+ name?: undefined;
159
+ } | {
160
+ id: any;
161
+ type: "album";
162
+ title: any;
163
+ subtitle: any;
164
+ description: any;
165
+ url: any;
166
+ images: import("../..").Image[];
167
+ flags: {
168
+ isExplicit: boolean;
169
+ isRadioPresent?: undefined;
170
+ };
171
+ name?: undefined;
172
+ } | {
173
+ id: any;
174
+ type: "artist";
175
+ name: any;
176
+ url: any;
177
+ images: import("../..").Image[];
178
+ flags: {
179
+ isRadioPresent: any;
180
+ isExplicit?: undefined;
181
+ };
182
+ title?: undefined;
183
+ subtitle?: undefined;
184
+ description?: undefined;
185
+ } | {
186
+ id: any;
187
+ type: "playlist";
188
+ title: any;
189
+ subtitle: any;
190
+ description: any;
191
+ url: any;
192
+ images: import("../..").Image[];
193
+ flags: {
194
+ isExplicit: boolean;
195
+ isRadioPresent?: undefined;
196
+ };
197
+ name?: undefined;
198
+ } | {
199
+ id: any;
200
+ type: "show";
201
+ title: any;
202
+ subtitle: any;
203
+ description: any;
204
+ url: any;
205
+ images: import("../..").Image[];
206
+ flags?: undefined;
207
+ name?: undefined;
208
+ } | null)[];
209
+ };
210
+ shows: {
211
+ position: number;
212
+ data: ({
213
+ id: any;
214
+ type: "song";
215
+ title: any;
216
+ subtitle: any;
217
+ description: any;
218
+ url: any;
219
+ images: import("../..").Image[];
220
+ flags: {
221
+ isExplicit: boolean;
222
+ isRadioPresent?: undefined;
223
+ };
224
+ name?: undefined;
225
+ } | {
226
+ id: any;
227
+ type: "album";
228
+ title: any;
229
+ subtitle: any;
230
+ description: any;
231
+ url: any;
232
+ images: import("../..").Image[];
233
+ flags: {
234
+ isExplicit: boolean;
235
+ isRadioPresent?: undefined;
236
+ };
237
+ name?: undefined;
238
+ } | {
239
+ id: any;
240
+ type: "artist";
241
+ name: any;
242
+ url: any;
243
+ images: import("../..").Image[];
244
+ flags: {
245
+ isRadioPresent: any;
246
+ isExplicit?: undefined;
247
+ };
248
+ title?: undefined;
249
+ subtitle?: undefined;
250
+ description?: undefined;
251
+ } | {
252
+ id: any;
253
+ type: "playlist";
254
+ title: any;
255
+ subtitle: any;
256
+ description: any;
257
+ url: any;
258
+ images: import("../..").Image[];
259
+ flags: {
260
+ isExplicit: boolean;
261
+ isRadioPresent?: undefined;
262
+ };
263
+ name?: undefined;
264
+ } | {
265
+ id: any;
266
+ type: "show";
267
+ title: any;
268
+ subtitle: any;
269
+ description: any;
270
+ url: any;
271
+ images: import("../..").Image[];
272
+ flags?: undefined;
273
+ name?: undefined;
274
+ } | null)[];
275
+ };
276
+ songs: {
277
+ position: number;
278
+ data: ({
279
+ id: any;
280
+ type: "song";
281
+ title: any;
282
+ subtitle: any;
283
+ description: any;
284
+ url: any;
285
+ images: import("../..").Image[];
286
+ flags: {
287
+ isExplicit: boolean;
288
+ isRadioPresent?: undefined;
289
+ };
290
+ name?: undefined;
291
+ } | {
292
+ id: any;
293
+ type: "album";
294
+ title: any;
295
+ subtitle: any;
296
+ description: any;
297
+ url: any;
298
+ images: import("../..").Image[];
299
+ flags: {
300
+ isExplicit: boolean;
301
+ isRadioPresent?: undefined;
302
+ };
303
+ name?: undefined;
304
+ } | {
305
+ id: any;
306
+ type: "artist";
307
+ name: any;
308
+ url: any;
309
+ images: import("../..").Image[];
310
+ flags: {
311
+ isRadioPresent: any;
312
+ isExplicit?: undefined;
313
+ };
314
+ title?: undefined;
315
+ subtitle?: undefined;
316
+ description?: undefined;
317
+ } | {
318
+ id: any;
319
+ type: "playlist";
320
+ title: any;
321
+ subtitle: any;
322
+ description: any;
323
+ url: any;
324
+ images: import("../..").Image[];
325
+ flags: {
326
+ isExplicit: boolean;
327
+ isRadioPresent?: undefined;
328
+ };
329
+ name?: undefined;
330
+ } | {
331
+ id: any;
332
+ type: "show";
333
+ title: any;
334
+ subtitle: any;
335
+ description: any;
336
+ url: any;
337
+ images: import("../..").Image[];
338
+ flags?: undefined;
339
+ name?: undefined;
340
+ } | null)[];
341
+ };
342
+ topquery: {
343
+ position: any;
344
+ data: any;
345
+ };
346
+ }>;
347
+ /**
348
+ * Get trending entities.
349
+ *
350
+ * @returns List of trending entities
351
+ */
352
+ declare function getTrendingAll(): Promise<(import("../models").Album | import("../models").Song | import("../models").Playlist)[]>;
353
+ /**
354
+ * Create a station for an entity.
355
+ *
356
+ * @param params - Parameters object
357
+ * @param params.songIds - Array of song IDs
358
+ * @returns Station object
359
+ */
360
+ declare function createEntityStation({ songIds }: {
361
+ songIds: string[];
362
+ }): Promise<{
363
+ stationId: string;
364
+ }>;
365
+ /**
366
+ * Create a featured station by language and name.
367
+ *
368
+ * @param params - Parameters object
369
+ * @param params.language - Language code
370
+ * @param params.name - Station name
371
+ * @returns Station object
372
+ */
373
+ declare function createFeaturedStation({ language, name, }: {
374
+ language: string;
375
+ name: string;
376
+ }): Promise<{
377
+ stationId: string;
378
+ }>;
379
+ export declare const ExtrasModule: {
380
+ searchAll: typeof searchAll;
381
+ getTrendingAll: typeof getTrendingAll;
382
+ createEntityStation: typeof createEntityStation;
383
+ createFeaturedStation: typeof createFeaturedStation;
384
+ };
385
+ export {};
@@ -0,0 +1,64 @@
1
+ import { SDKError } from '../../helpers/errors';
2
+ import { SaavnGetTrending, SaavnSearchResults, SaavnWebRadio, } from '../../saavn/operations';
3
+ import { runOperation } from '../../saavn/run-operation';
4
+ export function stringArrayToJSONStringArray(value) {
5
+ if (!Array.isArray(value) || value.length === 0) {
6
+ throw new SDKError('INVALID_PARAMS', 'Expected a non-empty array of strings');
7
+ }
8
+ if (!value.every((v) => typeof v === 'string' && v.length > 0)) {
9
+ throw new SDKError('INVALID_PARAMS', 'All items must be non-empty strings');
10
+ }
11
+ return JSON.stringify(value);
12
+ }
13
+ /**
14
+ * Search all entities by query.
15
+ *
16
+ * @param params - Parameters object
17
+ * @param params.query - Search query string
18
+ * @returns List of matching entities
19
+ */
20
+ function searchAll({ query }) {
21
+ return runOperation(SaavnSearchResults.all, { query });
22
+ }
23
+ /**
24
+ * Get trending entities.
25
+ *
26
+ * @returns List of trending entities
27
+ */
28
+ function getTrendingAll() {
29
+ return runOperation(SaavnGetTrending.all, {});
30
+ }
31
+ /**
32
+ * Create a station for an entity.
33
+ *
34
+ * @param params - Parameters object
35
+ * @param params.songIds - Array of song IDs
36
+ * @returns Station object
37
+ */
38
+ function createEntityStation({ songIds }) {
39
+ return runOperation(SaavnWebRadio.createEntityStation, {
40
+ ctx: 'android',
41
+ entity_type: 'queue',
42
+ entity_id: stringArrayToJSONStringArray(songIds),
43
+ });
44
+ }
45
+ /**
46
+ * Create a featured station by language and name.
47
+ *
48
+ * @param params - Parameters object
49
+ * @param params.language - Language code
50
+ * @param params.name - Station name
51
+ * @returns Station object
52
+ */
53
+ function createFeaturedStation({ language, name, }) {
54
+ return runOperation(SaavnWebRadio.createFeaturedStation, {
55
+ language,
56
+ name,
57
+ });
58
+ }
59
+ export const ExtrasModule = {
60
+ searchAll,
61
+ getTrendingAll,
62
+ createEntityStation,
63
+ createFeaturedStation,
64
+ };