Skip to content

feat(types): add Media Library asset aspect types #9146

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 1 commit into from
Apr 15, 2025

Conversation

juice49
Copy link
Contributor

@juice49 juice49 commented Apr 5, 2025

Description

This branch adds types for Media Library aspects and a defineAssetAspect function for defining aspects. This is based on prior work by @sgulseth and @sjelfull.

These additions can be imported from either sanity or @sanity/types.

What to review

The new defineAssetAspect and types. Does all the naming make sense?

Testing

Added some basic unit tests.

Copy link

vercel bot commented Apr 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 15, 2025 9:18am
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 15, 2025 9:18am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 15, 2025 9:18am
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
e2e-studio ⬜️ Ignored (Inspect) Apr 15, 2025 9:18am
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Apr 15, 2025 9:18am
test-next-studio ⬜️ Ignored (Inspect) Apr 15, 2025 9:18am

Copy link
Contributor

github-actions bot commented Apr 5, 2025

No changes to documentation

Copy link
Contributor

github-actions bot commented Apr 5, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 43.38% 57071 / 131549
🔵 Statements 43.38% 57071 / 131549
🔵 Functions 47.9% 2854 / 5958
🔵 Branches 79.85% 10654 / 13341
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/@sanity/types/src/index.ts 100% 100% 100% 100%
packages/@sanity/types/src/mediaLibrary/asserters.ts 100% 100% 100% 100%
packages/@sanity/types/src/mediaLibrary/defineAssetAspect.ts 85.71% 50% 100% 85.71% 25-26
packages/@sanity/types/src/mediaLibrary/index.ts 100% 100% 100% 100%
packages/@sanity/types/src/mediaLibrary/types.ts 100% 100% 100% 100%
Generated in workflow #33685 for commit 5966f1a by the Vitest Coverage Report Action

Copy link
Contributor

github-actions bot commented Apr 5, 2025

⚡️ Editor Performance Report

Updated Tue, 15 Apr 2025 09:28:59 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 23.8 efps (42ms) 23.5 efps (43ms) +1ms (+1.2%)
article (body) 46.9 efps (21ms) 64.3 efps (16ms) -6ms (-27.0%)
article (string inside object) 26.3 efps (38ms) 26.7 efps (38ms) -1ms (-1.3%)
article (string inside array) 22.2 efps (45ms) 23.8 efps (42ms) -3ms (-6.7%)
recipe (name) 45.5 efps (22ms) 45.5 efps (22ms) +0ms (-/-%)
recipe (description) 52.6 efps (19ms) 52.6 efps (19ms) +0ms (-/-%)
recipe (instructions) 99.9+ efps (6ms) 99.9+ efps (5ms) -1ms (-/-%)
synthetic (title) 18.2 efps (55ms) 19.2 efps (52ms) -3ms (-5.5%)
synthetic (string inside object) 18.2 efps (55ms) 18.5 efps (54ms) -1ms (-1.8%)

efps — editor "frames per second". The number of updates assumed to be possible within a second.

Derived from input latency. efps = 1000 / input_latency

Detailed information

🏠 Reference result

The performance result of sanity@latest

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 42ms 44ms 46ms 76ms 87ms 11.4s
article (body) 21ms 25ms 43ms 439ms 1058ms 8.1s
article (string inside object) 38ms 40ms 43ms 49ms 17ms 7.2s
article (string inside array) 45ms 47ms 50ms 59ms 155ms 7.0s
recipe (name) 22ms 24ms 26ms 66ms 0ms 7.7s
recipe (description) 19ms 20ms 21ms 24ms 0ms 4.7s
recipe (instructions) 6ms 7ms 8ms 18ms 0ms 3.1s
synthetic (title) 55ms 56ms 59ms 227ms 987ms 12.9s
synthetic (string inside object) 55ms 57ms 65ms 230ms 832ms 8.2s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 43ms 47ms 53ms 74ms 209ms 11.4s
article (body) 16ms 17ms 18ms 36ms 49ms 5.3s
article (string inside object) 38ms 40ms 44ms 64ms 119ms 7.1s
article (string inside array) 42ms 44ms 47ms 49ms 56ms 6.7s
recipe (name) 22ms 23ms 27ms 38ms 0ms 7.9s
recipe (description) 19ms 20ms 20ms 35ms 0ms 4.7s
recipe (instructions) 5ms 7ms 7ms 8ms 0ms 3.1s
synthetic (title) 52ms 56ms 61ms 182ms 821ms 14.3s
synthetic (string inside object) 54ms 56ms 58ms 201ms 851ms 8.4s

📚 Glossary

column definitions

  • benchmark — the name of the test, e.g. "article", followed by the label of the field being measured, e.g. "(title)".
  • latency — the time between when a key was pressed and when it was rendered. derived from a set of samples. the median (p50) is shown to show the most common latency.
  • p75 — the 75th percentile of the input latency in the test run. 75% of the sampled inputs in this benchmark were processed faster than this value. this provides insight into the upper range of typical performance.
  • p90 — the 90th percentile of the input latency in the test run. 90% of the sampled inputs were faster than this. this metric helps identify slower interactions that occurred less frequently during the benchmark.
  • p99 — the 99th percentile of the input latency in the test run. only 1% of sampled inputs were slower than this. this represents the worst-case scenarios encountered during the benchmark, useful for identifying potential performance outliers.
  • blocking time — the total time during which the main thread was blocked, preventing user input and UI updates. this metric helps identify performance bottlenecks that may cause the interface to feel unresponsive.
  • test duration — how long the test run took to complete.

Copy link
Contributor

github-actions bot commented Apr 5, 2025

📊 Playwright Test Report

Download Full E2E Report

This report contains test results, including videos of failing tests.

Copy link
Contributor Author

juice49 commented Apr 5, 2025

@juice49 juice49 force-pushed the feat/dam-410/media-library-types branch from 2e1be79 to 93fad0d Compare April 5, 2025 22:46
@juice49 juice49 force-pushed the feat/dam-410/media-library-types branch from 93fad0d to 17abd4c Compare April 5, 2025 23:10
@juice49 juice49 force-pushed the feat/dam-410/media-library-types branch from 38560b1 to 8f78b2d Compare April 6, 2025 14:25
@juice49 juice49 force-pushed the feat/dam-410/media-library-types branch from 8f78b2d to 6d10258 Compare April 9, 2025 07:27
sgulseth
sgulseth previously approved these changes Apr 14, 2025
Copy link
Member

@sgulseth sgulseth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!


return {
_type: MEDIA_LIBRARY_ASSET_ASPECT_TYPE_NAME,
_id: `${name}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me!

Copy link
Contributor

🧪 E2E Preview environment

🔑 Environment Variables for Local Testing

This is the preview URL for the E2E tests: https://e2e-studio-cs2vpvdxf.sanity.dev

To run the E2E tests locally, you can use the following environment variables, then run pnpm test:e2e --ui to open the Playwright test runner.

💬 Remember to build the project first with pnpm build:e2e.

  SANITY_E2E_PROJECT_ID=kin4wkua
  SANITY_E2E_BASE_URL=https://e2e-studio-cs2vpvdxf.sanity.dev
  SANITY_E2E_DATASET="update depending the project you want to test (pr-chromium-9146 || pr-firefox-9146 )"
  SANITY_E2E_DATASET_CHROMIUM=pr-chromium-9146
  SANITY_E2E_DATASET_FIREFOX=pr-firefox-9146

@juice49 juice49 merged commit 1e99f49 into main Apr 15, 2025
64 checks passed
@juice49 juice49 deleted the feat/dam-410/media-library-types branch April 15, 2025 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants