Skip to content

Commit

Permalink
Merge branch 'main' into COMPASS-8459-move-generative-ai-sign-in-enab…
Browse files Browse the repository at this point in the history
…le-to-gen-ai-package
  • Loading branch information
Anemy authored Nov 8, 2024
2 parents d1514f8 + fac4f9d commit 7bc3e60
Show file tree
Hide file tree
Showing 50 changed files with 920 additions and 597 deletions.
2 changes: 1 addition & 1 deletion THIRD-PARTY-NOTICES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The following third-party software is used by and included in **Mongodb Compass**.
This document was automatically generated on Thu Nov 07 2024.
This document was automatically generated on Fri Nov 08 2024.

## List of dependencies

Expand Down
2 changes: 1 addition & 1 deletion docs/tracking-plan.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Compass Tracking Plan

Generated on Thu, Nov 7, 2024 at 05:59 PM
Generated on Fri, Nov 8, 2024 at 03:38 PM

## Table of Contents

Expand Down
718 changes: 359 additions & 359 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/atlas-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"email": "[email protected]"
},
"homepage": "https://github.com/mongodb-js/compass",
"version": "0.31.1",
"version": "0.32.0",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/compass.git"
Expand Down Expand Up @@ -83,7 +83,7 @@
"@mongodb-js/devtools-proxy-support": "^0.4.1",
"@mongodb-js/oidc-plugin": "^1.1.1",
"hadron-app-registry": "^9.2.7",
"compass-preferences-model": "^2.29.3",
"compass-preferences-model": "^2.30.0",
"electron": "^32.2.2",
"hadron-ipc": "^3.2.25",
"lodash": "^4.17.21",
Expand Down
26 changes: 26 additions & 0 deletions packages/atlas-service/src/atlas-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,30 @@ describe('AtlasService', function () {
);
expect(getAuthHeadersFn.calledOnce).to.be.true;
});

it('should set CSRF headers when available', async function () {
const fetchStub = sandbox.stub().resolves({ status: 200, ok: true });
global.fetch = fetchStub;
document.head.append(
(() => {
const el = document.createElement('meta');
el.setAttribute('name', 'csrf-token');
el.setAttribute('content', 'token');
return el;
})()
);
document.head.append(
(() => {
const el = document.createElement('meta');
el.setAttribute('name', 'CSRF-TIME');
el.setAttribute('content', 'time');
return el;
})()
);
await atlasService.fetch('/foo/bar', { method: 'POST' });
expect(fetchStub.firstCall.lastArg.headers).to.deep.eq({
'X-CSRF-Time': 'time',
'X-CSRF-Token': 'token',
});
});
});
18 changes: 18 additions & 0 deletions packages/atlas-service/src/atlas-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ function normalizePath(path?: string) {
return encodeURI(path);
}

function getCSRFHeaders() {
return {
'X-CSRF-Token':
document
.querySelector('meta[name="csrf-token" i]')
?.getAttribute('content') ?? '',
'X-CSRF-Time':
document
.querySelector('meta[name="csrf-time" i]')
?.getAttribute('content') ?? '',
};
}

function shouldAddCSRFHeaders(method = 'get') {
return !/^(get|head|options|trace)$/.test(method.toLowerCase());
}

