Skip to content
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

feat(core): Global Document References support #8299

Open
wants to merge 32 commits into
base: next
Choose a base branch
from

Conversation

sgulseth
Copy link
Member

@sgulseth sgulseth commented Jan 16, 2025

Description

This is @skogsmaskin writing BTW 👋

This will add support for Global Document References (GDR) in the Studio. A Global Document Reference can reference something inside another project across the user's Sanity organization.

The implementation is very much alike cross-dataset-references, but there is a separate schema type that has it's unique config options:

export const globalDocumentReferenceType = defineType({
  type: 'globalDocumentReference',
  name: 'globalDocumentSubtype',
  title: 'Global document reference',
  resourceType: 'dataset',
  resourceId: 'exx11uqh.blog',
  to: [
    {
      type: 'book',
      icon: BookIcon,
      preview: {
        select: {
          title: 'title',
          media: 'coverImage',
        },
        prepare(val) {
          return {
            title: val.title,
            media: val.coverImage,
          }
        },
      },
    },
  ],
})

We don't want to release this yet to the public just yet, but it would be great if we could start reviewing it, so that it's ready to go when we need it. It also makes it possible to get some more test usage before we announce it.

What to review

  • That we are happy with the config options.
  • That the current implementation works well enough to be merged to next.

Testing

Open up the test studio in this branch, and select "playground (Staging)" workspace. Go to "Standard Inputs" and "Global document references test":

image

There is also added some automatic tests.

Note that the API currently only works in staging, and needs to be released first.

Notes for release

N/A - not to be announced yet.

Copy link

vercel bot commented Jan 16, 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 Mar 11, 2025 2:18pm
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 11, 2025 2:18pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 11, 2025 2:18pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Mar 11, 2025 2:18pm
test-next-studio ⬜️ Ignored (Inspect) Mar 11, 2025 2:18pm

@juice49 juice49 force-pushed the next branch 2 times, most recently from 9caf5d8 to 691aad1 Compare January 23, 2025 13:56
@skogsmaskin skogsmaskin force-pushed the feat/dam-190/gdr branch 2 times, most recently from 9d4c639 to 2fbe79b Compare January 30, 2025 14:05
Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Jan 30, 2025

Component Testing Report Updated Mar 11, 2025 12:16 PM (UTC)

❌ Failed Tests (1) -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 1m 9s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 13s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ❌ Failed (Inspect) 1m 17s 5 0 1
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 43s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 24s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 14s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 27s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 1m 7s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 31s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 45s 21 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 12s 3 9 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 1m 36s 21 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

Copy link
Contributor

github-actions bot commented Jan 30, 2025

⚡️ Editor Performance Report

Updated Tue, 11 Mar 2025 14:25:26 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 26.3 efps (38ms) 20.6 efps (49ms) +11ms (+27.6%) 🔴
article (body) 67.6 efps (15ms) 71.9 efps (14ms) -1ms (-/-%)
article (string inside object) 27.0 efps (37ms) 23.8 efps (42ms) +5ms (+13.5%)
article (string inside array) 23.8 efps (42ms) 20.4 efps (49ms) +7ms (+16.7%)
recipe (name) 47.6 efps (21ms) 47.6 efps (21ms) +0ms (-/-%)
recipe (description) 52.6 efps (19ms) 50.0 efps (20ms) +1ms (+5.3%)
recipe (instructions) 99.9+ efps (5ms) 99.9+ efps (5ms) +0ms (-/-%)
synthetic (title) 18.2 efps (55ms) 18.9 efps (53ms) -2ms (-3.6%)
synthetic (string inside object) 19.2 efps (52ms) 19.6 efps (51ms) -1ms (-1.9%)

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) 38ms 41ms 45ms 323ms 501ms 9.9s
article (body) 15ms 17ms 19ms 128ms 52ms 5.4s
article (string inside object) 37ms 40ms 46ms 184ms 158ms 7.0s
article (string inside array) 42ms 45ms 48ms 57ms 193ms 7.0s
recipe (name) 21ms 23ms 27ms 44ms 0ms 7.8s
recipe (description) 19ms 20ms 24ms 46ms 0ms 4.8s
recipe (instructions) 5ms 7ms 8ms 31ms 0ms 3.1s
synthetic (title) 55ms 62ms 68ms 240ms 1038ms 14.5s
synthetic (string inside object) 52ms 53ms 57ms 222ms 817ms 7.8s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 49ms 76ms 89ms 377ms 845ms 12.2s
article (body) 14ms 16ms 23ms 163ms 202ms 5.3s
article (string inside object) 42ms 44ms 49ms 78ms 147ms 6.8s
article (string inside array) 49ms 52ms 55ms 146ms 538ms 7.7s
recipe (name) 21ms 22ms 25ms 48ms 19ms 8.3s
recipe (description) 20ms 21ms 23ms 29ms 0ms 4.8s
recipe (instructions) 5ms 6ms 7ms 15ms 0ms 3.1s
synthetic (title) 53ms 56ms 61ms 248ms 871ms 12.9s
synthetic (string inside object) 51ms 53ms 56ms 216ms 915ms 7.8s

📚 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.

@skogsmaskin skogsmaskin changed the title Feat/dam 190/gdr feat(core): Global Document References support Jan 30, 2025
@skogsmaskin
Copy link
Member

Renamed references to routes that is currently being renamed in the API.

if (!resourceType) {
return 'The resource type must be a non-empty string'
}
if (resourceType != 'asset-library' && resourceType != 'dataset') {
Copy link
Member

Choose a reason for hiding this comment

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

should this be media-library?

return 'The resource type must be a non-empty string'
}
if (resourceType != 'asset-library' && resourceType != 'dataset') {
return 'The resource type must be either "asset-library" or "dataset"'
Copy link
Member

Choose a reason for hiding this comment

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

should it say "media-library" here?

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.

4 participants