soundcloud-api-ts 1.4.0 → 1.4.2

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.
@@ -53,5 +53,5 @@ var SoundCloudError = class extends Error {
53
53
  };
54
54
 
55
55
  export { SoundCloudError };
56
- //# sourceMappingURL=chunk-ALTJSKVN.mjs.map
57
- //# sourceMappingURL=chunk-ALTJSKVN.mjs.map
56
+ //# sourceMappingURL=chunk-CYDTNVV3.mjs.map
57
+ //# sourceMappingURL=chunk-CYDTNVV3.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts"],"names":[],"mappings":";AA6DO,IAAM,eAAA,GAAN,cAA8B,KAAA,CAAM;AAAA;AAAA,EAEhC,MAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA,EAEA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAST,WAAA,CAAY,MAAA,EAAgB,UAAA,EAAoB,IAAA,EAA4B;AAE1E,IAAA,MAAM,MACJ,IAAA,EAAM,OAAA,IACN,IAAA,EAAM,iBAAA,IACN,MAAM,UAAA,IACN,IAAA,EAAM,MAAA,GAAS,CAAC,GAAG,aAAA,IACnB,IAAA,EAAM,SACN,CAAA,EAAG,MAAM,IAAI,UAAU,CAAA,CAAA;AAEzB,IAAA,KAAA,CAAM,GAAG,CAAA;AACT,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAClB,IAAA,IAAA,CAAK,SAAA,GAAY,MAAM,UAAA,IAAc,MAAA;AACrC,IAAA,IAAA,CAAK,QAAA,GAAW,MAAM,IAAA,IAAQ,MAAA;AAC9B,IAAA,IAAA,CAAK,SACH,IAAA,EAAM,MAAA,EACF,GAAA,CAAI,CAAC,MAAM,CAAA,CAAE,aAAa,CAAA,CAC3B,MAAA,CAAO,CAAC,CAAA,KAAmB,CAAC,CAAC,CAAC,KAAK,EAAC;AACzC,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,cAAA,GAA0B;AAC5B,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,WAAA,GAAuB;AACzB,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,UAAA,GAAsB;AACxB,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,aAAA,GAAyB;AAC3B,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,aAAA,GAAyB;AAC3B,IAAA,OAAO,IAAA,CAAK,MAAA,IAAU,GAAA,IAAO,IAAA,CAAK,MAAA,GAAS,GAAA;AAAA,EAC7C;AACF","file":"chunk-ALTJSKVN.mjs","sourcesContent":["/**\n * Shape of error response bodies returned by the SoundCloud API.\n *\n * The API returns varying combinations of these fields depending on the endpoint\n * and error type. All fields are optional.\n *\n * @example\n * ```json\n * {\n * \"code\": 401,\n * \"message\": \"invalid_client\",\n * \"link\": \"https://developers.soundcloud.com/docs/api/explorer/open-api\",\n * \"status\": \"401 - Unauthorized\",\n * \"errors\": [{\"error_message\": \"invalid_client\"}],\n * \"error\": null,\n * \"error_code\": \"invalid_client\"\n * }\n * ```\n *\n * @see https://developers.soundcloud.com/docs/api/explorer/open-api\n */\nexport interface SoundCloudErrorBody {\n /** HTTP status code echoed in the response body */\n code?: number;\n /** Error message from SoundCloud (e.g. \"invalid_client\", \"404 - Not Found\") */\n message?: string;\n /** Human-readable status string (e.g. \"401 - Unauthorized\") */\n status?: string;\n /** Link to SoundCloud API documentation */\n link?: string;\n /** Array of individual error detail objects */\n errors?: Array<{ error_message?: string }>;\n /** Generic error field — typically null in SoundCloud responses */\n error?: string | null;\n /** Machine-readable error code (e.g. \"invalid_client\") */\n error_code?: string;\n /** OAuth error description, present in `/oauth2/token` error responses */\n error_description?: string;\n}\n\n/**\n * Error class thrown when a SoundCloud API request fails.\n *\n * Provides structured access to HTTP status, error codes, and convenience\n * getters for common error categories.\n *\n * @example\n * ```ts\n * import { SoundCloudError } from 'tsd-soundcloud';\n *\n * try {\n * await sc.tracks.getTrack(999999999);\n * } catch (err) {\n * if (err instanceof SoundCloudError) {\n * if (err.isNotFound) console.log('Track not found');\n * if (err.isRateLimited) console.log('Rate limited, retry later');\n * console.log(err.status, err.message);\n * }\n * }\n * ```\n */\nexport class SoundCloudError extends Error {\n /** HTTP status code of the failed response (e.g. 401, 404, 429) */\n readonly status: number;\n /** HTTP status text of the failed response (e.g. \"Unauthorized\", \"Not Found\") */\n readonly statusText: string;\n /** Machine-readable error code from SoundCloud (e.g. \"invalid_client\"), if present */\n readonly errorCode?: string;\n /** Link to SoundCloud API documentation, if included in the error response */\n readonly docsLink?: string;\n /** Individual error messages extracted from the response body's `errors` array */\n readonly errors: string[];\n /** The full parsed error response body, if available */\n readonly body?: SoundCloudErrorBody;\n\n /**\n * Creates a new SoundCloudError.\n *\n * @param status - HTTP status code\n * @param statusText - HTTP status text\n * @param body - Parsed JSON error response body from SoundCloud, if available\n */\n constructor(status: number, statusText: string, body?: SoundCloudErrorBody) {\n // Build the most useful message we can from SC's response\n const msg =\n body?.message ||\n body?.error_description ||\n body?.error_code ||\n body?.errors?.[0]?.error_message ||\n body?.error ||\n `${status} ${statusText}`;\n\n super(msg);\n this.name = \"SoundCloudError\";\n this.status = status;\n this.statusText = statusText;\n this.errorCode = body?.error_code ?? undefined;\n this.docsLink = body?.link ?? undefined;\n this.errors =\n body?.errors\n ?.map((e) => e.error_message)\n .filter((m): m is string => !!m) ?? [];\n this.body = body;\n }\n\n /** True if status is 401 Unauthorized (invalid or expired token) */\n get isUnauthorized(): boolean {\n return this.status === 401;\n }\n\n /** True if status is 403 Forbidden (insufficient permissions) */\n get isForbidden(): boolean {\n return this.status === 403;\n }\n\n /** True if status is 404 Not Found (resource does not exist) */\n get isNotFound(): boolean {\n return this.status === 404;\n }\n\n /** True if status is 429 Too Many Requests (rate limit exceeded) */\n get isRateLimited(): boolean {\n return this.status === 429;\n }\n\n /** True if status is 5xx (SoundCloud server error) */\n get isServerError(): boolean {\n return this.status >= 500 && this.status < 600;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/errors.ts"],"names":[],"mappings":";AA6DO,IAAM,eAAA,GAAN,cAA8B,KAAA,CAAM;AAAA;AAAA,EAEhC,MAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA,EAEA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAST,WAAA,CAAY,MAAA,EAAgB,UAAA,EAAoB,IAAA,EAA4B;AAE1E,IAAA,MAAM,MACJ,IAAA,EAAM,OAAA,IACN,IAAA,EAAM,iBAAA,IACN,MAAM,UAAA,IACN,IAAA,EAAM,MAAA,GAAS,CAAC,GAAG,aAAA,IACnB,IAAA,EAAM,SACN,CAAA,EAAG,MAAM,IAAI,UAAU,CAAA,CAAA;AAEzB,IAAA,KAAA,CAAM,GAAG,CAAA;AACT,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAClB,IAAA,IAAA,CAAK,SAAA,GAAY,MAAM,UAAA,IAAc,MAAA;AACrC,IAAA,IAAA,CAAK,QAAA,GAAW,MAAM,IAAA,IAAQ,MAAA;AAC9B,IAAA,IAAA,CAAK,SACH,IAAA,EAAM,MAAA,EACF,GAAA,CAAI,CAAC,MAAM,CAAA,CAAE,aAAa,CAAA,CAC3B,MAAA,CAAO,CAAC,CAAA,KAAmB,CAAC,CAAC,CAAC,KAAK,EAAC;AACzC,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,cAAA,GAA0B;AAC5B,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,WAAA,GAAuB;AACzB,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,UAAA,GAAsB;AACxB,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,aAAA,GAAyB;AAC3B,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,aAAA,GAAyB;AAC3B,IAAA,OAAO,IAAA,CAAK,MAAA,IAAU,GAAA,IAAO,IAAA,CAAK,MAAA,GAAS,GAAA;AAAA,EAC7C;AACF","file":"chunk-CYDTNVV3.mjs","sourcesContent":["/**\n * Shape of error response bodies returned by the SoundCloud API.\n *\n * The API returns varying combinations of these fields depending on the endpoint\n * and error type. All fields are optional.\n *\n * @example\n * ```json\n * {\n * \"code\": 401,\n * \"message\": \"invalid_client\",\n * \"link\": \"https://developers.soundcloud.com/docs/api/explorer/open-api\",\n * \"status\": \"401 - Unauthorized\",\n * \"errors\": [{\"error_message\": \"invalid_client\"}],\n * \"error\": null,\n * \"error_code\": \"invalid_client\"\n * }\n * ```\n *\n * @see https://developers.soundcloud.com/docs/api/explorer/open-api\n */\nexport interface SoundCloudErrorBody {\n /** HTTP status code echoed in the response body */\n code?: number;\n /** Error message from SoundCloud (e.g. \"invalid_client\", \"404 - Not Found\") */\n message?: string;\n /** Human-readable status string (e.g. \"401 - Unauthorized\") */\n status?: string;\n /** Link to SoundCloud API documentation */\n link?: string;\n /** Array of individual error detail objects */\n errors?: Array<{ error_message?: string }>;\n /** Generic error field — typically null in SoundCloud responses */\n error?: string | null;\n /** Machine-readable error code (e.g. \"invalid_client\") */\n error_code?: string;\n /** OAuth error description, present in `/oauth2/token` error responses */\n error_description?: string;\n}\n\n/**\n * Error class thrown when a SoundCloud API request fails.\n *\n * Provides structured access to HTTP status, error codes, and convenience\n * getters for common error categories.\n *\n * @example\n * ```ts\n * import { SoundCloudError } from 'soundcloud-api-ts';\n *\n * try {\n * await sc.tracks.getTrack(999999999);\n * } catch (err) {\n * if (err instanceof SoundCloudError) {\n * if (err.isNotFound) console.log('Track not found');\n * if (err.isRateLimited) console.log('Rate limited, retry later');\n * console.log(err.status, err.message);\n * }\n * }\n * ```\n */\nexport class SoundCloudError extends Error {\n /** HTTP status code of the failed response (e.g. 401, 404, 429) */\n readonly status: number;\n /** HTTP status text of the failed response (e.g. \"Unauthorized\", \"Not Found\") */\n readonly statusText: string;\n /** Machine-readable error code from SoundCloud (e.g. \"invalid_client\"), if present */\n readonly errorCode?: string;\n /** Link to SoundCloud API documentation, if included in the error response */\n readonly docsLink?: string;\n /** Individual error messages extracted from the response body's `errors` array */\n readonly errors: string[];\n /** The full parsed error response body, if available */\n readonly body?: SoundCloudErrorBody;\n\n /**\n * Creates a new SoundCloudError.\n *\n * @param status - HTTP status code\n * @param statusText - HTTP status text\n * @param body - Parsed JSON error response body from SoundCloud, if available\n */\n constructor(status: number, statusText: string, body?: SoundCloudErrorBody) {\n // Build the most useful message we can from SC's response\n const msg =\n body?.message ||\n body?.error_description ||\n body?.error_code ||\n body?.errors?.[0]?.error_message ||\n body?.error ||\n `${status} ${statusText}`;\n\n super(msg);\n this.name = \"SoundCloudError\";\n this.status = status;\n this.statusText = statusText;\n this.errorCode = body?.error_code ?? undefined;\n this.docsLink = body?.link ?? undefined;\n this.errors =\n body?.errors\n ?.map((e) => e.error_message)\n .filter((m): m is string => !!m) ?? [];\n this.body = body;\n }\n\n /** True if status is 401 Unauthorized (invalid or expired token) */\n get isUnauthorized(): boolean {\n return this.status === 401;\n }\n\n /** True if status is 403 Forbidden (insufficient permissions) */\n get isForbidden(): boolean {\n return this.status === 403;\n }\n\n /** True if status is 404 Not Found (resource does not exist) */\n get isNotFound(): boolean {\n return this.status === 404;\n }\n\n /** True if status is 429 Too Many Requests (rate limit exceeded) */\n get isRateLimited(): boolean {\n return this.status === 429;\n }\n\n /** True if status is 5xx (SoundCloud server error) */\n get isServerError(): boolean {\n return this.status >= 500 && this.status < 600;\n }\n}\n"]}
@@ -55,5 +55,5 @@ var SoundCloudError = class extends Error {
55
55
  };
