Add Kaggle platform support and path transformation
Introduces Kaggle as a supported platform in the configuration and health check. Implements special path transformation logic for Kaggle API endpoints in transformPath, and adds comprehensive tests to verify correct path handling for various Kaggle API routes.
This commit is contained in:
1 parent
fc2c02f6ae
commit
1480595fbc
3 files changed
+86
-1
No files matched your search
+2
-1
@@ -45,7 +45,8 @@ export default async function handler(request) {
|
||||
'Container Registries',
|
||||
'AI Inference Providers',
|
||||
'arXiv',
|
||||
'F-Droid'
|
||||
'F-Droid',
|
||||
'Kaggle'
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ export const PLATFORMS = {
|
||||
arch: 'https://geo.mirror.pkgbuild.com',
|
||||
arxiv: 'https://arxiv.org',
|
||||
fdroid: 'https://f-droid.org',
|
||||
kaggle: 'https://www.kaggle.com',
|
||||
|
||||
// AI Inference Providers
|
||||
'ip-openai': 'https://api.openai.com',
|
||||
@@ -157,5 +158,24 @@ export function transformPath(path, platformKey) {
|
||||
}
|
||||
}
|
||||
|
||||
// Special handling for Kaggle API paths
|
||||
if (platformKey === 'kaggle') {
|
||||
// Transform paths to include the API prefix
|
||||
if (transformedPath.startsWith('/')) {
|
||||
// Handle different Kaggle API endpoints:
|
||||
// /datasets/download/owner/dataset-slug -> /api/v1/datasets/download/owner/dataset-slug
|
||||
// /competitions/data/download/competition-name -> /api/v1/competitions/data/download/competition-name
|
||||
// /datasets/list -> /api/v1/datasets/list
|
||||
// /competitions/list -> /api/v1/competitions/list
|
||||
// /models/list -> /api/v1/models/list
|
||||
// /kernels/list -> /api/v1/kernels/list
|
||||
|
||||
// Add API prefix if not already present
|
||||
if (!transformedPath.startsWith('/api/v1/')) {
|
||||
transformedPath = `/api/v1${transformedPath}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return transformedPath;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { transformPath } from '../src/config/platforms.js';
|
||||
|
||||
describe('Kaggle API path transformation', () => {
|
||||
it('should transform dataset download URLs correctly', () => {
|
||||
const path = '/kaggle/datasets/download/zillow/zecon';
|
||||
const result = transformPath(path, 'kaggle');
|
||||
expect(result).toBe('/api/v1/datasets/download/zillow/zecon');
|
||||
});
|
||||
|
||||
it('should transform dataset list URLs correctly', () => {
|
||||
const path = '/kaggle/datasets/list';
|
||||
const result = transformPath(path, 'kaggle');
|
||||
expect(result).toBe('/api/v1/datasets/list');
|
||||
});
|
||||
|
||||
it('should transform competition data download URLs correctly', () => {
|
||||
const path = '/kaggle/competitions/data/download/titanic';
|
||||
const result = transformPath(path, 'kaggle');
|
||||
expect(result).toBe('/api/v1/competitions/data/download/titanic');
|
||||
});
|
||||
|
||||
it('should transform competition list URLs correctly', () => {
|
||||
const path = '/kaggle/competitions/list';
|
||||
const result = transformPath(path, 'kaggle');
|
||||
expect(result).toBe('/api/v1/competitions/list');
|
||||
});
|
||||
|
||||
it('should transform model list URLs correctly', () => {
|
||||
const path = '/kaggle/models/list';
|
||||
const result = transformPath(path, 'kaggle');
|
||||
expect(result).toBe('/api/v1/models/list');
|
||||
});
|
||||
|
||||
it('should transform kernel list URLs correctly', () => {
|
||||
const path = '/kaggle/kernels/list';
|
||||
const result = transformPath(path, 'kaggle');
|
||||
expect(result).toBe('/api/v1/kernels/list');
|
||||
});
|
||||
|
||||
it('should handle URLs that already have API prefix', () => {
|
||||
const path = '/kaggle/api/v1/datasets/download/owner/dataset';
|
||||
const result = transformPath(path, 'kaggle');
|
||||
expect(result).toBe('/api/v1/datasets/download/owner/dataset');
|
||||
});
|
||||
|
||||
it('should handle search endpoints with query parameters', () => {
|
||||
const path = '/kaggle/datasets/list?search=housing&sortBy=votes';
|
||||
const result = transformPath(path, 'kaggle');
|
||||
expect(result).toBe('/api/v1/datasets/list?search=housing&sortBy=votes');
|
||||
});
|
||||
|
||||
it('should handle dataset metadata URLs', () => {
|
||||
const path = '/kaggle/datasets/metadata/owner/dataset-slug';
|
||||
const result = transformPath(path, 'kaggle');
|
||||
expect(result).toBe('/api/v1/datasets/metadata/owner/dataset-slug');
|
||||
});
|
||||
|
||||
it('should handle competition submissions', () => {
|
||||
const path = '/kaggle/competitions/submissions/submit';
|
||||
const result = transformPath(path, 'kaggle');
|
||||
expect(result).toBe('/api/v1/competitions/submissions/submit');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user