Skip to content

feat(save-user-data): extend user data abstract class for api backend COMPASS-9558 #7114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3f336ec
feat(save-user-data): create a user data abstract class
myang1220 Jul 10, 2025
ad5e416
Merge branch 'main' into user-data-interface
myang1220 Jul 10, 2025
78026a3
fix: rm defaults and add semaphore to FileUserData
myang1220 Jul 10, 2025
b24d748
merge remote branch back into local
myang1220 Jul 10, 2025
8413d43
Merge branch 'main' into user-data-interface
myang1220 Jul 10, 2025
dc38640
feat(save-user-data): push for help
myang1220 Jul 15, 2025
41abc96
feat(save-user-data): comment out nulls
myang1220 Jul 15, 2025
e90412e
feat(save-user-data): create a user data abstract class
myang1220 Jul 10, 2025
701adaf
fix: rm defaults and add semaphore to FileUserData
myang1220 Jul 10, 2025
daee65a
feat(save-user-data): push for help
myang1220 Jul 15, 2025
90573c7
feat(save-user-data): comment out nulls
myang1220 Jul 15, 2025
0e997ff
rebase main into branch
myang1220 Jul 15, 2025
5d39eb3
Merge branch 'main' of https://github.com/mongodb-js/compass into ext…
myang1220 Jul 15, 2025
5edf5e2
potentital org and group id retrieval
myang1220 Jul 17, 2025
729c6db
minor fixes
myang1220 Jul 17, 2025
055b898
unit testing
myang1220 Jul 18, 2025
fed4e96
fix package-lock.json merge conflict
myang1220 Jul 18, 2025
2058a32
typo
myang1220 Jul 18, 2025
296147a
package-lock.json
myang1220 Jul 18, 2025
d128447
merge origin back into branch
myang1220 Jul 18, 2025
18240da
fix: parse one by one in readAll
myang1220 Jul 21, 2025
31a8643
fix: change updateAttributes return type to boolean
myang1220 Jul 21, 2025
e88856f
stricter typing for type param and fix update tests
myang1220 Jul 22, 2025
3b8fc66
add getResourceUrl and change groupId to projectId
myang1220 Jul 22, 2025
7d42eef
merge main back into branch
myang1220 Jul 22, 2025
3c033fe
change wsBaseUrl to ccsBaseUrl in spec files
myang1220 Jul 22, 2025
ef94ff8
chore(user-data): remove redundant withStats methods
gribnoysup Jul 23, 2025
3f8405a
fix(user-data): remove nonexistent exports
gribnoysup Jul 23, 2025
7f07ddd
fix(my-queries-storage): adjust types to match the method behavior
gribnoysup Jul 23, 2025
e09d426
fix(saved-aggregations-queries): adjust test fixture
gribnoysup Jul 23, 2025
04ba804
put data type in IUserData class
myang1220 Jul 23, 2025
cf510ce
Merge branch 'main' into extend-user-data
myang1220 Jul 23, 2025
73b2bd1
fix(user-data): add datatype to IUserData abstract class & tests
myang1220 Jul 24, 2025
51ab01e
fix: merge stats change to branch
myang1220 Jul 24, 2025
df135f3
fix(user-data): make create and update return type to be boolean, lik…
myang1220 Jul 24, 2025
0bb77b8
pull remote branch back into local
myang1220 Jul 24, 2025
f6efcd6
fix(compass-aggregations): fix method typing
myang1220 Jul 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/atlas-service/src/atlas-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createNoopLogger } from '@mongodb-js/compass-logging/provider';
import { CompassAtlasAuthService } from './compass-atlas-auth-service';