56
56
 
57
57
  exports.SoundCloudError = SoundCloudError;
58
- //# sourceMappingURL=chunk-DZRZLIAH.js.map
59
- //# sourceMappingURL=chunk-DZRZLIAH.js.map
58
+ //# sourceMappingURL=chunk-NBKG62HR.js.map
59
+ //# sourceMappingURL=chunk-NBKG62HR.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts"],"names":[],"mappings":";;;AA6DO,IAAM,eAAA,GAAN,cAA8B,KAAA,CAAM;AAAA;AAAA,EAEhC,MAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA,EAEA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAST,WAAA,CAAY,MAAA,EAAgB,UAAA,EAAoB,IAAA,EAA4B;AAE1E,IAAA,MAAM,MACJ,IAAA,EAAM,OAAA,IACN,IAAA,EAAM,iBAAA,IACN,MAAM,UAAA,IACN,IAAA,EAAM,MAAA,GAAS,CAAC,GAAG,aAAA,IACnB,IAAA,EAAM,SACN,CAAA,EAAG,MAAM,IAAI,UAAU,CAAA,CAAA;AAEzB,IAAA,KAAA,CAAM,GAAG,CAAA;AACT,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAClB,IAAA,IAAA,CAAK,SAAA,GAAY,MAAM,UAAA,IAAc,MAAA;AACrC,IAAA,IAAA,CAAK,QAAA,GAAW,MAAM,IAAA,IAAQ,MAAA;AAC9B,IAAA,IAAA,CAAK,SACH,IAAA,EAAM,MAAA,EACF,GAAA,CAAI,CAAC,MAAM,CAAA,CAAE,aAAa,CAAA,CAC3B,MAAA,CAAO,CAAC,CAAA,KAAmB,CAAC,CAAC,CAAC,KAAK,EAAC;AACzC,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,cAAA,GAA0B;AAC5B,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,WAAA,GAAuB;AACzB,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,UAAA,GAAsB;AACxB,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,aAAA,GAAyB;AAC3B,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,aAAA,GAAyB;AAC3B,IAAA,OAAO,IAAA,CAAK,MAAA,IAAU,GAAA,IAAO,IAAA,CAAK,MAAA,GAAS,GAAA;AAAA,EAC7C;AACF","file":"chunk-DZRZLIAH.js","sourcesContent":["/**\n * Shape of error response bodies returned by the SoundCloud API.\n *\n * The API returns varying combinations of these fields depending on the endpoint\n * and error type. All fields are optional.\n *\n * @example\n * ```json\n * {\n * \"code\": 401,\n * \"message\": \"invalid_client\",\n * \"link\": \"https://developers.soundcloud.com/docs/api/explorer/open-api\",\n * \"status\": \"401 - Unauthorized\",\n * \"errors\": [{\"error_message\": \"invalid_client\"}],\n * \"error\": null,\n * \"error_code\": \"invalid_client\"\n * }\n * ```\n *\n * @see https://developers.soundcloud.com/docs/api/explorer/open-api\n */\nexport interface SoundCloudErrorBody {\n /** HTTP status code echoed in the response body */\n code?: number;\n /** Error message from SoundCloud (e.g. \"invalid_client\", \"404 - Not Found\") */\n message?: string;\n /** Human-readable status string (e.g. \"401 - Unauthorized\") */\n status?: string;\n /** Link to SoundCloud API documentation */\n link?: string;\n /** Array of individual error detail objects */\n errors?: Array<{ error_message?: string }>;\n /** Generic error field — typically null in SoundCloud responses */\n error?: string | null;\n /** Machine-readable error code (e.g. \"invalid_client\") */\n error_code?: string;\n /** OAuth error description, present in `/oauth2/token` error responses */\n error_description?: string;\n}\n\n/**\n * Error class thrown when a SoundCloud API request fails.\n *\n * Provides structured access to HTTP status, error codes, and convenience\n * getters for common error categories.\n *\n * @example\n * ```ts\n * import { SoundCloudError } from 'tsd-soundcloud';\n *\n * try {\n * await sc.tracks.getTrack(999999999);\n * } catch (err) {\n * if (err instanceof SoundCloudError) {\n * if (err.isNotFound) console.log('Track not found');\n * if (err.isRateLimited) console.log('Rate limited, retry later');\n * console.log(err.status, err.message);\n * }\n * }\n * ```\n */\nexport class SoundCloudError extends Error {\n /** HTTP status code of the failed response (e.g. 401, 404, 429) */\n readonly status: number;\n /** HTTP status text of the failed response (e.g. \"Unauthorized\", \"Not Found\") */\n readonly statusText: string;\n /** Machine-readable error code from SoundCloud (e.g. \"invalid_client\"), if present */\n readonly errorCode?: string;\n /** Link to SoundCloud API documentation, if included in the error response */\n readonly docsLink?: string;\n /** Individual error messages extracted from the response body's `errors` array */\n readonly errors: string[];\n /** The full parsed error response body, if available */\n readonly body?: SoundCloudErrorBody;\n\n /**\n * Creates a new SoundCloudError.\n *\n * @param status - HTTP status code\n * @param statusText - HTTP status text\n * @param body - Parsed JSON error response body from SoundCloud, if available\n */\n constructor(status: number, statusText: string, body?: SoundCloudErrorBody) {\n // Build the most useful message we can from SC's response\n const msg =\n body?.message ||\n body?.error_description ||\n body?.error_code ||\n body?.errors?.[0]?.error_message ||\n body?.error ||\n `${status} ${statusText}`;\n\n super(msg);\n this.name = \"SoundCloudError\";\n this.status = status;\n this.statusText = statusText;\n this.errorCode = body?.error_code ?? undefined;\n this.docsLink = body?.link ?? undefined;\n this.errors =\n body?.errors\n ?.map((e) => e.error_message)\n .filter((m): m is string => !!m) ?? [];\n this.body = body;\n }\n\n /** True if status is 401 Unauthorized (invalid or expired token) */\n get isUnauthorized(): boolean {\n return this.status === 401;\n }\n\n /** True if status is 403 Forbidden (insufficient permissions) */\n get isForbidden(): boolean {\n return this.status === 403;\n }\n\n /** True if status is 404 Not Found (resource does not exist) */\n get isNotFound(): boolean {\n return this.status === 404;\n }\n\n /** True if status is 429 Too Many Requests (rate limit exceeded) */\n get isRateLimited(): boolean {\n return this.status === 429;\n }\n\n /** True if status is 5xx (SoundCloud server error) */\n get isServerError(): boolean {\n return this.status >= 500 && this.status < 600;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/errors.ts"],"names":[],"mappings":";;;AA6DO,IAAM,eAAA,GAAN,cAA8B,KAAA,CAAM;AAAA;AAAA,EAEhC,MAAA;AAAA;AAAA,EAEA,UAAA;AAAA;AAAA,EAEA,SAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAAA,EAEA,MAAA;AAAA;AAAA,EAEA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAST,WAAA,CAAY,MAAA,EAAgB,UAAA,EAAoB,IAAA,EAA4B;AAE1E,IAAA,MAAM,MACJ,IAAA,EAAM,OAAA,IACN,IAAA,EAAM,iBAAA,IACN,MAAM,UAAA,IACN,IAAA,EAAM,MAAA,GAAS,CAAC,GAAG,aAAA,IACnB,IAAA,EAAM,SACN,CAAA,EAAG,MAAM,IAAI,UAAU,CAAA,CAAA;AAEzB,IAAA,KAAA,CAAM,GAAG,CAAA;AACT,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAClB,IAAA,IAAA,CAAK,SAAA,GAAY,MAAM,UAAA,IAAc,MAAA;AACrC,IAAA,IAAA,CAAK,QAAA,GAAW,MAAM,IAAA,IAAQ,MAAA;AAC9B,IAAA,IAAA,CAAK,SACH,IAAA,EAAM,MAAA,EACF,GAAA,CAAI,CAAC,MAAM,CAAA,CAAE,aAAa,CAAA,CAC3B,MAAA,CAAO,CAAC,CAAA,KAAmB,CAAC,CAAC,CAAC,KAAK,EAAC;AACzC,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,cAAA,GAA0B;AAC5B,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,WAAA,GAAuB;AACzB,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,UAAA,GAAsB;AACxB,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,aAAA,GAAyB;AAC3B,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,aAAA,GAAyB;AAC3B,IAAA,OAAO,IAAA,CAAK,MAAA,IAAU,GAAA,IAAO,IAAA,CAAK,MAAA,GAAS,GAAA;AAAA,EAC7C;AACF","file":"chunk-NBKG62HR.js","sourcesContent":["/**\n * Shape of error response bodies returned by the SoundCloud API.\n *\n * The API returns varying combinations of these fields depending on the endpoint\n * and error type. All fields are optional.\n *\n * @example\n * ```json\n * {\n * \"code\": 401,\n * \"message\": \"invalid_client\",\n * \"link\": \"https://developers.soundcloud.com/docs/api/explorer/open-api\",\n * \"status\": \"401 - Unauthorized\",\n * \"errors\": [{\"error_message\": \"invalid_client\"}],\n * \"error\": null,\n * \"error_code\": \"invalid_client\"\n * }\n * ```\n *\n * @see https://developers.soundcloud.com/docs/api/explorer/open-api\n */\nexport interface SoundCloudErrorBody {\n /** HTTP status code echoed in the response body */\n code?: number;\n /** Error message from SoundCloud (e.g. \"invalid_client\", \"404 - Not Found\") */\n message?: string;\n /** Human-readable status string (e.g. \"401 - Unauthorized\") */\n status?: string;\n /** Link to SoundCloud API documentation */\n link?: string;\n /** Array of individual error detail objects */\n errors?: Array<{ error_message?: string }>;\n /** Generic error field — typically null in SoundCloud responses */\n error?: string | null;\n /** Machine-readable error code (e.g. \"invalid_client\") */\n error_code?: string;\n /** OAuth error description, present in `/oauth2/token` error responses */\n error_description?: string;\n}\n\n/**\n * Error class thrown when a SoundCloud API request fails.\n *\n * Provides structured access to HTTP status, error codes, and convenience\n * getters for common error categories.\n *\n * @example\n * ```ts\n * import { SoundCloudError } from 'soundcloud-api-ts';\n *\n * try {\n * await sc.tracks.getTrack(999999999);\n * } catch (err) {\n * if (err instanceof SoundCloudError) {\n * if (err.isNotFound) console.log('Track not found');\n * if (err.isRateLimited) console.log('Rate limited, retry later');\n * console.log(err.status, err.message);\n * }\n * }\n * ```\n */\nexport class SoundCloudError extends Error {\n /** HTTP status code of the failed response (e.g. 401, 404, 429) */\n readonly status: number;\n /** HTTP status text of the failed response (e.g. \"Unauthorized\", \"Not Found\") */\n readonly statusText: string;\n /** Machine-readable error code from SoundCloud (e.g. \"invalid_client\"), if present */\n readonly errorCode?: string;\n /** Link to SoundCloud API documentation, if included in the error response */\n readonly docsLink?: string;\n /** Individual error messages extracted from the response body's `errors` array */\n readonly errors: string[];\n /** The full parsed error response body, if available */\n readonly body?: SoundCloudErrorBody;\n\n /**\n * Creates a new SoundCloudError.\n *\n * @param status - HTTP status code\n * @param statusText - HTTP status text\n * @param body - Parsed JSON error response body from SoundCloud, if available\n */\n constructor(status: number, statusText: string, body?: SoundCloudErrorBody) {\n // Build the most useful message we can from SC's response\n const msg =\n body?.message ||\n body?.error_description ||\n body?.error_code ||\n body?.errors?.[0]?.error_message ||\n body?.error ||\n `${status} ${statusText}`;\n\n super(msg);\n this.name = \"SoundCloudError\";\n this.status = status;\n this.statusText = statusText;\n this.errorCode = body?.error_code ?? undefined;\n this.docsLink = body?.link ?? undefined;\n this.errors =\n body?.errors\n ?.map((e) => e.error_message)\n .filter((m): m is string => !!m) ?? [];\n this.body = body;\n }\n\n /** True if status is 401 Unauthorized (invalid or expired token) */\n get isUnauthorized(): boolean {\n return this.status === 401;\n }\n\n /** True if status is 403 Forbidden (insufficient permissions) */\n get isForbidden(): boolean {\n return this.status === 403;\n }\n\n /** True if status is 404 Not Found (resource does not exist) */\n get isNotFound(): boolean {\n return this.status === 404;\n }\n\n /** True if status is 429 Too Many Requests (rate limit exceeded) */\n get isRateLimited(): boolean {\n return this.status === 429;\n }\n\n /** True if status is 5xx (SoundCloud server error) */\n get isServerError(): boolean {\n return this.status >= 500 && this.status < 600;\n }\n}\n"]}