Skip to content

Commit

Permalink
Merge branch 'main' into poll-regular-indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
lerouxb committed Sep 23, 2024
2 parents 14e1ff8 + 108bdcf commit f26a73c
Show file tree
Hide file tree
Showing 50 changed files with 1,193 additions and 440 deletions.
2 changes: 1 addition & 1 deletion THIRD-PARTY-NOTICES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The following third-party software is used by and included in **Mongodb Compass**.
This document was automatically generated on Wed Sep 18 2024.
This document was automatically generated on Mon Sep 23 2024.

## List of dependencies

Expand Down
2 changes: 1 addition & 1 deletion docs/tracking-plan.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Compass Tracking Plan

Generated on Wed, Sep 18, 2024 at 11:44 AM
Generated on Mon, Sep 23, 2024 at 01:02 PM

## Table of Contents

Expand Down
56 changes: 33 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/atlas-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"@mongodb-js/compass-telemetry": "^1.1.7",
"@mongodb-js/compass-user-data": "^0.3.7",
"@mongodb-js/compass-utils": "^0.6.12",
"@mongodb-js/connection-info": "^0.8.0",
"@mongodb-js/devtools-connect": "^3.2.10",
"@mongodb-js/devtools-proxy-support": "^0.3.9",
"@mongodb-js/oidc-plugin": "^1.1.1",
Expand Down
53 changes: 44 additions & 9 deletions packages/atlas-service/src/atlas-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import {
} from './util';
import type { Logger } from '@mongodb-js/compass-logging';
import type { PreferencesAccess } from 'compass-preferences-model';
import type { AtlasClusterMetadata } from '@mongodb-js/connection-info';
import type {
AutomationAgentRequestTypes,
AutomationAgentResponse,
} from './make-automation-agent-op-request';
import { makeAutomationAgentOpRequest } from './make-automation-agent-op-request';

export type AtlasServiceOptions = {
defaultHeaders?: Record<string, string>;
Expand Down Expand Up @@ -35,19 +41,25 @@ export class AtlasService {
cloudEndpoint(path?: string): string {
return encodeURI(`${this.config.cloudBaseUrl}${path ? `/${path}` : ''}`);
}
regionalizedCloudEndpoint(
_atlasMetadata: Pick<AtlasClusterMetadata, 'regionalBaseUrl'>,
path?: string
): string {
// TODO: eventually should apply the regional url logic
// https://github.com/10gen/mms/blob/9f858bb987aac6aa80acfb86492dd74c89cbb862/client/packages/project/common/ajaxPrefilter.ts#L34-L49
return this.cloudEndpoint(path);
}
driverProxyEndpoint(path?: string): string {
return encodeURI(`${this.config.wsBaseUrl}${path ? `/${path}` : ''}`);
}
async fetch(url: RequestInfo, init?: RequestInit): Promise<Response> {
async fetch(url: RequestInfo | URL, init?: RequestInit): Promise<Response> {
throwIfNetworkTrafficDisabled(this.preferences);
throwIfAborted(init?.signal as AbortSignal);
this.logger.log.info(
this.logger.mongoLogId(1_001_000_297),
'AtlasService',
'Making a fetch',
{
url,
}
{ url }
);
try {
const res = await fetch(url, {
Expand All @@ -74,16 +86,13 @@ export class AtlasService {
this.logger.mongoLogId(1_001_000_298),
'AtlasService',
'Fetch errored',
{
url,
err,
}
{ url, err }
);
throw err;
}
}
async authenticatedFetch(
url: RequestInfo,
url: RequestInfo | URL,
init?: RequestInit
): Promise<Response> {
const authHeaders = await this.authService.getAuthHeaders();
Expand All @@ -95,4 +104,30 @@ export class AtlasService {
},
});
}
automationAgentFetch<OpType extends keyof AutomationAgentRequestTypes>(
atlasMetadata: Pick<
AtlasClusterMetadata,
'projectId' | 'clusterUniqueId' | 'regionalBaseUrl' | 'metricsType'
>,
opType: OpType,
opBody: Omit<
AutomationAgentRequestTypes[OpType],
'clusterId' | 'serverlessId'
>
): Promise<AutomationAgentResponse<OpType>> {
const opBodyClusterId =
atlasMetadata.metricsType === 'serverless'
? { serverlessId: atlasMetadata.clusterUniqueId }
: { clusterId: atlasMetadata.clusterUniqueId };
return makeAutomationAgentOpRequest(
this.authenticatedFetch.bind(this),
this.regionalizedCloudEndpoint(atlasMetadata),
atlasMetadata.projectId,
opType,
Object.assign(
opBodyClusterId,
opBody
) as AutomationAgentRequestTypes[OpType]
);
}
}
Loading

0 comments on commit f26a73c

Please sign in to comment.