export class AtlasService {
private config: AtlasServiceConfig;
constructor(
Expand Down Expand Up @@ -60,6 +77,7 @@ export class AtlasService {
...init,
headers: {
...this.options?.defaultHeaders,
...(shouldAddCSRFHeaders(init?.method) && getCSRFHeaders()),
...init?.headers,
},
});
Expand Down
20 changes: 10 additions & 10 deletions packages/compass-aggregations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@mongodb-js/compass-aggregations",
"description": "Compass Aggregation Pipeline Builder",
"private": true,
"version": "9.48.0",
"version": "9.49.0",
"main": "dist/index.js",
"compass:main": "src/index.ts",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -61,25 +61,25 @@
"@dnd-kit/core": "^6.0.7",
"@dnd-kit/sortable": "^7.0.2",
"@dnd-kit/utilities": "^3.2.1",
"@mongodb-js/atlas-service": "^0.31.1",
"@mongodb-js/compass-app-stores": "^7.32.0",
"@mongodb-js/compass-collection": "^4.45.0",
"@mongodb-js/atlas-service": "^0.32.0",
"@mongodb-js/compass-app-stores": "^7.33.0",
"@mongodb-js/compass-collection": "^4.46.0",
"@mongodb-js/compass-components": "^1.31.1",
"@mongodb-js/compass-connections": "^1.46.0",
"@mongodb-js/compass-crud": "^13.46.0",
"@mongodb-js/compass-connections": "^1.47.0",
"@mongodb-js/compass-crud": "^13.47.0",
"@mongodb-js/compass-editor": "^0.33.0",
"@mongodb-js/compass-field-store": "^9.21.0",
"@mongodb-js/compass-generative-ai": "^0.26.0",
"@mongodb-js/compass-field-store": "^9.22.0",
"@mongodb-js/compass-generative-ai": "^0.27.0",
"@mongodb-js/compass-logging": "^1.4.10",
"@mongodb-js/compass-telemetry": "^1.2.3",
"@mongodb-js/compass-utils": "^0.6.14",
"@mongodb-js/compass-workspaces": "^0.27.0",
"@mongodb-js/compass-workspaces": "^0.28.0",
"@mongodb-js/explain-plan-helper": "^1.2.4",
"@mongodb-js/mongodb-constants": "^0.10.0",
"@mongodb-js/my-queries-storage": "^0.19.0",
"@mongodb-js/shell-bson-parser": "^1.1.2",
"bson": "^6.8.0",
"compass-preferences-model": "^2.29.3",
"compass-preferences-model": "^2.30.0",
"hadron-app-registry": "^9.2.7",
"hadron-document": "^8.6.5",
"hadron-type-checker": "^7.2.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/compass-app-stores/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"email": "[email protected]"
},
"homepage": "https://github.com/mongodb-js/compass",
"version": "7.32.0",
"version": "7.33.0",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/compass.git"
Expand Down Expand Up @@ -74,7 +74,7 @@
},
"dependencies": {
"@mongodb-js/compass-components": "^1.31.1",
"@mongodb-js/compass-connections": "^1.46.0",
"@mongodb-js/compass-connections": "^1.47.0",
"@mongodb-js/compass-logging": "^1.4.10",
"@mongodb-js/connection-info": "^0.9.3",
"hadron-app-registry": "^9.2.7",
Expand Down
10 changes: 5 additions & 5 deletions packages/compass-collection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"email": "[email protected]"
},
"homepage": "https://github.com/mongodb-js/compass",
"version": "4.45.0",
"version": "4.46.0",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/compass.git"
Expand Down Expand Up @@ -48,15 +48,15 @@
"reformat": "npm run eslint . -- --fix && npm run prettier -- --write ."
},
"dependencies": {
"@mongodb-js/compass-app-stores": "^7.32.0",
"@mongodb-js/compass-app-stores": "^7.33.0",
"@mongodb-js/compass-components": "^1.31.1",
"@mongodb-js/compass-connections": "^1.46.0",
"@mongodb-js/compass-connections": "^1.47.0",
"@mongodb-js/compass-logging": "^1.4.10",
"@mongodb-js/compass-telemetry": "^1.2.3",
"@mongodb-js/compass-workspaces": "^0.27.0",
"@mongodb-js/compass-workspaces": "^0.28.0",
"@mongodb-js/connection-info": "^0.9.3",
"@mongodb-js/mongodb-constants": "^0.10.2",
"compass-preferences-model": "^2.29.3",
"compass-preferences-model": "^2.30.0",
"hadron-app-registry": "^9.2.7",
"mongodb-collection-model": "^5.23.7",
"mongodb-ns": "^2.4.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ const HadronDocument: React.FunctionComponent<{
editable?: boolean;
editing?: boolean;
onEditStart?: () => void;
}> = ({ value: document, editable = false, editing = false, onEditStart }) => {
extraGutterWidth?: number;
}> = ({
value: document,
editable = false,
editing = false,
onEditStart,
extraGutterWidth,
}) => {
const { elements, visibleElements } = useHadronDocument(document);
const [autoFocus, setAutoFocus] = useState<{
id: string;
Expand Down Expand Up @@ -113,8 +120,9 @@ const HadronDocument: React.FunctionComponent<{
editable,
level: 0,
alignWithNestedExpandIcon: false,
extraGutterWidth,
}),
[editable]
[editable, extraGutterWidth]
);

return (
Expand Down Expand Up @@ -147,6 +155,7 @@ const HadronDocument: React.FunctionComponent<{
type: el.parent?.currentType === 'Array' ? 'value' : 'key',
});
}}
extraGutterWidth={extraGutterWidth}
></HadronElement>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,36 +363,39 @@ const elementKeyDarkMode = css({
color: palette.gray.light2,
});

