Skip to content

Commit 729c6db

Browse files
committed
minor fixes
1 parent 5edf5e2 commit 729c6db

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export type { Stats, ReadAllResult, ReadAllWithStatsResult } from './user-data';
2-
export { IUserData, FileUserData } from './user-data';
2+
export { type IUserData, FileUserData } from './user-data';
33
export { z } from 'zod';

packages/compass-user-data/src/user-data.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export abstract class IUserData<T extends z.Schema> {
7373
protected readonly validator: T;
7474
protected readonly serialize: SerializeContent<z.input<T>>;
7575
protected readonly deserialize: DeserializeContent;
76-
7776
constructor(
7877
validator: T,
7978
{
@@ -96,6 +95,7 @@ export abstract class IUserData<T extends z.Schema> {
9695
id: string,
9796
data: Partial<z.input<T>>
9897
): Promise<z.output<T>>;
98+
abstract setOrgAndGroupId(orgId: string, groupId: string): void;
9999
}
100100

101101
export class FileUserData<T extends z.Schema> extends IUserData<T> {
@@ -333,15 +333,28 @@ export class FileUserData<T extends z.Schema> extends IUserData<T> {
333333
});
334334
return await this.readOne(id);
335335
}
336+
337+
setOrgAndGroupId(orgId: string, groupId: string): void {
338+
// sample log error
339+
log.error(
340+
mongoLogId(1_001_000_237), // not sure what this log id should be
341+
'UserData',
342+
'setOrgAndGroupId should not be called for FileUserData',
343+
{
344+
orgId,
345+
groupId,
346+
}
347+
);
348+
}
336349
}
337350

338351
// TODO: update endpoints to reflect the merged api endpoints
339352
export class AtlasUserData<T extends z.Schema> extends IUserData<T> {
340353
private readonly authenticatedFetch;
341354
// should this BASE_URL be a parameter passed to the constructor?
342355
// this might make future usage of this code easier, if we want to call a different endpoint
343-
private readonly orgId;
344-
private readonly groupId;
356+
private orgId: string = '';
357+
private groupId: string = '';
345358
private readonly BASE_URL = 'cluster-connection.cloud-local.mongodb.com';
346359
constructor(
347360
validator: T,

packages/my-queries-storage/src/compass-query-storage.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ export abstract class CompassQueryStorage<TSchema extends z.Schema> {
5454
}
5555

5656
setOrgAndGroupId(orgId: string, groupId: string): void {
57-
if (this.userData instanceof AtlasUserData) {
58-
this.userData.setOrgAndGroupId(orgId, groupId);
59-
}
57+
this.userData.setOrgAndGroupId?.(orgId, groupId);
6058
}
6159

6260
abstract saveQuery(data: Partial<z.input<TSchema>>): Promise<void>;

0 commit comments

Comments
 (0)