Skip to content

Commit 699e255

Browse files
committed
bbox method from Workspaces client to avoid X-Workspace header issues
1 parent 47c7cf5 commit 699e255

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

services/osm.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,11 @@ export class OsmApiClient extends BaseHttpClient implements ICancelableClient {
253253
}
254254

255255
async getWorkspaceBbox(workspaceId: WorkspaceId) {
256-
const response = await this._get(`workspaces/${workspaceId}/bbox.json`);
257-
258-
if (response.status === 204) {
259-
return undefined
260-
}
261-
262-
return await response.json();
256+
// The workspace bbox lives on the v1 tasking API, owned by WorkspacesClient.
257+
// OsmApiClient is constructed before workspacesClient (which depends on it),
258+
// so we resolve the singleton lazily at call time to avoid the import cycle.
259+
const { workspacesClient } = await import('~/services/index');
260+
return workspacesClient.getWorkspaceBbox(workspaceId);
263261
}
264262

265263
async getExportBbox(id: number) {

services/workspaces.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,22 @@ export class WorkspacesClient extends BaseHttpClient implements ICancelableClien
119119
}
120120
}
121121

122-
getWorkspaceBbox(id: WorkspaceId): Promise<BoundingBox> {
123-
return this.#osmClient.getWorkspaceBbox(id);
122+
async getWorkspaceBbox(id: WorkspaceId): Promise<BoundingBox | undefined> {
123+
const originalBaseUrl = this._baseUrl;
124+
this._baseUrl = this.#newApiUrl;
125+
126+
try {
127+
const response = await this._send(`workspaces/${id}/bbox`, 'GET');
128+
129+
if (response.status === 204) {
130+
return undefined;
131+
}
132+
133+
return await response.json();
134+
}
135+
finally {
136+
this._baseUrl = originalBaseUrl;
137+
}
124138
}
125139

126140
async createWorkspace(workspace: WorkspaceCreation): Promise<WorkspaceId> {

0 commit comments

Comments
 (0)