odesli.js 1.3.6 → 1.3.8

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.
Files changed (4) hide show
  1. package/CHANGELOG.md +130 -0
  2. package/README.md +3 -10
  3. package/lib/index.d.ts +391 -363
  4. package/package.json +10 -10
package/CHANGELOG.md CHANGED
@@ -7,6 +7,102 @@ All notable changes to this project will be documented in this file.
7
7
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8
8
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
9
 
10
+ ## [1.3.8] - 2025-01-27
11
+
12
+ ### Changed
13
+
14
+ - **Dependency Updates**: Updated multiple development dependencies to their latest compatible versions for improved security and performance
15
+ - Updated `@types/node` from 24.0.13 to 24.6.2
16
+ - Updated `@types/jest` from 30.0.0 (already on latest)
17
+ - Updated `eslint-config-prettier` from 10.1.5 to 10.1.8
18
+ - Updated `eslint-plugin-import` from 2.28.0 to 2.32.0
19
+ - Updated `eslint-plugin-prettier` from 5.5.1 to 5.5.4
20
+ - Updated `jest` from 29.5.0 to 30.2.0 (major version update)
21
+ - Updated `jsdoc` from 4.0.2 to 4.0.4
22
+ - Updated `snyk` from 1.1297.3 to 1.1299.1
23
+ - Updated `ts-jest` from 29.1.0 to 29.4.4
24
+ - Updated `typescript` from 5.0.0 to 5.9.3
25
+
26
+ ### Notes
27
+
28
+ - Kept `eslint` at 8.57.1 (ESLint 9 requires configuration migration)
29
+ - Kept `node-fetch` at 2.7.0 (v3 is ESM-only, incompatible with current CommonJS setup)
30
+ - Kept `eslint-plugin-promise` at 6.6.0 (v7 has peer dependency conflicts with eslint-config-standard)
31
+ - All tests passing with 100% test suite coverage
32
+ - No security vulnerabilities detected
33
+
34
+ ## [1.3.7] - 2025-01-27
35
+
36
+ ### Fixed
37
+
38
+ - **Enhanced TypeScript Definitions**: Improved type definitions for better IntelliSense and type safety
39
+ - **Batch Operations Support**: Added proper types for batch URL fetching with error handling
40
+ - **Entity Data Completeness**: Added missing properties to EntityData interface (thumbnailWidth, thumbnailHeight, apiProvider, platforms)
41
+ - **Platform Link Enhancement**: Added entityUniqueId property to PlatformLink interface
42
+ - **Configuration Options**: Added metrics configuration option to OdesliOptions interface
43
+
44
+ ### Added
45
+
46
+ - **BatchError Interface**: Proper error typing for batch operations with specific error categories
47
+ - **BatchResult Type**: Type-safe return type for batch fetch operations
48
+ - **Enhanced Error Types**: Added specific error types (BAD_REQUEST, UNAUTHORIZED, RATE_LIMITED, etc.)
49
+
50
+ ## [1.3.6] - 2025-07-12
51
+
52
+ ### Changed
53
+
54
+ - Version bump for dependency updates and workflow improvements
55
+
56
+ ## [1.3.5] - 2025-07-12
57
+
58
+ ### Added
59
+
60
+ - **Automated Workflows**: Enhanced Dependabot auto-merge workflow with version bumping and tagging
61
+ - **Dependency Updates**: Updated development dependencies for security and compatibility
62
+
63
+ ### Changed
64
+
65
+ - Improved CI/CD pipeline automation
66
+ - Enhanced dependency management workflows
67
+
68
+ ## [1.3.4] - 2025-06-23
69
+
70
+ ### Changed
71
+
72
+ - **Code Refactoring**: Removed redundant `fetchBatch` method to improve code maintainability
73
+ - **Documentation Updates**: Updated README badges and documentation links
74
+
75
+ ### Fixed
76
+
77
+ - **Build System**: Fixed build configuration for better cross-platform compatibility
78
+ - **Dependencies**: Updated development dependencies for improved security
79
+
80
+ ## [1.3.3] - 2025-06-23
81
+
82
+ ### Changed
83
+
84
+ - Version bump for registry publishing and workflow improvements
85
+
86
+ ## [1.3.2] - 2025-06-23
87
+
88
+ ### Fixed
89
+
90
+ - **Security Vulnerabilities**: Fixed security vulnerabilities in dependencies
91
+ - **Test Dependencies**: Added missing `jest-fetch-mock` dependency for proper testing
92
+ - **User-Agent Validation**: Relaxed user-agent check in tests for better compatibility
93
+ - **Publishing Workflows**: Streamlined publishing workflows for both npm and GitHub Packages
94
+
95
+ ### Changed
96
+
97
+ - Updated package-lock.json and package.json for security improvements
98
+ - Enhanced build and deployment processes
99
+
100
+ ## [1.3.1] - 2025-06-23
101
+
102
+ ### Changed
103
+
104
+ - Version bump for GitHub Packages release and registry configuration
105
+
10
106
  ## [1.3.0] - 2025-06-23
11
107
 
12
108
  ### Fixed
@@ -17,6 +113,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
17
113
 
18
114
  - The `Odesli` constructor now accepts `{ metrics: false }` as an option to completely disable the metrics collection feature.
19
115
 
