Skip to content

Commit e2b078e

Browse files
myang1220Copilotgribnoysupnvs119
authored
feat(save-user-data): extend user data abstract class for api backend COMPASS-9558 (#7114)
* feat(save-user-data): create a user data abstract class * fix: rm defaults and add semaphore to FileUserData * feat(save-user-data): push for help * feat(save-user-data): comment out nulls * feat(save-user-data): create a user data abstract class * fix: rm defaults and add semaphore to FileUserData * feat(save-user-data): push for help * feat(save-user-data): comment out nulls * potentital org and group id retrieval * minor fixes * unit testing * typo Co-authored-by: Copilot <[email protected]> * package-lock.json * fix: parse one by one in readAll * fix: change updateAttributes return type to boolean * stricter typing for type param and fix update tests * add getResourceUrl and change groupId to projectId * change wsBaseUrl to ccsBaseUrl in spec files * chore(user-data): remove redundant withStats methods * fix(user-data): remove nonexistent exports * fix(my-queries-storage): adjust types to match the method behavior * fix(saved-aggregations-queries): adjust test fixture * put data type in IUserData class * fix(user-data): add datatype to IUserData abstract class & tests * fix(user-data): make create and update return type to be boolean, like queries * fix(compass-aggregations): fix method typing * revert: reset bson-transpilers files to master state Remove unwanted bson-transpilers changes that were accidentally included in the rebase. This resets the bson-transpilers package back to its master state while preserving the user-data related changes that are needed for this PR. * fix: rebuild bson-transpilers symbol tables Rebuild the generated symbol table files to ensure they are properly formatted and up-to-date with the current source templates. * restore big files * restore again * package lock * comments * log ids * changes * copilot review changes --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Sergey Petushkov <[email protected]> Co-authored-by: Niva Vaani Sivakumar <[email protected]>
1 parent de5c297 commit e2b078e

File tree

19 files changed

+1296
-120
lines changed

19 files changed

+1296
-120
lines changed

package-lock.json

Lines changed: 468 additions & 0 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.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { createNoopLogger } from '@mongodb-js/compass-logging/provider';
77
import { CompassAtlasAuthService } from './compass-atlas-auth-service';
88

99
const ATLAS_CONFIG = {
10-
wsBaseUrl: 'ws://example.com',
10+
ccsBaseUrl: 'ws://example.com',
1111
cloudBaseUrl: 'ws://example.com/cloud',
1212
atlasApiBaseUrl: 'http://example.com/api',
1313
atlasLogin: {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class AtlasService {
7979
return this.cloudEndpoint(path);
8080
}
8181
driverProxyEndpoint(path?: string): string {
82-
return `${this.config.wsBaseUrl}${normalizePath(path)}`;
82+
return `${this.config.ccsBaseUrl}${normalizePath(path)}`;
8383
}
8484
async fetch(url: RequestInfo | URL, init?: RequestInit): Promise<Response> {
8585
throwIfNetworkTrafficDisabled(this.preferences);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('CompassAuthServiceMain', function () {
4848
};
4949

5050
const defaultConfig = {
51-
wsBaseUrl: 'ws://example.com',
51+
ccsBaseUrl: 'ws://example.com',
5252
cloudBaseUrl: 'ws://example.com/cloud',
5353
atlasApiBaseUrl: 'http://example.com/api',
5454
atlasLogin: {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ export class SecretStore {
77
private readonly userData: FileUserData<typeof AtlasPluginStateSchema>;
88
private readonly fileName = 'AtlasPluginState';
99
constructor(basePath?: string) {
10-
this.userData = new FileUserData(AtlasPluginStateSchema, {
11-
subdir: 'AtlasState',
10+
this.userData = new FileUserData(AtlasPluginStateSchema, 'AtlasState', {
1211
basePath,
1312
});
1413
}

packages/atlas-service/src/util.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export type AtlasServiceConfig = {
9696
/**
9797
* MongoDB Driver WebSocket proxy base url
9898
*/
99-
wsBaseUrl: string;
99+
ccsBaseUrl: string;
100100
/**
101101
* Cloud UI backend base url
102102
*/
@@ -135,7 +135,7 @@ export type AtlasServiceConfig = {
135135
*/
136136
const config = {
137137
'atlas-local': {
138-
wsBaseUrl: 'ws://localhost:61001/ws',
138+
ccsBaseUrl: 'ws://localhost:61001/ws',
139139
cloudBaseUrl: '',
140140
atlasApiBaseUrl: 'http://localhost:8080/api/private',
141141
atlasLogin: {
@@ -146,7 +146,7 @@ const config = {
146146
assistantApiBaseUrl: 'https://knowledge.staging.corp.mongodb.com/api/v1',
147147
},
148148
'atlas-dev': {
149-
wsBaseUrl: '',
149+
ccsBaseUrl: '',
150150
cloudBaseUrl: '',
151151
atlasApiBaseUrl: 'https://cloud-dev.mongodb.com/api/private',
152152
atlasLogin: {
@@ -157,7 +157,7 @@ const config = {
157157
assistantApiBaseUrl: 'https://knowledge.staging.corp.mongodb.com/api/v1',
158158
},
159159
'atlas-qa': {
160-
wsBaseUrl: '',
160+
ccsBaseUrl: '',
161161
cloudBaseUrl: '',
162162
atlasApiBaseUrl: 'https://cloud-qa.mongodb.com/api/private',
163163
atlasLogin: {
@@ -168,7 +168,7 @@ const config = {
168168
assistantApiBaseUrl: 'https://knowledge.staging.corp.mongodb.com/api/v1',
169169
},
170170
atlas: {
171-
wsBaseUrl: '',
171+
ccsBaseUrl: '',
172172
cloudBaseUrl: '',
173173
atlasApiBaseUrl: 'https://cloud.mongodb.com/api/private',
174174
atlasLogin: {
@@ -179,7 +179,7 @@ const config = {
179179
assistantApiBaseUrl: 'https://knowledge.staging.corp.mongodb.com/api/v1',
180180
},
181181
'web-sandbox-atlas-local': {
182-
wsBaseUrl: '/ccs',
182+
ccsBaseUrl: '/ccs',
183183
cloudBaseUrl: '/cloud-mongodb-com',
184184
atlasApiBaseUrl: 'http://localhost:8080/api/private',
185185
atlasLogin: {
@@ -190,7 +190,7 @@ const config = {
190190
assistantApiBaseUrl: 'https://knowledge.staging.corp.mongodb.com/api/v1',
191191
},
192192
'web-sandbox-atlas-dev': {
193-
wsBaseUrl: '/ccs',
193+
ccsBaseUrl: '/ccs',
194194
cloudBaseUrl: '/cloud-mongodb-com',
195195
atlasApiBaseUrl: 'https://cloud-dev.mongodb.com/api/private',
196196
atlasLogin: {
@@ -201,7 +201,7 @@ const config = {
201201
assistantApiBaseUrl: 'https://knowledge.staging.corp.mongodb.com/api/v1',
202202
},
203203
'web-sandbox-atlas-qa': {
204-
wsBaseUrl: '/ccs',
204+
ccsBaseUrl: '/ccs',
205205
cloudBaseUrl: '/cloud-mongodb-com',
206206
atlasApiBaseUrl: 'https://cloud-dev.mongodb.com/api/private',
207207
atlasLogin: {
@@ -212,7 +212,7 @@ const config = {
212212
assistantApiBaseUrl: 'https://knowledge.staging.corp.mongodb.com/api/v1',
213213
},
214214
'web-sandbox-atlas': {
215-
wsBaseUrl: '/ccs',
215+
ccsBaseUrl: '/ccs',
216216
cloudBaseUrl: '/cloud-mongodb-com',
217217
atlasApiBaseUrl: 'https://cloud.mongodb.com/api/private',
218218
atlasLogin: {

packages/compass-data-modeling/src/services/data-model-storage-electron.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ class DataModelStorageElectron implements DataModelStorage {
1212
typeof MongoDBDataModelDescriptionSchema
1313
>;
1414
constructor(basePath?: string) {
15-
this.userData = new FileUserData(MongoDBDataModelDescriptionSchema, {
16-
subdir: 'DataModelDescriptions',
17-
basePath,
18-
});
15+
this.userData = new FileUserData(
16+
MongoDBDataModelDescriptionSchema,
17+
'DataModelDescriptions',
18+
{
19+
basePath,
20+
}
21+
);
1922
}
2023
save(description: MongoDBDataModelDescription) {
2124
return this.userData.write(description.id, description);

packages/compass-preferences-model/src/preferences-persistent-storage.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ export class PersistentStorage implements PreferencesStorage {
2525
private safeStorage?: PreferencesSafeStorage;
2626

2727
constructor(basePath?: string, safeStorage?: PreferencesSafeStorage) {
28-
this.userData = new FileUserData(getPreferencesValidator(), {
29-
subdir: 'AppPreferences',
30-
basePath,
31-
});
28+
this.userData = new FileUserData(
29+
getPreferencesValidator(),
30+
'AppPreferences',
31+
{
32+
basePath,
33+
}
34+
);
3235
this.safeStorage = safeStorage;
3336
}
3437

packages/compass-preferences-model/src/user-storage.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ export interface UserStorage {
2626
export class UserStorageImpl implements UserStorage {
2727
private readonly userData: FileUserData<typeof UserSchema>;
2828
constructor(basePath?: string) {
29-
this.userData = new FileUserData(UserSchema, {
30-
subdir: 'Users',
29+
this.userData = new FileUserData(UserSchema, 'Users', {
3130
basePath,
3231
});
3332
}

packages/compass-shell/src/modules/history-storage.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ export class HistoryStorage {
66
userData;
77

88
constructor(basePath?: string) {
9-
this.userData = new FileUserData(z.string().array(), {
10-
// Todo: https://jira.mongodb.org/browse/COMPASS-7080
11-
subdir: getAppName() ?? '',
9+
// TODO: https://jira.mongodb.org/browse/COMPASS-7080
10+
this.userData = new FileUserData(z.string().array(), getAppName() ?? '', {
1211
basePath,
1312
});
1413
}

0 commit comments

Comments
 (0)