@lobehub/chat 0.161.6 → 0.161.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.161.7](https://github.com/lobehub/lobe-chat/compare/v0.161.6...v0.161.7)
6
+
7
+ <sup>Released on **2024-05-22**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Refactor to serverDB ENV.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Code refactoring
19
+
20
+ - **misc**: Refactor to serverDB ENV, closes [#2612](https://github.com/lobehub/lobe-chat/issues/2612) ([fa1409e](https://github.com/lobehub/lobe-chat/commit/fa1409e))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ### [Version 0.161.6](https://github.com/lobehub/lobe-chat/compare/v0.161.5...v0.161.6)
6
31
 
7
32
  <sup>Released on **2024-05-22**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.161.6",
3
+ "version": "0.161.7",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it, vi } from 'vitest';
2
2
 
3
- import { getClientConfig } from '../client';
3
+ import { getDebugConfig } from '../debug';
4
4
 
5
5
  // 测试前重置 process.env
6
6
  vi.stubGlobal('process', {
@@ -17,7 +17,7 @@ describe('getClientConfig', () => {
17
17
  process.env.NEXT_PUBLIC_I18N_DEBUG_BROWSER = '1';
18
18
  process.env.NEXT_PUBLIC_I18N_DEBUG_SERVER = '1';
19
19
 
20
- const config = getClientConfig();
20
+ const config = getDebugConfig();
21
21
  expect(config.I18N_DEBUG).toBe(true);
22
22
  expect(config.I18N_DEBUG_BROWSER).toBe(true);
23
23
  expect(config.I18N_DEBUG_SERVER).toBe(true);
@@ -31,7 +31,7 @@ describe('getClientConfig', () => {
31
31
  process.env.NEXT_PUBLIC_I18N_DEBUG_BROWSER = '0';
32
32
  process.env.NEXT_PUBLIC_I18N_DEBUG_SERVER = '0';
33
33
 
34
- const config = getClientConfig();
34
+ const config = getDebugConfig();
35
35
 
36
36
  expect(config.I18N_DEBUG).toBe(false);
37
37
  expect(config.I18N_DEBUG_BROWSER).toBe(false);
@@ -0,0 +1,16 @@
1
+ /* eslint-disable sort-keys-fix/sort-keys-fix , typescript-sort-keys/interface */
2
+ import { createEnv } from '@t3-oss/env-nextjs';
3
+ import { z } from 'zod';
4
+
5
+ export const getServerDBConfig = () => {
6
+ return createEnv({
7
+ client: {
8
+ NEXT_PUBLIC_ENABLED_SERVER_SERVICE: z.boolean(),
9
+ },
10
+ runtimeEnv: {
11
+ NEXT_PUBLIC_ENABLED_SERVER_SERVICE: process.env.NEXT_PUBLIC_SERVICE_MODE === 'server',
12
+ },
13
+ });
14
+ };
15
+
16
+ export const serverDBEnv = getServerDBConfig();
@@ -1,32 +1,22 @@
1
- /**
2
- * the client config is only used in Vercel deployment
3
- */
4
-
5
- /* eslint-disable sort-keys-fix/sort-keys-fix , typescript-sort-keys/interface */
6
-
7
1
  declare global {
8
2
  // eslint-disable-next-line @typescript-eslint/no-namespace
9
3
  namespace NodeJS {
10
4
  interface ProcessEnv {
5
+ NEXT_PUBLIC_DEVELOPER_DEBUG: string;
11
6
  NEXT_PUBLIC_I18N_DEBUG: string;
12
7
  NEXT_PUBLIC_I18N_DEBUG_BROWSER: string;
13
- NEXT_PUBLIC_I18N_DEBUG_SERVER: string;
14
-
15
- NEXT_PUBLIC_DEVELOPER_DEBUG: string;
16
8
 
17
- NEXT_PUBLIC_SERVICE_MODE?: 'server' | 'browser';
9
+ NEXT_PUBLIC_I18N_DEBUG_SERVER: string;
18
10
  }
19
11
  }
20
12
  }
21
13
 
22
- export const getClientConfig = () => ({
23
- ENABLED_SERVER_SERVICE: process.env.NEXT_PUBLIC_SERVICE_MODE === 'server',
14
+ export const getDebugConfig = () => ({
15
+ // developer debug mode
16
+ DEBUG_MODE: process.env.NEXT_PUBLIC_DEVELOPER_DEBUG === '1',
24
17
 
25
18
  // i18n debug mode
26
19
  I18N_DEBUG: process.env.NEXT_PUBLIC_I18N_DEBUG === '1',
27
20
  I18N_DEBUG_BROWSER: process.env.NEXT_PUBLIC_I18N_DEBUG_BROWSER === '1',
28
21
  I18N_DEBUG_SERVER: process.env.NEXT_PUBLIC_I18N_DEBUG_SERVER === '1',
29
-
30
- // developer debug mode
31
- DEBUG_MODE: process.env.NEXT_PUBLIC_DEVELOPER_DEBUG === '1',
32
22
  });
@@ -1,6 +1,6 @@
1
1
  import pkg from '@/../package.json';
2
- import { getClientConfig } from '@/config/client';
2
+ import { getServerDBConfig } from '@/config/db';
3
3
 
4
4
  export const CURRENT_VERSION = pkg.version;
5
5
 
6
- export const isServerMode = getClientConfig().ENABLED_SERVER_SERVICE;
6
+ export const isServerMode = getServerDBConfig().NEXT_PUBLIC_ENABLED_SERVER_SERVICE;
@@ -2,7 +2,7 @@ import dynamic from 'next/dynamic';
2
2
  import { cookies } from 'next/headers';
3
3
  import { FC, ReactNode } from 'react';
4
4
 
5
- import { getClientConfig } from '@/config/client';
5
+ import { getDebugConfig } from '@/config/debug';
6
6
  import { getServerFeatureFlagsValue } from '@/config/featureFlags';
7
7
  import { LOBE_LOCALE_COOKIE } from '@/const/locale';
8
8
  import {
@@ -26,7 +26,7 @@ let DebugUI: FC = () => null;
26
26
  // refs: https://webpack.js.org/plugins/internal-plugins/#constplugin
27
27
  if (process.env.NODE_ENV === 'development') {
28
28
  // eslint-disable-next-line unicorn/no-lonely-if
29
- if (getClientConfig().DEBUG_MODE) {
29
+ if (getDebugConfig().DEBUG_MODE) {
30
30
  DebugUI = dynamic(() => import('@/features/DebugUI'), { ssr: false }) as FC;
31
31
  }
32
32
  }
@@ -4,13 +4,13 @@ import resourcesToBackend from 'i18next-resources-to-backend';
4
4
  import { initReactI18next } from 'react-i18next';
5
5
  import { isRtlLang } from 'rtl-detect';
6
6
 
7
- import { getClientConfig } from '@/config/client';
7
+ import { getDebugConfig } from '@/config/debug';
8
8
  import { DEFAULT_LANG, LOBE_LOCALE_COOKIE } from '@/const/locale';
9
9
  import { COOKIE_CACHE_DAYS } from '@/const/settings';
10
10
  import { normalizeLocale } from '@/locales/resources';
11
11
  import { isDev, isOnServerSide } from '@/utils/env';
12
12
 
13
- const { I18N_DEBUG, I18N_DEBUG_BROWSER, I18N_DEBUG_SERVER } = getClientConfig();
13
+ const { I18N_DEBUG, I18N_DEBUG_BROWSER, I18N_DEBUG_SERVER } = getDebugConfig();
14
14
  const debugMode = I18N_DEBUG ?? isOnServerSide ? I18N_DEBUG_SERVER : I18N_DEBUG_BROWSER;
15
15
 
16
16
  export const createI18nNext = (lang?: string) => {