-
Notifications
You must be signed in to change notification settings - Fork 12.7k
feat(assets): align local API with cloud spec #12863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
07d17ed
feat(assets): align local API with cloud spec
luke-mino-altherr e767f48
Fix review issues: tags validation, size nullability, type annotation…
luke-mino-altherr 8efd261
Add preview_url to /assets API response using /api/view endpoint
luke-mino-altherr acadeb8
chore: remove unused imports from asset_reference queries
luke-mino-altherr 6c02ece
feat: resolve blake3 hashes in /view endpoint via asset database
luke-mino-altherr b909270
Register uploaded images in asset database when --enable-assets is set
luke-mino-altherr 77bf530
Exclude None fields from asset API JSON responses
luke-mino-altherr c3a8378
Add comment explaining why /view resolves blake3 hashes
luke-mino-altherr aa953a2
Move blake3 hash resolution to asset_management service
luke-mino-altherr 9cfb9c7
Require at least one tag in UploadAssetSpec
luke-mino-altherr 58e4bbf
Add owner_id check to resolve_hash_to_path
luke-mino-altherr 357765e
Make ReferenceData.created_at and updated_at required
luke-mino-altherr da0ae02
Fix double commit in create_from_hash
luke-mino-altherr 2e35c77
Add exclude_none=True to create/upload responses
luke-mino-altherr 23e458e
Change preview_id to reference asset by reference ID, not content ID
luke-mino-altherr d78c741
Filter soft-deleted and missing refs from visibility queries
luke-mino-altherr a322664
Pass preview_id and mime_type through all asset creation fast paths
luke-mino-altherr bec0e70
Remove unimplemented client-provided ID from upload API
luke-mino-altherr 0ba183a
Make asset mime_type immutable after first ingest
luke-mino-altherr aa79b64
Use resolved content_type from asset lookup in /view endpoint
luke-mino-altherr 1d1de34
Merge system+user metadata into filter projection
luke-mino-altherr 97341de
Standardize tag ordering to alphabetical across all endpoints
luke-mino-altherr 8006fde
Derive subfolder tags from path in register_file_in_place
luke-mino-altherr 940b202
Reject client-provided id, fix preview URLs, rename tags→total_tags
luke-mino-altherr 08dfff5
fix: SQLite migration 0003 FK drop fails on file-backed DBs (MB-2)
luke-mino-altherr fb2e70c
Fix missing tag count for is_missing references and update test for t…
luke-mino-altherr 735fda9
Remove unused imports in scanner.py
luke-mino-altherr d67870f
Rename prompt_id to job_id on asset_references
luke-mino-altherr e86186c
Add index on asset_references.preview_id for FK cascade performance
luke-mino-altherr 94de8af
Add clarifying comments for Asset/AssetReference naming and preview_id
luke-mino-altherr 24a6a7c
Disallow all-null meta rows: add CHECK constraint, skip null values o…
luke-mino-altherr 0b6d48d
Remove dead None guards on result.asset in upload handler
luke-mino-altherr 8570fd5
Remove mime_type from asset update API
luke-mino-altherr b6e0df3
Fix migration constraint naming double-prefix and NULL in mixed metad…
luke-mino-altherr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| """ | ||
| Add system_metadata and job_id columns to asset_references. | ||
| Change preview_id FK from assets.id to asset_references.id. | ||
|
|
||
| Revision ID: 0003_add_metadata_job_id | ||
| Revises: 0002_merge_to_asset_references | ||
| Create Date: 2026-03-09 | ||
| """ | ||
|
|
||
| from alembic import op | ||
| import sqlalchemy as sa | ||
|
|
||
| from app.database.models import NAMING_CONVENTION | ||
|
|
||
| revision = "0003_add_metadata_job_id" | ||
| down_revision = "0002_merge_to_asset_references" | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| with op.batch_alter_table("asset_references") as batch_op: | ||
| batch_op.add_column( | ||
| sa.Column("system_metadata", sa.JSON(), nullable=True) | ||
| ) | ||
| batch_op.add_column( | ||
| sa.Column("job_id", sa.String(length=36), nullable=True) | ||
| ) | ||
|
|
||
| # Change preview_id FK from assets.id to asset_references.id (self-ref). | ||
| # Existing values are asset-content IDs that won't match reference IDs, | ||
| # so null them out first. | ||
| op.execute("UPDATE asset_references SET preview_id = NULL WHERE preview_id IS NOT NULL") | ||
| with op.batch_alter_table( | ||
| "asset_references", naming_convention=NAMING_CONVENTION | ||
| ) as batch_op: | ||
| batch_op.drop_constraint( | ||
| "fk_asset_references_preview_id_assets", type_="foreignkey" | ||
| ) | ||
| batch_op.create_foreign_key( | ||
| "fk_asset_references_preview_id_asset_references", | ||
| "asset_references", | ||
| ["preview_id"], | ||
| ["id"], | ||
| ondelete="SET NULL", | ||
| ) | ||
| batch_op.create_index( | ||
| "ix_asset_references_preview_id", ["preview_id"] | ||
| ) | ||
|
|
||
| # Purge any all-null meta rows before adding the constraint | ||
| op.execute( | ||
| "DELETE FROM asset_reference_meta" | ||
| " WHERE val_str IS NULL AND val_num IS NULL AND val_bool IS NULL AND val_json IS NULL" | ||
| ) | ||
| with op.batch_alter_table("asset_reference_meta") as batch_op: | ||
| batch_op.create_check_constraint( | ||
| "ck_asset_reference_meta_has_value", | ||
| "val_str IS NOT NULL OR val_num IS NOT NULL OR val_bool IS NOT NULL OR val_json IS NOT NULL", | ||
| ) | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| # SQLite doesn't reflect CHECK constraints, so we must declare it | ||
| # explicitly via table_args for the batch recreate to find it. | ||
| # Use the fully-rendered constraint name to avoid the naming convention | ||
| # doubling the prefix. | ||
| with op.batch_alter_table( | ||
| "asset_reference_meta", | ||
| table_args=[ | ||
| sa.CheckConstraint( | ||
| "val_str IS NOT NULL OR val_num IS NOT NULL OR val_bool IS NOT NULL OR val_json IS NOT NULL", | ||
| name="ck_asset_reference_meta_has_value", | ||
| ), | ||
| ], | ||
| ) as batch_op: | ||
| batch_op.drop_constraint( | ||
| "ck_asset_reference_meta_has_value", type_="check" | ||
| ) | ||
|
|
||
| with op.batch_alter_table( | ||
| "asset_references", naming_convention=NAMING_CONVENTION | ||
| ) as batch_op: | ||
| batch_op.drop_index("ix_asset_references_preview_id") | ||
| batch_op.drop_constraint( | ||
| "fk_asset_references_preview_id_asset_references", type_="foreignkey" | ||
| ) | ||
| batch_op.create_foreign_key( | ||
| "fk_asset_references_preview_id_assets", | ||
| "assets", | ||
| ["preview_id"], | ||
| ["id"], | ||
| ondelete="SET NULL", | ||
| ) | ||
|
|
||
| with op.batch_alter_table("asset_references") as batch_op: | ||
| batch_op.drop_column("job_id") | ||
| batch_op.drop_column("system_metadata") | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.