Fix build issues

This commit is contained in:
Laurent Nguyen 2024-04-18 16:49:34 +02:00
parent 8e7fbe65fa
commit 73d38439ff
3 changed files with 40 additions and 11 deletions

View File

@ -0,0 +1,11 @@
diff --git a/node_modules/@uiw/react-split/cjs/index.d.ts b/node_modules/@uiw/react-split/cjs/index.d.ts
index 644bcc3..f794760 100644
--- a/node_modules/@uiw/react-split/cjs/index.d.ts
+++ b/node_modules/@uiw/react-split/cjs/index.d.ts
@@ -56,5 +56,5 @@ export default class Split extends React.Component<SplitProps, SplitState> {
onMouseDown(paneNumber: number, env: React.MouseEvent<HTMLDivElement, MouseEvent>): void;
onDragging(env: Event): void;
onDragEnd(): void;
- render(): import("react/jsx-runtime").JSX.Element;
+ render(): JSX.Element;
}

View File

@ -39,7 +39,6 @@ import CloseIcon from "../../../../images/close-black.svg";
import DiscardIcon from "../../../../images/discard.svg"; import DiscardIcon from "../../../../images/discard.svg";
import SaveIcon from "../../../../images/save-cosmos.svg"; import SaveIcon from "../../../../images/save-cosmos.svg";
import * as Constants from "../../../Common/Constants"; import * as Constants from "../../../Common/Constants";
import * as HeadersUtility from "../../../Common/HeadersUtility";
import * as Logger from "../../../Common/Logger"; import * as Logger from "../../../Common/Logger";
import * as MongoProxyClient from "../../../Common/MongoProxyClient"; import * as MongoProxyClient from "../../../Common/MongoProxyClient";
import * as DataModels from "../../../Contracts/DataModels"; import * as DataModels from "../../../Contracts/DataModels";
@ -633,12 +632,15 @@ const DocumentsTabComponent: React.FunctionComponent<{
const filter: string = filterContent.trim(); const filter: string = filterContent.trim();
const query: string = buildQuery(filter); const query: string = buildQuery(filter);
const options: FeedOptions = {}; const options: FeedOptions = {};
options.enableCrossPartitionQuery = HeadersUtility.shouldEnableCrossPartitionKey(); // TODO: Property 'enableCrossPartitionQuery' does not exist on type 'FeedOptions'.
// options.enableCrossPartitionQuery = HeadersUtility.shouldEnableCrossPartitionKey();
if (resourceTokenPartitionKey) { if (resourceTokenPartitionKey) {
options.partitionKey = resourceTokenPartitionKey; options.partitionKey = resourceTokenPartitionKey;
} }
options.abortSignal = _queryAbortController.signal; // Fixes compile error error TS2741: Property 'throwIfAborted' is missing in type 'AbortSignal' but required in type 'import("/home/runner/work/cosmos-explorer/cosmos-explorer/node_modules/node-abort-controller/index").AbortSignal'.
options.abortSignal = { ..._queryAbortController.signal, throwIfAborted: () => {} };
return isQueryCopilotSampleContainer return isQueryCopilotSampleContainer
? querySampleDocuments(query, options) ? querySampleDocuments(query, options)
: queryDocuments(props.collection.databaseId, props.collection.id(), query, options); : queryDocuments(props.collection.databaseId, props.collection.id(), query, options);
@ -965,7 +967,7 @@ const DocumentsTabComponent: React.FunctionComponent<{
// Table config here // Table config here
const tableItems: DocumentsTableComponentItem[] = documentIds.map((documentId) => { const tableItems: DocumentsTableComponentItem[] = documentIds.map((documentId) => {
const item: Record<string, string> = { const item: Record<string, string> & { id: string } = {
id: documentId.id(), id: documentId.id(),
}; };
@ -1012,7 +1014,7 @@ const DocumentsTabComponent: React.FunctionComponent<{
loadDocument(documentIds[index]); loadDocument(documentIds[index]);
}; };
const loadDocument = (documentId: DocumentId) => let loadDocument = (documentId: DocumentId) =>
(_isQueryCopilotSampleContainer ? readSampleDocument(documentId) : readDocument(props.collection, documentId)).then( (_isQueryCopilotSampleContainer ? readSampleDocument(documentId) : readDocument(props.collection, documentId)).then(
(content) => { (content) => {
initDocumentEditor(documentId, content); initDocumentEditor(documentId, content);
@ -1133,6 +1135,15 @@ const DocumentsTabComponent: React.FunctionComponent<{
// ********* Override here for mongo (from MongoDocumentsTab) ********** // ********* Override here for mongo (from MongoDocumentsTab) **********
console.log("isPreferredApiMongoDB", props.isPreferredApiMongoDB); console.log("isPreferredApiMongoDB", props.isPreferredApiMongoDB);
if (props.isPreferredApiMongoDB) { if (props.isPreferredApiMongoDB) {
loadDocument = (documentId: DocumentId) =>
MongoProxyClient.readDocument(
props.collection.databaseId,
props.collection as ViewModels.Collection,
documentId,
).then((content) => {
initDocumentEditor(documentId, content);
});
renderObjectForEditor = (value: unknown): string => MongoUtility.tojson(value, null, false); renderObjectForEditor = (value: unknown): string => MongoUtility.tojson(value, null, false);
const _hasShardKeySpecified = (document: unknown): boolean => { const _hasShardKeySpecified = (document: unknown): boolean => {
@ -1176,7 +1187,11 @@ const DocumentsTabComponent: React.FunctionComponent<{
}); });
__deleteDocument = (documentId: DocumentId): Promise<void> => __deleteDocument = (documentId: DocumentId): Promise<void> =>
MongoProxyClient.deleteDocument(props.collection.databaseId, props.collection, documentId); MongoProxyClient.deleteDocument(
props.collection.databaseId,
props.collection as ViewModels.Collection,
documentId,
);
onSaveNewDocumentClick = (): Promise<unknown> => { onSaveNewDocumentClick = (): Promise<unknown> => {
const documentContent = JSON.parse(selectedDocumentContent); const documentContent = JSON.parse(selectedDocumentContent);
@ -1214,7 +1229,7 @@ const DocumentsTabComponent: React.FunctionComponent<{
setIsExecuting(true); setIsExecuting(true);
return MongoProxyClient.createDocument( return MongoProxyClient.createDocument(
props.collection.databaseId, props.collection.databaseId,
props.collection, props.collection as ViewModels.Collection,
partitionKeyProperties?.[0], partitionKeyProperties?.[0],
documentContent, documentContent,
) )
@ -1277,7 +1292,7 @@ const DocumentsTabComponent: React.FunctionComponent<{
const selectedDocumentId = documentIds[clickedRow as number]; const selectedDocumentId = documentIds[clickedRow as number];
return MongoProxyClient.updateDocument( return MongoProxyClient.updateDocument(
props.collection.databaseId, props.collection.databaseId,
props.collection, props.collection as ViewModels.Collection,
selectedDocumentId, selectedDocumentId,
documentContent, documentContent,
) )
@ -1338,7 +1353,7 @@ const DocumentsTabComponent: React.FunctionComponent<{
return MongoProxyClient.queryDocuments( return MongoProxyClient.queryDocuments(
props.collection.databaseId, props.collection.databaseId,
props.collection, props.collection as ViewModels.Collection,
true, true,
query, query,
continuationToken, continuationToken,
@ -1352,7 +1367,8 @@ const DocumentsTabComponent: React.FunctionComponent<{
.filter((d: { _rid: string }) => { .filter((d: { _rid: string }) => {
return currentDocumentsRids.indexOf(d._rid) < 0; return currentDocumentsRids.indexOf(d._rid) < 0;
}) })
.map((rawDocument: { _partitionKeyValue: string }) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any
.map((rawDocument: any) => {
const partitionKeyValue = rawDocument._partitionKeyValue; const partitionKeyValue = rawDocument._partitionKeyValue;
return new DocumentId(this, rawDocument, [partitionKeyValue]); return new DocumentId(this, rawDocument, [partitionKeyValue]);
}); });

View File

@ -224,7 +224,9 @@ export const DocumentsTableComponent: React.FC<IDocumentsTableComponentProps> =
// Cell keyboard navigation // Cell keyboard navigation
const keyboardNavAttr = useArrowNavigationGroup({ axis: "grid" }); const keyboardNavAttr = useArrowNavigationGroup({ axis: "grid" });
const tableProps = { // TODO: Bug in fluent UI typings that requires any here
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const tableProps: any = {
"aria-label": "Filtered documents table", "aria-label": "Filtered documents table",
role: "grid", role: "grid",
...columnSizing.getTableProps(), ...columnSizing.getTableProps(),