refactor: Use librechat-data-provider app-wide 🔄 (#1326)

* chore: bump vite, vitejs/plugin-react, mark client package as esm, move react-query as a peer dep in data-provider

* chore: import changes due to new data-provider export strategy, also fix type imports where applicable

* chore: export react-query services as separate to avoid react dependencies in /api/

* chore: suppress sourcemap warnings and polyfill node:path which is used by filenamify
TODO: replace filenamify with an alternative and REMOVE polyfill

* chore: /api/ changes to support `librechat-data-provider`

* refactor: rewrite Dockerfile.multi in light of /api/ changes to support `librechat-data-provider`

* chore: remove volume mapping to node_modules directories in default compose file

* chore: remove schemas from /api/ as is no longer needed with use of `librechat-data-provider`

* fix(ci): jest `librechat-data-provider/react-query` module resolution
This commit is contained in:
Danny Avila 2023-12-11 14:48:40 -05:00 committed by GitHub
parent d4c846b543
commit df1dfa7d46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
97 changed files with 1831 additions and 1343 deletions

View file

@ -7,15 +7,12 @@ import {
createContext,
useContext,
} from 'react';
import { TUser, TLoginResponse, setTokenHeader, TLoginUser } from 'librechat-data-provider';
import {
TUser,
TLoginResponse,
setTokenHeader,
useLoginUserMutation,
useGetUserQuery,
useLoginUserMutation,
useRefreshTokenMutation,
TLoginUser,
} from 'librechat-data-provider';
} from 'librechat-data-provider/react-query';
import { useNavigate } from 'react-router-dom';
import { TAuthConfig, TUserContext, TAuthContext, TResError } from '~/common';
import { useLogoutUserMutation } from '~/data-provider';

View file

@ -1,4 +1,5 @@
import { QueryKeys, modularEndpoints, useCreatePresetMutation } from 'librechat-data-provider';
import { QueryKeys, modularEndpoints } from 'librechat-data-provider';
import { useCreatePresetMutation } from 'librechat-data-provider/react-query';
import filenamify from 'filenamify';
import { useCallback, useEffect, useRef } from 'react';
import { useRecoilState, useSetRecoilState } from 'recoil';

View file

@ -1,4 +1,4 @@
import { useGetEndpointsQuery } from 'librechat-data-provider';
import { useGetEndpointsQuery } from 'librechat-data-provider/react-query';
import { useChatContext } from '~/Providers/ChatContext';
import useUserKey from './useUserKey';

View file

@ -1,9 +1,9 @@
import { useMemo, useCallback } from 'react';
import {
useUpdateUserKeysMutation,
useUserKeyQuery,
useGetEndpointsQuery,
} from 'librechat-data-provider';
useUpdateUserKeysMutation,
} from 'librechat-data-provider/react-query';
const useUserKey = (endpoint: string) => {
const { data: endpointsConfig } = useGetEndpointsQuery();

View file

@ -2,12 +2,8 @@ import { v4 } from 'uuid';
import { useCallback, useState } from 'react';
import { useQueryClient } from '@tanstack/react-query';
import { useRecoilState, useResetRecoilState, useSetRecoilState } from 'recoil';
import {
QueryKeys,
parseCompactConvo,
getResponseSender,
useGetMessagesByConvoId,
} from 'librechat-data-provider';
import { QueryKeys, parseCompactConvo, getResponseSender } from 'librechat-data-provider';
import { useGetMessagesByConvoId } from 'librechat-data-provider/react-query';
import type {
TMessage,
TSubmission,

View file

@ -1,6 +1,6 @@
import { useCallback } from 'react';
import { useSetRecoilState, useResetRecoilState, useRecoilCallback } from 'recoil';
import { useGetEndpointsQuery } from 'librechat-data-provider';
import { useGetEndpointsQuery } from 'librechat-data-provider/react-query';
import type {
TConversation,
TMessagesAtom,

View file

@ -1,5 +1,5 @@
import { useRecoilValue } from 'recoil';
import { useGetEndpointsQuery } from 'librechat-data-provider';
import { useGetEndpointsQuery } from 'librechat-data-provider/react-query';
import type { TConversation, TPreset } from 'librechat-data-provider';
import { getDefaultEndpoint, buildDefaultConvo } from '~/utils';
import store from '~/store';

View file

@ -1,6 +1,7 @@
import { v4 } from 'uuid';
import { parseConvo, getResponseSender } from 'librechat-data-provider';
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
import { parseConvo, getResponseSender, useGetEndpointsQuery } from 'librechat-data-provider';
import { useGetEndpointsQuery } from 'librechat-data-provider/react-query';
import type { TMessage, TSubmission, TEndpointOption } from 'librechat-data-provider';
import type { TAskFunction } from '~/common';
import useUserKey from './Input/useUserKey';

View file

@ -1,5 +1,5 @@
import { useCallback } from 'react';
import { useGetEndpointsQuery } from 'librechat-data-provider';
import { useGetEndpointsQuery } from 'librechat-data-provider/react-query';
import {
useSetRecoilState,
useResetRecoilState,

View file

@ -4,13 +4,12 @@ import {
/* @ts-ignore */
SSE,
createPayload,
useGetUserBalance,
tMessageSchema,
tConversationSchema,
useGetStartupConfig,
EModelEndpoint,
removeNullishValues,
} from 'librechat-data-provider';
import { useGetUserBalance, useGetStartupConfig } from 'librechat-data-provider/react-query';
import type { TResPlugin, TMessage, TConversation, TSubmission } from 'librechat-data-provider';
import { useAuthContext } from './AuthContext';
import useChatHelpers from './useChatHelpers';

View file

@ -4,11 +4,10 @@ import {
/* @ts-ignore */
SSE,
createPayload,
useGetUserBalance,
tMessageSchema,
tConversationSchema,
useGetStartupConfig,
} from 'librechat-data-provider';
import { useGetUserBalance, useGetStartupConfig } from 'librechat-data-provider/react-query';
import type { TResPlugin, TMessage, TConversation, TSubmission } from 'librechat-data-provider';
import useConversations from './useConversations';
import { useAuthContext } from './AuthContext';