Skip to content

Commit 8f9aaf9

Browse files
committed
Pass requestId for tracking
1 parent a444035 commit 8f9aaf9

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

packages/compass-collection/src/modules/collection-tab.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Reducer, AnyAction, Action } from 'redux';
22
import { analyzeDocuments } from 'mongodb-schema';
3+
import { UUID } from 'bson';
34

45
import type { CollectionMetadata } from 'mongodb-collection-model';
56
import type { ThunkAction } from 'redux-thunk';
@@ -15,7 +16,6 @@ import { type PreferencesAccess } from 'compass-preferences-model/provider';
1516
import type {
1617
MockDataSchemaRequest,
1718
MockDataSchemaResponse,
18-
MockDataSchemaRawField,
1919
} from '@mongodb-js/compass-generative-ai';
2020
import { isInternalFieldPath } from 'hadron-document';
2121
import toNS from 'mongodb-ns';
@@ -584,8 +584,8 @@ export const generateFakerMappings = (
584584
return;
585585
}
586586

587-
// todo: dedup/abort around requestId
588-
const requestId = 'some-request-id';
587+
// todo: dedup/abort requests using requestId (CLOUDP-333850)
588+
const requestId = new UUID().toString();
589589

590590
try {
591591
logger.debug('Generating faker mappings');

packages/compass-generative-ai/src/atlas-ai-service.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ describe('AtlasAiService', function () {
409409
},
410410
},
411411
includeSampleValues: false,
412+
requestId: 'test-request-id',
412413
};
413414

414415
if (apiURLPreset === 'admin-api') {
@@ -467,7 +468,7 @@ describe('AtlasAiService', function () {
467468
expect(fetchStub).to.have.been.calledOnce;
468469
const { args } = fetchStub.firstCall;
469470
expect(args[0]).to.eq(
470-
'/cloud/ai/v1/groups/testProject/mock-data-schema'
471+
'/cloud/ai/v1/groups/testProject/mock-data-schema?request_id=test-request-id'
471472
);
472473
expect(result).to.deep.equal(mockResponse);
473474
});

packages/compass-generative-ai/src/atlas-ai-service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ export interface MockDataSchemaRequest {
227227
schema: Record<string, MockDataSchemaRawField>;
228228
validationRules?: Record<string, unknown> | null;
229229
includeSampleValues?: boolean;
230+
requestId: string;
230231
}
231232

232233
export const MockDataSchemaResponseShape = z.object({
@@ -466,7 +467,10 @@ export class AtlasAiService {
466467
const { collectionName, databaseName } = input;
467468
let schema = input.schema;
468469

469-
const url = this.getUrlForEndpoint('mock-data-schema', connectionInfo);
470+
const url = `${this.getUrlForEndpoint(
471+
'mock-data-schema',
472+
connectionInfo
473+
)}?request_id=${encodeURIComponent(input.requestId)}`;
470474

471475
if (!input.includeSampleValues) {
472476
const newSchema: Record<

0 commit comments

Comments
 (0)