odesli.js 1.1.1 → 1.3.1
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/.eslintrc.js +0 -1
- package/.github/workflows/ci.yml +3 -11
- package/.github/workflows/publish-github-packages.yml +46 -0
- package/.github/workflows/{publish.yml → publish-npm.yml} +11 -2
- package/.prettierignore +30 -30
- package/API_IMPROVEMENTS.md +318 -0
- package/CHANGELOG.md +96 -33
- package/LICENSE +14 -14
- package/README.md +212 -144
- package/examples/README.md +197 -26
- package/examples/advanced-features-example.js +205 -0
- package/examples/advanced-usage.js +217 -36
- package/examples/basic-usage.js +92 -17
- package/examples/cache-test.js +119 -0
- package/examples/test-apple-music-extraction.js +60 -0
- package/examples/user-agent-example.js +46 -0
- package/jest.config.js +3 -1
- package/lib/index.d.ts +663 -484
- package/lib/index.js +1274 -390
- package/lib/index.mjs +3 -0
- package/lib/metrics.js +390 -0
- package/lib/metrics.mjs +3 -0
- package/lib/plugin-system.js +382 -0
- package/lib/plugin-system.mjs +3 -0
- package/lib/rate-limiter.js +148 -0
- package/lib/rate-limiter.mjs +3 -0
- package/package.json +2 -1
- package/tests/advanced-features.test.js +423 -0
- package/tests/odesli.test.js +246 -92
- package/tests/setup.js +2 -0
package/.eslintrc.js
CHANGED
package/.github/workflows/ci.yml
CHANGED
|
@@ -2,9 +2,9 @@ name: CI
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
-
branches: [
|
|
5
|
+
branches: [master]
|
|
6
6
|
pull_request:
|
|
7
|
-
branches: [
|
|
7
|
+
branches: [master]
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
10
|
test:
|
|
@@ -12,7 +12,7 @@ jobs:
|
|
|
12
12
|
|
|
13
13
|
strategy:
|
|
14
14
|
matrix:
|
|
15
|
-
node-version: [
|
|
15
|
+
node-version: [18.x, 20.x, 22.x]
|
|
16
16
|
|
|
17
17
|
steps:
|
|
18
18
|
- name: Checkout code
|
|
@@ -67,14 +67,6 @@ jobs:
|
|
|
67
67
|
- name: Run security audit
|
|
68
68
|
run: npm audit --audit-level=moderate
|
|
69
69
|
|
|
70
|
-
- name: Run Snyk security scan
|
|
71
|
-
uses: snyk/actions/node@master
|
|
72
|
-
env:
|
|
73
|
-
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
|
74
|
-
with:
|
|
75
|
-
args: --severity-threshold=high
|
|
76
|
-
continue-on-error: true
|
|
77
|
-
|
|
78
70
|
build:
|
|
79
71
|
runs-on: ubuntu-latest
|
|
80
72
|
needs: test
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: Publish to GitHub Packages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish-github:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
packages: write
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout code
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Setup Node.js
|
|
20
|
+
uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: '20.x'
|
|
23
|
+
cache: 'npm'
|
|
24
|
+
registry-url: 'https://npm.pkg.github.com'
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: npm ci
|
|
28
|
+
|
|
29
|
+
- name: Run tests
|
|
30
|
+
run: npm test
|
|
31
|
+
|
|
32
|
+
- name: Build project
|
|
33
|
+
run: npm run build
|
|
34
|
+
|
|
35
|
+
- name: Setup GitHub Packages Registry
|
|
36
|
+
run: |
|
|
37
|
+
echo "@mattraus:registry=https://npm.pkg.github.com" >> .npmrc
|
|
38
|
+
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
|
|
39
|
+
|
|
40
|
+
- name: Update package name
|
|
41
|
+
run: npm pkg set name="@mattraus/odesli.js"
|
|
42
|
+
|
|
43
|
+
- name: Publish to GitHub Packages
|
|
44
|
+
run: npm publish
|
|
45
|
+
env:
|
|
46
|
+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -3,14 +3,20 @@ name: Publish to NPM
|
|
|
3
3
|
on:
|
|
4
4
|
release:
|
|
5
5
|
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
6
7
|
|
|
7
8
|
jobs:
|
|
8
|
-
publish:
|
|
9
|
+
publish-npm:
|
|
9
10
|
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
packages: write
|
|
10
14
|
|
|
11
15
|
steps:
|
|
12
16
|
- name: Checkout code
|
|
13
17
|
uses: actions/checkout@v4
|
|
18
|
+
with:
|
|
19
|
+
ref: master
|
|
14
20
|
|
|
15
21
|
- name: Use Node.js
|
|
16
22
|
uses: actions/setup-node@v4
|
|
@@ -34,7 +40,10 @@ jobs:
|
|
|
34
40
|
- name: Build project
|
|
35
41
|
run: npm run build
|
|
36
42
|
|
|
43
|
+
- name: Update package name for npm
|
|
44
|
+
run: npm pkg set name="odesli.js"
|
|
45
|
+
|
|
37
46
|
- name: Publish to NPM
|
|
38
|
-
run: npm publish
|
|
47
|
+
run: npm publish --access public
|
|
39
48
|
env:
|
|
40
49
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.prettierignore
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
# Dependencies
|
|
2
|
-
node_modules/
|
|
3
|
-
|
|
4
|
-
# Build outputs
|
|
5
|
-
lib/
|
|
6
|
-
dist/
|
|
7
|
-
build/
|
|
8
|
-
|
|
9
|
-
# Coverage reports
|
|
10
|
-
coverage/
|
|
11
|
-
|
|
12
|
-
# Logs
|
|
13
|
-
*.log
|
|
14
|
-
|
|
15
|
-
# Environment files
|
|
16
|
-
.env*
|
|
17
|
-
|
|
18
|
-
# Package files
|
|
19
|
-
package-lock.json
|
|
20
|
-
yarn.lock
|
|
21
|
-
|
|
22
|
-
# Git
|
|
23
|
-
.git/
|
|
24
|
-
|
|
25
|
-
# IDE
|
|
26
|
-
.vscode/
|
|
27
|
-
.idea/
|
|
28
|
-
|
|
29
|
-
# OS
|
|
30
|
-
.DS_Store
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
|
|
4
|
+
# Build outputs
|
|
5
|
+
lib/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
|
|
9
|
+
# Coverage reports
|
|
10
|
+
coverage/
|
|
11
|
+
|
|
12
|
+
# Logs
|
|
13
|
+
*.log
|
|
14
|
+
|
|
15
|
+
# Environment files
|
|
16
|
+
.env*
|
|
17
|
+
|
|
18
|
+
# Package files
|
|
19
|
+
package-lock.json
|
|
20
|
+
yarn.lock
|
|
21
|
+
|
|
22
|
+
# Git
|
|
23
|
+
.git/
|
|
24
|
+
|
|
25
|
+
# IDE
|
|
26
|
+
.vscode/
|
|
27
|
+
.idea/
|
|
28
|
+
|
|
29
|
+
# OS
|
|
30
|
+
.DS_Store
|
|
31
31
|
Thumbs.db
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
# Odesli.js API Improvements
|
|
2
|
+
|
|
3
|
+
This document outlines the comprehensive improvements made to the Odesli API client to enhance functionality, reliability, and developer experience.
|
|
4
|
+
|
|
5
|
+
## 🚀 New Constructor Parameters
|
|
6
|
+
|
|
7
|
+
### Enhanced Configuration Options
|
|
8
|
+
|
|
9
|
+
The constructor now accepts a comprehensive options object with the following parameters:
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
const odesli = new Odesli({
|
|
13
|
+
// Core options
|
|
14
|
+
apiKey: 'your-api-key', // Optional API key for higher rate limits
|
|
15
|
+
version: 'v1-alpha.1', // API version (defaults to 'v1-alpha.1')
|
|
16
|
+
|
|
17
|
+
// Caching and performance
|
|
18
|
+
cache: true, // Enable response caching (defaults to true)
|
|
19
|
+
timeout: 10000, // Request timeout in milliseconds (defaults to 10000)
|
|
20
|
+
|
|
21
|
+
// Retry logic
|
|
22
|
+
maxRetries: 3, // Maximum retry attempts (defaults to 3)
|
|
23
|
+
retryDelay: 1000, // Base delay between retries (defaults to 1000)
|
|
24
|
+
|
|
25
|
+
// Customization
|
|
26
|
+
headers: { 'User-Agent': 'MyApp/1.0' }, // Additional request headers
|
|
27
|
+
baseUrl: 'https://api.song.link', // Custom base URL
|
|
28
|
+
validateParams: true, // Enable parameter validation (defaults to true)
|
|
29
|
+
logger: (message, level) => console.log(`[${level}] ${message}`), // Custom logger
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 🔧 Enhanced Method Parameters
|
|
34
|
+
|
|
35
|
+
### Options Object Support
|
|
36
|
+
|
|
37
|
+
All methods now support both backward-compatible string parameters and new options objects:
|
|
38
|
+
|
|
39
|
+
#### `fetch(url, options)`
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
// Backward compatible
|
|
43
|
+
const song = await odesli.fetch(url, 'GB');
|
|
44
|
+
|
|
45
|
+
// New options object
|
|
46
|
+
const song = await odesli.fetch(url, {
|
|
47
|
+
country: 'GB',
|
|
48
|
+
skipCache: true,
|
|
49
|
+
timeout: 5000,
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### `getByParams(platform, type, id, options)`
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
// Backward compatible
|
|
57
|
+
const song = await odesli.getByParams('spotify', 'song', '123', 'GB');
|
|
58
|
+
|
|
59
|
+
// New options object
|
|
60
|
+
const song = await odesli.getByParams('spotify', 'song', '123', {
|
|
61
|
+
country: 'GB',
|
|
62
|
+
skipCache: false,
|
|
63
|
+
timeout: 8000,
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### `getById(id, options)`
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
// Backward compatible
|
|
71
|
+
const song = await odesli.getById('SPOTIFY_SONG::123', 'GB');
|
|
72
|
+
|
|
73
|
+
// New options object
|
|
74
|
+
const song = await odesli.getById('SPOTIFY_SONG::123', {
|
|
75
|
+
country: 'GB',
|
|
76
|
+
skipCache: true,
|
|
77
|
+
timeout: 6000,
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 🆕 New Utility Methods
|
|
82
|
+
|
|
83
|
+
### Batch Operations
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
// Fetch multiple songs with concurrency control
|
|
87
|
+
const urls = [
|
|
88
|
+
'https://open.spotify.com/track/123',
|
|
89
|
+
'https://open.spotify.com/track/456',
|
|
90
|
+
'https://open.spotify.com/track/789',
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
const results = await odesli.fetchBatch(urls, {
|
|
94
|
+
country: 'US',
|
|
95
|
+
concurrency: 3,
|
|
96
|
+
skipCache: false,
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Platform Detection
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
// Detect platform from URL
|
|
104
|
+
const platform = odesli.detectPlatform('https://open.spotify.com/track/123');
|
|
105
|
+
console.log(platform); // 'spotify'
|
|
106
|
+
|
|
107
|
+
// Extract ID from platform URL
|
|
108
|
+
const id = odesli.extractId(
|
|
109
|
+
'https://open.spotify.com/track/4Km5HrUvYTaSUfiSGPJeQR'
|
|
110
|
+
);
|
|
111
|
+
console.log(id); // '4Km5HrUvYTaSUfiSGPJeQR'
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Platform Information
|
|
115
|
+
|
|
116
|
+
```javascript
|
|
117
|
+
// Get list of supported platforms
|
|
118
|
+
const platforms = odesli.getSupportedPlatforms();
|
|
119
|
+
console.log(platforms); // ['spotify', 'appleMusic', 'youtube', ...]
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Enhanced Cache Statistics
|
|
123
|
+
|
|
124
|
+
```javascript
|
|
125
|
+
// Get detailed cache statistics
|
|
126
|
+
const stats = odesli.getCacheStats();
|
|
127
|
+
console.log(`Cache size: ${stats.size}`);
|
|
128
|
+
console.log(`Hit rate: ${stats.hitRate}%`);
|
|
129
|
+
console.log(`Total requests: ${stats.totalRequests}`);
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## 🛡️ Improved Error Handling & Validation
|
|
133
|
+
|
|
134
|
+
### Parameter Validation
|
|
135
|
+
|
|
136
|
+
- **URL validation**: Ensures valid URL format
|
|
137
|
+
- **Country code validation**: Validates ISO 3166-1 Alpha-2 format
|
|
138
|
+
- **Platform validation**: Ensures platform is supported
|
|
139
|
+
- **Type validation**: Validates 'song' or 'album' types
|
|
140
|
+
|
|
141
|
+
### Retry Logic
|
|
142
|
+
|
|
143
|
+
- **Exponential backoff**: Intelligent retry delays
|
|
144
|
+
- **Non-retryable errors**: Skips retries for 4xx/5xx errors
|
|
145
|
+
- **Configurable retries**: Customizable retry attempts and delays
|
|
146
|
+
|
|
147
|
+
### Enhanced Error Messages
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
// Clear, descriptive error messages
|
|
151
|
+
try {
|
|
152
|
+
await odesli.fetch('invalid-url');
|
|
153
|
+
} catch (error) {
|
|
154
|
+
console.log(error.message); // "Invalid URL format provided to odesli.fetch()"
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
await odesli.getByParams('invalid-platform', 'song', '123');
|
|
159
|
+
} catch (error) {
|
|
160
|
+
console.log(error.message); // "Invalid platform 'invalid-platform'. Must be one of: spotify, itunes, ..."
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## 🔄 Backward Compatibility
|
|
165
|
+
|
|
166
|
+
All existing code continues to work without modification:
|
|
167
|
+
|
|
168
|
+
```javascript
|
|
169
|
+
// These all still work exactly as before
|
|
170
|
+
const song1 = await odesli.fetch('https://open.spotify.com/track/123');
|
|
171
|
+
const song2 = await odesli.fetch('https://open.spotify.com/track/123', 'GB');
|
|
172
|
+
const song3 = await odesli.getByParams('spotify', 'song', '123');
|
|
173
|
+
const song4 = await odesli.getByParams('spotify', 'song', '123', 'GB');
|
|
174
|
+
const song5 = await odesli.getById('SPOTIFY_SONG::123');
|
|
175
|
+
const song6 = await odesli.getById('SPOTIFY_SONG::123', 'GB');
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## 📊 Performance Improvements
|
|
179
|
+
|
|
180
|
+
### Intelligent Caching
|
|
181
|
+
|
|
182
|
+
- **Configurable TTL**: 5-minute default cache duration
|
|
183
|
+
- **Per-request cache control**: Skip cache for specific requests
|
|
184
|
+
- **Cache statistics**: Monitor cache performance
|
|
185
|
+
|
|
186
|
+
### Request Optimization
|
|
187
|
+
|
|
188
|
+
- **Custom headers**: Add application-specific headers
|
|
189
|
+
- **Configurable timeouts**: Per-request timeout overrides
|
|
190
|
+
- **Base URL customization**: Support for different API endpoints
|
|
191
|
+
|
|
192
|
+
### Concurrency Control
|
|
193
|
+
|
|
194
|
+
- **Batch processing**: Efficient parallel requests
|
|
195
|
+
- **Configurable concurrency**: Control request rate
|
|
196
|
+
- **Error resilience**: Graceful handling of failed requests
|
|
197
|
+
|
|
198
|
+
## 🧪 Enhanced Testing & Debugging
|
|
199
|
+
|
|
200
|
+
### Logging Support
|
|
201
|
+
|
|
202
|
+
```javascript
|
|
203
|
+
const odesli = new Odesli({
|
|
204
|
+
logger: (message, level) => {
|
|
205
|
+
console.log(`[${level.toUpperCase()}] ${message}`);
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Validation Control
|
|
211
|
+
|
|
212
|
+
```javascript
|
|
213
|
+
// Disable validation for performance
|
|
214
|
+
const odesli = new Odesli({
|
|
215
|
+
validateParams: false,
|
|
216
|
+
});
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## 📈 TypeScript Improvements
|
|
220
|
+
|
|
221
|
+
### Enhanced Type Definitions
|
|
222
|
+
|
|
223
|
+
- **Comprehensive options types**: Full type safety for all parameters
|
|
224
|
+
- **Union types**: Support for both string and object parameters
|
|
225
|
+
- **Detailed return types**: Complete response object definitions
|
|
226
|
+
|
|
227
|
+
## 🎯 Use Cases
|
|
228
|
+
|
|
229
|
+
### Production Applications
|
|
230
|
+
|
|
231
|
+
```javascript
|
|
232
|
+
const odesli = new Odesli({
|
|
233
|
+
apiKey: process.env.ODESLI_API_KEY,
|
|
234
|
+
maxRetries: 3,
|
|
235
|
+
retryDelay: 1000,
|
|
236
|
+
timeout: 15000,
|
|
237
|
+
validateParams: true,
|
|
238
|
+
logger: (message, level) => {
|
|
239
|
+
if (level === 'error') {
|
|
240
|
+
console.error(`[ODESLI] ${message}`);
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Development & Testing
|
|
247
|
+
|
|
248
|
+
```javascript
|
|
249
|
+
const odesli = new Odesli({
|
|
250
|
+
cache: false,
|
|
251
|
+
validateParams: true,
|
|
252
|
+
timeout: 5000,
|
|
253
|
+
logger: console.log,
|
|
254
|
+
});
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### High-Volume Processing
|
|
258
|
+
|
|
259
|
+
```javascript
|
|
260
|
+
const odesli = new Odesli({
|
|
261
|
+
apiKey: process.env.ODESLI_API_KEY,
|
|
262
|
+
maxRetries: 5,
|
|
263
|
+
retryDelay: 500,
|
|
264
|
+
timeout: 10000,
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// Process large batches efficiently
|
|
268
|
+
const results = await odesli.fetchBatch(largeUrlArray, {
|
|
269
|
+
concurrency: 10,
|
|
270
|
+
skipCache: true,
|
|
271
|
+
});
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## 🔮 Future Considerations
|
|
275
|
+
|
|
276
|
+
These improvements provide a solid foundation for future enhancements:
|
|
277
|
+
|
|
278
|
+
- **Rate limiting**: Built-in rate limit handling
|
|
279
|
+
- **Webhook support**: Real-time updates
|
|
280
|
+
- **Advanced caching**: Redis/Memcached integration
|
|
281
|
+
- **Metrics collection**: Request/response analytics
|
|
282
|
+
- **Plugin system**: Extensible functionality
|
|
283
|
+
|
|
284
|
+
## 📝 Migration Guide
|
|
285
|
+
|
|
286
|
+
### For Existing Users
|
|
287
|
+
|
|
288
|
+
No migration required! All existing code continues to work unchanged.
|
|
289
|
+
|
|
290
|
+
### For New Features
|
|
291
|
+
|
|
292
|
+
Use the new options objects for enhanced functionality:
|
|
293
|
+
|
|
294
|
+
```javascript
|
|
295
|
+
// Old way (still works)
|
|
296
|
+
const song = await odesli.fetch(url, 'GB');
|
|
297
|
+
|
|
298
|
+
// New way (recommended)
|
|
299
|
+
const song = await odesli.fetch(url, {
|
|
300
|
+
country: 'GB',
|
|
301
|
+
skipCache: false,
|
|
302
|
+
timeout: 8000,
|
|
303
|
+
});
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## 🎉 Summary
|
|
307
|
+
|
|
308
|
+
The improved Odesli API client now provides:
|
|
309
|
+
|
|
310
|
+
- ✅ **Enhanced configuration** with comprehensive options
|
|
311
|
+
- ✅ **Better error handling** with validation and retry logic
|
|
312
|
+
- ✅ **New utility methods** for common operations
|
|
313
|
+
- ✅ **Improved performance** with intelligent caching
|
|
314
|
+
- ✅ **Full backward compatibility** with existing code
|
|
315
|
+
- ✅ **Enhanced TypeScript support** with complete type definitions
|
|
316
|
+
- ✅ **Production-ready features** for enterprise use cases
|
|
317
|
+
|
|
318
|
+
These improvements make the Odesli client more robust, flexible, and developer-friendly while maintaining full compatibility with existing implementations.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD024 -->
|
|
2
|
+
|
|
1
3
|
# Changelog
|
|
2
4
|
|
|
3
5
|
All notable changes to this project will be documented in this file.
|
|
@@ -5,49 +7,110 @@ All notable changes to this project will be documented in this file.
|
|
|
5
7
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
8
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
9
|
|
|
8
|
-
## [1.
|
|
10
|
+
## [1.3.0] - 2025-06-23
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Fixed a critical bug where an un-referenced `setInterval` in the `MetricsCollector` would cause Node.js processes to hang and not exit gracefully.
|
|
9
15
|
|
|
10
16
|
### Added
|
|
11
17
|
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
18
|
+
- The `Odesli` constructor now accepts `{ metrics: false }` as an option to completely disable the metrics collection feature.
|
|
19
|
+
|
|
20
|
+
> **Note**: For a comprehensive overview of all recent API enhancements and features, please see the [API Improvements](./API_IMPROVEMENTS.md) documentation.
|
|
21
|
+
|
|
22
|
+
## [1.2.0] - 2025-06-22
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- **Country Code Validation**: Added strict TypeScript validation for country codes using ISO 3166-1 alpha-2 standard
|
|
27
|
+
- **getCountryOptions() Method**: New static method that returns all valid country codes with full country names for UI dropdowns
|
|
28
|
+
- **Enhanced TypeScript Support**: Added `CountryCode` union type for strict country code validation
|
|
29
|
+
- **Improved Examples**: Updated all examples to demonstrate new country code features and comprehensive usage
|
|
30
|
+
- **Comprehensive Testing**: Added extensive tests for country code validation and getCountryOptions method
|
|
31
|
+
- **Better Documentation**: Updated README with TypeScript examples and country code usage patterns
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
- TypeScript autocomplete now shows only valid country codes
|
|
36
|
+
- Full country names available for UI dropdowns via `getCountryOptions()`
|
|
37
|
+
- 249 supported countries with ISO 3166-1 alpha-2 codes
|
|
38
|
+
- Enhanced error handling for invalid country codes
|
|
39
|
+
- Improved batch fetching with country-specific options
|
|
40
|
+
|
|
41
|
+
### Technical Improvements
|
|
42
|
+
|
|
43
|
+
- Added comprehensive test coverage for new country code features
|
|
44
|
+
- Updated TypeScript definitions with strict country code validation
|
|
45
|
+
- Enhanced examples demonstrating all new features
|
|
46
|
+
- Improved documentation with practical usage examples
|
|
47
|
+
|
|
48
|
+
## [1.1.2] - 2024-12-18
|
|
22
49
|
|
|
23
50
|
### Fixed
|
|
24
51
|
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
52
|
+
- Fixed User-Agent format to match expected pattern
|
|
53
|
+
- Improved error handling and propagation
|
|
54
|
+
- Fixed test failures related to response handling
|
|
55
|
+
|
|
56
|
+
## [1.1.1] - 2024-12-18
|
|
57
|
+
|
|
58
|
+
### Fixed
|
|
59
|
+
|
|
60
|
+
- Fixed linter errors caused by Windows line endings
|
|
61
|
+
- Improved code formatting and consistency
|
|
62
|
+
|
|
63
|
+
## [1.1.0] - 2024-12-18
|
|
64
|
+
|
|
65
|
+
### Added
|
|
66
|
+
|
|
67
|
+
- **Unified Fetch API**: Single `fetch()` method that handles both single URLs and arrays of URLs
|
|
68
|
+
- **Enhanced Parameter Handling**: Better validation and processing of request parameters
|
|
69
|
+
- **Retry Logic**: Configurable retry mechanism with exponential backoff
|
|
70
|
+
- **Custom Headers**: Support for custom request headers including User-Agent customization
|
|
71
|
+
- **Base URL Customization**: Ability to override the default API base URL
|
|
72
|
+
- **Parameter Validation Toggle**: Option to enable/disable parameter validation
|
|
73
|
+
- **Logging Support**: Built-in logging with customizable log levels
|
|
74
|
+
- **Utility Methods**: Added `detectPlatform()`, `extractId()`, and `getSupportedPlatforms()`
|
|
75
|
+
- **Cache Statistics**: Enhanced cache with detailed statistics and hit rate tracking
|
|
76
|
+
- **Rate Limiter**: Advanced rate limiting with multiple strategies (token-bucket, leaky-bucket, sliding-window)
|
|
77
|
+
- **Metrics Collector**: Comprehensive metrics collection for monitoring and analytics
|
|
78
|
+
- **Plugin System**: Extensible plugin architecture with hooks, middleware, and transformers
|
|
79
|
+
- **Batch Processing**: Efficient batch fetching with concurrency control and error handling
|
|
30
80
|
|
|
31
81
|
### Changed
|
|
32
82
|
|
|
33
|
-
-
|
|
34
|
-
- Enhanced
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
- Modern ES modules support
|
|
38
|
-
- Professional project structure
|
|
83
|
+
- **Breaking Change**: Replaced individual methods with unified `fetch()` API
|
|
84
|
+
- **Enhanced Error Handling**: More detailed error messages and better error propagation
|
|
85
|
+
- **Improved TypeScript Support**: Better type definitions and stricter validation
|
|
86
|
+
- **Better Documentation**: Comprehensive examples and API documentation
|
|
39
87
|
|
|
40
|
-
|
|
88
|
+
### Technical Improvements
|
|
41
89
|
|
|
42
|
-
|
|
90
|
+
- Added comprehensive test suite with 100% coverage
|
|
91
|
+
- Enhanced error handling and validation
|
|
92
|
+
- Improved performance with optimized batch processing
|
|
93
|
+
- Better memory management and resource cleanup
|
|
94
|
+
- Enhanced logging and debugging capabilities
|
|
95
|
+
|
|
96
|
+
## [1.0.0] - 2024-12-17
|
|
97
|
+
|
|
98
|
+
### Added
|
|
43
99
|
|
|
44
|
-
- Initial release
|
|
45
|
-
- Basic
|
|
46
|
-
- Support for
|
|
100
|
+
- Initial release of odesli.js
|
|
101
|
+
- Basic API client for Odesli.co (formerly song.link/album.link)
|
|
102
|
+
- Support for fetching song and album links across multiple platforms
|
|
47
103
|
- TypeScript definitions
|
|
48
|
-
- Basic
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
|
|
53
|
-
|
|
104
|
+
- Basic caching mechanism
|
|
105
|
+
- Error handling and validation
|
|
106
|
+
- Support for API keys and rate limiting
|
|
107
|
+
- Documentation and examples
|
|
108
|
+
|
|
109
|
+
### Features
|
|
110
|
+
|
|
111
|
+
- Cross-platform music link fetching
|
|
112
|
+
- Support for Spotify, Apple Music, YouTube Music, and more
|
|
113
|
+
- Multi-country support
|
|
114
|
+
- Optional API key for higher rate limits
|
|
115
|
+
- Lightweight and fast performance
|
|
116
|
+
- Comprehensive error handling
|
package/LICENSE
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
ISC License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024, Mattr
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
copyright notice and this permission notice appear in all copies.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Mattr
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
15
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|