Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 0 additions & 168 deletions schemas/cache/1.0.0/asset-type.json

This file was deleted.

91 changes: 0 additions & 91 deletions schemas/cache/1.0.0/core/asset-type.json

This file was deleted.

40 changes: 40 additions & 0 deletions scripts/sync_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
not just those listed in index.json. This ensures we get all schemas including
asset types (vast-asset.json, daast-asset.json) with discriminators from PR #189.

Features:
- Content-based change detection (only updates files when content changes)
- Automatic cleanup of orphaned schemas (files removed upstream)
- Preserves directory structure from upstream
- Symlink to latest version for convenience

Usage:
python scripts/sync_schemas.py # Normal sync (uses content hashing)
python scripts/sync_schemas.py --force # Force re-download all schemas
Expand Down Expand Up @@ -207,6 +213,7 @@ def main():
print("Downloading schemas:")
updated_count = 0
cached_count = 0
removed_count = 0

for url in schema_urls:
was_updated, new_hash = download_schema_file(url, version, hash_cache, force=args.force)
Expand All @@ -219,6 +226,37 @@ def main():
if new_hash:
updated_hashes[url] = new_hash

# Clean up orphaned schemas (files that exist locally but not upstream)
version_dir = CACHE_DIR / version
if version_dir.exists():
# Get list of expected filenames from URLs
expected_files = {url.split("/")[-1] for url in schema_urls}
# Also allow the hash cache file
expected_files.add(".hashes.json")

# Find orphaned JSON files
orphaned_files = []
for json_file in version_dir.rglob("*.json"):
if json_file.name not in expected_files and json_file.name != ".hashes.json":
orphaned_files.append(json_file)

# Remove orphaned files
if orphaned_files:
print("\nCleaning up orphaned schemas:")
for orphan in orphaned_files:
rel_path = orphan.relative_to(version_dir)
print(f" ✗ {rel_path} (removed - no longer in upstream)")
orphan.unlink()
removed_count += 1

# Remove empty directories
parent = orphan.parent
try:
if parent != version_dir and not any(parent.iterdir()):
parent.rmdir()
except OSError:
pass

# Save updated hash cache
if updated_hashes:
save_hash_cache(updated_hashes)
Expand All @@ -237,6 +275,8 @@ def main():
print(f" Location: {version_dir}")
print(f" Updated: {updated_count}")
print(f" Cached: {cached_count}")
if removed_count > 0:
print(f" Removed: {removed_count} (orphaned)")

except Exception as e:
print(f"\n✗ Error syncing schemas: {e}", file=sys.stderr)
Expand Down
6 changes: 6 additions & 0 deletions src/adcp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
# Audience & Targeting
ActivateSignalRequest,
ActivateSignalResponse,
# Type enums from PR #222
AssetContentType,
# Core domain types
BrandManifest,
# Creative Operations
Expand All @@ -131,6 +133,7 @@
Error,
FlatRatePricingOption,
Format,
FormatCategory,
FormatId,
GetMediaBuyDeliveryRequest,
GetMediaBuyDeliveryResponse,
Expand Down Expand Up @@ -218,6 +221,9 @@
"Error",
"Format",
"FormatId",
# New type enums from PR #222
"AssetContentType",
"FormatCategory",
"Product",
"Property",
# Core domain types (from stable API)
Expand Down
Loading