116
+ ### Changed
117
+
118
+ - **Code Formatting**: Applied Prettier formatting for consistent code style
119
+ - **Linting**: Resolved linting and formatting errors for better code quality
120
+ - **Metrics Stability**: Improved metrics collector stability and performance
121
+
20
122
  > **Note**: For a comprehensive overview of all recent API enhancements and features, please see the [API Improvements](./API_IMPROVEMENTS.md) documentation.
21
123
 
22
124
  ## [1.2.0] - 2025-06-22
@@ -52,6 +154,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
52
154
  - Fixed User-Agent format to match expected pattern
53
155
  - Improved error handling and propagation
54
156
  - Fixed test failures related to response handling
157
+ - **ESLint Compatibility**: Resolved ESLint structuredClone compatibility issue
158
+ - **Formatting Issues**: Fixed formatting issues causing CI failure
159
+ - **Workflow Configuration**: Updated workflows to use master branch for CI badge
160
+
161
+ ### Added
162
+
163
+ - **GitHub Packages Support**: Added automated GitHub Packages publishing workflows
164
+ - **Enhanced Documentation**: Updated documentation and policy files
165
+ - **CI/CD Improvements**: Added comprehensive CI/CD pipeline with automated testing and publishing
166
+
167
+ ### Changed
168
+
169
+ - **Dependencies**: Updated and reverted dependencies for better compatibility
170
+ - **Line Endings**: Added .gitattributes for consistent line endings across platforms
171
+ - **Linting**: Fixed lint and formatting issues for CI compliance
55
172
 
56
173
  ## [1.1.1] - 2024-12-18
57
174
 
@@ -59,6 +176,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
59
176
 
60
177
  - Fixed linter errors caused by Windows line endings
61
178
  - Improved code formatting and consistency
179
+ - **GitHub Packages Workflow**: Enhanced GitHub Packages workflow with debugging and GITHUB_TOKEN usage
180
+ - **Package Configuration**: Fixed package names configuration for different registries
181
+ - **Permissions**: Added proper permissions to npm publish job
182
+
183
+ ### Added
184
+
185
+ - **Manual Trigger Support**: Added manual trigger support to publish workflows
186
+ - **Dedicated Tokens**: Implemented dedicated GH_PACKAGES_TOKEN for GitHub Packages publishing
187
+
188
+ ### Changed
189
+
190
+ - **Workflow Splitting**: Split deployment workflows for npm and GitHub Packages
191
+ - **Documentation Links**: Updated API documentation links to correct Odesli API docs
62
192
 
63
193
  ## [1.1.0] - 2024-12-18
64
194
 
