Skip to content

Commit 3eab096

Browse files
committed
path segment and method binding
1 parent 2c0de81 commit 3eab096

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ export class AtlasService {
7676
return this.cloudEndpoint(path);
7777
}
7878
tempEndpoint(path?: string): string {
79-
return `https://cluster-connection.cloud-dev.mongodb.com${normalizePath(
80-
path
81-
)}`;
79+
return `${normalizePath(path)}`;
8280
}
8381
driverProxyEndpoint(path?: string): string {
8482
return `${this.config.ccsBaseUrl}${normalizePath(path)}`;
@@ -127,6 +125,7 @@ export class AtlasService {
127125
url: RequestInfo | URL,
128126
init?: RequestInit
129127
): Promise<Response> {
128+
debugger;
130129
const authHeaders = await this.authService.getAuthHeaders();
131130
return this.fetch(url, {
132131
...init,

packages/compass-web/src/entrypoint.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ const WithStorageProviders: React.FC<{ orgId: string; projectId: string }> = ({
101101
}) => {
102102
const atlasService = useAtlasServiceContext();
103103
console.log('atlasService', atlasService);
104-
const authenticatedFetch = atlasService.authenticatedFetch;
104+
const authenticatedFetch = atlasService.authenticatedFetch.bind(atlasService);
105105
// TODO: use non-hardcoded endpoint
106-
const getResourceUrl = atlasService.tempEndpoint;
106+
const getResourceUrl = atlasService.tempEndpoint.bind(atlasService);
107107
const pipelineStorage = useRef(
108108
new CompassPipelineStorage({
109109
orgId,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type PipelineStorageOptions = {
2121
export class CompassPipelineStorage implements PipelineStorage {
2222
private readonly userData: IUserData<typeof PipelineSchema>;
2323
constructor(options: PipelineStorageOptions = {}) {
24+
const dataType = 'SavedPipelines';
2425
if (
2526
options.orgId &&
2627
options.projectId &&
@@ -29,15 +30,15 @@ export class CompassPipelineStorage implements PipelineStorage {
2930
) {
3031
this.userData = new AtlasUserData(
3132
PipelineSchema,
32-
'favoriteAggregations',
33+
dataType,
3334
options.orgId,
3435
options.projectId,
3536
options.getResourceUrl,
3637
options.authenticatedFetch,
3738
{}
3839
);
3940
} else {
40-
this.userData = new FileUserData(PipelineSchema, 'SavedPipelines', {
41+
this.userData = new FileUserData(PipelineSchema, dataType, {
4142
basePath: options.basePath,
4243
});
4344
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export abstract class CompassQueryStorage<TSchema extends z.Schema> {
2323
protected readonly userData: IUserData<TSchema>;
2424
constructor(
2525
schemaValidator: TSchema,
26-
protected readonly folder: string,
26+
protected readonly dataType: string,
2727
protected readonly options: QueryStorageOptions
2828
) {
2929
if (
@@ -32,11 +32,9 @@ export abstract class CompassQueryStorage<TSchema extends z.Schema> {
3232
options.getResourceUrl &&
3333
options.authenticatedFetch
3434
) {
35-
const pathSegment =
36-
folder === 'RecentQueries' ? 'recentQueries' : 'favoriteQueries';
3735
this.userData = new AtlasUserData(
3836
schemaValidator,
39-
pathSegment,
37+
dataType,
4038
options.orgId,
4139
options.projectId,
4240
options.getResourceUrl,
@@ -47,7 +45,7 @@ export abstract class CompassQueryStorage<TSchema extends z.Schema> {
4745
}
4846
);
4947
} else {
50-
this.userData = new FileUserData(schemaValidator, folder, {
48+
this.userData = new FileUserData(schemaValidator, dataType, {
5149
basePath: options.basepath,
5250
serialize: (content) => EJSON.stringify(content, undefined, 2),
5351
deserialize: (content: string) => EJSON.parse(content),

0 commit comments

Comments
 (0)