odesli.js 1.3.3 → 1.3.5

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.
@@ -0,0 +1,56 @@
1
+ version: 2
2
+ updates:
3
+ # Enable version updates for npm
4
+ - package-ecosystem: 'npm'
5
+ directory: '/'
6
+ schedule:
7
+ interval: 'weekly'
8
+ day: 'monday'
9
+ time: '09:00'
10
+ timezone: 'America/New_York'
11
+
12
+ # Group minor and patch updates together
13
+ groups:
14
+ minor-and-patch:
15
+ patterns:
16
+ - '*'
17
+ update-types:
18
+ - 'minor'
19
+ - 'patch'
20
+
21
+ # Commit message format
22
+ commit-message:
23
+ prefix: 'chore'
24
+ prefix-development: 'chore'
25
+ include: 'scope'
26
+
27
+ # PR settings
28
+ open-pull-requests-limit: 10
29
+ reviewers:
30
+ - 'MattrAus'
31
+ assignees:
32
+ - 'MattrAus'
33
+ labels:
34
+ - 'dependencies'
35
+ - 'automated'
36
+
37
+ # Ignore certain updates
38
+ ignore:
39
+ # Ignore major version updates for critical dependencies
40
+ - dependency-name: 'typescript'
41
+ update-types: ['version-update:semver-major']
42
+ - dependency-name: 'jest'
43
+ update-types: ['version-update:semver-major']
44
+ - dependency-name: 'eslint'
45
+ update-types: ['version-update:semver-major']
46
+ # Ignore major updates that break compatibility
47
+ - dependency-name: 'eslint-plugin-promise'
48
+ update-types: ['version-update:semver-major']
49
+ - dependency-name: 'node-fetch'
50
+ update-types: ['version-update:semver-major']
51
+
52
+ # Rebase strategy
53
+ rebase-strategy: 'auto'
54
+
55
+ # Versioning strategy
56
+ versioning-strategy: 'auto'
@@ -0,0 +1,137 @@
1
+ name: Dependabot Auto Merge
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize, reopened, ready_for_review]
6
+ branches: [master]
7
+
8
+ permissions:
9
+ contents: write
10
+ pull-requests: write
11
+ packages: write
12
+
13
+ jobs:
14
+ dependabot-auto-merge:
15
+ runs-on: ubuntu-latest
16
+ if: github.actor == 'dependabot[bot]'
17
+
18
+ steps:
19
+ - name: Checkout code
20
+ uses: actions/checkout@v4
21
+ with:
22
+ ref: ${{ github.head_ref }}
23
+ token: ${{ secrets.GITHUB_TOKEN }}
24
+
25
+ - name: Use Node.js
26
+ uses: actions/setup-node@v4
27
+ with:
28
+ node-version: '20.x'
29
+ cache: 'npm'
30
+
31
+ - name: Install dependencies
32
+ run: npm ci
33
+
34
+ - name: Run linting
35
+ run: npm run lint
36
+
37
+ - name: Check formatting
38
+ run: npm run format:check
39
+
40
+ - name: Run tests
41
+ run: npm test
42
+
43
+ - name: Run security audit
44
+ run: npm audit --audit-level=moderate
45
+
46
+ - name: Build project
47
+ run: npm run build
48
+
49
+ - name: Auto-approve PR
50
+ uses: actions/github-script@v7
51
+ with:
52
+ script: |
53
+ github.rest.pulls.createReview({
54
+ owner: context.repo.owner,
55
+ repo: context.repo.repo,
56
+ pull_number: context.issue.number,
57
+ event: 'APPROVE',
58
+ body: '✅ Automated approval: All tests passed successfully!'
59
+ })
60
+
61
+ - name: Comment on PR
62
+ uses: actions/github-script@v7
63
+ with:
64
+ script: |
65
+ github.rest.issues.createComment({
66
+ owner: context.repo.owner,
67
+ repo: context.repo.repo,
68
+ issue_number: context.issue.number,
69
+ body: '✅ All tests passed! This PR is ready for merge.'
70
+ })
71
+
72
+ # Auto-release after Dependabot PR is merged
73
+ auto-release:
74
+ runs-on: ubuntu-latest
75
+ needs: dependabot-auto-merge
76
+ if: github.actor == 'dependabot[bot]' && github.event.pull_request.merged == true
77
+
78
+ steps:
79
+ - name: Checkout code
80
+ uses: actions/checkout@v4
81
+ with:
82
+ token: ${{ secrets.GITHUB_TOKEN }}
83
+
84
+ - name: Use Node.js
85
+ uses: actions/setup-node@v4
86
+ with:
87
+ node-version: '20.x'
88
+ cache: 'npm'
89
+
90
+ - name: Install dependencies
91
+ run: npm ci
92
+
93
+ - name: Bump version
94
+ id: version
95
+ run: |
96
+ npm run version:patch
97
+ VERSION=$(node -p "require('./package.json').version")
98
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
99
+
100
+ - name: Create git tag
101
+ run: |
102
+ VERSION=$(node -p "require('./package.json').version")
103
+ git config --local user.email "action@github.com"
104
+ git config --local user.name "GitHub Action"
105
+ git add package.json
106
+ git commit -m "chore: bump version to $VERSION"
107
+ git tag "v$VERSION"
108
+ git push origin HEAD:master --tags
109
+
110
+ - name: Create Release
111
+ uses: actions/create-release@v1
112
+ env:
113
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114
+ with:
115
+ tag_name: v${{ steps.version.outputs.version }}
116
+ release_name: Release v${{ steps.version.outputs.version }}
117
+ body: |
118
+ ## 🔄 Dependabot Update
119
+
120
+ This release includes dependency updates from Dependabot.
121
+
122
+ ### Changes
123
+ - Updated dependencies to latest versions
124
+ - All tests passing ✅
125
+ - Security audit passed ✅
126
+
127
+ ### Updated Dependencies
128
+ ${{ github.event.pull_request.body }}
129
+ draft: false
130
+ prerelease: false
131
+
132
+ - name: Publish to NPM
133
+ run: |
134
+ npm pkg set name="odesli.js"
135
+ npm publish --access public
136
+ env:
137
+ 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
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.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # odesli.js
2
2
 