const ATLAS_CONFIG = {
wsBaseUrl: 'ws://example.com',
ccsBaseUrl: 'ws://example.com',
cloudBaseUrl: 'ws://example.com/cloud',
atlasApiBaseUrl: 'http://example.com/api',
atlasLogin: {
Expand Down
2 changes: 1 addition & 1 deletion packages/atlas-service/src/atlas-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class AtlasService {
return this.cloudEndpoint(path);
}
driverProxyEndpoint(path?: string): string {
return `${this.config.wsBaseUrl}${normalizePath(path)}`;
return `${this.config.ccsBaseUrl}${normalizePath(path)}`;
}
async fetch(url: RequestInfo | URL, init?: RequestInit): Promise<Response> {
throwIfNetworkTrafficDisabled(this.preferences);
Expand Down
2 changes: 1 addition & 1 deletion packages/atlas-service/src/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('CompassAuthServiceMain', function () {
};

const defaultConfig = {
wsBaseUrl: 'ws://example.com',
ccsBaseUrl: 'ws://example.com',
cloudBaseUrl: 'ws://example.com/cloud',
atlasApiBaseUrl: 'http://example.com/api',
atlasLogin: {
Expand Down
3 changes: 1 addition & 2 deletions packages/atlas-service/src/secret-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export class SecretStore {
private readonly userData: FileUserData<typeof AtlasPluginStateSchema>;
private readonly fileName = 'AtlasPluginState';
constructor(basePath?: string) {
this.userData = new FileUserData(AtlasPluginStateSchema, {
subdir: 'AtlasState',
this.userData = new FileUserData(AtlasPluginStateSchema, 'AtlasState', {
basePath,
});
}
Expand Down
18 changes: 9 additions & 9 deletions packages/atlas-service/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export type AtlasServiceConfig = {
/**
* MongoDB Driver WebSocket proxy base url
*/
wsBaseUrl: string;
ccsBaseUrl: string;
/**
* Cloud UI backend base url
*/
Expand Down Expand Up @@ -131,7 +131,7 @@ export type AtlasServiceConfig = {
*/
const config = {
'atlas-local': {
wsBaseUrl: 'ws://localhost:61001/ws',
ccsBaseUrl: 'ws://localhost:61001/ws',
cloudBaseUrl: '',
atlasApiBaseUrl: 'http://localhost:8080/api/private',
atlasLogin: {
Expand All @@ -141,7 +141,7 @@ const config = {
authPortalUrl: 'https://account-dev.mongodb.com/account/login',
},
'atlas-dev': {
wsBaseUrl: '',
ccsBaseUrl: '',
cloudBaseUrl: '',
atlasApiBaseUrl: 'https://cloud-dev.mongodb.com/api/private',
atlasLogin: {
Expand All @@ -151,7 +151,7 @@ const config = {
authPortalUrl: 'https://account-dev.mongodb.com/account/login',
},
'atlas-qa': {
wsBaseUrl: '',
ccsBaseUrl: '',
cloudBaseUrl: '',
atlasApiBaseUrl: 'https://cloud-qa.mongodb.com/api/private',
atlasLogin: {
Expand All @@ -161,7 +161,7 @@ const config = {
authPortalUrl: 'https://account-qa.mongodb.com/account/login',
},
atlas: {
wsBaseUrl: '',
ccsBaseUrl: '',
cloudBaseUrl: '',
atlasApiBaseUrl: 'https://cloud.mongodb.com/api/private',
atlasLogin: {
Expand All @@ -171,7 +171,7 @@ const config = {
authPortalUrl: 'https://account.mongodb.com/account/login',
},
'web-sandbox-atlas-local': {
wsBaseUrl: '/ccs',
ccsBaseUrl: '/ccs',
cloudBaseUrl: '/cloud-mongodb-com',
atlasApiBaseUrl: 'http://localhost:8080/api/private',
atlasLogin: {
Expand All @@ -181,7 +181,7 @@ const config = {
authPortalUrl: 'https://account-dev.mongodb.com/account/login',
},
'web-sandbox-atlas-dev': {
wsBaseUrl: '/ccs',
ccsBaseUrl: '/ccs',
cloudBaseUrl: '/cloud-mongodb-com',
atlasApiBaseUrl: 'https://cloud-dev.mongodb.com/api/private',
atlasLogin: {
Expand All @@ -191,7 +191,7 @@ const config = {
authPortalUrl: 'https://account-dev.mongodb.com/account/login',
},
'web-sandbox-atlas-qa': {
wsBaseUrl: '/ccs',
ccsBaseUrl: '/ccs',
cloudBaseUrl: '/cloud-mongodb-com',
atlasApiBaseUrl: 'https://cloud-dev.mongodb.com/api/private',
atlasLogin: {
Expand All @@ -201,7 +201,7 @@ const config = {
authPortalUrl: 'https://account-dev.mongodb.com/account/login',
},
'web-sandbox-atlas': {
wsBaseUrl: '/ccs',
ccsBaseUrl: '/ccs',
cloudBaseUrl: '/cloud-mongodb-com',
atlasApiBaseUrl: 'https://cloud.mongodb.com/api/private',
atlasLogin: {
Expand Down
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gribnoysup @Anemy
Do you guys have any clue where these may have come from? I haven't personally modified any of them, so I wonder whether it's due to command line commands?

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/bson-transpilers/lib/symbol-table/shelltogo.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/bson-transpilers/lib/symbol-table/shelltojava.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/bson-transpilers/lib/symbol-table/shelltophp.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/bson-transpilers/lib/symbol-table/shelltoruby.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/bson-transpilers/lib/symbol-table/shelltorust.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ class DataModelStorageElectron implements DataModelStorage {
typeof MongoDBDataModelDescriptionSchema
>;
constructor(basePath?: string) {
this.userData = new FileUserData(MongoDBDataModelDescriptionSchema, {
subdir: 'DataModelDescriptions',
basePath,
});
this.userData = new FileUserData(
MongoDBDataModelDescriptionSchema,
'DataModelDescription',
{
basePath,
}
);
}
save(description: MongoDBDataModelDescription) {
return this.userData.write(description.id, description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ export class PersistentStorage implements PreferencesStorage {
private safeStorage?: PreferencesSafeStorage;

constructor(basePath?: string, safeStorage?: PreferencesSafeStorage) {
this.userData = new FileUserData(getPreferencesValidator(), {
subdir: 'AppPreferences',
basePath,
});
this.userData = new FileUserData(
getPreferencesValidator(),
'AppPreferences',
{
basePath,
}
);
this.safeStorage = safeStorage;
}

Expand Down
7 changes: 1 addition & 6 deletions packages/compass-preferences-model/src/user-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ export interface UserStorage {
export class UserStorageImpl implements UserStorage {
private readonly userData: FileUserData<typeof UserSchema>;
constructor(basePath?: string) {
this.userData = new FileUserData(UserSchema, {
subdir: 'Users',
this.userData = new FileUserData(UserSchema, 'Users', {
basePath,
});
}
Expand Down Expand Up @@ -79,8 +78,4 @@ export class UserStorageImpl implements UserStorage {
await this.userData.write(user.id, user);
return this.getUser(user.id);
}

private getFileName(id: string) {
return `${id}.json`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,11 @@ describe('AggregationsAndQueriesAndUpdatemanyList', function () {
queryStorageLoadAllStub = sandbox
.stub(queryStorage, 'loadAll')
.resolves(queries.map((item) => item.query));
sandbox
.stub(pipelineStorage, 'loadAll')
.resolves(pipelines.map((item) => item.aggregation));
sandbox.stub(pipelineStorage, 'loadAll').resolves(
pipelines.map((item) => {
return { ...item.aggregation, lastModified: new Date() };
})
);

renderPlugin();

Expand Down
3 changes: 1 addition & 2 deletions packages/compass-shell/src/modules/history-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ export class HistoryStorage {
userData;

constructor(basePath?: string) {
this.userData = new FileUserData(z.string().array(), {
this.userData = new FileUserData(z.string().array(), getAppName() ?? '', {
// Todo: https://jira.mongodb.org/browse/COMPASS-7080
subdir: getAppName() ?? '',
basePath,
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/compass-user-data/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export type { Stats, ReadAllResult, ReadAllWithStatsResult } from './user-data';
export { IUserData, FileUserData } from './user-data';
export type { ReadAllResult } from './user-data';
export { type IUserData, FileUserData, AtlasUserData } from './user-data';
export { z } from 'zod';
Loading
Loading