Skip to content

Commit

Permalink
Merge pull request #27 from LangStory/client-type-update
Browse files Browse the repository at this point in the history
Update types
  • Loading branch information
yoaquim committed Jun 11, 2024
2 parents e3c50b0 + bc7a6bb commit a5e5a4b
Show file tree
Hide file tree
Showing 36 changed files with 98 additions and 102 deletions.
10 changes: 5 additions & 5 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ErrorBoundary, Provider } from '@rollbar/react'
import { BrowserRouter } from 'react-router-dom'
import { Toaster } from 'react-hot-toast'
import init from 'lib/init.ts'
import { AuthProvider, useAuth } from 'hooks/use-auth.tsx'
import ErrorFallbackUI from 'components/core/ErrorFallbackUI.tsx'
import OfflineNotification from 'components/core/OfflineNotification.tsx'
import Routes from 'components/routing/Routes.tsx'
import init from '@lib/init.ts'
import { AuthProvider, useAuth } from '@hooks/use-auth.tsx'
import ErrorFallbackUI from '@components/core/ErrorFallbackUI.tsx'
import OfflineNotification from '@components/core/OfflineNotification.tsx'
import Routes from '@components/routing/Routes.tsx'

export default function App() {
const {validateJwtToken} = useAuth()
Expand Down
12 changes: 6 additions & 6 deletions client/src/components/ChatContent.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { FormEvent, useEffect, useRef, useState } from 'react'
import axios from 'axios'
import { ArrowRightIcon, PaperClipIcon } from '@heroicons/react/24/outline'
import Chat from 'types/Chat.ts'
import Message from 'types/Message.ts'
import Nullable from 'types/Nullable.ts'
import Optional from 'types/Optional.ts'
import { URLS } from 'lib/constants.ts'
import MessageComponent from 'components/MessageComponent.tsx'
import Chat from '@typing/Chat.ts'
import Message from '@typing/Message.ts'
import Nullable from '@typing/Nullable.ts'
import Optional from '@typing/Optional.ts'
import { URLS } from '@lib/constants.ts'
import MessageComponent from '@components/MessageComponent.tsx'

interface Properties {
chat: Nullable<Optional<Chat>>
Expand Down
12 changes: 6 additions & 6 deletions client/src/components/ChatSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import axios from 'axios'
import { Link, useNavigate, useParams } from 'react-router-dom'
import { FormEvent, useEffect, useState } from 'react'
import { PlusIcon } from '@heroicons/react/24/outline'
import Chat from 'types/Chat.ts'
import ApiCollectionResponse from 'types/ApiCollectionResponse.ts'
import Nullable from 'types/Nullable.ts'
import { URLS } from 'lib/constants.ts'
import { useAuth } from 'hooks/use-auth.tsx'
import Modal from 'components/core/Modal.tsx'
import Chat from '@typing/Chat.ts'
import ApiCollectionResponse from '@typing/ApiCollectionResponse.ts'
import Nullable from '@typing/Nullable.ts'
import { URLS } from '@lib/constants.ts'
import { useAuth } from '@hooks/use-auth.tsx'
import Modal from '@components/core/Modal.tsx'

export default function ChatSidebar() {
const navigate = useNavigate()
Expand Down
6 changes: 2 additions & 4 deletions client/src/components/MessageComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { RefObject } from 'react'
import { format } from 'date-fns'
import { capitalize } from 'lodash'
import Nullable from 'types/Nullable.ts'
import Message, { MessageType } from 'types/Message.ts'
import { classNames } from 'lib/helpers.ts'
import Message, { MessageType } from '@typing/Message.ts'
import { classNames } from '@lib/helpers.ts'

function getMessageClasses(type: MessageType): string {
if (type === 'system_message') return 'bg-amber-400'
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/SchemaBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState, useEffect, FocusEvent } from 'react'
import toast from 'react-hot-toast'
import { PlusIcon } from '@heroicons/react/24/solid'
import { Square2StackIcon, TrashIcon } from '@heroicons/react/24/outline'
import { classNames } from 'lib/helpers.ts'
import { classNames } from '@lib/helpers.ts'

type FieldType = 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string'

Expand Down
2 changes: 1 addition & 1 deletion client/src/components/core/ErrorFallbackUI.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Nullable from 'types/Nullable.ts'
import Nullable from '@typing/Nullable.ts'

export default function ErrorFallbackUI({error, resetError}: {
error: Nullable<Error>,
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/core/OfflineNotification.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react'
import toast from 'react-hot-toast'
import Nullable from 'types/Nullable.ts'
import Nullable from '@typing/Nullable.ts'

export default function OfflineNotification() {
const [toastId, setToastId] = useState<Nullable<string>>(null)
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/routing/AuthRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactNode } from 'react'
import { Navigate, useLocation } from 'react-router-dom'
import { useAuth } from '../../hooks/use-auth'
import { useAuth } from '@hooks/use-auth.tsx'

export default function AuthRoute({children}: { children: ReactNode }) {
const location = useLocation()
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/routing/NoAuthRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactNode } from 'react'
import { Navigate, useLocation } from 'react-router-dom'
import { useAuth } from '../../hooks/use-auth'
import { useAuth } from '@hooks/use-auth.tsx'

export default function AuthRoute({children}: { children: ReactNode }) {
const location = useLocation()
Expand Down
26 changes: 13 additions & 13 deletions client/src/components/routing/Routes.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { RollbarContext } from '@rollbar/react'
import { ReactNode, useEffect, useState } from 'react'
import { Route, Routes, Navigate } from 'react-router-dom'
import { useAuth } from 'hooks/use-auth'
import AuthRoute from 'components/routing/AuthRoute'
import NoAuthRoute from 'components/routing/NoAuthRoute'
import Navbar from 'components/core/Navbar'

import Login from 'pages/Login'
import MagicLinkLogin from 'pages/MagicLinkLogin.tsx'
import Settings from 'pages/Settings.tsx'
import ChatsList from 'pages/ChatsList.tsx'
import ChatComponent from 'pages/ChatComponent.tsx'
import ProjectsList from 'pages/ProjectsList.tsx'
import ProjectComponent from 'pages/ProjectComponent.tsx'
import ProjectToolComponent from 'pages/ProjectToolComponent.tsx'
import { useAuth } from '@hooks/use-auth'
import AuthRoute from '@components/routing/AuthRoute'
import NoAuthRoute from '@components/routing/NoAuthRoute'
import Navbar from '@components/core/Navbar'

import Login from '@pages/Login'
import MagicLinkLogin from '@pages/MagicLinkLogin.tsx'
import Settings from '@pages/Settings.tsx'
import ChatsList from '@pages/ChatsList.tsx'
import ChatComponent from '@pages/ChatComponent.tsx'
import ProjectsList from '@pages/ProjectsList.tsx'
import ProjectComponent from '@pages/ProjectComponent.tsx'
import ProjectToolComponent from '@pages/ProjectToolComponent.tsx'

function withNoAuth(children: ReactNode): ReactNode {
return (
Expand Down
10 changes: 5 additions & 5 deletions client/src/hooks/use-auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { jwtDecode } from 'jwt-decode'
import { StatusCodes } from 'http-status-codes'
import { useRollbarPerson } from '@rollbar/react'
import mixpanel from 'mixpanel-browser'
import Nullable from 'types/Nullable.ts'
import RefreshTokenResponse from 'types/Auth.ts'
import { AuthJwtPayload } from 'types/AuthJwtPayload.ts'
import { deleteValue, getValue, STORAGE_KEYS, storeValue } from 'lib/session-manager'
import { URLS } from 'lib/constants'
import Nullable from '@typing/Nullable.ts'
import RefreshTokenResponse from '@typing/Auth.ts'
import { AuthJwtPayload } from '@typing/AuthJwtPayload.ts'
import { deleteValue, getValue, STORAGE_KEYS, storeValue } from '@lib/session-manager'
import { URLS } from '@lib/constants'

function tokenExpired(token: string | null): boolean {
if (token) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/use-debounce.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MutableRefObject, useCallback, useRef } from 'react'
import Nullable from 'types/Nullable.ts'
import Nullable from '../typing/Nullable.ts'

export default function useDebounce<T extends Array<any>>(callback: (...args: T) => void, delay: number) {
const timer: MutableRefObject<Nullable<NodeJS.Timeout>> = useRef<Nullable<NodeJS.Timeout>>(null)
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Rollbar from 'rollbar'
import { StatusCodes } from 'http-status-codes'
import mixpanel from 'mixpanel-browser'
import { getValue, STORAGE_KEYS } from './session-manager.ts'
import Nullable from 'types/Nullable.ts'
import Nullable from '../typing/Nullable.ts'

export default function init(validateJwtToken: () => Promise<void>): { rollbar: Rollbar } {
//==============================
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib/session-manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Nullable from 'types/Nullable.ts'
import Nullable from '@typing/Nullable.ts'

const KEY_PREFIX = '__LANGSTORY__'

Expand Down
4 changes: 1 addition & 3 deletions client/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'

ReactDOM.createRoot(document.getElementById('root')!).render(
<App/>
)
ReactDOM.createRoot(document.getElementById('root')!).render(<App/>)
10 changes: 5 additions & 5 deletions client/src/pages/ChatComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import axios from 'axios'
import Chat from 'types/Chat.ts'
import { URLS } from 'lib/constants.ts'
import Chat from '../typing/Chat.ts'
import { URLS } from '@lib/constants.ts'
import { useEffect, useState } from 'react'
import { useParams } from 'react-router-dom'
import ChatContent from 'components/ChatContent.tsx'
import Nullable from 'types/Nullable.ts'
import ChatSidebar from 'components/ChatSidebar.tsx'
import ChatContent from '@components/ChatContent.tsx'
import Nullable from '@typing/Nullable.ts'
import ChatSidebar from '@components/ChatSidebar.tsx'

export default function ChatComponent() {
const {id: chatId} = useParams()
Expand Down
8 changes: 4 additions & 4 deletions client/src/pages/ChatsList.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useEffect, useState } from 'react'
import Chat from 'types/Chat.ts'
import axios from 'axios'
import ApiCollectionResponse from 'types/ApiCollectionResponse.ts'
import { URLS } from 'lib/constants.ts'
import { Link } from 'react-router-dom'
import axios from 'axios'
import Chat from '@typing/Chat.ts'
import ApiCollectionResponse from '@typing/ApiCollectionResponse.ts'
import { URLS } from '@lib/constants.ts'

export default function ChatsList() {
const [chats, setChats] = useState<Array<Chat>>([])
Expand Down
10 changes: 5 additions & 5 deletions client/src/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { Link, useNavigate } from 'react-router-dom'
import axios, { AxiosError, AxiosResponse } from 'axios'
import { StatusCodes } from 'http-status-codes'
import { useRollbar } from '@rollbar/react'
import RefreshTokenResponse from 'types/Auth.ts'
import { STORAGE_KEYS, storeValue } from 'lib/session-manager.ts'
import { URLS } from 'lib/constants.ts'
import { useAuth } from 'hooks/use-auth.tsx'
import logo from 'assets/yin-yang.png'
import RefreshTokenResponse from '../typing/Auth.ts'
import { STORAGE_KEYS, storeValue } from '@lib/session-manager.ts'
import { URLS } from '@lib/constants.ts'
import { useAuth } from '@hooks/use-auth.tsx'
import logo from '@assets/yin-yang.png'

function Login() {
const navigate = useNavigate()
Expand Down
10 changes: 5 additions & 5 deletions client/src/pages/ProjectComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useEffect, useState } from 'react'
import { Link, useParams, useNavigate } from 'react-router-dom'
import axios from 'axios'
import Nullable from 'types/Nullable.ts'
import Project from 'types/Project.ts'
import Tool from 'types/Tool.ts'
import { URLS } from 'lib/constants.ts'
import Modal from 'components/core/Modal.tsx'
import Nullable from '@typing/Nullable.ts'
import Project from '@typing/Project.ts'
import Tool from '@typing/Tool.ts'
import { URLS } from '@lib/constants.ts'
import Modal from '@components/core/Modal.tsx'

export default function ProjectComponent() {
const {id: projectId} = useParams()
Expand Down
10 changes: 5 additions & 5 deletions client/src/pages/ProjectToolComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useEffect, useState } from 'react'
import { useParams } from 'react-router-dom'
import axios from 'axios'
import Nullable from 'types/Nullable.ts'
import Tool from 'types/Tool.ts'
import { URLS } from 'lib/constants.ts'
import SchemaBuilder from 'components/SchemaBuilder.tsx'
import toast from 'react-hot-toast'
import axios from 'axios'
import Nullable from '@typing/Nullable.ts'
import Tool from '@typing/Tool.ts'
import { URLS } from '@lib/constants.ts'
import SchemaBuilder from '@components/SchemaBuilder.tsx'

export default function ProjectToolComponent() {
const {id: projectId} = useParams()
Expand Down
6 changes: 3 additions & 3 deletions client/src/pages/ProjectToolsList.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useEffect, useState } from 'react'
import { Link, useParams } from 'react-router-dom'
import axios from 'axios'
import Tool from 'types/Tool.ts'
import { URLS } from 'lib/constants.ts'
import Project from 'types/Project.ts'
import Tool from '@typing/Tool.ts'
import Project from '@typing/Project.ts'
import { URLS } from '@lib/constants.ts'

export default function ProjectToolsList() {
const {id: projectId} = useParams()
Expand Down
6 changes: 3 additions & 3 deletions client/src/pages/ProjectsList.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useEffect, useState } from 'react'
import Project from 'types/Project.ts'
import Project from '../typing/Project.ts'
import axios from 'axios'
import ApiCollectionResponse from 'types/ApiCollectionResponse.ts'
import { URLS } from 'lib/constants.ts'
import ApiCollectionResponse from '../typing/ApiCollectionResponse.ts'
import { URLS } from '@lib/constants.ts'
import { Link } from 'react-router-dom'

export default function ProjectsList() {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { JwtPayload } from 'jwt-decode'
import { User } from 'types/User.ts'
import { Organization } from 'types/Organization.ts'
import { User } from './User.ts'
import { Organization } from './Organization.ts'

export interface AuthJwtPayload extends JwtPayload {
user: User;
Expand Down
4 changes: 2 additions & 2 deletions client/src/types/Chat.ts → client/src/typing/Chat.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Message from 'types/Message.ts'
import Nullable from 'types/Nullable.ts'
import Message from './Message.ts'
import Nullable from './Nullable.ts'

export default interface jjChat {
id: string
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions client/src/types/Project.ts → client/src/typing/Project.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Nullable from 'types/Nullable.ts'
import Tool from 'types/Tool.ts'
import Nullable from './Nullable.ts'
import Tool from './Tool.ts'

export default interface Project {
id: string
Expand Down
2 changes: 1 addition & 1 deletion client/src/types/Tool.ts → client/src/typing/Tool.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Nullable from 'types/Nullable.ts'
import Nullable from './Nullable.ts'

export default interface Tool {
id: string
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion client/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/// <reference types="vite/client" />
/// <reference typing="vite/client" />
14 changes: 7 additions & 7 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"module": "ESNext",
"skipLibCheck": true,
"paths": {
"pages/*": ["./src/pages/*"],
"components/*": ["./src/components/*"],
"hooks/*": ["./src/hooks/*"],
"lib/*": ["./src/lib/*"],
"types/*": ["./src/types/*"],
"assets/*": ["./src/assets/*"],
"services/*": ["./src/services/*"],
"@pages/*": ["./src/pages/*"],
"@components/*": ["./src/components/*"],
"@hooks/*": ["./src/hooks/*"],
"@lib/*": ["./src/lib/*"],
"@typing/*": ["./src/typing/*"],
"@assets/*": ["./src/assets/*"],
"@services/*": ["./src/services/*"],
},


Expand Down
14 changes: 7 additions & 7 deletions client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'pages': path.resolve(__dirname, './src/pages'),
'components': path.resolve(__dirname, './src/components'),
'hooks': path.resolve(__dirname, './src/hooks'),
'lib': path.resolve(__dirname, './src/lib'),
'types': path.resolve(__dirname, './src/types'),
'assets': path.resolve(__dirname, './src/assets'),
'services': path.resolve(__dirname, './src/services'),
'@pages': path.resolve(__dirname, './src/pages'),
'@components': path.resolve(__dirname, './src/components'),
'@hooks': path.resolve(__dirname, './src/hooks'),
'@lib': path.resolve(__dirname, './src/lib'),
'@typing': path.resolve(__dirname, './src/typing'),
'@assets': path.resolve(__dirname, './src/assets'),
'@services': path.resolve(__dirname, './src/services'),
}
}
})

0 comments on commit a5e5a4b

Please sign in to comment.