Skip to content

Commit cebd5db

Browse files
committed
Merge branch 'main' into sharded-state'
1 parent 9c255d6 commit cebd5db

File tree

61 files changed

+960
-2834
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+960
-2834
lines changed

THIRD-PARTY-NOTICES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The following third-party software is used by and included in **Mongodb Compass**.
2-
This document was automatically generated on Sun Sep 29 2024.
2+
This document was automatically generated on Tue Oct 01 2024.
33

44
## List of dependencies
55

configs/webpack-config-compass/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"email": "[email protected]"
1414
},
1515
"homepage": "https://github.com/mongodb-js/compass",
16-
"version": "1.4.3",
16+
"version": "1.4.4",
1717
"repository": {
1818
"type": "git",
1919
"url": "https://github.com/mongodb-js/compass.git"

configs/webpack-config-compass/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,3 +372,4 @@ export { sharedExternals, pluginExternals };
372372
export { webpackArgsWithDefaults, isServe } from './args';
373373
export { default as webpack } from 'webpack';
374374
export { merge } from 'webpack-merge';
375+
export { default as WebpackDevServer } from 'webpack-dev-server';

docs/tracking-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Compass Tracking Plan
33

4-
Generated on Sun, Sep 29, 2024 at 03:16 AM
4+
Generated on Tue, Oct 1, 2024 at 07:33 AM
55

66
## Table of Contents
77

package-lock.json

Lines changed: 256 additions & 258 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/atlas-service/src/atlas-service.ts

Lines changed: 80 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ import {
99
import type { Logger } from '@mongodb-js/compass-logging';
1010
import type { PreferencesAccess } from 'compass-preferences-model';
1111
import type { AtlasClusterMetadata } from '@mongodb-js/connection-info';
12-
import type {
13-
AutomationAgentRequestTypes,
14-
AutomationAgentResponse,
15-
} from './make-automation-agent-op-request';
16-
import { makeAutomationAgentOpRequest } from './make-automation-agent-op-request';
1712

1813
export type AtlasServiceOptions = {
1914
defaultHeaders?: Record<string, string>;
@@ -104,34 +99,90 @@ export class AtlasService {
10499
},
105100
});
106101
}
107-
automationAgentFetch<OpType extends keyof AutomationAgentRequestTypes>(
108-
atlasMetadata: Pick<
109-
AtlasClusterMetadata,
110-
| 'projectId'
111-
| 'clusterUniqueId'
112-
| 'regionalBaseUrl'
113-
| 'metricsType'
114-
| 'metricsId'
115-
>,
116-
opType: OpType,
117-
opBody: Omit<
118-
AutomationAgentRequestTypes[OpType],
119-
'clusterId' | 'serverlessId'
120-
>
121-
): Promise<AutomationAgentResponse<OpType>> {
102+
async automationAgentRequest(
103+
atlasMetadata: AtlasClusterMetadata,
104+
opType: string,
105+
opBody: Record<string, unknown>
106+
): Promise<{ _id: string; requestType: string } | undefined> {
122107
const opBodyClusterId =
123108
atlasMetadata.metricsType === 'serverless'
124109
? { serverlessId: atlasMetadata.clusterUniqueId }
125110
: { clusterId: atlasMetadata.metricsId };
126-
return makeAutomationAgentOpRequest(
127-
this.authenticatedFetch.bind(this),
128-
this.regionalizedCloudEndpoint(atlasMetadata),
129-
atlasMetadata.projectId,
130-
opType,
131-
Object.assign(
132-
opBodyClusterId,
133-
opBody
134-
) as AutomationAgentRequestTypes[OpType]
111+
const requestUrl = this.regionalizedCloudEndpoint(
112+
atlasMetadata,
113+
`/explorer/v1/groups/${atlasMetadata.projectId}/requests/${opType}`
135114
);
115+
const json = await this.authenticatedFetch(requestUrl, {
116+
method: 'POST',
117+
headers: {
118+
'content-type': 'application/json',
119+
},
120+
body: JSON.stringify({ ...opBodyClusterId, ...opBody }),
121+
}).then((res) => {
122+
if (
123+
res.headers
124+
.get('content-type')
125+
?.toLowerCase()
126+
.includes('application/json')
127+
) {
128+
return res.json();
129+
}
130+
});
131+
assertAutomationAgentRequestResponse(json, opType);
132+
return json;
133+
}
134+
async automationAgentAwait<T>(
135+
atlasMetadata: AtlasClusterMetadata,
136+
opType: string,
137+
requestId: string
138+
): Promise<{
139+
_id: string;
140+
requestType: string;
141+
response: T[];
142+
}> {
143+
const requestUrl = this.regionalizedCloudEndpoint(
144+
atlasMetadata,
145+
`/explorer/v1/groups/${atlasMetadata.projectId}/requests/${requestId}/types/${opType}/await`
146+
);
147+
const json = await this.authenticatedFetch(requestUrl, {
148+
method: 'GET',
149+
}).then((res) => {
150+
return res.json();
151+
});
152+
assertAutomationAgentAwaitResponse<T>(json, opType);
153+
return json;
154+
}
155+
}
156+
157+
function assertAutomationAgentRequestResponse(
158+
json: any,
159+
opType: string
160+
): asserts json is { _id: string; requestType: string } {
161+
if (
162+
Object.prototype.hasOwnProperty.call(json, '_id') &&
163+
Object.prototype.hasOwnProperty.call(json, 'requestType') &&
164+
json.requestType === opType
165+
) {
166+
return;
167+
}
168+
throw new Error(
169+
'Got unexpected backend response for automation agent request'
170+
);
171+
}
172+
173+
function assertAutomationAgentAwaitResponse<T>(
174+
json: any,
175+
opType: string
176+
): asserts json is { _id: string; requestType: string; response: T[] } {
177+
if (
178+
Object.prototype.hasOwnProperty.call(json, '_id') &&
179+
Object.prototype.hasOwnProperty.call(json, 'requestType') &&
180+
Object.prototype.hasOwnProperty.call(json, 'response') &&
181+
json.requestType === opType
182+
) {
183+
return;
136184
}
185+
throw new Error(
186+
'Got unexpected backend response for automation agent request await'
187+
);
137188
}

packages/atlas-service/src/make-automation-agent-op-request.spec.ts

Lines changed: 0 additions & 124 deletions
This file was deleted.

0 commit comments

Comments
 (0)