Fix review issues: lyrics polling, validation, undici fetch, retry, timeout, throttle, payload helper

This commit is contained in:
OpenCode
2026-07-14 16:17:51 +07:00
parent ac22e28128
commit 82087be1b3
14 changed files with 628 additions and 315 deletions
+10 -2
View File
@@ -1,5 +1,5 @@
/**
* Suno API HTTP client with rate limiting and polling helpers.
* Suno API HTTP client with rate limiting, proxy support, retries and polling helpers.
*
* Rate limit: 20 requests per 10 seconds (sunoapi.org).
* Proxy support via SUNO_HTTP_PROXY / HTTPS_PROXY / HTTP_PROXY env vars.
@@ -28,13 +28,19 @@ export interface SunoTrack {
createTime?: string;
duration?: number;
}
export interface SunoLyricsVariant {
text?: string;
title?: string;
status?: string;
errorMessage?: string;
}
export interface SunoTaskData {
taskId: string;
parentMusicId?: string;
param?: string;
response?: {
taskId?: string;
data?: SunoTrack[];
data?: SunoTrack[] | SunoLyricsVariant[];
sunoData?: SunoTrack[];
};
status: string;
@@ -49,6 +55,8 @@ export declare class SunoClient {
private readonly maxRequests;
private readonly windowMs;
private readonly proxyAgent?;
private readonly requestTimeoutMs;
private readonly maxRetries;
private requestTimestamps;
constructor(apiKey: string);
/**