@@ -47,8 +47,8 @@ import type { AllPreferences } from 'compass-preferences-model/provider';
4747import { PreferencesProvider } from 'compass-preferences-model/provider' ;
4848import FieldStorePlugin from '@mongodb-js/compass-field-store' ;
4949import {
50+ atlasServiceLocator ,
5051 AtlasServiceProvider ,
51- useAtlasServiceContext ,
5252} from '@mongodb-js/atlas-service/provider' ;
5353import { AtlasAiServiceProvider } from '@mongodb-js/compass-generative-ai/provider' ;
5454import { LoggerProvider } from '@mongodb-js/compass-logging/provider' ;
@@ -64,6 +64,7 @@ import { WorkspaceTab as MyQueriesWorkspace } from '@mongodb-js/compass-saved-ag
6464import { useCompassWebPreferences } from './preferences' ;
6565import { DataModelingWorkspaceTab as DataModelingWorkspace } from '@mongodb-js/compass-data-modeling' ;
6666import { DataModelStorageServiceProviderInMemory } from '@mongodb-js/compass-data-modeling/web' ;
67+ // My Queries storage (web variant uses Atlas user data backend)
6768import {
6869 CompassFavoriteQueryStorage ,
6970 CompassPipelineStorage ,
@@ -77,6 +78,7 @@ import {
7778 type RecentQueryStorageAccess ,
7879 type PipelineStorageAccess ,
7980} from '@mongodb-js/my-queries-storage/provider' ;
81+ import { createServiceProvider } from '@mongodb-js/compass-app-registry' ;
8082import { CompassAssistantProvider } from '@mongodb-js/compass-assistant' ;
8183import { CompassAssistantDrawerWithConnections } from './compass-assistant-drawer' ;
8284import { APP_NAMES_FOR_PROMPT } from '@mongodb-js/compass-assistant' ;
@@ -103,69 +105,66 @@ const WithAtlasProviders: React.FC<{ children: React.ReactNode }> = ({
103105 ) ;
104106} ;
105107
106- const WithStorageProviders : React . FC < {
107- orgId : string ;
108- projectId : string ;
109- children : React . ReactNode ;
110- } > = ( { children, orgId, projectId } ) => {
111- const atlasService = useAtlasServiceContext ( ) ;
112- const authenticatedFetch = atlasService . authenticatedFetch . bind ( atlasService ) ;
113- const getResourceUrl = ( path ?: string ) => {
114- const url = atlasService . userDataEndpoint ( `/${ path || '' } ` ) ;
115- return url ;
116- } ;
117- const pipelineStorage = useRef < PipelineStorageAccess > ( {
118- getStorage ( options ?: {
119- basePath ?: string ;
120- orgId ?: string ;
121- projectId ?: string ;
122- getResourceUrl ?: ( path ?: string ) => string ;
123- authenticatedFetch ?: (
124- url : RequestInfo | URL ,
125- options ?: RequestInit
126- ) => Promise < Response > ;
127- } ) {
128- return new CompassPipelineStorage ( {
129- ...options ,
130- orgId,
131- projectId,
132- getResourceUrl,
133- authenticatedFetch,
134- } ) ;
135- } ,
136- } ) ;
137- const favoriteQueryStorage = useRef < FavoriteQueryStorageAccess > ( {
138- getStorage ( options ) {
139- return new CompassFavoriteQueryStorage ( {
140- ...options ,
141- orgId,
142- projectId,
143- getResourceUrl,
144- authenticatedFetch,
145- } ) ;
146- } ,
147- } ) ;
148- const recentQueryStorage = useRef < RecentQueryStorageAccess > ( {
149- getStorage ( options ) {
150- return new CompassRecentQueryStorage ( {
151- ...options ,
152- orgId,
153- projectId,
154- getResourceUrl,
155- authenticatedFetch,
156- } ) ;
157- } ,
158- } ) ;
159- return (
160- < PipelineStorageProvider value = { pipelineStorage . current } >
161- < FavoriteQueryStorageProvider value = { favoriteQueryStorage . current } >
162- < RecentQueryStorageProvider value = { recentQueryStorage . current } >
163- { children }
164- </ RecentQueryStorageProvider >
165- </ FavoriteQueryStorageProvider >
166- </ PipelineStorageProvider >
167- ) ;
168- } ;
108+ const WithStorageProviders = createServiceProvider (
109+ function WithStorageProviders ( {
110+ orgId,
111+ projectId,
112+ children,
113+ } : {
114+ orgId : string ;
115+ projectId : string ;
116+ children : React . ReactNode ;
117+ } ) {
118+ const atlasService = atlasServiceLocator ( ) ;
119+ const authenticatedFetch =
120+ atlasService . authenticatedFetch . bind ( atlasService ) ;
121+ const getResourceUrl = ( path ?: string ) =>
122+ atlasService . userDataEndpoint ( `/${ path || '' } ` ) ;
123+
124+ const pipelineStorage = useRef < PipelineStorageAccess > ( {
125+ getStorage ( options ) {
126+ return new CompassPipelineStorage ( {
127+ ...options ,
128+ orgId,
129+ projectId,
130+ getResourceUrl,
131+ authenticatedFetch,
132+ } ) ;
133+ } ,
134+ } ) ;
135+ const favoriteQueryStorage = useRef < FavoriteQueryStorageAccess > ( {
136+ getStorage ( options ) {
137+ return new CompassFavoriteQueryStorage ( {
138+ ...options ,
139+ orgId,
140+ projectId,
141+ getResourceUrl,
142+ authenticatedFetch,
143+ } ) ;
144+ } ,
145+ } ) ;
146+ const recentQueryStorage = useRef < RecentQueryStorageAccess > ( {
147+ getStorage ( options ) {
148+ return new CompassRecentQueryStorage ( {
149+ ...options ,
150+ orgId,
151+ projectId,
152+ getResourceUrl,
153+ authenticatedFetch,
154+ } ) ;
155+ } ,
156+ } ) ;
157+ return (
158+ < PipelineStorageProvider value = { pipelineStorage . current } >
159+ < FavoriteQueryStorageProvider value = { favoriteQueryStorage . current } >
160+ < RecentQueryStorageProvider value = { recentQueryStorage . current } >
161+ { children }
162+ </ RecentQueryStorageProvider >
163+ </ FavoriteQueryStorageProvider >
164+ </ PipelineStorageProvider >
165+ ) ;
166+ }
167+ ) ;
169168
170169type CompassWorkspaceProps = Pick <
171170 React . ComponentProps < typeof WorkspacesPlugin > ,
0 commit comments