soundcloud-api-ts 1.11.1 → 1.12.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/AGENTS.md +6 -1
- package/README.md +90 -1
- package/dist/{chunk-GTSVJU3P.js → chunk-D7AF372V.js} +243 -11
- package/dist/chunk-D7AF372V.js.map +1 -0
- package/dist/{chunk-DGZEPXIQ.mjs → chunk-JLRQJWU5.mjs} +241 -12
- package/dist/chunk-JLRQJWU5.mjs.map +1 -0
- package/dist/cli.js +6 -6
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +163 -1
- package/dist/index.d.ts +163 -1
- package/dist/index.js +75 -63
- package/dist/index.mjs +1 -1
- package/llms.txt +45 -0
- package/package.json +4 -2
- package/dist/chunk-DGZEPXIQ.mjs.map +0 -1
- package/dist/chunk-GTSVJU3P.js.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -35,6 +35,21 @@ interface SCRequestTelemetry {
|
|
|
35
35
|
/** Error message if the request ultimately failed */
|
|
36
36
|
error?: string;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Information passed to the `onRetry` callback on each retry attempt.
|
|
40
|
+
*/
|
|
41
|
+
interface RetryInfo {
|
|
42
|
+
/** Which retry attempt this is (1-based) */
|
|
43
|
+
attempt: number;
|
|
44
|
+
/** Delay in milliseconds before this retry fires */
|
|
45
|
+
delayMs: number;
|
|
46
|
+
/** Human-readable reason (e.g. "429 Too Many Requests") */
|
|
47
|
+
reason: string;
|
|
48
|
+
/** HTTP status that triggered the retry, if applicable */
|
|
49
|
+
status?: number;
|
|
50
|
+
/** The URL that was requested */
|
|
51
|
+
url: string;
|
|
52
|
+
}
|
|
38
53
|
/**
|
|
39
54
|
* Configuration for automatic retry with exponential backoff on transient errors.
|
|
40
55
|
*/
|
|
@@ -45,6 +60,8 @@ interface RetryConfig {
|
|
|
45
60
|
retryBaseDelay: number;
|
|
46
61
|
/** Optional callback for debug logging of retry attempts */
|
|
47
62
|
onDebug?: (message: string) => void;
|
|
63
|
+
/** Optional callback fired before each retry with structured retry info */
|
|
64
|
+
onRetry?: (info: RetryInfo) => void;
|
|
48
65
|
}
|
|
49
66
|
/**
|
|
50
67
|
* Context for automatic token refresh when a request returns 401 Unauthorized.
|
|
@@ -114,6 +131,103 @@ declare function scFetch<T>(options: RequestOptions, refreshCtx?: AutoRefreshCon
|
|
|
114
131
|
*/
|
|
115
132
|
declare function scFetchUrl<T>(url: string, token?: string, retryConfig?: RetryConfig, onRequest?: (telemetry: SCRequestTelemetry) => void): Promise<T>;
|
|
116
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Raw response from the SoundCloud API, including status code and headers.
|
|
136
|
+
*/
|
|
137
|
+
type RawResponse<T = unknown> = {
|
|
138
|
+
/** Parsed response body */
|
|
139
|
+
data: T;
|
|
140
|
+
/** HTTP status code */
|
|
141
|
+
status: number;
|
|
142
|
+
/** Response headers as a plain object */
|
|
143
|
+
headers: Record<string, string>;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Low-level HTTP client that returns raw responses without throwing on non-2xx status codes.
|
|
147
|
+
* Useful when you need access to status codes, headers, or want to handle errors manually.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* const raw = sc.raw;
|
|
152
|
+
* const res = await raw.get('/tracks/123456');
|
|
153
|
+
* console.log(res.status, res.headers, res.data);
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
declare class RawClient {
|
|
157
|
+
private baseUrl;
|
|
158
|
+
private getToken;
|
|
159
|
+
private fetchFn;
|
|
160
|
+
constructor(baseUrl: string, getToken: () => string | undefined, fetchFn: typeof fetch);
|
|
161
|
+
/**
|
|
162
|
+
* Make a raw HTTP request. Path template placeholders like `{id}` are substituted
|
|
163
|
+
* from matching keys in `query` before the remaining query params are appended to
|
|
164
|
+
* the URL as search parameters.
|
|
165
|
+
*/
|
|
166
|
+
request<T = unknown>({ method, path, query, body, token, }: {
|
|
167
|
+
method: string;
|
|
168
|
+
path: string;
|
|
169
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
170
|
+
body?: unknown;
|
|
171
|
+
token?: string;
|
|
172
|
+
}): Promise<RawResponse<T>>;
|
|
173
|
+
/** GET shorthand */
|
|
174
|
+
get<T = unknown>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<RawResponse<T>>;
|
|
175
|
+
/** POST shorthand */
|
|
176
|
+
post<T = unknown>(path: string, body?: unknown): Promise<RawResponse<T>>;
|
|
177
|
+
/** PUT shorthand */
|
|
178
|
+
put<T = unknown>(path: string, body?: unknown): Promise<RawResponse<T>>;
|
|
179
|
+
/** DELETE shorthand */
|
|
180
|
+
delete<T = unknown>(path: string): Promise<RawResponse<T>>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* A cache entry with an expiration timestamp.
|
|
185
|
+
*/
|
|
186
|
+
interface SoundCloudCacheEntry<T> {
|
|
187
|
+
/** The cached value */
|
|
188
|
+
value: T;
|
|
189
|
+
/** Unix timestamp (ms) when this entry expires */
|
|
190
|
+
expiresAt: number;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Cache interface for SoundCloud API responses.
|
|
194
|
+
*
|
|
195
|
+
* Implement this interface to plug in any caching backend (in-memory, Redis, etc.).
|
|
196
|
+
* Pass an instance as `cache` in {@link SoundCloudClientConfig} to enable caching.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* // Simple in-memory implementation
|
|
201
|
+
* class SimpleCache implements SoundCloudCache {
|
|
202
|
+
* private store = new Map<string, SoundCloudCacheEntry<unknown>>();
|
|
203
|
+
*
|
|
204
|
+
* get<T>(key: string): T | undefined {
|
|
205
|
+
* const entry = this.store.get(key) as SoundCloudCacheEntry<T> | undefined;
|
|
206
|
+
* if (!entry || Date.now() > entry.expiresAt) return undefined;
|
|
207
|
+
* return entry.value;
|
|
208
|
+
* }
|
|
209
|
+
*
|
|
210
|
+
* set<T>(key: string, value: T, { ttlMs }: { ttlMs: number }): void {
|
|
211
|
+
* this.store.set(key, { value, expiresAt: Date.now() + ttlMs });
|
|
212
|
+
* }
|
|
213
|
+
*
|
|
214
|
+
* delete(key: string): void {
|
|
215
|
+
* this.store.delete(key);
|
|
216
|
+
* }
|
|
217
|
+
* }
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
interface SoundCloudCache {
|
|
221
|
+
/** Retrieve a cached value by key, or `undefined` if missing or expired */
|
|
222
|
+
get<T>(key: string): Promise<T | undefined> | T | undefined;
|
|
223
|
+
/** Store a value with a TTL in milliseconds */
|
|
224
|
+
set<T>(key: string, value: T, options: {
|
|
225
|
+
ttlMs: number;
|
|
226
|
+
}): Promise<void> | void;
|
|
227
|
+
/** Remove a cached entry */
|
|
228
|
+
delete(key: string): Promise<void> | void;
|
|
229
|
+
}
|
|
230
|
+
|
|
117
231
|
/**
|
|
118
232
|
* Parameters for updating a track's metadata via {@link updateTrack}.
|
|
119
233
|
*/
|
|
@@ -321,6 +435,16 @@ interface SoundCloudClientConfig {
|
|
|
321
435
|
onDebug?: (message: string) => void;
|
|
322
436
|
/** Called after every API request with structured telemetry (timing, status, retries) */
|
|
323
437
|
onRequest?: (telemetry: SCRequestTelemetry) => void;
|
|
438
|
+
/** Custom fetch implementation (defaults to `globalThis.fetch`) */
|
|
439
|
+
fetch?: typeof globalThis.fetch;
|
|
440
|
+
/** Deduplicate concurrent identical requests (default: true) */
|
|
441
|
+
dedupe?: boolean;
|
|
442
|
+
/** Optional cache backend for API responses */
|
|
443
|
+
cache?: SoundCloudCache;
|
|
444
|
+
/** Default TTL in milliseconds for cached responses (default: 60000) */
|
|
445
|
+
cacheTtlMs?: number;
|
|
446
|
+
/** Called before each retry attempt with structured retry info */
|
|
447
|
+
onRetry?: (info: RetryInfo) => void;
|
|
324
448
|
}
|
|
325
449
|
/**
|
|
326
450
|
* Optional token override that can be passed as the last parameter to client methods.
|
|
@@ -386,6 +510,8 @@ declare class SoundCloudClient {
|
|
|
386
510
|
likes: SoundCloudClient.Likes;
|
|
387
511
|
/** Repost/unrepost actions (/reposts) */
|
|
388
512
|
reposts: SoundCloudClient.Reposts;
|
|
513
|
+
/** Low-level raw HTTP client — returns status/headers without throwing on non-2xx */
|
|
514
|
+
raw: RawClient;
|
|
389
515
|
/**
|
|
390
516
|
* Creates a new SoundCloudClient instance.
|
|
391
517
|
*
|
|
@@ -1311,6 +1437,42 @@ declare namespace SoundCloudClient {
|
|
|
1311
1437
|
}
|
|
1312
1438
|
}
|
|
1313
1439
|
|
|
1440
|
+
/**
|
|
1441
|
+
* Deduplicates concurrent in-flight requests with the same key.
|
|
1442
|
+
*
|
|
1443
|
+
* When multiple callers request the same resource simultaneously,
|
|
1444
|
+
* only one underlying promise is created — all callers share the result.
|
|
1445
|
+
* The key is cleaned up automatically once the promise settles.
|
|
1446
|
+
*
|
|
1447
|
+
* @example
|
|
1448
|
+
* ```ts
|
|
1449
|
+
* const deduper = new InFlightDeduper();
|
|
1450
|
+
*
|
|
1451
|
+
* // Both calls share a single fetch:
|
|
1452
|
+
* const [a, b] = await Promise.all([
|
|
1453
|
+
* deduper.add('track:123', () => fetchTrack(123)),
|
|
1454
|
+
* deduper.add('track:123', () => fetchTrack(123)),
|
|
1455
|
+
* ]);
|
|
1456
|
+
* // a === b (same resolved value)
|
|
1457
|
+
* ```
|
|
1458
|
+
*/
|
|
1459
|
+
declare class InFlightDeduper {
|
|
1460
|
+
private inFlight;
|
|
1461
|
+
/**
|
|
1462
|
+
* Return an existing in-flight promise for `key`, or start a new one via `factory`.
|
|
1463
|
+
* The entry is removed from the map once the promise settles (resolve or reject).
|
|
1464
|
+
*/
|
|
1465
|
+
add<T>(key: string, factory: () => Promise<T>): Promise<T>;
|
|
1466
|
+
/** Number of currently in-flight requests */
|
|
1467
|
+
get size(): number;
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
/**
|
|
1471
|
+
* List of operation IDs currently implemented by soundcloud-api-ts.
|
|
1472
|
+
* Used for OpenAPI coverage reporting.
|
|
1473
|
+
*/
|
|
1474
|
+
declare const IMPLEMENTED_OPERATIONS: string[];
|
|
1475
|
+
|
|
1314
1476
|
/**
|
|
1315
1477
|
* Async generator that automatically follows `next_href` pagination,
|
|
1316
1478
|
* yielding each page's `collection` array.
|
|
@@ -2463,4 +2625,4 @@ declare const unrepostPlaylist: (token: string, playlistId: string | number) =>
|
|
|
2463
2625
|
*/
|
|
2464
2626
|
declare const getSoundCloudWidgetUrl: (trackId: string | number) => string;
|
|
2465
2627
|
|
|
2466
|
-
export { type CreatePlaylistParams, type RequestOptions, type RetryConfig, type SCRequestTelemetry, SoundCloudActivitiesResponse, SoundCloudClient, type SoundCloudClientConfig, SoundCloudComment, SoundCloudMe, SoundCloudPaginatedResponse, SoundCloudPlaylist, SoundCloudStreams, SoundCloudToken, SoundCloudTrack, SoundCloudUser, SoundCloudWebProfile, type TokenOption, type UpdatePlaylistParams, type UpdateTrackParams, createPlaylist, createTrackComment, deletePlaylist, deleteTrack, fetchAll, followUser, generateCodeChallenge, generateCodeVerifier, getAuthorizationUrl, getClientToken, getFollowers, getFollowings, getMe, getMeActivities, getMeActivitiesOwn, getMeActivitiesTracks, getMeFollowers, getMeFollowings, getMeFollowingsTracks, getMeLikesPlaylists, getMeLikesTracks, getMePlaylists, getMeTracks, getPlaylist, getPlaylistReposts, getPlaylistTracks, getRelatedTracks, getSoundCloudWidgetUrl, getTrack, getTrackComments, getTrackLikes, getTrackReposts, getTrackStreams, getUser, getUserLikesPlaylists, getUserLikesTracks, getUserPlaylists, getUserToken, getUserTracks, getUserWebProfiles, likePlaylist, likeTrack, paginate, paginateItems, refreshUserToken, repostPlaylist, repostTrack, resolveUrl, scFetch, scFetchUrl, searchPlaylists, searchTracks, searchUsers, signOut, unfollowUser, unlikePlaylist, unlikeTrack, unrepostPlaylist, unrepostTrack, updatePlaylist, updateTrack };
|
|
2628
|
+
export { type CreatePlaylistParams, IMPLEMENTED_OPERATIONS, InFlightDeduper, RawClient, type RawResponse, type RequestOptions, type RetryConfig, type RetryInfo, type SCRequestTelemetry, SoundCloudActivitiesResponse, type SoundCloudCache, type SoundCloudCacheEntry, SoundCloudClient, type SoundCloudClientConfig, SoundCloudComment, SoundCloudMe, SoundCloudPaginatedResponse, SoundCloudPlaylist, SoundCloudStreams, SoundCloudToken, SoundCloudTrack, SoundCloudUser, SoundCloudWebProfile, type TokenOption, type UpdatePlaylistParams, type UpdateTrackParams, createPlaylist, createTrackComment, deletePlaylist, deleteTrack, fetchAll, followUser, generateCodeChallenge, generateCodeVerifier, getAuthorizationUrl, getClientToken, getFollowers, getFollowings, getMe, getMeActivities, getMeActivitiesOwn, getMeActivitiesTracks, getMeFollowers, getMeFollowings, getMeFollowingsTracks, getMeLikesPlaylists, getMeLikesTracks, getMePlaylists, getMeTracks, getPlaylist, getPlaylistReposts, getPlaylistTracks, getRelatedTracks, getSoundCloudWidgetUrl, getTrack, getTrackComments, getTrackLikes, getTrackReposts, getTrackStreams, getUser, getUserLikesPlaylists, getUserLikesTracks, getUserPlaylists, getUserToken, getUserTracks, getUserWebProfiles, likePlaylist, likeTrack, paginate, paginateItems, refreshUserToken, repostPlaylist, repostTrack, resolveUrl, scFetch, scFetchUrl, searchPlaylists, searchTracks, searchUsers, signOut, unfollowUser, unlikePlaylist, unlikeTrack, unrepostPlaylist, unrepostTrack, updatePlaylist, updateTrack };
|
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,21 @@ interface SCRequestTelemetry {
|
|
|
35
35
|
/** Error message if the request ultimately failed */
|
|
36
36
|
error?: string;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Information passed to the `onRetry` callback on each retry attempt.
|
|
40
|
+
*/
|
|
41
|
+
interface RetryInfo {
|
|
42
|
+
/** Which retry attempt this is (1-based) */
|
|
43
|
+
attempt: number;
|
|
44
|
+
/** Delay in milliseconds before this retry fires */
|
|
45
|
+
delayMs: number;
|
|
46
|
+
/** Human-readable reason (e.g. "429 Too Many Requests") */
|
|
47
|
+
reason: string;
|
|
48
|
+
/** HTTP status that triggered the retry, if applicable */
|
|
49
|
+
status?: number;
|
|
50
|
+
/** The URL that was requested */
|
|
51
|
+
url: string;
|
|
52
|
+
}
|
|
38
53
|
/**
|
|
39
54
|
* Configuration for automatic retry with exponential backoff on transient errors.
|
|
40
55
|
*/
|
|
@@ -45,6 +60,8 @@ interface RetryConfig {
|
|
|
45
60
|
retryBaseDelay: number;
|
|
46
61
|
/** Optional callback for debug logging of retry attempts */
|
|
47
62
|
onDebug?: (message: string) => void;
|
|
63
|
+
/** Optional callback fired before each retry with structured retry info */
|
|
64
|
+
onRetry?: (info: RetryInfo) => void;
|
|
48
65
|
}
|
|
49
66
|
/**
|
|
50
67
|
* Context for automatic token refresh when a request returns 401 Unauthorized.
|
|
@@ -114,6 +131,103 @@ declare function scFetch<T>(options: RequestOptions, refreshCtx?: AutoRefreshCon
|
|
|
114
131
|
*/
|
|
115
132
|
declare function scFetchUrl<T>(url: string, token?: string, retryConfig?: RetryConfig, onRequest?: (telemetry: SCRequestTelemetry) => void): Promise<T>;
|
|
116
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Raw response from the SoundCloud API, including status code and headers.
|
|
136
|
+
*/
|
|
137
|
+
type RawResponse<T = unknown> = {
|
|
138
|
+
/** Parsed response body */
|
|
139
|
+
data: T;
|
|
140
|
+
/** HTTP status code */
|
|
141
|
+
status: number;
|
|
142
|
+
/** Response headers as a plain object */
|
|
143
|
+
headers: Record<string, string>;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Low-level HTTP client that returns raw responses without throwing on non-2xx status codes.
|
|
147
|
+
* Useful when you need access to status codes, headers, or want to handle errors manually.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* const raw = sc.raw;
|
|
152
|
+
* const res = await raw.get('/tracks/123456');
|
|
153
|
+
* console.log(res.status, res.headers, res.data);
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
declare class RawClient {
|
|
157
|
+
private baseUrl;
|
|
158
|
+
private getToken;
|
|
159
|
+
private fetchFn;
|
|
160
|
+
constructor(baseUrl: string, getToken: () => string | undefined, fetchFn: typeof fetch);
|
|
161
|
+
/**
|
|
162
|
+
* Make a raw HTTP request. Path template placeholders like `{id}` are substituted
|
|
163
|
+
* from matching keys in `query` before the remaining query params are appended to
|
|
164
|
+
* the URL as search parameters.
|
|
165
|
+
*/
|
|
166
|
+
request<T = unknown>({ method, path, query, body, token, }: {
|
|
167
|
+
method: string;
|
|
168
|
+
path: string;
|
|
169
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
170
|
+
body?: unknown;
|
|
171
|
+
token?: string;
|
|
172
|
+
}): Promise<RawResponse<T>>;
|
|
173
|
+
/** GET shorthand */
|
|
174
|
+
get<T = unknown>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<RawResponse<T>>;
|
|
175
|
+
/** POST shorthand */
|
|
176
|
+
post<T = unknown>(path: string, body?: unknown): Promise<RawResponse<T>>;
|
|
177
|
+
/** PUT shorthand */
|
|
178
|
+
put<T = unknown>(path: string, body?: unknown): Promise<RawResponse<T>>;
|
|
179
|
+
/** DELETE shorthand */
|
|
180
|
+
delete<T = unknown>(path: string): Promise<RawResponse<T>>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* A cache entry with an expiration timestamp.
|
|
185
|
+
*/
|
|
186
|
+
interface SoundCloudCacheEntry<T> {
|
|
187
|
+
/** The cached value */
|
|
188
|
+
value: T;
|
|
189
|
+
/** Unix timestamp (ms) when this entry expires */
|
|
190
|
+
expiresAt: number;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Cache interface for SoundCloud API responses.
|
|
194
|
+
*
|
|
195
|
+
* Implement this interface to plug in any caching backend (in-memory, Redis, etc.).
|
|
196
|
+
* Pass an instance as `cache` in {@link SoundCloudClientConfig} to enable caching.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* // Simple in-memory implementation
|
|
201
|
+
* class SimpleCache implements SoundCloudCache {
|
|
202
|
+
* private store = new Map<string, SoundCloudCacheEntry<unknown>>();
|
|
203
|
+
*
|
|
204
|
+
* get<T>(key: string): T | undefined {
|
|
205
|
+
* const entry = this.store.get(key) as SoundCloudCacheEntry<T> | undefined;
|
|
206
|
+
* if (!entry || Date.now() > entry.expiresAt) return undefined;
|
|
207
|
+
* return entry.value;
|
|
208
|
+
* }
|
|
209
|
+
*
|
|
210
|
+
* set<T>(key: string, value: T, { ttlMs }: { ttlMs: number }): void {
|
|
211
|
+
* this.store.set(key, { value, expiresAt: Date.now() + ttlMs });
|
|
212
|
+
* }
|
|
213
|
+
*
|
|
214
|
+
* delete(key: string): void {
|
|
215
|
+
* this.store.delete(key);
|
|
216
|
+
* }
|
|
217
|
+
* }
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
interface SoundCloudCache {
|
|
221
|
+
/** Retrieve a cached value by key, or `undefined` if missing or expired */
|
|
222
|
+
get<T>(key: string): Promise<T | undefined> | T | undefined;
|
|
223
|
+
/** Store a value with a TTL in milliseconds */
|
|
224
|
+
set<T>(key: string, value: T, options: {
|
|
225
|
+
ttlMs: number;
|
|
226
|
+
}): Promise<void> | void;
|
|
227
|
+
/** Remove a cached entry */
|
|
228
|
+
delete(key: string): Promise<void> | void;
|
|
229
|
+
}
|
|
230
|
+
|
|
117
231
|
/**
|
|
118
232
|
* Parameters for updating a track's metadata via {@link updateTrack}.
|
|
119
233
|
*/
|
|
@@ -321,6 +435,16 @@ interface SoundCloudClientConfig {
|
|
|
321
435
|
onDebug?: (message: string) => void;
|
|
322
436
|
/** Called after every API request with structured telemetry (timing, status, retries) */
|
|
323
437
|
onRequest?: (telemetry: SCRequestTelemetry) => void;
|
|
438
|
+
/** Custom fetch implementation (defaults to `globalThis.fetch`) */
|
|
439
|
+
fetch?: typeof globalThis.fetch;
|
|
440
|
+
/** Deduplicate concurrent identical requests (default: true) */
|
|
441
|
+
dedupe?: boolean;
|
|
442
|
+
/** Optional cache backend for API responses */
|
|
443
|
+
cache?: SoundCloudCache;
|
|
444
|
+
/** Default TTL in milliseconds for cached responses (default: 60000) */
|
|
445
|
+
cacheTtlMs?: number;
|
|
446
|
+
/** Called before each retry attempt with structured retry info */
|
|
447
|
+
onRetry?: (info: RetryInfo) => void;
|
|
324
448
|
}
|
|
325
449
|
/**
|
|
326
450
|
* Optional token override that can be passed as the last parameter to client methods.
|
|
@@ -386,6 +510,8 @@ declare class SoundCloudClient {
|
|
|
386
510
|
likes: SoundCloudClient.Likes;
|
|
387
511
|
/** Repost/unrepost actions (/reposts) */
|
|
388
512
|
reposts: SoundCloudClient.Reposts;
|
|
513
|
+
/** Low-level raw HTTP client — returns status/headers without throwing on non-2xx */
|
|
514
|
+
raw: RawClient;
|
|
389
515
|
/**
|
|
390
516
|
* Creates a new SoundCloudClient instance.
|
|
391
517
|
*
|
|
@@ -1311,6 +1437,42 @@ declare namespace SoundCloudClient {
|
|
|
1311
1437
|
}
|
|
1312
1438
|
}
|
|
1313
1439
|
|
|
1440
|
+
/**
|
|
1441
|
+
* Deduplicates concurrent in-flight requests with the same key.
|
|
1442
|
+
*
|
|
1443
|
+
* When multiple callers request the same resource simultaneously,
|
|
1444
|
+
* only one underlying promise is created — all callers share the result.
|
|
1445
|
+
* The key is cleaned up automatically once the promise settles.
|
|
1446
|
+
*
|
|
1447
|
+
* @example
|
|
1448
|
+
* ```ts
|
|
1449
|
+
* const deduper = new InFlightDeduper();
|
|
1450
|
+
*
|
|
1451
|
+
* // Both calls share a single fetch:
|
|
1452
|
+
* const [a, b] = await Promise.all([
|
|
1453
|
+
* deduper.add('track:123', () => fetchTrack(123)),
|
|
1454
|
+
* deduper.add('track:123', () => fetchTrack(123)),
|
|
1455
|
+
* ]);
|
|
1456
|
+
* // a === b (same resolved value)
|
|
1457
|
+
* ```
|
|
1458
|
+
*/
|
|
1459
|
+
declare class InFlightDeduper {
|
|
1460
|
+
private inFlight;
|
|
1461
|
+
/**
|
|
1462
|
+
* Return an existing in-flight promise for `key`, or start a new one via `factory`.
|
|
1463
|
+
* The entry is removed from the map once the promise settles (resolve or reject).
|
|
1464
|
+
*/
|
|
1465
|
+
add<T>(key: string, factory: () => Promise<T>): Promise<T>;
|
|
1466
|
+
/** Number of currently in-flight requests */
|
|
1467
|
+
get size(): number;
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
/**
|
|
1471
|
+
* List of operation IDs currently implemented by soundcloud-api-ts.
|
|
1472
|
+
* Used for OpenAPI coverage reporting.
|
|
1473
|
+
*/
|
|
1474
|
+
declare const IMPLEMENTED_OPERATIONS: string[];
|
|
1475
|
+
|
|
1314
1476
|
/**
|
|
1315
1477
|
* Async generator that automatically follows `next_href` pagination,
|
|
1316
1478
|
* yielding each page's `collection` array.
|
|
@@ -2463,4 +2625,4 @@ declare const unrepostPlaylist: (token: string, playlistId: string | number) =>
|
|
|
2463
2625
|
*/
|
|
2464
2626
|
declare const getSoundCloudWidgetUrl: (trackId: string | number) => string;
|
|
2465
2627
|
|
|
2466
|
-
export { type CreatePlaylistParams, type RequestOptions, type RetryConfig, type SCRequestTelemetry, SoundCloudActivitiesResponse, SoundCloudClient, type SoundCloudClientConfig, SoundCloudComment, SoundCloudMe, SoundCloudPaginatedResponse, SoundCloudPlaylist, SoundCloudStreams, SoundCloudToken, SoundCloudTrack, SoundCloudUser, SoundCloudWebProfile, type TokenOption, type UpdatePlaylistParams, type UpdateTrackParams, createPlaylist, createTrackComment, deletePlaylist, deleteTrack, fetchAll, followUser, generateCodeChallenge, generateCodeVerifier, getAuthorizationUrl, getClientToken, getFollowers, getFollowings, getMe, getMeActivities, getMeActivitiesOwn, getMeActivitiesTracks, getMeFollowers, getMeFollowings, getMeFollowingsTracks, getMeLikesPlaylists, getMeLikesTracks, getMePlaylists, getMeTracks, getPlaylist, getPlaylistReposts, getPlaylistTracks, getRelatedTracks, getSoundCloudWidgetUrl, getTrack, getTrackComments, getTrackLikes, getTrackReposts, getTrackStreams, getUser, getUserLikesPlaylists, getUserLikesTracks, getUserPlaylists, getUserToken, getUserTracks, getUserWebProfiles, likePlaylist, likeTrack, paginate, paginateItems, refreshUserToken, repostPlaylist, repostTrack, resolveUrl, scFetch, scFetchUrl, searchPlaylists, searchTracks, searchUsers, signOut, unfollowUser, unlikePlaylist, unlikeTrack, unrepostPlaylist, unrepostTrack, updatePlaylist, updateTrack };
|
|
2628
|
+
export { type CreatePlaylistParams, IMPLEMENTED_OPERATIONS, InFlightDeduper, RawClient, type RawResponse, type RequestOptions, type RetryConfig, type RetryInfo, type SCRequestTelemetry, SoundCloudActivitiesResponse, type SoundCloudCache, type SoundCloudCacheEntry, SoundCloudClient, type SoundCloudClientConfig, SoundCloudComment, SoundCloudMe, SoundCloudPaginatedResponse, SoundCloudPlaylist, SoundCloudStreams, SoundCloudToken, SoundCloudTrack, SoundCloudUser, SoundCloudWebProfile, type TokenOption, type UpdatePlaylistParams, type UpdateTrackParams, createPlaylist, createTrackComment, deletePlaylist, deleteTrack, fetchAll, followUser, generateCodeChallenge, generateCodeVerifier, getAuthorizationUrl, getClientToken, getFollowers, getFollowings, getMe, getMeActivities, getMeActivitiesOwn, getMeActivitiesTracks, getMeFollowers, getMeFollowings, getMeFollowingsTracks, getMeLikesPlaylists, getMeLikesTracks, getMePlaylists, getMeTracks, getPlaylist, getPlaylistReposts, getPlaylistTracks, getRelatedTracks, getSoundCloudWidgetUrl, getTrack, getTrackComments, getTrackLikes, getTrackReposts, getTrackStreams, getUser, getUserLikesPlaylists, getUserLikesTracks, getUserPlaylists, getUserToken, getUserTracks, getUserWebProfiles, likePlaylist, likeTrack, paginate, paginateItems, refreshUserToken, repostPlaylist, repostTrack, resolveUrl, scFetch, scFetchUrl, searchPlaylists, searchTracks, searchUsers, signOut, unfollowUser, unlikePlaylist, unlikeTrack, unrepostPlaylist, unrepostTrack, updatePlaylist, updateTrack };
|