feat(content-preview): add metadataApiHost prop for regional metadata routing#4615
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
WalkthroughThis PR adds optional ChangesRegional Metadata Instance Endpoint Routing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Biome (2.4.16)src/api/Base.jsFile contains syntax errors that prevent linting: Line 21: 'import type' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 22: 'import type' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 28: return types can only be used in TypeScript files; Line 33: return types can only be used in TypeScript files; Line 38: return types can only be used in TypeScript files; Line 43: return types can only be used in TypeScript files; Line 60: return types can only be used in TypeScript files; Line 60: expected a semicolon to end the class property, but found none; Line 60: Expected an identifier, a string literal, a number literal, a private field name, or a computed name but instead found '; Line 65: return types can only be used in TypeScript files; Line 70: return types can only be used in TypeScript files; Line 75: return types can only be used in TypeScript files; Line 80: return types can only be ... [truncated 4112 characters] ... only feature. Convert your file to a TypeScript file or remove the syntax.; Line 383: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 384: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 385: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 386: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 387: return type annotation are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 396: type annotation are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax. src/api/Metadata.jsFile contains syntax errors that prevent linting: Line 7: 'import type' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 55: 'import type' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 56: 'import type' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 66: 'import type' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 67: 'import type' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 76: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 76: return type annotation are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 86: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 86: ... [truncated 24149 characters] ... y feature. Convert your file to a TypeScript file or remove the syntax.; Line 1600: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 1601: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 1602: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 1603: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 1604: optional parameters are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 1604: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax. src/common/types/api.jsFile contains syntax errors that prevent linting: Line 4: 'import type' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 5: 'import type' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 6: 'import type' are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 8: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 16: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 26: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 28: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 35: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 37: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 45: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 55: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 57: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 65: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 69: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 71: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 76: type alias are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.; Line 113: 'export type' declarations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.
🔧 ast-grep (0.43.0)src/api/__tests__/Metadata.test.jsThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merge Queue Status
This pull request spent 13 minutes 47 seconds in the queue, including 13 minutes 26 seconds running CI. Required conditions to merge
|
Summary
Adds a new optional
metadataApiHostprop toContentPreview(forwarded down toContentSidebar) that lets host applications route metadata instance endpoints to a regional metadata host, while every other API call continues to useapiHost.Why
Some Box deployments need file/folder metadata to live in a specific region (e.g.
https://api-jp.box.com) for data-residency reasons. Today, all metadata calls flow through a singleapiHost. A second, optional host is required so that file/folder metadata reads/writes can be pinned to a regional gateway, while shared resources (templates, taxonomies, suggestions, options, queries) stay on the global host.What changed
ContentPreviewandContentSidebar:metadataApiHost?: string. Forwarded intoAPIOptions.APIOptions.metadataApiHostis stored onBaseand a small shared helperbuildApiUrl(host)is added so subclasses can derive a/2.0URL from any host.MetadataaddsgetMetadataInstanceBaseUrl()and uses it fromgetMetadataUrl()/getMetadataUrlForFolder(). WhenmetadataApiHostis set and distinct fromapiHost, file/folder metadata instance endpoints route through it; otherwise they fall back toapiHost.apiHost.Backward compatibility
The new prop is fully optional and forward-compatible:
undefined, empty string, or a value equal toapiHostproduce URLs that are byte-identical to today's behavior.Unit tests cover all three branches (regional, fallback, and "all non-instance endpoints stay on
apiHost").How to test
The prop only changes URL routing, so the only meaningful end-to-end test is loading Preview/Sidebar against a real regional gateway and confirming metadata-instance traffic goes there while every other endpoint still hits
apiHost.Steps:
ContentPreview(or a downstream consumer that wraps it) with:apiHost = "https://api.box.com"metadataApiHost = "https://api-jp.box.com"(or whichever regional host monoproxy is forwarding to)metadataApiHost:GET/POST/PUT/DELETE /2.0/files/{id}/metadata[/{scope}/{template}]GET/POST/PUT/DELETE /2.0/folders/{id}/metadata[/{scope}/{template}]apiHost:/2.0/metadata_templates/...(templates, schema, field options)/2.0/metadata_taxonomies/...(taxonomies and nodes)/2.0/metadata_instances/suggestionsexecute_read)metadataApiHostset — every metadata request should go toapiHost, identical to current production behavior.Summary by CodeRabbit
New Features
Documentation
Tests