@lrclib.js/api-types
Advanced tools
+135
| //#region src/types/API.d.ts | ||
| declare namespace APIOptions { | ||
| namespace Get { | ||
| interface TrackSignatureOptions { | ||
| /** | ||
| * Title of the track | ||
| */ | ||
| track_name: string; | ||
| /** | ||
| * Name of the artist | ||
| */ | ||
| artist_name: string; | ||
| /** | ||
| * Name of the album | ||
| */ | ||
| album_name?: string; | ||
| /** | ||
| * Track's duration in seconds | ||
| */ | ||
| duration: number; | ||
| } | ||
| interface TrackById { | ||
| /** | ||
| * ID of the lyrics record | ||
| */ | ||
| id: number; | ||
| } | ||
| interface SearchQuery { | ||
| /** | ||
| * Search for keyword present in ANY fields (track's title, artist name or album name) | ||
| */ | ||
| q: string; | ||
| } | ||
| interface SearchTrackSignature { | ||
| /** | ||
| * Search for keyword in track's title | ||
| */ | ||
| track_name: string; | ||
| /** | ||
| * Search for keyword in artist's name | ||
| */ | ||
| artist_name?: string; | ||
| /** | ||
| * Search for keyword in album's name | ||
| */ | ||
| album_name?: string; | ||
| } | ||
| type Search = SearchQuery | SearchTrackSignature; | ||
| } | ||
| namespace Post { | ||
| interface Publish { | ||
| /** | ||
| * Title of the track | ||
| */ | ||
| trackName: string; | ||
| /** | ||
| * Track's artist name | ||
| */ | ||
| artistName: string; | ||
| /** | ||
| * Track's album name | ||
| */ | ||
| albumName: string; | ||
| /** | ||
| * Track's duration | ||
| */ | ||
| duration: number; | ||
| /** | ||
| * Plain lyrics for the track | ||
| */ | ||
| plainLyrics: string; | ||
| /** | ||
| * Synchronized lyrics for the track | ||
| */ | ||
| syncedLyrics: string; | ||
| } | ||
| interface RequestChallenge {} | ||
| } | ||
| } | ||
| declare namespace APIResponse { | ||
| interface Error { | ||
| code: number; | ||
| name: string; | ||
| message: string; | ||
| } | ||
| namespace Get { | ||
| interface TrackSignature { | ||
| id: number; | ||
| trackName: string; | ||
| artistName: string; | ||
| albumName: string; | ||
| duration: number; | ||
| instrumental: boolean; | ||
| plainLyrics: string | null; | ||
| syncedLyrics: string | null; | ||
| } | ||
| interface TrackById extends TrackSignature {} | ||
| interface SearchQuery extends Array<TrackSignature> {} | ||
| interface SearchTrackSignature extends Array<TrackSignature> {} | ||
| } | ||
| namespace Post { | ||
| interface Publish {} | ||
| interface RequestChallenge { | ||
| prefix: string; | ||
| target: string; | ||
| } | ||
| } | ||
| } | ||
| interface APIPublishTokenData { | ||
| prefix: string; | ||
| nonce: string; | ||
| } | ||
| //#endregion | ||
| //#region src/structures/Routes.d.ts | ||
| declare class Routes { | ||
| private constructor(); | ||
| static [`/api/get`](options: APIOptions.Get.TrackSignatureOptions): `/api/get`; | ||
| static [`/api/get/{id}`](options: APIOptions.Get.TrackById): `/api/get/{id}`; | ||
| static [`/api/search`](options: APIOptions.Get.Search): `/api/search`; | ||
| static [`/api/publish`](): `/api/publish`; | ||
| static [`/api/request-challenge`](): `/api/request-challenge`; | ||
| private static parseURLSearchParams; | ||
| } | ||
| declare namespace Routes { | ||
| interface Metadata { | ||
| [`/api/get`]: [APIOptions.Get.TrackSignatureOptions, APIResponse.Get.TrackSignature]; | ||
| [`/api/get/{id}`]: [APIOptions.Get.TrackById, APIResponse.Get.TrackById]; | ||
| [`/api/search`]: [APIOptions.Get.Search, APIResponse.Get.SearchQuery]; | ||
| [`/api/publish`]: [APIOptions.Post.Publish, APIResponse.Post.Publish]; | ||
| [`/api/request-challenge`]: [APIOptions.Post.RequestChallenge, APIResponse.Post.RequestChallenge]; | ||
| [key: string]: [any, any]; | ||
| } | ||
| } | ||
| //#endregion | ||
| export { APIOptions, APIPublishTokenData, APIResponse, Routes }; |
| //#region src/structures/Routes.ts | ||
| var Routes = class Routes { | ||
| constructor() {} | ||
| static [`/api/get`](options) { | ||
| return `/api/get?${Routes.parseURLSearchParams(options)}`; | ||
| } | ||
| static [`/api/get/{id}`](options) { | ||
| return `/api/get/${options.id}`; | ||
| } | ||
| static [`/api/search`](options) { | ||
| return `/api/search?${Routes.parseURLSearchParams(options)}`; | ||
| } | ||
| static [`/api/publish`]() { | ||
| return `/api/publish`; | ||
| } | ||
| static [`/api/request-challenge`]() { | ||
| return `/api/request-challenge`; | ||
| } | ||
| static parseURLSearchParams(data) { | ||
| const searchParams = new URLSearchParams(); | ||
| for (const [key, value] of Object.entries(data)) if (value !== void 0) searchParams.append(key, String(value)); | ||
| return searchParams; | ||
| } | ||
| }; | ||
| //#endregion | ||
| export { Routes }; |
+24
| <div align="center"> | ||
| <img src="https://raw.githubusercontent.com/catplvsplus/lrclib.js/refs/heads/main/apps/website/static/banner.png" width="300"> | ||
| <h3 style="margin-top: 0">A library for interacting with lrclib.net API</h3> | ||
| </div> | ||
| --- | ||
| ``` | ||
| npm i @lrclib.js/api-types | ||
| ``` | ||
| ## Usage | ||
| ```ts | ||
| import { type APIOptions, type APIResponse, Routes } from '@lrclib.js/api-types'; | ||
| const options: APIOptions.Get.Search = { | ||
| q: 'Afterglow Taylor Swift' | ||
| }; | ||
| const response: APIResponse.Get.SearchQuery = await fetch( | ||
| Routes[`/api/search`](options) | ||
| ).then(res => res.json()); | ||
| ``` |
+7
-11
| { | ||
| "name": "@lrclib.js/api-types", | ||
| "version": "1.0.0", | ||
| "version": "1.1.0", | ||
| "type": "module", | ||
| "module": "dist/index.js", | ||
| "types": "dist/index.d.ts", | ||
| "module": "dist/index.mjs", | ||
| "types": "dist/index.d.mts", | ||
| "exports": { | ||
| ".": { | ||
| "import": { | ||
| "types": "./dist/index.d.ts", | ||
| "default": "./dist/index.js" | ||
| "types": "./dist/index.d.mts", | ||
| "default": "./dist/index.mjs" | ||
| } | ||
@@ -16,4 +16,3 @@ } | ||
| "scripts": { | ||
| "clean": "rimraf dist", | ||
| "build": "tsup", | ||
| "build": "tsdown --config-loader unrun", | ||
| "prepack": "npm run build" | ||
@@ -24,9 +23,6 @@ }, | ||
| ], | ||
| "devDependencies": { | ||
| "tsup": "^8.3.6" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "gitHead": "56d8a483dd6328cdbc51157d454625b1ac5a6e0f" | ||
| "gitHead": "bb1d176030b922b5f8681cc5c882d683794987bf" | ||
| } |
-138
| declare namespace APIOptions { | ||
| namespace Get { | ||
| interface TrackSignatureOptions { | ||
| /** | ||
| * Title of the track | ||
| */ | ||
| track_name: string; | ||
| /** | ||
| * Name of the artist | ||
| */ | ||
| artist_name: string; | ||
| /** | ||
| * Name of the album | ||
| */ | ||
| album_name?: string; | ||
| /** | ||
| * Track's duration in seconds | ||
| */ | ||
| duration: number; | ||
| } | ||
| interface TrackById { | ||
| /** | ||
| * ID of the lyrics record | ||
| */ | ||
| id: number; | ||
| } | ||
| interface SearchQuery { | ||
| /** | ||
| * Search for keyword present in ANY fields (track's title, artist name or album name) | ||
| */ | ||
| q: string; | ||
| } | ||
| interface SearchTrackSignature { | ||
| /** | ||
| * Search for keyword in track's title | ||
| */ | ||
| track_name: string; | ||
| /** | ||
| * Search for keyword in artist's name | ||
| */ | ||
| artist_name?: string; | ||
| /** | ||
| * Search for keyword in album's name | ||
| */ | ||
| album_name?: string; | ||
| } | ||
| type Search = SearchQuery | SearchTrackSignature; | ||
| } | ||
| namespace Post { | ||
| interface Publish { | ||
| /** | ||
| * Title of the track | ||
| */ | ||
| trackName: string; | ||
| /** | ||
| * Track's artist name | ||
| */ | ||
| artistName: string; | ||
| /** | ||
| * Track's album name | ||
| */ | ||
| albumName: string; | ||
| /** | ||
| * Track's duration | ||
| */ | ||
| duration: number; | ||
| /** | ||
| * Plain lyrics for the track | ||
| */ | ||
| plainLyrics: string; | ||
| /** | ||
| * Synchronized lyrics for the track | ||
| */ | ||
| syncedLyrics: string; | ||
| } | ||
| interface RequestChallenge { | ||
| } | ||
| } | ||
| } | ||
| declare namespace APIResponse { | ||
| interface Error { | ||
| code: number; | ||
| name: string; | ||
| message: string; | ||
| } | ||
| namespace Get { | ||
| interface TrackSignature { | ||
| id: number; | ||
| trackName: string; | ||
| artistName: string; | ||
| albumName: string; | ||
| duration: number; | ||
| instrumental: boolean; | ||
| plainLyrics: string | null; | ||
| syncedLyrics: string | null; | ||
| } | ||
| interface TrackById extends TrackSignature { | ||
| } | ||
| interface SearchQuery extends Array<TrackSignature> { | ||
| } | ||
| interface SearchTrackSignature extends Array<TrackSignature> { | ||
| } | ||
| } | ||
| namespace Post { | ||
| interface Publish { | ||
| } | ||
| interface RequestChallenge { | ||
| prefix: string; | ||
| target: string; | ||
| } | ||
| } | ||
| } | ||
| interface APIPublishTokenData { | ||
| prefix: string; | ||
| nonce: string; | ||
| } | ||
| declare class Routes { | ||
| private constructor(); | ||
| static [`/api/get`](options: APIOptions.Get.TrackSignatureOptions): `/api/get`; | ||
| static [`/api/get/{id}`](options: APIOptions.Get.TrackById): `/api/get/{id}`; | ||
| static [`/api/search`](options: APIOptions.Get.Search): `/api/search`; | ||
| static [`/api/publish`](): `/api/publish`; | ||
| static [`/api/request-challenge`](): `/api/request-challenge`; | ||
| private static parseURLSearchParams; | ||
| } | ||
| declare namespace Routes { | ||
| interface Metadata { | ||
| [`/api/get`]: [APIOptions.Get.TrackSignatureOptions, APIResponse.Get.TrackSignature]; | ||
| [`/api/get/{id}`]: [APIOptions.Get.TrackById, APIResponse.Get.TrackById]; | ||
| [`/api/search`]: [APIOptions.Get.Search, APIResponse.Get.SearchQuery]; | ||
| [`/api/publish`]: [APIOptions.Post.Publish, APIResponse.Post.Publish]; | ||
| [`/api/request-challenge`]: [APIOptions.Post.RequestChallenge, APIResponse.Post.RequestChallenge]; | ||
| [key: string]: [any, any]; | ||
| } | ||
| } | ||
| export { APIOptions, type APIPublishTokenData, APIResponse, Routes }; |
| var __defProp = Object.defineProperty; | ||
| var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); | ||
| // src/structures/Routes.ts | ||
| var Routes = class _Routes { | ||
| static { | ||
| __name(this, "Routes"); | ||
| } | ||
| constructor() { | ||
| } | ||
| static [`/api/get`](options) { | ||
| return `/api/get?${_Routes.parseURLSearchParams(options)}`; | ||
| } | ||
| static [`/api/get/{id}`](options) { | ||
| return `/api/get/${options.id}`; | ||
| } | ||
| static [`/api/search`](options) { | ||
| return `/api/search?${_Routes.parseURLSearchParams(options)}`; | ||
| } | ||
| static [`/api/publish`]() { | ||
| return `/api/publish`; | ||
| } | ||
| static [`/api/request-challenge`]() { | ||
| return `/api/request-challenge`; | ||
| } | ||
| static parseURLSearchParams(data) { | ||
| const searchParams = new URLSearchParams(); | ||
| for (const [key, value] of Object.entries(data)) { | ||
| if (value !== void 0) { | ||
| searchParams.append(key, String(value)); | ||
| } | ||
| } | ||
| return searchParams; | ||
| } | ||
| }; | ||
| export { Routes }; | ||
| //# sourceMappingURL=index.js.map | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"sources":["../src/structures/Routes.ts"],"names":[],"mappings":";;;;AAEO,IAAM,MAAA,GAAN,MAAM,OAAA,CAAO;AAAA,EAFpB;AAEoB,IAAA,MAAA,CAAA,IAAA,EAAA,QAAA,CAAA;AAAA;AAAA,EACR,WAAA,GAAc;AAAA,EAAC;AAAA,EAEvB,QAAe,CAAA,QAAA,CAAU,CAAA,CAAE,OAAA,EAA2D;AAClF,IAAA,OAAO,CAAA,SAAA,EAAY,OAAA,CAAO,oBAAA,CAAqB,OAAO,CAAC,CAAA,CAAA;AAAA,EAC3D;AAAA,EAEA,QAAe,CAAA,aAAA,CAAe,CAAA,CAAE,OAAA,EAAoD;AAChF,IAAA,OAAO,CAAA,SAAA,EAAY,QAAQ,EAAE,CAAA,CAAA;AAAA,EACjC;AAAA,EAEA,QAAe,CAAA,WAAA,CAAa,CAAA,CAAE,OAAA,EAA+C;AACzE,IAAA,OAAO,CAAA,YAAA,EAAe,OAAA,CAAO,oBAAA,CAAqB,OAAO,CAAC,CAAA,CAAA;AAAA,EAC9D;AAAA,EAEA,QAAe,cAAc,CAAA,GAAoB;AAC7C,IAAA,OAAO,CAAA,YAAA,CAAA;AAAA,EACX;AAAA,EAEA,QAAe,wBAAwB,CAAA,GAA8B;AACjE,IAAA,OAAO,CAAA,sBAAA,CAAA;AAAA,EACX;AAAA,EAEA,OAAe,qBAAqB,IAAA,EAA4C;AAC5E,IAAA,MAAM,YAAA,GAAe,IAAI,eAAA,EAAgB;AAEzC,IAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,EAAG;AAC7C,MAAA,IAAI,UAAU,MAAA,EAAW;AACrB,QAAA,YAAA,CAAa,MAAA,CAAO,GAAA,EAAK,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,MAC1C;AAAA,IACJ;AAEA,IAAA,OAAO,YAAA;AAAA,EACX;AACJ","file":"index.js","sourcesContent":["import type { APIOptions, APIResponse } from '../types/API.js';\n\nexport class Routes {\n private constructor() {}\n\n public static [`/api/get`](options: APIOptions.Get.TrackSignatureOptions): `/api/get` {\n return `/api/get?${Routes.parseURLSearchParams(options)}` as `/api/get`;\n }\n\n public static [`/api/get/{id}`](options: APIOptions.Get.TrackById): `/api/get/{id}` {\n return `/api/get/${options.id}` as `/api/get/{id}`;\n }\n\n public static [`/api/search`](options: APIOptions.Get.Search): `/api/search` {\n return `/api/search?${Routes.parseURLSearchParams(options)}` as `/api/search`;\n }\n\n public static [`/api/publish`](): `/api/publish` {\n return `/api/publish`;\n }\n\n public static [`/api/request-challenge`](): `/api/request-challenge` {\n return `/api/request-challenge`;\n }\n\n private static parseURLSearchParams(data: Record<string, any>): URLSearchParams {\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(data)) {\n if (value !== undefined) {\n searchParams.append(key, String(value));\n }\n }\n\n return searchParams;\n }\n}\n\nexport namespace Routes {\n export interface Metadata {\n [`/api/get`]: [APIOptions.Get.TrackSignatureOptions, APIResponse.Get.TrackSignature];\n [`/api/get/{id}`]: [APIOptions.Get.TrackById, APIResponse.Get.TrackById];\n [`/api/search`]: [APIOptions.Get.Search, APIResponse.Get.SearchQuery];\n [`/api/publish`]: [APIOptions.Post.Publish, APIResponse.Post.Publish];\n [`/api/request-challenge`]: [APIOptions.Post.RequestChallenge, APIResponse.Post.RequestChallenge];\n [key: string]: [any, any];\n }\n}"]} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
0
-100%1
-50%25
Infinity%6406
-32.79%25
-85.47%1
Infinity%