@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.
- package/LICENSE +21 -0
- package/README.md +339 -0
- package/dist/core/models/album.d.ts +32 -0
- package/dist/core/models/album.js +1 -0
- package/dist/core/models/artist.d.ts +61 -0
- package/dist/core/models/artist.js +1 -0
- package/dist/core/models/index.d.ts +4 -0
- package/dist/core/models/index.js +4 -0
- package/dist/core/models/playlist.d.ts +35 -0
- package/dist/core/models/playlist.js +1 -0
- package/dist/core/models/song.d.ts +52 -0
- package/dist/core/models/song.js +1 -0
- package/dist/core/modules/album.module.d.ts +82 -0
- package/dist/core/modules/album.module.js +74 -0
- package/dist/core/modules/artist.module.d.ts +97 -0
- package/dist/core/modules/artist.module.js +49 -0
- package/dist/core/modules/extras.module.d.ts +385 -0
- package/dist/core/modules/extras.module.js +64 -0
- package/dist/core/modules/playlist.module.d.ts +79 -0
- package/dist/core/modules/playlist.module.js +74 -0
- package/dist/core/modules/song.module.d.ts +91 -0
- package/dist/core/modules/song.module.js +97 -0
- package/dist/helpers/errors.d.ts +25 -0
- package/dist/helpers/errors.js +84 -0
- package/dist/helpers/experimental/stream-urls/index.d.ts +20 -0
- package/dist/helpers/experimental/stream-urls/index.js +33 -0
- package/dist/helpers/experimental/stream-urls/stream-urls.edge.d.ts +4 -0
- package/dist/helpers/experimental/stream-urls/stream-urls.edge.js +38 -0
- package/dist/helpers/experimental/stream-urls/stream-urls.node.d.ts +4 -0
- package/dist/helpers/experimental/stream-urls/stream-urls.node.js +27 -0
- package/dist/helpers/fetch.d.ts +38 -0
- package/dist/helpers/fetch.js +38 -0
- package/dist/helpers/utils.d.ts +13 -0
- package/dist/helpers/utils.js +58 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +8 -0
- package/dist/saavn/common-mapper.d.ts +77 -0
- package/dist/saavn/common-mapper.js +348 -0
- package/dist/saavn/entities/album.entity.d.ts +151 -0
- package/dist/saavn/entities/album.entity.js +25 -0
- package/dist/saavn/entities/artist.entity.d.ts +274 -0
- package/dist/saavn/entities/artist.entity.js +49 -0
- package/dist/saavn/entities/base.d.ts +117 -0
- package/dist/saavn/entities/base.js +71 -0
- package/dist/saavn/entities/extras.d.ts +102 -0
- package/dist/saavn/entities/extras.js +43 -0
- package/dist/saavn/entities/index.d.ts +6 -0
- package/dist/saavn/entities/index.js +6 -0
- package/dist/saavn/entities/playlist.entity.d.ts +143 -0
- package/dist/saavn/entities/playlist.entity.js +55 -0
- package/dist/saavn/entities/show.entity.d.ts +14 -0
- package/dist/saavn/entities/show.entity.js +14 -0
- package/dist/saavn/entities/song.entity.d.ts +142 -0
- package/dist/saavn/entities/song.entity.js +48 -0
- package/dist/saavn/operations/get-details/index.d.ts +755 -0
- package/dist/saavn/operations/get-details/index.js +34 -0
- package/dist/saavn/operations/get-details/mapper.ops.d.ts +35 -0
- package/dist/saavn/operations/get-details/mapper.ops.js +55 -0
- package/dist/saavn/operations/get-details/schema.ops.d.ts +706 -0
- package/dist/saavn/operations/get-details/schema.ops.js +49 -0
- package/dist/saavn/operations/get-reco/index.d.ts +144 -0
- package/dist/saavn/operations/get-reco/index.js +19 -0
- package/dist/saavn/operations/get-reco/mapper.ops.d.ts +36 -0
- package/dist/saavn/operations/get-reco/mapper.ops.js +43 -0
- package/dist/saavn/operations/get-reco/schema.ops.d.ts +103 -0
- package/dist/saavn/operations/get-reco/schema.ops.js +28 -0
- package/dist/saavn/operations/get-trending/index.d.ts +288 -0
- package/dist/saavn/operations/get-trending/index.js +24 -0
- package/dist/saavn/operations/get-trending/mapper.ops.d.ts +13 -0
- package/dist/saavn/operations/get-trending/mapper.ops.js +134 -0
- package/dist/saavn/operations/get-trending/schema.ops.d.ts +272 -0
- package/dist/saavn/operations/get-trending/schema.ops.js +34 -0
- package/dist/saavn/operations/index.d.ts +6 -0
- package/dist/saavn/operations/index.js +6 -0
- package/dist/saavn/operations/search-results/index.d.ts +790 -0
- package/dist/saavn/operations/search-results/index.js +29 -0
- package/dist/saavn/operations/search-results/mapper.ops.d.ts +413 -0
- package/dist/saavn/operations/search-results/mapper.ops.js +80 -0
- package/dist/saavn/operations/search-results/schema.ops.d.ts +366 -0
- package/dist/saavn/operations/search-results/schema.ops.js +101 -0
- package/dist/saavn/operations/web-api/index.d.ts +604 -0
- package/dist/saavn/operations/web-api/index.js +29 -0
- package/dist/saavn/operations/web-api/mapper.ops.d.ts +11 -0
- package/dist/saavn/operations/web-api/mapper.ops.js +23 -0
- package/dist/saavn/operations/web-api/schema.ops.d.ts +582 -0
- package/dist/saavn/operations/web-api/schema.ops.js +50 -0
- package/dist/saavn/operations/web-radio/index.d.ts +181 -0
- package/dist/saavn/operations/web-radio/index.js +19 -0
- package/dist/saavn/operations/web-radio/mapper.ops.d.ts +14 -0
- package/dist/saavn/operations/web-radio/mapper.ops.js +35 -0
- package/dist/saavn/operations/web-radio/schema.ops.d.ts +162 -0
- package/dist/saavn/operations/web-radio/schema.ops.js +56 -0
- package/dist/saavn/primitives/enums.d.ts +17 -0
- package/dist/saavn/primitives/enums.js +4 -0
- package/dist/saavn/primitives/string.d.ts +5 -0
- package/dist/saavn/primitives/string.js +22 -0
- package/dist/saavn/run-operation.d.ts +12 -0
- package/dist/saavn/run-operation.js +39 -0
- package/dist/schemas/index.d.ts +2188 -0
- package/dist/schemas/index.js +14 -0
- package/dist/types.d.ts +24 -0
- package/dist/types.js +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { SaavnWebRadioSchema } from './schema.ops';
|
|
2
|
+
export declare const SaavnWebRadio: {
|
|
3
|
+
createEntityStation: {
|
|
4
|
+
call: string;
|
|
5
|
+
schema: {
|
|
6
|
+
readonly params: import("zod").ZodObject<{
|
|
7
|
+
ctx: import("zod").ZodLiteral<"android">;
|
|
8
|
+
entity_type: import("zod").ZodLiteral<"queue">;
|
|
9
|
+
entity_id: import("zod").ZodString;
|
|
10
|
+
}, import("zod/v4/core").$strict>;
|
|
11
|
+
readonly response: import("zod").ZodObject<{
|
|
12
|
+
stationid: import("zod").ZodString;
|
|
13
|
+
}, import("zod/v4/core").$loose>;
|
|
14
|
+
};
|
|
15
|
+
mapper: (data: import("zod").infer<typeof SaavnWebRadioSchema.createEntityStation.response>) => {
|
|
16
|
+
stationId: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
createFeaturedStation: {
|
|
20
|
+
call: string;
|
|
21
|
+
schema: {
|
|
22
|
+
readonly params: import("zod").ZodObject<{
|
|
23
|
+
name: import("zod").ZodString;
|
|
24
|
+
language: import("zod").ZodString;
|
|
25
|
+
}, import("zod/v4/core").$strict>;
|
|
26
|
+
readonly response: import("zod").ZodObject<{
|
|
27
|
+
stationid: import("zod").ZodString;
|
|
28
|
+
}, import("zod/v4/core").$loose>;
|
|
29
|
+
};
|
|
30
|
+
mapper: (data: import("zod").infer<typeof SaavnWebRadioSchema.createFeaturedStation.response>) => {
|
|
31
|
+
stationId: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
songs: {
|
|
35
|
+
call: string;
|
|
36
|
+
schema: {
|
|
37
|
+
readonly params: import("zod").ZodObject<{
|
|
38
|
+
ctx: import("zod").ZodLiteral<"android">;
|
|
39
|
+
stationid: import("zod").ZodString;
|
|
40
|
+
k: import("zod").ZodOptional<import("zod").ZodString>;
|
|
41
|
+
next: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
42
|
+
0: "0";
|
|
43
|
+
1: "1";
|
|
44
|
+
}>>;
|
|
45
|
+
}, import("zod/v4/core").$strict>;
|
|
46
|
+
readonly response: import("zod").ZodUnion<readonly [import("zod").ZodObject<{
|
|
47
|
+
song: import("zod").ZodObject<{
|
|
48
|
+
id: import("zod").ZodString;
|
|
49
|
+
title: import("zod").ZodString;
|
|
50
|
+
subtitle: import("zod").ZodString;
|
|
51
|
+
type: import("zod").ZodLiteral<"song">;
|
|
52
|
+
perma_url: import("zod").ZodString;
|
|
53
|
+
image: import("zod").ZodString;
|
|
54
|
+
explicit_content: import("zod").ZodString;
|
|
55
|
+
header_desc: import("zod").ZodString;
|
|
56
|
+
language: import("zod").ZodString;
|
|
57
|
+
year: import("zod").ZodString;
|
|
58
|
+
play_count: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber]>;
|
|
59
|
+
more_info: import("zod").ZodObject<{
|
|
60
|
+
music: import("zod").ZodString;
|
|
61
|
+
album_id: import("zod").ZodString;
|
|
62
|
+
album: import("zod").ZodString;
|
|
63
|
+
label: import("zod").ZodString;
|
|
64
|
+
label_id: import("zod").ZodNullable<import("zod").ZodString>;
|
|
65
|
+
origin: import("zod").ZodString;
|
|
66
|
+
is_dolby_content: import("zod").ZodBoolean;
|
|
67
|
+
encrypted_media_url: import("zod").ZodString;
|
|
68
|
+
encrypted_drm_media_url: import("zod").ZodString;
|
|
69
|
+
album_url: import("zod").ZodString;
|
|
70
|
+
duration: import("zod").ZodString;
|
|
71
|
+
has_lyrics: import("zod").ZodString;
|
|
72
|
+
lyrics_snippet: import("zod").ZodString;
|
|
73
|
+
lyrics_id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
74
|
+
copyright_text: import("zod").ZodString;
|
|
75
|
+
release_date: import("zod").ZodNullable<import("zod").ZodString>;
|
|
76
|
+
label_url: import("zod").ZodOptional<import("zod").ZodString>;
|
|
77
|
+
vcode: import("zod").ZodOptional<import("zod").ZodString>;
|
|
78
|
+
vlink: import("zod").ZodOptional<import("zod").ZodString>;
|
|
79
|
+
artistMap: import("zod").ZodLazy<import("zod").ZodObject<{
|
|
80
|
+
primary_artists: import("zod").ZodArray<import("zod").ZodObject<{
|
|
81
|
+
id: import("zod").ZodString;
|
|
82
|
+
name: import("zod").ZodString;
|
|
83
|
+
role: import("zod").ZodString;
|
|
84
|
+
image: import("zod").ZodString;
|
|
85
|
+
type: import("zod").ZodLiteral<"artist">;
|
|
86
|
+
perma_url: import("zod").ZodString;
|
|
87
|
+
}, import("zod/v4/core").$loose>>;
|
|
88
|
+
featured_artists: import("zod").ZodArray<import("zod").ZodObject<{
|
|
89
|
+
id: import("zod").ZodString;
|
|
90
|
+
name: import("zod").ZodString;
|
|
91
|
+
role: import("zod").ZodString;
|
|
92
|
+
image: import("zod").ZodString;
|
|
93
|
+
type: import("zod").ZodLiteral<"artist">;
|
|
94
|
+
perma_url: import("zod").ZodString;
|
|
95
|
+
}, import("zod/v4/core").$loose>>;
|
|
96
|
+
artists: import("zod").ZodArray<import("zod").ZodObject<{
|
|
97
|
+
id: import("zod").ZodString;
|
|
98
|
+
name: import("zod").ZodString;
|
|
99
|
+
role: import("zod").ZodString;
|
|
100
|
+
image: import("zod").ZodString;
|
|
101
|
+
type: import("zod").ZodLiteral<"artist">;
|
|
102
|
+
perma_url: import("zod").ZodString;
|
|
103
|
+
}, import("zod/v4/core").$loose>>;
|
|
104
|
+
}, import("zod/v4/core").$loose>>;
|
|
105
|
+
}, import("zod/v4/core").$loose>;
|
|
106
|
+
}, import("zod/v4/core").$loose>;
|
|
107
|
+
stationid: import("zod").ZodString;
|
|
108
|
+
}, import("zod/v4/core").$loose>, import("zod").ZodObject<{
|
|
109
|
+
stationid: import("zod").ZodString;
|
|
110
|
+
}, import("zod/v4/core").$catchall<import("zod").ZodObject<{
|
|
111
|
+
song: import("zod").ZodObject<{
|
|
112
|
+
id: import("zod").ZodString;
|
|
113
|
+
title: import("zod").ZodString;
|
|
114
|
+
subtitle: import("zod").ZodString;
|
|
115
|
+
type: import("zod").ZodLiteral<"song">;
|
|
116
|
+
perma_url: import("zod").ZodString;
|
|
117
|
+
image: import("zod").ZodString;
|
|
118
|
+
explicit_content: import("zod").ZodString;
|
|
119
|
+
header_desc: import("zod").ZodString;
|
|
120
|
+
language: import("zod").ZodString;
|
|
121
|
+
year: import("zod").ZodString;
|
|
122
|
+
play_count: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber]>;
|
|
123
|
+
more_info: import("zod").ZodObject<{
|
|
124
|
+
music: import("zod").ZodString;
|
|
125
|
+
album_id: import("zod").ZodString;
|
|
126
|
+
album: import("zod").ZodString;
|
|
127
|
+
label: import("zod").ZodString;
|
|
128
|
+
label_id: import("zod").ZodNullable<import("zod").ZodString>;
|
|
129
|
+
origin: import("zod").ZodString;
|
|
130
|
+
is_dolby_content: import("zod").ZodBoolean;
|
|
131
|
+
encrypted_media_url: import("zod").ZodString;
|
|
132
|
+
encrypted_drm_media_url: import("zod").ZodString;
|
|
133
|
+
album_url: import("zod").ZodString;
|
|
134
|
+
duration: import("zod").ZodString;
|
|
135
|
+
has_lyrics: import("zod").ZodString;
|
|
136
|
+
lyrics_snippet: import("zod").ZodString;
|
|
137
|
+
lyrics_id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
138
|
+
copyright_text: import("zod").ZodString;
|
|
139
|
+
release_date: import("zod").ZodNullable<import("zod").ZodString>;
|
|
140
|
+
label_url: import("zod").ZodOptional<import("zod").ZodString>;
|
|
141
|
+
vcode: import("zod").ZodOptional<import("zod").ZodString>;
|
|
142
|
+
vlink: import("zod").ZodOptional<import("zod").ZodString>;
|
|
143
|
+
artistMap: import("zod").ZodLazy<import("zod").ZodObject<{
|
|
144
|
+
primary_artists: import("zod").ZodArray<import("zod").ZodObject<{
|
|
145
|
+
id: import("zod").ZodString;
|
|
146
|
+
name: import("zod").ZodString;
|
|
147
|
+
role: import("zod").ZodString;
|
|
148
|
+
image: import("zod").ZodString;
|
|
149
|
+
type: import("zod").ZodLiteral<"artist">;
|
|
150
|
+
perma_url: import("zod").ZodString;
|
|
151
|
+
}, import("zod/v4/core").$loose>>;
|
|
152
|
+
featured_artists: import("zod").ZodArray<import("zod").ZodObject<{
|
|
153
|
+
id: import("zod").ZodString;
|
|
154
|
+
name: import("zod").ZodString;
|
|
155
|
+
role: import("zod").ZodString;
|
|
156
|
+
image: import("zod").ZodString;
|
|
157
|
+
type: import("zod").ZodLiteral<"artist">;
|
|
158
|
+
perma_url: import("zod").ZodString;
|
|
159
|
+
}, import("zod/v4/core").$loose>>;
|
|
160
|
+
artists: import("zod").ZodArray<import("zod").ZodObject<{
|
|
161
|
+
id: import("zod").ZodString;
|
|
162
|
+
name: import("zod").ZodString;
|
|
163
|
+
role: import("zod").ZodString;
|
|
164
|
+
image: import("zod").ZodString;
|
|
165
|
+
type: import("zod").ZodLiteral<"artist">;
|
|
166
|
+
perma_url: import("zod").ZodString;
|
|
167
|
+
}, import("zod/v4/core").$loose>>;
|
|
168
|
+
}, import("zod/v4/core").$loose>>;
|
|
169
|
+
}, import("zod/v4/core").$loose>;
|
|
170
|
+
}, import("zod/v4/core").$loose>;
|
|
171
|
+
}, import("zod/v4/core").$loose>>>, import("zod").ZodObject<{
|
|
172
|
+
stationid: import("zod").ZodOptional<import("zod").ZodString>;
|
|
173
|
+
error: import("zod").ZodString;
|
|
174
|
+
}, import("zod/v4/core").$loose>]>;
|
|
175
|
+
};
|
|
176
|
+
mapper: (data: import("zod").infer<typeof SaavnWebRadioSchema.songs.response>) => {
|
|
177
|
+
stationId: string | undefined;
|
|
178
|
+
songs: import("../../../core/models").Song[];
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SaavnWebRadioMapper } from './mapper.ops';
|
|
2
|
+
import { SaavnWebRadioSchema } from './schema.ops';
|
|
3
|
+
export const SaavnWebRadio = {
|
|
4
|
+
createEntityStation: {
|
|
5
|
+
call: 'webradio.createEntityStation',
|
|
6
|
+
schema: SaavnWebRadioSchema.createEntityStation,
|
|
7
|
+
mapper: SaavnWebRadioMapper.createEntityStation,
|
|
8
|
+
},
|
|
9
|
+
createFeaturedStation: {
|
|
10
|
+
call: 'webradio.createFeaturedStation',
|
|
11
|
+
schema: SaavnWebRadioSchema.createFeaturedStation,
|
|
12
|
+
mapper: SaavnWebRadioMapper.createFeaturedStation,
|
|
13
|
+
},
|
|
14
|
+
songs: {
|
|
15
|
+
call: 'webradio.getSong',
|
|
16
|
+
schema: SaavnWebRadioSchema.songs,
|
|
17
|
+
mapper: SaavnWebRadioMapper.songs,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SaavnWebRadioSchema } from './schema.ops';
|
|
3
|
+
export declare const SaavnWebRadioMapper: {
|
|
4
|
+
createEntityStation: (data: z.infer<typeof SaavnWebRadioSchema.createEntityStation.response>) => {
|
|
5
|
+
stationId: string;
|
|
6
|
+
};
|
|
7
|
+
createFeaturedStation: (data: z.infer<typeof SaavnWebRadioSchema.createFeaturedStation.response>) => {
|
|
8
|
+
stationId: string;
|
|
9
|
+
};
|
|
10
|
+
songs: (data: z.infer<typeof SaavnWebRadioSchema.songs.response>) => {
|
|
11
|
+
stationId: string | undefined;
|
|
12
|
+
songs: import("../../../core/models").Song[];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { mapSong } from '../../common-mapper';
|
|
3
|
+
import { SaavnWebRadioSchema } from './schema.ops';
|
|
4
|
+
export const SaavnWebRadioMapper = {
|
|
5
|
+
createEntityStation: (data) => {
|
|
6
|
+
return {
|
|
7
|
+
stationId: data.stationid,
|
|
8
|
+
};
|
|
9
|
+
},
|
|
10
|
+
createFeaturedStation: (data) => {
|
|
11
|
+
return {
|
|
12
|
+
stationId: data.stationid,
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
songs: (data) => {
|
|
16
|
+
if ('song' in data && data.song) {
|
|
17
|
+
return {
|
|
18
|
+
stationId: data.stationid,
|
|
19
|
+
songs: [mapSong(data.song)],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const songs = Object.entries(data)
|
|
23
|
+
.filter(([key, value]) => key !== 'stationid' &&
|
|
24
|
+
!Number.isNaN(Number(key)) &&
|
|
25
|
+
typeof value === 'object' &&
|
|
26
|
+
value !== null &&
|
|
27
|
+
'song' in value)
|
|
28
|
+
.sort(([a], [b]) => Number(a) - Number(b))
|
|
29
|
+
.map(([, value]) => mapSong(value.song));
|
|
30
|
+
return {
|
|
31
|
+
stationId: data.stationid,
|
|
32
|
+
songs,
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const SaavnWebRadioSchema: {
|
|
3
|
+
readonly createEntityStation: {
|
|
4
|
+
readonly params: z.ZodObject<{
|
|
5
|
+
ctx: z.ZodLiteral<"android">;
|
|
6
|
+
entity_type: z.ZodLiteral<"queue">;
|
|
7
|
+
entity_id: z.ZodString;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
readonly response: z.ZodObject<{
|
|
10
|
+
stationid: z.ZodString;
|
|
11
|
+
}, z.core.$loose>;
|
|
12
|
+
};
|
|
13
|
+
readonly createFeaturedStation: {
|
|
14
|
+
readonly params: z.ZodObject<{
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
language: z.ZodString;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
|
+
readonly response: z.ZodObject<{
|
|
19
|
+
stationid: z.ZodString;
|
|
20
|
+
}, z.core.$loose>;
|
|
21
|
+
};
|
|
22
|
+
readonly songs: {
|
|
23
|
+
readonly params: z.ZodObject<{
|
|
24
|
+
ctx: z.ZodLiteral<"android">;
|
|
25
|
+
stationid: z.ZodString;
|
|
26
|
+
k: z.ZodOptional<z.ZodString>;
|
|
27
|
+
next: z.ZodOptional<z.ZodEnum<{
|
|
28
|
+
0: "0";
|
|
29
|
+
1: "1";
|
|
30
|
+
}>>;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
readonly response: z.ZodUnion<readonly [z.ZodObject<{
|
|
33
|
+
song: z.ZodObject<{
|
|
34
|
+
id: z.ZodString;
|
|
35
|
+
title: z.ZodString;
|
|
36
|
+
subtitle: z.ZodString;
|
|
37
|
+
type: z.ZodLiteral<"song">;
|
|
38
|
+
perma_url: z.ZodString;
|
|
39
|
+
image: z.ZodString;
|
|
40
|
+
explicit_content: z.ZodString;
|
|
41
|
+
header_desc: z.ZodString;
|
|
42
|
+
language: z.ZodString;
|
|
43
|
+
year: z.ZodString;
|
|
44
|
+
play_count: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
45
|
+
more_info: z.ZodObject<{
|
|
46
|
+
music: z.ZodString;
|
|
47
|
+
album_id: z.ZodString;
|
|
48
|
+
album: z.ZodString;
|
|
49
|
+
label: z.ZodString;
|
|
50
|
+
label_id: z.ZodNullable<z.ZodString>;
|
|
51
|
+
origin: z.ZodString;
|
|
52
|
+
is_dolby_content: z.ZodBoolean;
|
|
53
|
+
encrypted_media_url: z.ZodString;
|
|
54
|
+
encrypted_drm_media_url: z.ZodString;
|
|
55
|
+
album_url: z.ZodString;
|
|
56
|
+
duration: z.ZodString;
|
|
57
|
+
has_lyrics: z.ZodString;
|
|
58
|
+
lyrics_snippet: z.ZodString;
|
|
59
|
+
lyrics_id: z.ZodOptional<z.ZodString>;
|
|
60
|
+
copyright_text: z.ZodString;
|
|
61
|
+
release_date: z.ZodNullable<z.ZodString>;
|
|
62
|
+
label_url: z.ZodOptional<z.ZodString>;
|
|
63
|
+
vcode: z.ZodOptional<z.ZodString>;
|
|
64
|
+
vlink: z.ZodOptional<z.ZodString>;
|
|
65
|
+
artistMap: z.ZodLazy<z.ZodObject<{
|
|
66
|
+
primary_artists: z.ZodArray<z.ZodObject<{
|
|
67
|
+
id: z.ZodString;
|
|
68
|
+
name: z.ZodString;
|
|
69
|
+
role: z.ZodString;
|
|
70
|
+
image: z.ZodString;
|
|
71
|
+
type: z.ZodLiteral<"artist">;
|
|
72
|
+
perma_url: z.ZodString;
|
|
73
|
+
}, z.core.$loose>>;
|
|
74
|
+
featured_artists: z.ZodArray<z.ZodObject<{
|
|
75
|
+
id: z.ZodString;
|
|
76
|
+
name: z.ZodString;
|
|
77
|
+
role: z.ZodString;
|
|
78
|
+
image: z.ZodString;
|
|
79
|
+
type: z.ZodLiteral<"artist">;
|
|
80
|
+
perma_url: z.ZodString;
|
|
81
|
+
}, z.core.$loose>>;
|
|
82
|
+
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
|
+
}, z.core.$loose>>;
|
|
91
|
+
}, z.core.$loose>;
|
|
92
|
+
}, z.core.$loose>;
|
|
93
|
+
stationid: z.ZodString;
|
|
94
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
95
|
+
stationid: z.ZodString;
|
|
96
|
+
}, z.core.$catchall<z.ZodObject<{
|
|
97
|
+
song: z.ZodObject<{
|
|
98
|
+
id: z.ZodString;
|
|
99
|
+
title: z.ZodString;
|
|
100
|
+
subtitle: z.ZodString;
|
|
101
|
+
type: z.ZodLiteral<"song">;
|
|
102
|
+
perma_url: z.ZodString;
|
|
103
|
+
image: z.ZodString;
|
|
104
|
+
explicit_content: z.ZodString;
|
|
105
|
+
header_desc: z.ZodString;
|
|
106
|
+
language: z.ZodString;
|
|
107
|
+
year: z.ZodString;
|
|
108
|
+
play_count: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
109
|
+
more_info: z.ZodObject<{
|
|
110
|
+
music: z.ZodString;
|
|
111
|
+
album_id: z.ZodString;
|
|
112
|
+
album: z.ZodString;
|
|
113
|
+
label: z.ZodString;
|
|
114
|
+
label_id: z.ZodNullable<z.ZodString>;
|
|
115
|
+
origin: z.ZodString;
|
|
116
|
+
is_dolby_content: z.ZodBoolean;
|
|
117
|
+
encrypted_media_url: z.ZodString;
|
|
118
|
+
encrypted_drm_media_url: z.ZodString;
|
|
119
|
+
album_url: z.ZodString;
|
|
120
|
+
duration: z.ZodString;
|
|
121
|
+
has_lyrics: z.ZodString;
|
|
122
|
+
lyrics_snippet: z.ZodString;
|
|
123
|
+
lyrics_id: z.ZodOptional<z.ZodString>;
|
|
124
|
+
copyright_text: z.ZodString;
|
|
125
|
+
release_date: z.ZodNullable<z.ZodString>;
|
|
126
|
+
label_url: z.ZodOptional<z.ZodString>;
|
|
127
|
+
vcode: z.ZodOptional<z.ZodString>;
|
|
128
|
+
vlink: z.ZodOptional<z.ZodString>;
|
|
129
|
+
artistMap: z.ZodLazy<z.ZodObject<{
|
|
130
|
+
primary_artists: z.ZodArray<z.ZodObject<{
|
|
131
|
+
id: z.ZodString;
|
|
132
|
+
name: z.ZodString;
|
|
133
|
+
role: z.ZodString;
|
|
134
|
+
image: z.ZodString;
|
|
135
|
+
type: z.ZodLiteral<"artist">;
|
|
136
|
+
perma_url: z.ZodString;
|
|
137
|
+
}, z.core.$loose>>;
|
|
138
|
+
featured_artists: z.ZodArray<z.ZodObject<{
|
|
139
|
+
id: z.ZodString;
|
|
140
|
+
name: z.ZodString;
|
|
141
|
+
role: z.ZodString;
|
|
142
|
+
image: z.ZodString;
|
|
143
|
+
type: z.ZodLiteral<"artist">;
|
|
144
|
+
perma_url: z.ZodString;
|
|
145
|
+
}, z.core.$loose>>;
|
|
146
|
+
artists: z.ZodArray<z.ZodObject<{
|
|
147
|
+
id: z.ZodString;
|
|
148
|
+
name: z.ZodString;
|
|
149
|
+
role: z.ZodString;
|
|
150
|
+
image: z.ZodString;
|
|
151
|
+
type: z.ZodLiteral<"artist">;
|
|
152
|
+
perma_url: z.ZodString;
|
|
153
|
+
}, z.core.$loose>>;
|
|
154
|
+
}, z.core.$loose>>;
|
|
155
|
+
}, z.core.$loose>;
|
|
156
|
+
}, z.core.$loose>;
|
|
157
|
+
}, z.core.$loose>>>, z.ZodObject<{
|
|
158
|
+
stationid: z.ZodOptional<z.ZodString>;
|
|
159
|
+
error: z.ZodString;
|
|
160
|
+
}, z.core.$loose>]>;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { JSONStringArray, NonEmptyString, PositiveString, } from '../../primitives/string';
|
|
3
|
+
import { SaavnExplicitFlagSchema } from '../../primitives/enums';
|
|
4
|
+
import { SaavnSongEntity } from '../../entities';
|
|
5
|
+
const WebRadioSingleSong = z.looseObject({
|
|
6
|
+
song: SaavnSongEntity,
|
|
7
|
+
stationid: z.string(),
|
|
8
|
+
});
|
|
9
|
+
const WebRadioMultipleSongs = z
|
|
10
|
+
.looseObject({
|
|
11
|
+
stationid: z.string(),
|
|
12
|
+
})
|
|
13
|
+
.catchall(z.looseObject({
|
|
14
|
+
song: SaavnSongEntity,
|
|
15
|
+
}))
|
|
16
|
+
.refine((obj) => Object.keys(obj).some((key) => key !== 'stationid' && !Number.isNaN(Number(key))), {
|
|
17
|
+
message: 'Expected numeric song keys (0,1,2,...)',
|
|
18
|
+
});
|
|
19
|
+
const WebRadioError = z.looseObject({
|
|
20
|
+
stationid: z.string().optional(),
|
|
21
|
+
error: z.string(),
|
|
22
|
+
});
|
|
23
|
+
export const SaavnWebRadioSchema = {
|
|
24
|
+
createEntityStation: {
|
|
25
|
+
params: z.strictObject({
|
|
26
|
+
ctx: z.literal('android'),
|
|
27
|
+
entity_type: z.literal('queue'),
|
|
28
|
+
entity_id: JSONStringArray,
|
|
29
|
+
}),
|
|
30
|
+
response: z.looseObject({
|
|
31
|
+
stationid: z.string(),
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
createFeaturedStation: {
|
|
35
|
+
params: z.strictObject({
|
|
36
|
+
name: NonEmptyString,
|
|
37
|
+
language: NonEmptyString,
|
|
38
|
+
}),
|
|
39
|
+
response: z.looseObject({
|
|
40
|
+
stationid: z.string(),
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
songs: {
|
|
44
|
+
params: z.strictObject({
|
|
45
|
+
ctx: z.literal('android'),
|
|
46
|
+
stationid: NonEmptyString,
|
|
47
|
+
k: PositiveString.optional(),
|
|
48
|
+
next: SaavnExplicitFlagSchema.optional(),
|
|
49
|
+
}),
|
|
50
|
+
response: z.union([
|
|
51
|
+
WebRadioSingleSong,
|
|
52
|
+
WebRadioMultipleSongs,
|
|
53
|
+
WebRadioError,
|
|
54
|
+
]),
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export type SaavnSortOrder = z.infer<typeof SaavnSortOrderSchema>;
|
|
3
|
+
export type SaavnSortBy = z.infer<typeof SaavnSortBySchema>;
|
|
4
|
+
export type SaavnExplicitFlag = z.infer<typeof SaavnExplicitFlagSchema>;
|
|
5
|
+
export declare const SaavnSortOrderSchema: z.ZodEnum<{
|
|
6
|
+
asc: "asc";
|
|
7
|
+
desc: "desc";
|
|
8
|
+
}>;
|
|
9
|
+
export declare const SaavnSortBySchema: z.ZodEnum<{
|
|
10
|
+
"": "";
|
|
11
|
+
alphabetical: "alphabetical";
|
|
12
|
+
latest: "latest";
|
|
13
|
+
}>;
|
|
14
|
+
export declare const SaavnExplicitFlagSchema: z.ZodEnum<{
|
|
15
|
+
0: "0";
|
|
16
|
+
1: "1";
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const NonEmptyString = z.string().min(1);
|
|
3
|
+
export const PositiveString = z
|
|
4
|
+
.string()
|
|
5
|
+
.regex(/^[1-9]\d*$/, 'Expected a positive numeric string');
|
|
6
|
+
export const CSVString = z
|
|
7
|
+
.string()
|
|
8
|
+
.min(1)
|
|
9
|
+
.refine((v) => v.split(',').every((part) => part.trim().length > 0), 'Expected comma-separated non-empty values');
|
|
10
|
+
export const JSONStringArray = z.string().refine((value) => {
|
|
11
|
+
try {
|
|
12
|
+
const parsed = JSON.parse(value);
|
|
13
|
+
return (Array.isArray(parsed) &&
|
|
14
|
+
parsed.length > 0 &&
|
|
15
|
+
parsed.every((item) => typeof item === 'string' && item.length > 0));
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}, {
|
|
21
|
+
message: 'Expected a JSON-stringified array of non-empty strings',
|
|
22
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z, type ZodType } from 'zod';
|
|
2
|
+
type AnyZodSchema = ZodType<unknown, any, any>;
|
|
3
|
+
type OperationLike<P extends AnyZodSchema, R extends AnyZodSchema, O> = {
|
|
4
|
+
call: string;
|
|
5
|
+
schema: {
|
|
6
|
+
params: P;
|
|
7
|
+
response: R;
|
|
8
|
+
};
|
|
9
|
+
mapper: (data: z.infer<R>) => O;
|
|
10
|
+
};
|
|
11
|
+
export declare function runOperation<P extends AnyZodSchema, R extends AnyZodSchema, O>(op: OperationLike<P, R, O>, input: z.input<P>): Promise<O>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z, ZodError } from 'zod';
|
|
2
|
+
import { fetchFromSaavn } from '../helpers/fetch';
|
|
3
|
+
import { fromZodError, networkError, internalError, SDKError, detectSaavnApiError, } from '../helpers/errors';
|
|
4
|
+
export async function runOperation(op, input) {
|
|
5
|
+
let parsedParams;
|
|
6
|
+
try {
|
|
7
|
+
parsedParams = op.schema.params.parse(input);
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
if (e instanceof ZodError) {
|
|
11
|
+
throw fromZodError(e, 'params', op.call);
|
|
12
|
+
}
|
|
13
|
+
throw internalError('Failed to validate parameters.', e);
|
|
14
|
+
}
|
|
15
|
+
const params = Object.fromEntries(Object.entries(parsedParams).map(([k, v]) => [k, String(v)]));
|
|
16
|
+
const res = await fetchFromSaavn({ call: op.call, params });
|
|
17
|
+
if (!res.ok) {
|
|
18
|
+
throw networkError(op.call, res.status);
|
|
19
|
+
}
|
|
20
|
+
const apiErrorMessage = detectSaavnApiError(res.data);
|
|
21
|
+
if (apiErrorMessage) {
|
|
22
|
+
throw new SDKError('API_ERROR', apiErrorMessage, {
|
|
23
|
+
details: {
|
|
24
|
+
call: op.call,
|
|
25
|
+
response: res.data,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const parsed = op.schema.response.parse(res.data);
|
|
31
|
+
return op.mapper(parsed);
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
if (e instanceof ZodError) {
|
|
35
|
+
throw fromZodError(e, 'response', op.call);
|
|
36
|
+
}
|
|
37
|
+
throw internalError('Failed to parse or map response.', e);
|
|
38
|
+
}
|
|
39
|
+
}
|