const calculateElementSpacerWidth = (editable: boolean, level: number) => {
return (editable ? spacing[100] : 0) + spacing[400] * level;
const calculateElementSpacerWidth = (
editable: boolean,
level: number,
extra: number
) => {
return (editable ? spacing[100] : 0) + extra + spacing[400] * level;
};

export const calculateShowMoreToggleOffset = ({
editable,
level,
alignWithNestedExpandIcon,
extraGutterWidth = 0,
}: {
editable: boolean;
level: number;
alignWithNestedExpandIcon: boolean;
extraGutterWidth: number | undefined;
}) => {
// the base padding that we have on all elements rendered in the document
const BASE_PADDING_LEFT = spacing[50];
const OFFSET_WHEN_EDITABLE = editable
const spacerWidth = calculateElementSpacerWidth(
editable,
level,
extraGutterWidth
);
const editableOffset = editable
? // space taken by element actions
spacing[300] +
// space and margin taken by line number element
spacing[400] +
spacing[100] +
// element spacer width that we render
calculateElementSpacerWidth(editable, level)
spacing[100]
: 0;
const EXPAND_ICON_SIZE = spacing[400];
return (
BASE_PADDING_LEFT +
OFFSET_WHEN_EDITABLE +
(alignWithNestedExpandIcon ? EXPAND_ICON_SIZE : 0)
);
const expandIconSize = alignWithNestedExpandIcon ? spacing[400] : 0;
return spacerWidth + editableOffset + expandIconSize;
};

export const HadronElement: React.FunctionComponent<{
Expand All @@ -402,13 +405,15 @@ export const HadronElement: React.FunctionComponent<{
onEditStart?: (id: string, field: 'key' | 'value' | 'type') => void;
lineNumberSize: number;
onAddElement(el: HadronElementType): void;
extraGutterWidth?: number;
}> = ({
value: element,
editable,
editingEnabled,
onEditStart,
lineNumberSize,
onAddElement,
extraGutterWidth = 0,
}) => {
const darkMode = useDarkMode();
const autoFocus = useAutoFocusContext();
Expand Down Expand Up @@ -445,8 +450,8 @@ export const HadronElement: React.FunctionComponent<{
}, [lineNumberSize, editingEnabled]);

const elementSpacerWidth = useMemo(
() => calculateElementSpacerWidth(editable, level),
[editable, level]
() => calculateElementSpacerWidth(editable, level, extraGutterWidth),
[editable, level, extraGutterWidth]
);

// To render the "Show more" toggle for the nested expandable elements we need
Expand All @@ -457,8 +462,9 @@ export const HadronElement: React.FunctionComponent<{
editable,
level,
alignWithNestedExpandIcon: true,
extraGutterWidth,
}),
[editable, level]
[editable, level, extraGutterWidth]
);

const isValid = key.valid && value.valid;
Expand Down Expand Up @@ -711,6 +717,7 @@ export const HadronElement: React.FunctionComponent<{
onEditStart={onEditStart}
lineNumberSize={lineNumberSize}
onAddElement={onAddElement}
extraGutterWidth={extraGutterWidth}
></HadronElement>
);
})}
Expand Down
8 changes: 4 additions & 4 deletions packages/compass-connection-import-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"email": "[email protected]"
},
"homepage": "https://github.com/mongodb-js/compass",
"version": "0.42.0",
"version": "0.43.0",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/compass.git"
Expand Down Expand Up @@ -52,9 +52,9 @@
},
"dependencies": {
"@mongodb-js/compass-components": "^1.31.1",
"@mongodb-js/compass-connections": "^1.46.0",
"@mongodb-js/connection-storage": "^0.22.4",
"compass-preferences-model": "^2.29.3",
"@mongodb-js/compass-connections": "^1.47.0",
"@mongodb-js/connection-storage": "^0.23.0",
"compass-preferences-model": "^2.30.0",
"hadron-ipc": "^3.2.25",
"react": "^17.0.2"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/compass-connections-navigation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"email": "[email protected]"
},
"homepage": "https://github.com/mongodb-js/compass",
"version": "1.45.0",
"version": "1.46.0",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/compass.git"
Expand Down Expand Up @@ -49,12 +49,12 @@
"reformat": "npm run eslint . -- --fix && npm run prettier -- --write ."
},
"dependencies": {
"@mongodb-js/compass-connections": "^1.46.0",
"@mongodb-js/compass-connections": "^1.47.0",
"@mongodb-js/compass-components": "^1.31.1",
"@mongodb-js/connection-info": "^0.9.3",
"@mongodb-js/connection-form": "^1.44.0",
"@mongodb-js/compass-workspaces": "^0.27.0",
"compass-preferences-model": "^2.29.3",
"@mongodb-js/compass-workspaces": "^0.28.0",
"compass-preferences-model": "^2.30.0",
"mongodb-build-info": "^1.7.2",
"react": "^17.0.2",
"react-virtualized-auto-sizer": "^1.0.6",
Expand Down
8 changes: 4 additions & 4 deletions packages/compass-connections/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"email": "[email protected]"
},
"homepage": "https://github.com/mongodb-js/compass",
"version": "1.46.0",
"version": "1.47.0",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/compass.git"
Expand Down Expand Up @@ -53,14 +53,14 @@
"dependencies": {
"@mongodb-js/compass-components": "^1.31.1",
"@mongodb-js/compass-logging": "^1.4.10",
"@mongodb-js/compass-maybe-protect-connection-string": "^0.27.3",
"@mongodb-js/compass-maybe-protect-connection-string": "^0.28.0",
"@mongodb-js/compass-telemetry": "^1.2.3",
"@mongodb-js/compass-utils": "^0.6.14",
"@mongodb-js/connection-form": "^1.44.0",
"@mongodb-js/connection-info": "^0.9.3",
"@mongodb-js/connection-storage": "^0.22.4",
"@mongodb-js/connection-storage": "^0.23.0",
"bson": "^6.8.0",
"compass-preferences-model": "^2.29.3",
"compass-preferences-model": "^2.30.0",
"hadron-app-registry": "^9.2.7",
"lodash": "^4.17.21",
"mongodb-build-info": "^1.7.2",
Expand Down
Loading

0 comments on commit 7bc3e60

Please sign in to comment.