3
- [![npm version](https://badge.fury.io/js/odesli.js.svg)](https://badge.fury.io/js/odesli.js)
4
- [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
5
- [![Node.js CI](https://github.com/MattrAus/odesli.js/workflows/CI/badge.svg)](https://github.com/MattrAus/odesli.js/actions/workflows/ci.yml)
3
+ [![npm version](https://img.shields.io/npm/v/odesli.js.svg)](https://www.npmjs.com/package/odesli.js)
4
+ [![npm license](https://img.shields.io/npm/l/odesli.js)](https://github.com/MattrAus/odesli.js/blob/master/LICENSE)
5
+ [![CI](https://github.com/MattrAus/odesli.js/actions/workflows/ci.yml/badge.svg)](https://github.com/MattrAus/odesli.js/actions/workflows/ci.yml)
6
6
  [![Test Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://github.com/MattrAus/odesli.js)
7
7
  [![Bundle Size](https://img.shields.io/bundlephobia/min/odesli.js)](https://bundlephobia.com/result?p=odesli.js)
8
8
  [![Downloads](https://img.shields.io/npm/dm/odesli.js.svg)](https://www.npmjs.com/package/odesli.js)
package/lib/index.js CHANGED
@@ -756,111 +756,12 @@ module.exports = class Odesli {
756
756
  }
757
757
  }
758
758
 
759
- /**
760
- * Fetch multiple URLs in batches with enhanced error handling
761
- *
762
- * @param {Array<string>} urls - Array of URLs to fetch
763
- * @param {Object} options - Batch options
764
- * @param {number} [options.concurrency=5] - Maximum concurrent requests
765
- * @param {string} [options.country='US'] - Country code for all requests
766
- * @param {boolean} [options.skipCache=false] - Skip cache for all requests
767
- * @param {number} [options.timeout] - Timeout for all requests
768
- * @returns {Promise<Array<Object>>} Array of results with enhanced error information
769
- *
770
- * @example
771
- * ```javascript
772
- * const results = await odesli.fetchBatch([
773
- * 'https://open.spotify.com/track/123',
774
- * 'https://music.apple.com/us/album/test/456?i=789'
775
- * ], { concurrency: 3, country: 'GB' });
776
- *
777
- * results.forEach((result, index) => {
778
- * if (result.success) {
779
- * console.log(`Song ${index + 1}: ${result.title}`);
780
- * } else {
781
- * console.log(`Song ${index + 1}: Error - ${result.error}`);
782
- * console.log(` Platform: ${result.platform}`);
783
- * console.log(` ID: ${result.extractedId || 'Not found'}`);
784
- * }
785
- * });
786
- * ```
787
- */
788
- async fetchBatch (urls, options = {}) {
789
- if (!Array.isArray(urls)) {
790
- throw new Error('URLs must be an array')
791
- }
792
-
793
- if (urls.length === 0) {
794
- return []
795
- }
796
-
797
- const { concurrency = 5, ...requestOptions } = options
798
-
799
- const results = []
800
- const chunks = []
801
-
802
- // Split URLs into chunks for concurrency control
803
- for (let i = 0; i < urls.length; i += concurrency) {
804
- chunks.push(urls.slice(i, i + concurrency))
805
- }
806
-
807
- for (const chunk of chunks) {
808
- const chunkPromises = chunk.map(async (url, _index) => {
809
- try {
810
- const result = await this.fetch(url, requestOptions)
811
- // Add success property to successful responses
812
- return { ...result, success: true }
813
- } catch (error) {
814
- // Enhanced error object with more context
815
- const errorInfo = {
816
- success: false,
817
- url,
818
- error: error.message,
819
- platform: this.detectPlatform(url),
820
- extractedId: this.extractId(url),
821
- timestamp: new Date().toISOString(),
822
- statusCode: this._extractStatusCode(error.message),
823
- retryable: this._isRetryableError(error.message)
824
- }
825
-
826
- // Add additional context based on error type
827
- if (error.message.includes('400')) {
828
- errorInfo.errorType = 'BAD_REQUEST'
829
- errorInfo.suggestion = 'Check if the URL is valid and accessible'
830
- } else if (error.message.includes('401')) {
831
- errorInfo.errorType = 'UNAUTHORIZED'
832
- errorInfo.suggestion = 'API key may be required or invalid'
833
- } else if (error.message.includes('429')) {
834
- errorInfo.errorType = 'RATE_LIMITED'
835
- errorInfo.suggestion = 'Rate limit exceeded, try again later'
836
- } else if (error.message.includes('404')) {
837
- errorInfo.errorType = 'NOT_FOUND'
838
- errorInfo.suggestion = 'Content may not be available in the specified region'
839
- } else if (error.message.includes('timeout')) {
840
- errorInfo.errorType = 'TIMEOUT'
841
- errorInfo.suggestion = 'Request timed out, try again'
842
- } else {
843
- errorInfo.errorType = 'UNKNOWN'
844
- errorInfo.suggestion = 'An unexpected error occurred'
845
- }
846
-
847
- return errorInfo
848
- }
849
- })
850
-
851
- const chunkResults = await Promise.all(chunkPromises)
852
- results.push(...chunkResults)
853
- }
854
-
855
- return results
856
- }
857
-
858
759
  /**
859
760
  * Extract status code from error message
860
761
  * @private
861
762
  */
862
763
  _extractStatusCode(errorMessage) {
863
- const match = errorMessage.match(/(\d{3}):/)
764
+ const match = errorMessage.match(/(\\d{3}):/)
864
765
  return match ? parseInt(match[1]) : null
865
766
  }
866
767
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "odesli.js",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
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",
@@ -54,7 +54,7 @@
54
54
  "url": "https://github.com/MattrAus/odesli.js/issues"
55
55
  },
56
56
  "dependencies": {
57
- "@types/node": "^24.0.3",
57
+ "@types/node": "^24.0.13",
58
58
  "node-fetch": "^2.7.0"
59
59
  },
60
60
  "devDependencies": {
@@ -68,13 +68,13 @@
68
68
  "eslint-plugin-import": "^2.28.0",
69
69
  "eslint-plugin-jest": "^29.0.1",
70
70
  "eslint-plugin-node": "^11.1.0",
71
- "eslint-plugin-prettier": "^5.5.0",
71
+ "eslint-plugin-prettier": "^5.5.1",
72
72
  "eslint-plugin-promise": "^6.6.0",
73
73
  "jest": "^29.5.0",
74
74
  "jest-fetch-mock": "^3.0.3",
75
75
  "jsdoc": "^4.0.2",
76
- "prettier": "^3.0.0",
77
- "snyk": "^1.1234.0",
76
+ "prettier": "^3.6.2",
77
+ "snyk": "^1.1297.3",
78
78
  "ts-jest": "^29.1.0",
79
79
  "typescript": "^5.0.0"
80
80
  },
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ /**
7
+ * Automatically bump version based on dependency changes
8
+ * Usage: node scripts/version-bump.js [patch|minor|major]
9
+ */
10
+
11
+ function bumpVersion(type = 'patch') {
12
+ const packagePath = path.join(__dirname, '..', 'package.json');
13
+ const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
14
+
15
+ const currentVersion = packageJson.version;
16
+ const [major, minor, patch] = currentVersion.split('.').map(Number);
17
+
18
+ let newVersion;
19
+ switch (type) {
20
+ case 'major':
21
+ newVersion = `${major + 1}.0.0`;
22
+ break;
23
+ case 'minor':
24
+ newVersion = `${major}.${minor + 1}.0`;
25
+ break;
26
+ case 'patch':
27
+ default:
28
+ newVersion = `${major}.${minor}.${patch + 1}`;
29
+ break;
30
+ }
31
+
32
+ packageJson.version = newVersion;
33
+ fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2) + '\n');
34
+
35
+ console.log(`Version bumped from ${currentVersion} to ${newVersion}`);
36
+ return newVersion;
37
+ }
38
+
39
+ // Get version type from command line argument
40
+ const versionType = process.argv[2] || 'patch';
41
+ bumpVersion(versionType);