From 91d0841cc995ecb98f4fdf4c439421499c6e22a6 Mon Sep 17 00:00:00 2001 From: Nico Ramirez Date: Tue, 14 Nov 2023 23:08:40 -0500 Subject: [PATCH] fix ts compile errors --- package-lock.json | 53 +++++++++++++++++++ package.json | 3 ++ pages/_document.tsx | 2 +- src/apps/chat/AppChat.tsx | 1 - .../chat/components/message/RenderCode.tsx | 15 ++++-- src/apps/link/ViewChatLink.tsx | 1 + src/modules/aifn/digrams/DiagramsModal.tsx | 1 + tsconfig.json | 3 +- 8 files changed, 71 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index c8bcbbfb57..83de770758 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,9 @@ "@trpc/next": "^10.43.3", "@trpc/react-query": "^10.43.3", "@trpc/server": "^10.43.3", + "@types/gapi": "^0.0.47", + "@types/gapi.client.bigquery": "^2.0.4", + "@types/google.accounts": "^0.0.14", "@vercel/analytics": "^1.1.1", "ag-grid-community": "^30.2.1", "ag-grid-enterprise": "^30.2.1", @@ -588,6 +591,24 @@ "node-pre-gyp": "bin/node-pre-gyp" } }, + "node_modules/@maxim_mazurok/gapi.client.bigquery-v2": { + "version": "0.0.20231030", + "resolved": "https://registry.npmjs.org/@maxim_mazurok/gapi.client.bigquery-v2/-/gapi.client.bigquery-v2-0.0.20231030.tgz", + "integrity": "sha512-Rd7V31eJJjNXXE1IKP5gsMoXAL6ad8TqUnX9EkTwMPq3ufFAm1umAXrLK3C87Fs0amuJYwQ2atdwQwVEKhh4Zw==", + "dependencies": { + "@types/gapi.client": "*", + "@types/gapi.client.discovery-v1": "*" + } + }, + "node_modules/@maxim_mazurok/gapi.client.discovery-v1": { + "version": "0.1.20200806", + "resolved": "https://registry.npmjs.org/@maxim_mazurok/gapi.client.discovery-v1/-/gapi.client.discovery-v1-0.1.20200806.tgz", + "integrity": "sha512-Wl6UfmZVDdWbY3PUu8E2ULk9RPLjnMqp/iOA4tcK8Ne+U/GmlnWP/e34IaZNGArfl7iXJNOG+/3Rj9L9jQyF9Q==", + "dependencies": { + "@types/gapi.client": "*", + "@types/gapi.client.discovery-v1": "*" + } + }, "node_modules/@mui/base": { "version": "5.0.0-beta.23", "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-beta.23.tgz", @@ -1292,6 +1313,38 @@ "@types/trusted-types": "*" } }, + "node_modules/@types/gapi": { + "version": "0.0.47", + "resolved": "https://registry.npmjs.org/@types/gapi/-/gapi-0.0.47.tgz", + "integrity": "sha512-/ZsLuq6BffMgbKMtZyDZ8vwQvTyKhKQ1G2K6VyWCgtHHhfSSXbk4+4JwImZiTjWNXfI2q1ZStAwFFHSkNoTkHA==" + }, + "node_modules/@types/gapi.client": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/gapi.client/-/gapi.client-1.0.8.tgz", + "integrity": "sha512-qJQUmmumbYym3Amax0S8CVzuSngcXsC1fJdwRS2zeW5lM63zXkw4wJFP+bG0jzgi0R6EsJKoHnGNVTDbOyG1ng==" + }, + "node_modules/@types/gapi.client.bigquery": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/gapi.client.bigquery/-/gapi.client.bigquery-2.0.4.tgz", + "integrity": "sha512-t41q6xr1vsAOvGh31Rw5r2dVPQNq3pDovX1SZAIN9eKsE0UDDaJp8v+GpQQbV9BKSS5+6fFwpiGZjN9S+0Fpsg==", + "deprecated": "use @types/gapi.client.bigquery-v2 instead; see https://github.com/Maxim-Mazurok/google-api-typings-generator/issues/652 for details", + "dependencies": { + "@maxim_mazurok/gapi.client.bigquery-v2": "latest" + } + }, + "node_modules/@types/gapi.client.discovery-v1": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@types/gapi.client.discovery-v1/-/gapi.client.discovery-v1-0.0.4.tgz", + "integrity": "sha512-uevhRumNE65F5mf2gABLaReOmbFSXONuzFZjNR3dYv6BmkHg+wciubHrfBAsp3554zNo3Dcg6dUAlwMqQfpwjQ==", + "dependencies": { + "@maxim_mazurok/gapi.client.discovery-v1": "latest" + } + }, + "node_modules/@types/google.accounts": { + "version": "0.0.14", + "resolved": "https://registry.npmjs.org/@types/google.accounts/-/google.accounts-0.0.14.tgz", + "integrity": "sha512-HqIVkVzpiLWhlajhQQd4rIV7czanFvXblJI2J1fSrL+VKQuQwwZ63m35D/mI0flsqKE6p/hNrAG0Yn4FD6JvNA==" + }, "node_modules/@types/hast": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.3.tgz", diff --git a/package.json b/package.json index 8f8ca29286..6b9eaa8525 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,9 @@ "@trpc/next": "^10.43.3", "@trpc/react-query": "^10.43.3", "@trpc/server": "^10.43.3", + "@types/gapi": "^0.0.47", + "@types/gapi.client.bigquery": "^2.0.4", + "@types/google.accounts": "^0.0.14", "@vercel/analytics": "^1.1.1", "ag-grid-community": "^30.2.1", "ag-grid-enterprise": "^30.2.1", diff --git a/pages/_document.tsx b/pages/_document.tsx index 9ce94ee6de..c37635aee1 100644 --- a/pages/_document.tsx +++ b/pages/_document.tsx @@ -49,7 +49,7 @@ export default function MyDocument({ emotionStyleTags }: MyDocumentProps) { {/* Style Sheets (injected and server-side) */} - + {emotionStyleTags} diff --git a/src/apps/chat/AppChat.tsx b/src/apps/chat/AppChat.tsx index 39395375a8..583bd4a924 100644 --- a/src/apps/chat/AppChat.tsx +++ b/src/apps/chat/AppChat.tsx @@ -249,7 +249,6 @@ export function AppChat() { conversationId={activeConversationId} messageId={null} isDeveloperMode={systemPurposeId === 'Developer'} onNewMessage={handleComposerNewMessage} - bigQueryResult={bigQueryResult} sx={{ zIndex: 21, // position: 'sticky', bottom: 0, backgroundColor: 'background.surface', diff --git a/src/apps/chat/components/message/RenderCode.tsx b/src/apps/chat/components/message/RenderCode.tsx index 1114fe1865..922e190711 100644 --- a/src/apps/chat/components/message/RenderCode.tsx +++ b/src/apps/chat/components/message/RenderCode.tsx @@ -26,7 +26,11 @@ const PROJECT_ID = 'symbiosys-prod'; const PAGE_SIZE = 100; // TODO: move this to an external hook for cleaner code -const useAccessTokenStore = create(persist( +interface AccessTokenStoreState { + accessToken: string | null; + setAccessToken: (accessToken: string) => void; +} +const useAccessTokenStore = create()(persist( (set) => ({ accessToken: null, setAccessToken: (accessToken: string) => set({ accessToken }), @@ -160,11 +164,11 @@ function RenderCodeImpl(props: { const tokenClientRef = React.useRef(google.accounts.oauth2.initTokenClient({ client_id: '361681009781-hns0m7bb5t9s09bb613vvuenr9t8o55a.apps.googleusercontent.com', scope: 'https://www.googleapis.com/auth/bigquery', - // callback: handleCredentialResponse + callback: () => null })); const tokenClient = tokenClientRef.current; - const getToken = async (err, isInitial = false) => { + const getToken = async (err: any, isInitial = false) => { if (isInitial) { // spoof error to trigger token request err = { result: { error: { code: 401 } } }; @@ -174,6 +178,7 @@ function RenderCodeImpl(props: { await new Promise((resolve, reject) => { try { // Settle this promise in the response callback for requestAccessToken() + // @ts-ignore tokenClient.callback = (resp) => { console.log('tokenClient.callback', resp); console.log(resp.error !== undefined) @@ -235,7 +240,7 @@ function RenderCodeImpl(props: { 'jobId': jobId, 'maxResults': PAGE_SIZE, 'timeoutMs': 180000, // we never want to deal with the job id, almost any query is faster than 3 min - 'startIndex': startRow, + 'startIndex': startRow ? '' + startRow : undefined, }); const getQueryResultsWithRetry = async (startRow: number | null = null) => { @@ -261,7 +266,7 @@ function RenderCodeImpl(props: { return nextPageResults; // Return the next page of results }; // Execute the initial query and get the first page of results - const resp = await queryWithRetry(); + const resp: any = await queryWithRetry(); jobId = resp.result.jobReference.jobId; location = resp.result.jobReference.location; diff --git a/src/apps/link/ViewChatLink.tsx b/src/apps/link/ViewChatLink.tsx index 5b41547688..546324ac5f 100644 --- a/src/apps/link/ViewChatLink.tsx +++ b/src/apps/link/ViewChatLink.tsx @@ -123,6 +123,7 @@ export function ViewChatLink(props: { conversation: DConversation, storedAt: Dat key={'msg-' + message.id} message={message} showDate={idx === 0 || idx === filteredMessages.length - 1} onMessageEdit={text => message.text = text} + setBigQueryResult={() => null} />, )} diff --git a/src/modules/aifn/digrams/DiagramsModal.tsx b/src/modules/aifn/digrams/DiagramsModal.tsx index 418598cbd8..798a914679 100644 --- a/src/modules/aifn/digrams/DiagramsModal.tsx +++ b/src/modules/aifn/digrams/DiagramsModal.tsx @@ -179,6 +179,7 @@ export function DiagramsModal(props: { config: DiagramConfig, onClose: () => voi message={message} hideAvatars noBottomBorder noMarkdown filterOnlyCode codeBackground='background.surface' onMessageEdit={(text) => setMessage({ ...message, text })} + setBigQueryResult={() => null} sx={{ backgroundColor: abortController ? 'background.level3' : 'background.level2', marginX: 'calc(-1 * var(--Card-padding))', diff --git a/tsconfig.json b/tsconfig.json index f7924e6b06..f9d0dd788d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -33,7 +33,8 @@ "~/common/*": ["src/common/*"], "~/modules/*": ["src/modules/*"], "~/server/*": ["src/server/*"] - } + }, + "typeRoots": ["node_modules/@types"] }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "exclude": ["node_modules"]