From 1386a6657926a6ea39ddc08f7a6d85052817895c Mon Sep 17 00:00:00 2001 From: forehalo Date: Wed, 2 Apr 2025 12:44:20 +0000 Subject: [PATCH] chore(server): hide not configurable module (#11406) --- .docker/selfhost/schema.json | 71 +------------------ packages/backend/server/scripts/genconfig.ts | 14 +++- packages/frontend/admin/src/config.json | 51 ------------- .../admin/src/modules/settings/config.ts | 5 +- 4 files changed, 15 insertions(+), 126 deletions(-) diff --git a/.docker/selfhost/schema.json b/.docker/selfhost/schema.json index 56ff4eb0d9..81e7900dab 100644 --- a/.docker/selfhost/schema.json +++ b/.docker/selfhost/schema.json @@ -3,42 +3,6 @@ "title": "AFFiNE Application Configuration", "type": "object", "properties": { - "redis": { - "type": "object", - "description": "Configuration for redis module", - "properties": { - "db": { - "type": "number", - "description": "The database index of redis server to be used(Must be less than 10).\n@default 0\n@environment `REDIS_SERVER_DATABASE`", - "default": 0 - }, - "host": { - "type": "string", - "description": "The host of the redis server.\n@default \"localhost\"\n@environment `REDIS_SERVER_HOST`", - "default": "localhost" - }, - "port": { - "type": "number", - "description": "The port of the redis server.\n@default 6379\n@environment `REDIS_SERVER_PORT`", - "default": 6379 - }, - "username": { - "type": "string", - "description": "The username of the redis server.\n@default \"\"\n@environment `REDIS_SERVER_USERNAME`", - "default": "" - }, - "password": { - "type": "string", - "description": "The password of the redis server.\n@default \"\"\n@environment `REDIS_SERVER_PASSWORD`", - "default": "" - }, - "ioredis": { - "type": "object", - "description": "The config for the ioredis client.\n@default {}\n@link https://github.com/luin/ioredis", - "default": {} - } - } - }, "metrics": { "type": "object", "description": "Configuration for metrics module", @@ -50,19 +14,6 @@ } } }, - "graphql": { - "type": "object", - "description": "Configuration for graphql module", - "properties": { - "apolloDriverConfig": { - "type": "object", - "description": "The config for underlying nestjs GraphQL and apollo driver engine.\n@default {\"introspection\":true}\n@link https://docs.nestjs.com/graphql/quick-start", - "default": { - "introspection": true - } - } - } - }, "crypto": { "type": "object", "description": "Configuration for crypto module", @@ -92,10 +43,8 @@ }, "worker": { "type": "object", - "description": "The config for job workers\n@default {\"defaultWorkerOptions\":{}}\n@link https://api.docs.bullmq.io/interfaces/v5.WorkerOptions.html", - "default": { - "defaultWorkerOptions": {} - } + "description": "The config for job workers\n@default {}\n@link https://api.docs.bullmq.io/interfaces/v5.WorkerOptions.html", + "default": {} }, "queues.copilot": { "type": "object", @@ -200,22 +149,6 @@ } } }, - "db": { - "type": "object", - "description": "Configuration for db module", - "properties": { - "datasourceUrl": { - "type": "string", - "description": "The datasource url for the prisma client.\n@default \"postgresql://localhost:5432/affine\"\n@environment `DATABASE_URL`", - "default": "postgresql://localhost:5432/affine" - }, - "prisma": { - "type": "object", - "description": "The config for the prisma client.\n@default {}\n@link https://www.prisma.io/docs/reference/api-reference/prisma-client-reference", - "default": {} - } - } - }, "auth": { "type": "object", "description": "Configuration for auth module", diff --git a/packages/backend/server/scripts/genconfig.ts b/packages/backend/server/scripts/genconfig.ts index 5e933ada24..86782669e7 100644 --- a/packages/backend/server/scripts/genconfig.ts +++ b/packages/backend/server/scripts/genconfig.ts @@ -5,8 +5,18 @@ import '../src/app.module'; import fs from 'node:fs'; import { ProjectRoot } from '@affine-tools/utils/path'; import { Package } from '@affine-tools/utils/workspace'; -import { getDescriptors, ConfigDescriptor } from '../src/base/config/register'; -import { pick } from 'lodash-es'; +import { + getDescriptors as getAllDescriptors, + ConfigDescriptor, +} from '../src/base/config/register'; + +const IGNORED_MODULES = new Set(['db', 'redis', 'graphql']); + +function getDescriptors() { + return getAllDescriptors().filter( + ({ module }) => !IGNORED_MODULES.has(module) + ); +} interface PropertySchema { description: string; diff --git a/packages/frontend/admin/src/config.json b/packages/frontend/admin/src/config.json index 47a0de6cb7..0da788480b 100644 --- a/packages/frontend/admin/src/config.json +++ b/packages/frontend/admin/src/config.json @@ -1,49 +1,10 @@ { - "redis": { - "db": { - "type": "Number", - "desc": "The database index of redis server to be used(Must be less than 10).", - "env": "REDIS_SERVER_DATABASE" - }, - "host": { - "type": "String", - "desc": "The host of the redis server.", - "env": "REDIS_SERVER_HOST" - }, - "port": { - "type": "Number", - "desc": "The port of the redis server.", - "env": "REDIS_SERVER_PORT" - }, - "username": { - "type": "String", - "desc": "The username of the redis server.", - "env": "REDIS_SERVER_USERNAME" - }, - "password": { - "type": "String", - "desc": "The password of the redis server.", - "env": "REDIS_SERVER_PASSWORD" - }, - "ioredis": { - "type": "Object", - "desc": "The config for the ioredis client.", - "link": "https://github.com/luin/ioredis" - } - }, "metrics": { "enabled": { "type": "Boolean", "desc": "Enable metric and tracing collection" } }, - "graphql": { - "apolloDriverConfig": { - "type": "Object", - "desc": "The config for underlying nestjs GraphQL and apollo driver engine.", - "link": "https://docs.nestjs.com/graphql/quick-start" - } - }, "crypto": { "privateKey": { "type": "String", @@ -104,18 +65,6 @@ "desc": "How many bytes or characters a message can be, before closing the session (to avoid DoS)." } }, - "db": { - "datasourceUrl": { - "type": "String", - "desc": "The datasource url for the prisma client.", - "env": "DATABASE_URL" - }, - "prisma": { - "type": "Object", - "desc": "The config for the prisma client.", - "link": "https://www.prisma.io/docs/reference/api-reference/prisma-client-reference" - } - }, "auth": { "allowSignup": { "type": "Boolean", diff --git a/packages/frontend/admin/src/modules/settings/config.ts b/packages/frontend/admin/src/modules/settings/config.ts index 2e73b2f87b..c3710ab6a9 100644 --- a/packages/frontend/admin/src/modules/settings/config.ts +++ b/packages/frontend/admin/src/modules/settings/config.ts @@ -35,13 +35,10 @@ type ConfigGroup = { }>[]; }; const IGNORED_MODULES: (keyof AppConfig)[] = [ - 'db', - 'redis', - 'graphql', 'copilot', // not ready ]; -if (!environment.isSelfHosted) { +if (environment.isSelfHosted) { IGNORED_MODULES.push('payment'); }