package/README.md CHANGED
@@ -16,8 +16,7 @@ A Node.js client for the [Odesli API](https://odesli.co/) (formerly song.link/al
16
16
  - [📋 Table of Contents](#-table-of-contents)
17
17
  - [Features](#features)
18
18
  - [Installation](#installation)
19
- - [From npm (recommended)](#from-npm-recommended)
20
- - [From GitHub Packages](#from-github-packages)
19
+ - [From npm](#from-npm)
21
20
  - [Quick Start](#quick-start)
22
21
  - [API Key](#api-key)
23
22
  - [Usage](#usage)
@@ -52,18 +51,12 @@ A Node.js client for the [Odesli API](https://odesli.co/) (formerly song.link/al
52
51
 
53
52
  ## Installation
54
53
 
55
- ### From npm (recommended)
54
+ ### From npm
56
55
 
57
56
  ```bash
58
57
  npm install odesli.js
59
58
  ```
60
59
 
61
- ### From GitHub Packages
62
-
63
- ```bash
64
- npm install @mattraus/odesli.js
65
- ```
66
-
67
60
  ## Quick Start
68
61
 
69
62
  **CommonJS (require):**
@@ -781,4 +774,4 @@ const { PluginSystem } = require('odesli.js/plugin-system');
781
774
  import { PluginSystem } from 'odesli.js/plugin-system';
782
775
  ```
783
776
 
784
- See the `examples/advanced-features-example.js` for a full demonstration of these extensions in action.
777
+ See the [`examples/advanced-features-example.js`](./examples/advanced-features-example.js) for a full demonstration of these extensions in action.
package/lib/index.d.ts CHANGED
@@ -3,264 +3,264 @@
3
3
  // Definitions by: Mattr <https://github.com/MattrAus>
4
4
  // TypeScript Version: 2.7
5
5
 
6
- // Export the CountryCode type
6
+ // Export the CountryCode type with enhanced intellisense
7
7
  type CountryCode =
8
- | "AF"
9
- | "AX"
10
- | "AL"
11
- | "DZ"
12
- | "AS"
13
- | "AD"
14
- | "AO"
15
- | "AI"
16
- | "AQ"
17
- | "AG"
18
- | "AR"
19
- | "AM"
20
- | "AW"
21
- | "AU"
22
- | "AT"
23
- | "AZ"
24
- | "BS"
25
- | "BH"
26
- | "BD"
27
- | "BB"
28
- | "BY"
29
- | "BE"
30
- | "BZ"
31
- | "BJ"
32
- | "BM"
33
- | "BT"
34
- | "BO"
35
- | "BQ"
36
- | "BA"
37
- | "BW"
38
- | "BV"
39
- | "BR"
40
- | "IO"
41
- | "BN"
42
- | "BG"
43
- | "BF"
44
- | "BI"
45
- | "KH"
46
- | "CM"
47
- | "CA"
48
- | "CV"
49
- | "KY"
50
- | "CF"
51
- | "TD"
52
- | "CL"
53
- | "CN"
54
- | "CX"
55
- | "CC"
56
- | "CO"
57
- | "KM"
58
- | "CG"
59
- | "CD"
60
- | "CK"
61
- | "CR"
62
- | "CI"
63
- | "HR"
64
- | "CU"
65
- | "CW"
66
- | "CY"
67
- | "CZ"
68
- | "DK"
69
- | "DJ"
70
- | "DM"
71
- | "DO"
72
- | "EC"
73
- | "EG"
74
- | "SV"
75
- | "GQ"
76
- | "ER"
77
- | "EE"
78
- | "ET"
79
- | "FK"
80
- | "FO"
81
- | "FJ"
82
- | "FI"
83
- | "FR"
84
- | "GF"
85
- | "PF"
86
- | "TF"
87
- | "GA"
88
- | "GM"
89
- | "GE"
90
- | "DE"
91
- | "GH"
92
- | "GI"
93
- | "GR"
94
- | "GL"
95
- | "GD"
96
- | "GP"
97
- | "GU"
98
- | "GT"
99
- | "GG"
100
- | "GN"
101
- | "GW"
102
- | "GY"
103
- | "HT"
104
- | "HM"
105
- | "VA"
106
- | "HN"
107
- | "HK"
108
- | "HU"
109
- | "IS"
110
- | "IN"
111
- | "ID"
112
- | "IR"
113
- | "IQ"
114
- | "IE"
115
- | "IM"
116
- | "IL"
117
- | "IT"
118
- | "JM"
119
- | "JP"
120
- | "JE"
121
- | "JO"
122
- | "KZ"
123
- | "KE"
124
- | "KI"
125
- | "KR"
126
- | "KP"
127
- | "KW"
128
- | "KG"
129
- | "LA"
130
- | "LV"
131
- | "LB"
132
- | "LS"
133
- | "LR"
134
- | "LY"
135
- | "LI"
136
- | "LT"
137
- | "LU"
138
- | "MO"
139
- | "MK"
140
- | "MG"
141
- | "MW"
142
- | "MY"
143
- | "MV"
144
- | "ML"
145
- | "MT"
146
- | "MH"
147
- | "MQ"
148
- | "MR"
149
- | "MU"
150
- | "YT"
151
- | "MX"
152
- | "FM"
153
- | "MD"
154
- | "MC"
155
- | "MN"
156
- | "ME"
157
- | "MS"
158
- | "MA"
159
- | "MZ"
160
- | "MM"
161
- | "NA"
162
- | "NR"
163
- | "NP"
164
- | "NL"
165
- | "NC"
166
- | "NZ"
167
- | "NI"
168
- | "NE"
169
- | "NG"
170
- | "NU"
171
- | "NF"
172
- | "MP"
173
- | "NO"
174
- | "OM"
175
- | "PK"
176
- | "PW"
177
- | "PS"
178
- | "PA"
179
- | "PG"
180
- | "PY"
181
- | "PE"
182
- | "PH"
183
- | "PN"
184
- | "PL"
185
- | "PT"
186
- | "PR"
187
- | "QA"
188
- | "RE"
189
- | "RO"
190
- | "RU"
191
- | "RW"
192
- | "BL"
193
- | "SH"
194
- | "KN"
195
- | "LC"
196
- | "MF"
197
- | "PM"
198
- | "VC"
199
- | "WS"
200
- | "SM"
201
- | "ST"
202
- | "SA"
203
- | "SN"
204
- | "RS"
205
- | "SC"
206
- | "SL"
207
- | "SG"
208
- | "SX"
209
- | "SK"
210
- | "SI"
211
- | "SB"
212
- | "SO"
213
- | "ZA"
214
- | "GS"
215
- | "SS"
216
- | "ES"
217
- | "LK"
218
- | "SD"
219
- | "SR"
220
- | "SJ"
221
- | "SZ"
222
- | "SE"
223
- | "CH"
224
- | "SY"
225
- | "TW"
226
- | "TJ"
227
- | "TZ"
228
- | "TH"
229
- | "TL"
230
- | "TG"
231
- | "TK"
232
- | "TO"
233
- | "TT"
234
- | "TN"
235
- | "TR"
236
- | "TM"
237
- | "TC"
238
- | "TV"
239
- | "UG"
240
- | "UA"
241
- | "AE"
242
- | "GB"
243
- | "US"
244
- | "UM"
245
- | "UY"
246
- | "UZ"
247
- | "VU"
248
- | "VE"
249
- | "VN"
250
- | "VG"
251
- | "VI"
252
- | "WF"
253
- | "EH"
254
- | "YE"
255
- | "ZM"
256
- | "ZW";
8
+ | "AF" // Afghanistan
9
+ | "AX" // Aland Islands
10
+ | "AL" // Albania
11
+ | "DZ" // Algeria
12
+ | "AS" // American Samoa
13
+ | "AD" // Andorra
14
+ | "AO" // Angola
15
+ | "AI" // Anguilla
16
+ | "AQ" // Antarctica
17
+ | "AG" // Antigua and Barbuda
18
+ | "AR" // Argentina
19
+ | "AM" // Armenia
20
+ | "AW" // Aruba
21
+ | "AU" // Australia
22
+ | "AT" // Austria
23
+ | "AZ" // Azerbaijan
24
+ | "BS" // Bahamas
25
+ | "BH" // Bahrain
26
+ | "BD" // Bangladesh
27
+ | "BB" // Barbados
28
+ | "BY" // Belarus
29
+ | "BE" // Belgium
30
+ | "BZ" // Belize
31
+ | "BJ" // Benin
32
+ | "BM" // Bermuda
33
+ | "BT" // Bhutan
34
+ | "BO" // Bolivia
35
+ | "BQ" // Bonaire, Sint Eustatius and Saba
36
+ | "BA" // Bosnia and Herzegovina
37
+ | "BW" // Botswana
38
+ | "BV" // Bouvet Island
39
+ | "BR" // Brazil
40
+ | "IO" // British Indian Ocean Territory
41
+ | "BN" // Brunei Darussalam
42
+ | "BG" // Bulgaria
43
+ | "BF" // Burkina Faso
44
+ | "BI" // Burundi
45
+ | "KH" // Cambodia
46
+ | "CM" // Cameroon
47
+ | "CA" // Canada
48
+ | "CV" // Cape Verde
49
+ | "KY" // Cayman Islands
50
+ | "CF" // Central African Republic
51
+ | "TD" // Chad
52
+ | "CL" // Chile
53
+ | "CN" // China
54
+ | "CX" // Christmas Island
55
+ | "CC" // Cocos (Keeling) Islands
56
+ | "CO" // Colombia
57
+ | "KM" // Comoros
58
+ | "CG" // Congo
59
+ | "CD" // Congo, Democratic Republic
60
+ | "CK" // Cook Islands
61
+ | "CR" // Costa Rica
62
+ | "CI" // Cote d'Ivoire
63
+ | "HR" // Croatia
64
+ | "CU" // Cuba
65
+ | "CW" // Curaçao
66
+ | "CY" // Cyprus
67
+ | "CZ" // Czech Republic
68
+ | "DK" // Denmark
69
+ | "DJ" // Djibouti
70
+ | "DM" // Dominica
71
+ | "DO" // Dominican Republic
72
+ | "EC" // Ecuador
73
+ | "EG" // Egypt
74
+ | "SV" // El Salvador
75
+ | "GQ" // Equatorial Guinea
76
+ | "ER" // Eritrea
77
+ | "EE" // Estonia
78
+ | "ET" // Ethiopia
79
+ | "FK" // Falkland Islands
80
+ | "FO" // Faroe Islands
81
+ | "FJ" // Fiji
82
+ | "FI" // Finland
83
+ | "FR" // France
84
+ | "GF" // French Guiana
85
+ | "PF" // French Polynesia
86
+ | "TF" // French Southern Territories
87
+ | "GA" // Gabon
88
+ | "GM" // Gambia
89
+ | "GE" // Georgia
90
+ | "DE" // Germany
91
+ | "GH" // Ghana
92
+ | "GI" // Gibraltar
93
+ | "GR" // Greece
94
+ | "GL" // Greenland
95
+ | "GD" // Grenada
96
+ | "GP" // Guadeloupe
97
+ | "GU" // Guam
98
+ | "GT" // Guatemala
99
+ | "GG" // Guernsey
100
+ | "GN" // Guinea
101
+ | "GW" // Guinea-Bissau
102
+ | "GY" // Guyana
103
+ | "HT" // Haiti
104
+ | "HM" // Heard Island and McDonald Islands
105
+ | "VA" // Holy See (Vatican City State)
106
+ | "HN" // Honduras
107
+ | "HK" // Hong Kong
108
+ | "HU" // Hungary
109
+ | "IS" // Iceland
110
+ | "IN" // India
111
+ | "ID" // Indonesia
112
+ | "IR" // Iran
113
+ | "IQ" // Iraq
114
+ | "IE" // Ireland
115
+ | "IM" // Isle of Man
116
+ | "IL" // Israel
117
+ | "IT" // Italy
118
+ | "JM" // Jamaica
119
+ | "JP" // Japan
120
+ | "JE" // Jersey
121
+ | "JO" // Jordan
122
+ | "KZ" // Kazakhstan
123
+ | "KE" // Kenya
124
+ | "KI" // Kiribati
125
+ | "KR" // Korea
126
+ | "KP" // Korea, Democratic People's Republic
127
+ | "KW" // Kuwait
128
+ | "KG" // Kyrgyzstan
129
+ | "LA" // Lao People's Democratic Republic
130
+ | "LV" // Latvia
131
+ | "LB" // Lebanon
132
+ | "LS" // Lesotho
133
+ | "LR" // Liberia
134
+ | "LY" // Libyan Arab Jamahiriya
135
+ | "LI" // Liechtenstein
136
+ | "LT" // Lithuania
137
+ | "LU" // Luxembourg
138
+ | "MO" // Macao
139
+ | "MK" // Macedonia
140
+ | "MG" // Madagascar
141
+ | "MW" // Malawi
142
+ | "MY" // Malaysia
143
+ | "MV" // Maldives
144
+ | "ML" // Mali
145
+ | "MT" // Malta
146
+ | "MH" // Marshall Islands
147
+ | "MQ" // Martinique
148
+ | "MR" // Mauritania
149
+ | "MU" // Mauritius
150
+ | "YT" // Mayotte
151
+ | "MX" // Mexico
152
+ | "FM" // Micronesia
153
+ | "MD" // Moldova
154
+ | "MC" // Monaco
155
+ | "MN" // Mongolia
156
+ | "ME" // Montenegro
157
+ | "MS" // Montserrat
158
+ | "MA" // Morocco
159
+ | "MZ" // Mozambique
160
+ | "MM" // Myanmar
161
+ | "NA" // Namibia
162
+ | "NR" // Nauru
163
+ | "NP" // Nepal
164
+ | "NL" // Netherlands
165
+ | "NC" // New Caledonia
166
+ | "NZ" // New Zealand
167
+ | "NI" // Nicaragua
168
+ | "NE" // Niger
169
+ | "NG" // Nigeria
170
+ | "NU" // Niue
171
+ | "NF" // Norfolk Island
172
+ | "MP" // Northern Mariana Islands
173
+ | "NO" // Norway
174
+ | "OM" // Oman
175
+ | "PK" // Pakistan
176
+ | "PW" // Palau
177
+ | "PS" // Palestinian Territory
178
+ | "PA" // Panama
179
+ | "PG" // Papua New Guinea
180
+ | "PY" // Paraguay
181
+ | "PE" // Peru
182
+ | "PH" // Philippines
183
+ | "PN" // Pitcairn
184
+ | "PL" // Poland
185
+ | "PT" // Portugal
186
+ | "PR" // Puerto Rico
187
+ | "QA" // Qatar
188
+ | "RE" // Reunion
189
+ | "RO" // Romania
190
+ | "RU" // Russian Federation
191
+ | "RW" // Rwanda
192
+ | "BL" // Saint Barthelemy
193
+ | "SH" // Saint Helena
194
+ | "KN" // Saint Kitts and Nevis
195
+ | "LC" // Saint Lucia
196
+ | "MF" // Saint Martin
197
+ | "PM" // Saint Pierre and Miquelon
198
+ | "VC" // Saint Vincent and Grenadines
199
+ | "WS" // Samoa
200
+ | "SM" // San Marino
201
+ | "ST" // Sao Tome and Principe
202
+ | "SA" // Saudi Arabia
203
+ | "SN" // Senegal
204
+ | "RS" // Serbia
205
+ | "SC" // Seychelles
206
+ | "SL" // Sierra Leone
207
+ | "SG" // Singapore
208
+ | "SX" // Sint Maarten
209
+ | "SK" // Slovakia
210
+ | "SI" // Slovenia
211
+ | "SB" // Solomon Islands
212
+ | "SO" // Somalia
213
+ | "ZA" // South Africa
214
+ | "GS" // South Georgia and the South Sandwich Islands
215
+ | "SS" // South Sudan
216
+ | "ES" // Spain
217
+ | "LK" // Sri Lanka
218
+ | "SD" // Sudan
219
+ | "SR" // Suriname
220
+ | "SJ" // Svalbard and Jan Mayen
221
+ | "SZ" // Swaziland
222
+ | "SE" // Sweden
223
+ | "CH" // Switzerland
224
+ | "SY" // Syrian Arab Republic
225
+ | "TW" // Taiwan
226
+ | "TJ" // Tajikistan
227
+ | "TZ" // Tanzania
228
+ | "TH" // Thailand
229
+ | "TL" // Timor-Leste
230
+ | "TG" // Togo
231
+ | "TK" // Tokelau
232
+ | "TO" // Tonga
233
+ | "TT" // Trinidad and Tobago
234
+ | "TN" // Tunisia
235
+ | "TR" // Turkey
236
+ | "TM" // Turkmenistan
237
+ | "TC" // Turks and Caicos Islands
238
+ | "TV" // Tuvalu
239
+ | "UG" // Uganda
240
+ | "UA" // Ukraine
241
+ | "AE" // United Arab Emirates
242
+ | "GB" // United Kingdom
243
+ | "US" // United States
244
+ | "UM" // United States Outlying Islands
245
+ | "UY" // Uruguay
246
+ | "UZ" // Uzbekistan
247
+ | "VU" // Vanuatu
248
+ | "VE" // Venezuela
249
+ | "VN" // Vietnam
250
+ | "VG" // Virgin Islands, British
251
+ | "VI" // Virgin Islands, U.S.
252
+ | "WF" // Wallis and Futuna
253
+ | "EH" // Western Sahara
254
+ | "YE" // Yemen
255
+ | "ZM" // Zambia
256
+ | "ZW"; // Zimbabwe
257
257
 
258
258
  // Core Odesli class
259
259
  declare class Odesli {
260
260
  constructor(options?: OdesliOptions);
261
261
 
262
262
  // Core methods
263
- fetch(urlOrUrls: string | string[], options?: FetchOptions): Promise<SongData | SongData[]>;
263
+ fetch(urlOrUrls: string | string[], options?: FetchOptions): Promise<SongData | SongData[] | BatchResult>;
264
264
  getByParams(platform: string, type: string, id: string, options?: FetchOptions): Promise<SongData>;
265
265
  getById(id: string, options?: FetchOptions): Promise<SongData>;
266
266
 
@@ -274,66 +274,93 @@ declare class Odesli {
274
274
  clearCache(): void;
275
275
  getCacheStats(): CacheStats;
276
276
 
277
+ // Metrics methods
278
+ getMetrics(): MetricsCollector;
279
+
277
280
  // Static methods
278
281
  static getCountryOptions(): Array<{ code: CountryCode; name: string }>;
279
282
  }
280
283
 
281
- // Configuration options
284
+ // Configuration options for Odesli client
282
285
  interface OdesliOptions {
283
- apiKey?: string;
284
- version?: string;
285
- cache?: boolean;
286
- timeout?: number;
287
- maxRetries?: number;
288
- retryDelay?: number;
289
- headers?: Record<string, string>;
290
- baseUrl?: string;
291
- validateParams?: boolean;
292
- logger?: (message: string, level: string) => void;
286
+ apiKey?: string; // Optional API key for higher rate limits (10+ requests/minute)
287
+ version?: string; // API version to use (default: 'v1-alpha.1')
288
+ cache?: boolean; // Enable response caching with 5-minute TTL (default: true)
289
+ timeout?: number; // Request timeout in milliseconds (default: 10000)
290
+ maxRetries?: number; // Maximum number of retry attempts for failed requests (default: 3)
291
+ retryDelay?: number; // Base delay between retries in milliseconds, uses exponential backoff (default: 1000)
292
+ headers?: Record<string, string>; // Additional headers to include in requests
293
+ baseUrl?: string; // Base URL for API requests (default: 'https://api.song.link')
294
+ validateParams?: boolean; // Enable parameter validation (default: true)
295
+ logger?: (message: string, level: string) => void; // Optional logger function for debugging
296
+ metrics?: MetricsCollector | boolean; // Optional metrics collector instance or `false` to disable
293
297
  }
294
298
 
295
- // Fetch options
299
+ // Options for fetch operations
296
300
  interface FetchOptions {
297
- country?: CountryCode;
298
- skipCache?: boolean;
299
- timeout?: number;
300
- concurrency?: number;
301
+ country?: CountryCode; // ISO 3166-1 Alpha-2 country code for region-specific results (default: 'US')
302
+ skipCache?: boolean; // Skip cache for this request (default: false)
303
+ timeout?: number; // Override timeout for this request (default: uses instance timeout)
304
+ concurrency?: number; // Maximum concurrent requests for batch operations (default: 5)
301
305
  }
302
306
 
303
- // Song/Album data structure
307
+ // Batch result type for array of URLs
308
+ type BatchResult = Array<SongData | BatchError>;
309
+
310
+ // Error result for batch operations
311
+ interface BatchError {
312
+ success: false;
313
+ url: string;
314
+ error: string;
315
+ platform: string | null;
316
+ extractedId: string | null;
317
+ timestamp: string;
318
+ statusCode: number | null;
319
+ retryable: boolean;
320
+ errorType: 'BAD_REQUEST' | 'UNAUTHORIZED' | 'RATE_LIMITED' | 'NOT_FOUND' | 'TIMEOUT' | 'UNKNOWN';
321
+ suggestion: string;
322
+ }
323
+
324
+ // Song/Album data structure returned by Odesli API
304
325
  interface SongData {
305
- entityUniqueId: string;
306
- entitiesByUniqueId: Record<string, EntityData>;
307
- linksByPlatform: Record<string, PlatformLink>;
308
- id: string;
309
- title: string;
310
- artist: string[];
311
- type: string;
312
- thumbnail: string;
326
+ entityUniqueId: string; // Unique identifier for the main entity
327
+ entitiesByUniqueId: Record<string, EntityData>; // Collection of all related entities
328
+ linksByPlatform: Record<string, PlatformLink>; // Links to different streaming platforms
329
+ id: string; // Platform-specific ID for the main entity
330
+ title: string; // Title of the song or album
331
+ artist: string[]; // Array of artist names
332
+ type: string; // Type of content ('song' or 'album')
333
+ thumbnail: string; // URL to the thumbnail/cover art
334
+ success?: boolean; // Added for batch operations
313
335
  }
314
336
 
315
337
  interface EntityData {
316
- id: string;
317
- title: string;
318
- artistName: string[];
319
- type: string;
320
- thumbnailUrl: string;
338
+ id: string; // Platform-specific entity ID
339
+ title: string; // Entity title
340
+ artistName: string[]; // Array of artist names
341
+ type: string; // Entity type ('song' or 'album')
342
+ thumbnailUrl: string; // URL to the thumbnail/cover art
343
+ thumbnailWidth?: number; // Coverart's width
344
+ thumbnailHeight?: number; // Coverart's height
345
+ apiProvider: APIProvider; // The API provider that powered this match
346
+ platforms: Platform[]; // Array of platforms "powered" by this entity
321
347
  }
322
348
 
323
349
  interface PlatformLink {
324
- url: string;
325
- nativeAppUriMobile?: string;
326
- nativeAppUriDesktop?: string;
350
+ url: string; // Web URL to the content on the platform
351
+ nativeAppUriMobile?: string; // Deep link for mobile native app
352
+ nativeAppUriDesktop?: string; // Deep link for desktop native app
353
+ entityUniqueId: string; // Unique ID for this entity
327
354
  }
328
355
 
329
- // Cache statistics
356
+ // Cache statistics and performance metrics
330
357
  interface CacheStats {
331
- size: number;
332
- ttl: number;
333
- hitCount: number;
334
- missCount: number;
335
- hitRate: number;
336
- totalRequests: number;
358
+ size: number; // Current number of cached items
359
+ ttl: number; // Time-to-live for cached items in milliseconds
360
+ hitCount: number; // Number of cache hits
361
+ missCount: number; // Number of cache misses
362
+ hitRate: number; // Cache hit rate as a percentage (0-100)
363
+ totalRequests: number; // Total number of requests made
337
364
  }
338
365
 
339
366
  // Rate Limiter
@@ -345,20 +372,20 @@ declare class RateLimiter {
345
372
  }
346
373
 
347
374
  interface RateLimiterOptions {
348
- maxRequests?: number;
349
- windowMs?: number;
350
- strategy?: 'token-bucket' | 'leaky-bucket' | 'sliding-window';
351
- retryAfterMs?: number;
375
+ maxRequests?: number; // Maximum number of requests allowed in the time window
376
+ windowMs?: number; // Time window in milliseconds for rate limiting
377
+ strategy?: 'token-bucket' | 'leaky-bucket' | 'sliding-window'; // Rate limiting algorithm: token-bucket (default), leaky-bucket, or sliding-window
378
+ retryAfterMs?: number; // Default retry delay in milliseconds when rate limited
352
379
  }
353
380
 
354
381
  interface RateLimiterStatus {
355
- available?: number;
356
- max?: number;
357
- refillRate?: number;
358
- used?: number;
359
- windowMs?: number;
360
- queued?: number;
361
- processing?: boolean;
382
+ available?: number; // Number of available request slots
383
+ max?: number; // Maximum number of requests allowed
384
+ refillRate?: number; // Rate at which tokens are refilled (tokens per second)
385
+ used?: number; // Number of requests used in current window
386
+ windowMs?: number; // Time window in milliseconds
387
+ queued?: number; // Number of requests waiting in queue
388
+ processing?: boolean; // Whether rate limiter is currently processing requests
362
389
  }
363
390
 
364
391
  // Metrics Collector
@@ -383,23 +410,23 @@ declare class MetricsCollector {
383
410
  }
384
411
 
385
412
  interface MetricsOptions {
386
- enabled?: boolean;
387
- retentionMs?: number;
388
- maxDataPoints?: number;
413
+ enabled?: boolean; // Enable metrics collection (default: true)
414
+ retentionMs?: number; // How long to retain metrics data in milliseconds (default: 24 hours)
415
+ maxDataPoints?: number; // Maximum number of data points to store (default: 1000)
389
416
  }
390
417
 
391
418
  interface RequestMetrics {
392
- url: string;
393
- method?: string;
394
- startTime: number;
395
- endTime?: number;
396
- success?: boolean;
397
- statusCode?: number;
398
- error?: string;
399
- responseTime?: number;
400
- platform?: string;
401
- country?: string;
402
- cacheHit?: boolean;
419
+ url: string; // Request URL
420
+ method?: string; // HTTP method used (GET, POST, etc.)
421
+ startTime: number; // Request start time (timestamp in milliseconds)
422
+ endTime?: number; // Request end time (timestamp in milliseconds)
423
+ success?: boolean; // Whether the request was successful
424
+ statusCode?: number; // HTTP status code returned
425
+ error?: string; // Error message if request failed
426
+ responseTime?: number; // Response time in milliseconds
427
+ platform?: string; // Platform being queried
428
+ country?: string; // Country code used for the request
429
+ cacheHit?: boolean; // Whether the response came from cache
403
430
  }
404
431
 
405
432
  interface MetricsSummary {
@@ -434,9 +461,9 @@ interface MetricsSummary {
434
461
  }
435
462
 
436
463
  interface DetailedMetricsOptions {
437
- startTime?: number;
438
- endTime?: number;
439
- groupBy?: 'hour' | 'minute' | 'platform' | 'country';
464
+ startTime?: number; // Start time for metrics query (timestamp in milliseconds)
465
+ endTime?: number; // End time for metrics query (timestamp in milliseconds)
466
+ groupBy?: 'hour' | 'minute' | 'platform' | 'country'; // Group metrics by time (hour/minute) or by dimension (platform/country)
440
467
  }
441
468
 
442
469
  // Plugin System
@@ -456,23 +483,23 @@ declare class PluginSystem {
456
483
  }
457
484
 
458
485
  interface Plugin {
459
- name?: string;
460
- version?: string;
461
- description?: string;
462
- init?: () => void;
463
- cleanup?: () => void;
464
- hooks?: Record<string, (context: any) => Promise<void> | void>;
465
- middleware?: (context: any, next: () => Promise<any>) => Promise<any>;
466
- transformers?: Record<string, (data: any, context: any) => Promise<any> | any>;
486
+ name?: string; // Plugin name for identification
487
+ version?: string; // Plugin version
488
+ description?: string; // Plugin description
489
+ init?: () => void; // Initialization function called when plugin is registered
490
+ cleanup?: () => void; // Cleanup function called when plugin is unregistered
491
+ hooks?: Record<string, (context: any) => Promise<void> | void>; // Event hooks for plugin lifecycle
492
+ middleware?: (context: any, next: () => Promise<any>) => Promise<any>; // Middleware function for request processing
493
+ transformers?: Record<string, (data: any, context: any) => Promise<any> | any>; // Data transformation functions
467
494
  }
468
495
 
469
496
  interface PluginInfo {
470
- name: string;
471
- hooks: string[];
472
- hasMiddleware: boolean;
473
- hasTransformers: boolean;
474
- version?: string;
475
- description?: string;
497
+ name: string; // Plugin name
498
+ hooks: string[]; // List of registered hook names
499
+ hasMiddleware: boolean; // Whether the plugin has middleware function
500
+ hasTransformers: boolean; // Whether the plugin has transformer functions
501
+ version?: string; // Plugin version
502
+ description?: string; // Plugin description
476
503
  }
477
504
 
478
505
  // Built-in plugins
@@ -481,6 +508,7 @@ declare const cachingPlugin: Plugin;
481
508
  declare const analyticsPlugin: Plugin;
482
509
  declare const responseTransformerPlugin: Plugin;
483
510
 
511
+ // Legacy Page namespace for backward compatibility
484
512
  declare namespace Page {
485
513
  interface Response {
486
514
  /**
@@ -624,40 +652,40 @@ declare namespace Page {
624
652
  }
625
653
 
626
654
  type Platform =
627
- | 'spotify'
628
- | 'itunes'
629
- | 'appleMusic'
630
- | 'youtube'
631
- | 'youtubeMusic'
632
- | 'google'
633
- | 'googleStore'
634
- | 'pandora'
635
- | 'deezer'
636
- | 'tidal'
637
- | 'amazonStore'
638
- | 'amazonMusic'
639
- | 'soundcloud'
640
- | 'napster'
641
- | 'yandex'
642
- | 'spinrilla';
655
+ | 'spotify' // Spotify - Music streaming platform
656
+ | 'itunes' // iTunes Store - Apple's digital media store
657
+ | 'appleMusic' // Apple Music - Apple's music streaming service
658
+ | 'youtube' // YouTube - Video platform with music content
659
+ | 'youtubeMusic' // YouTube Music - YouTube's dedicated music service
660
+ | 'google' // Google Play Music - Google's music service (discontinued)
661
+ | 'googleStore' // Google Play Store - Android app store
662
+ | 'pandora' // Pandora - Internet radio service
663
+ | 'deezer' // Deezer - French music streaming service
664
+ | 'tidal' // Tidal - High-fidelity music streaming service
665
+ | 'amazonStore' // Amazon Music Store - Amazon's digital music store
666
+ | 'amazonMusic' // Amazon Music - Amazon's music streaming service
667
+ | 'soundcloud' // SoundCloud - Audio distribution platform
668
+ | 'napster' // Napster - Music streaming service
669
+ | 'yandex' // Yandex Music - Russian music streaming service
670
+ | 'spinrilla'; // Spinrilla - Mixtape and hip-hop music platform
643
671
 
644
672
  type APIProvider =
645
- | 'spotify'
646
- | 'itunes'
647
- | 'youtube'
648
- | 'google'
649
- | 'pandora'
650
- | 'deezer'
651
- | 'tidal'
652
- | 'amazon'
653
- | 'soundcloud'
654
- | 'napster'
655
- | 'yandex'
656
- | 'spinrilla';
673
+ | 'spotify' // Spotify Web API
674
+ | 'itunes' // iTunes Search API
675
+ | 'youtube' // YouTube Data API
676
+ | 'google' // Google Play Music API (discontinued)
677
+ | 'pandora' // Pandora API
678
+ | 'deezer' // Deezer API
679
+ | 'tidal' // Tidal API
680
+ | 'amazon' // Amazon Music API
681
+ | 'soundcloud' // SoundCloud API
682
+ | 'napster' // Napster API
683
+ | 'yandex' // Yandex Music API
684
+ | 'spinrilla'; // Spinrilla API
657
685
 
658
686
  type entityType =
659
- | 'song'
660
- | 'album'
687
+ | 'song' // Individual track/song
688
+ | 'album'; // Complete album or compilation
661
689
 
662
690
  // Export the main class
663
691
  export = Odesli;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "odesli.js",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "description": "Node.js Client to query odesli.co (song.link/album.link) API",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",
@@ -66,7 +66,7 @@
66
66
  "url": "https://github.com/MattrAus/odesli.js/issues"
67
67
  },
68
68
  "dependencies": {
69
- "@types/node": "^24.0.13",
69
+ "@types/node": "^24.6.2",
70
70
  "node-fetch": "^2.7.0"
71
71
  },
72
72
  "devDependencies": {
@@ -75,20 +75,20 @@
75
75
  "@types/jest": "^30.0.0",
76
76
  "@types/prettier": "^2.7.3",
77
77
  "eslint": "^8.57.1",
78
- "eslint-config-prettier": "^10.1.5",
78
+ "eslint-config-prettier": "^10.1.8",
79
79
  "eslint-config-standard": "^17.1.0",
80
- "eslint-plugin-import": "^2.28.0",
80
+ "eslint-plugin-import": "^2.32.0",
81
81
  "eslint-plugin-jest": "^29.0.1",
82
82
  "eslint-plugin-node": "^11.1.0",
83
- "eslint-plugin-prettier": "^5.5.1",
83
+ "eslint-plugin-prettier": "^5.5.4",
84
84
  "eslint-plugin-promise": "^6.6.0",
85
- "jest": "^29.5.0",
85
+ "jest": "^30.2.0",
86
86
  "jest-fetch-mock": "^3.0.3",
87
- "jsdoc": "^4.0.2",
87
+ "jsdoc": "^4.0.4",
88
88
  "prettier": "^3.6.2",
89
- "snyk": "^1.1297.3",
90
- "ts-jest": "^29.1.0",
91
- "typescript": "^5.0.0"
89
+ "snyk": "^1.1299.1",
90
+ "ts-jest": "^29.4.4",
91
+ "typescript": "^5.9.3"
92
92
  },
93
93
  "homepage": "https://github.com/MattrAus/odesli.js#readme"
94
94
  }