Enhance packages API with pagination, filtering, and metadata
Backend changes:
- Add format and platform columns to Package model with validation
- Add database migrations for new columns with indexes
- Create PackageDetailResponse schema with aggregated fields:
- tag_count, artifact_count, total_size
- latest_tag, latest_upload_at
- recent_tags (last 5 tags)
- Update list_packages endpoint:
- Add pagination (page, limit)
- Add search by name/description
- Add sort (name, created_at, updated_at) and order (asc, desc)
- Add format and platform filters
- Return aggregated metadata for each package
- Add GET /api/v1/project/{project}/packages/{package_name} endpoint
- Returns single package with full metadata
- Optional include_tags parameter for all tags
- Update create_package to accept format and platform
Frontend changes:
- Update Package type with format, platform, and optional metadata fields
- Update listPackages to handle paginated response
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,32 @@ def _run_migrations():
|
||||
END IF;
|
||||
END $$;
|
||||
""",
|
||||
# Add format column to packages table
|
||||
"""
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'packages' AND column_name = 'format'
|
||||
) THEN
|
||||
ALTER TABLE packages ADD COLUMN format VARCHAR(50) DEFAULT 'generic' NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS idx_packages_format ON packages(format);
|
||||
END IF;
|
||||
END $$;
|
||||
""",
|
||||
# Add platform column to packages table
|
||||
"""
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'packages' AND column_name = 'platform'
|
||||
) THEN
|
||||
ALTER TABLE packages ADD COLUMN platform VARCHAR(50) DEFAULT 'any' NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS idx_packages_platform ON packages(platform);
|
||||
END IF;
|
||||
END $$;
|
||||
""",
|
||||
]
|
||||
|
||||
with engine.connect() as conn:
|
||||
|
||||
Reference in New Issue
Block a user