mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-19 11:02:11 +08:00
374eee9196
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Chores** - Updated the default setting for the indexer feature to be disabled by default. - Added a sample environment variable for enabling the indexer in the example configuration file. - Introduced a new environment variable for the indexer in the CI workflow configuration. - **Tests** - Adjusted test configurations to explicitly enable the indexer feature during test execution. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
78 lines
2.2 KiB
TypeScript
78 lines
2.2 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
import { defineModuleConfig } from '../../base';
|
|
|
|
export enum SearchProviderType {
|
|
Manticoresearch = 'manticoresearch',
|
|
Elasticsearch = 'elasticsearch',
|
|
}
|
|
|
|
const SearchProviderTypeSchema = z.nativeEnum(SearchProviderType);
|
|
|
|
declare global {
|
|
interface AppConfigSchema {
|
|
indexer: {
|
|
enabled: boolean;
|
|
provider: {
|
|
type: SearchProviderType;
|
|
endpoint: string;
|
|
apiKey: string;
|
|
username: string;
|
|
password: string;
|
|
};
|
|
autoIndex: {
|
|
batchSize: number;
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
defineModuleConfig('indexer', {
|
|
enabled: {
|
|
desc: 'Enable indexer plugin',
|
|
default: false,
|
|
env: ['AFFINE_INDEXER_ENABLED', 'boolean'],
|
|
},
|
|
'provider.type': {
|
|
desc: 'Indexer search service provider name',
|
|
default: SearchProviderType.Manticoresearch,
|
|
shape: SearchProviderTypeSchema,
|
|
env: ['AFFINE_INDEXER_SEARCH_PROVIDER', 'string'],
|
|
},
|
|
'provider.endpoint': {
|
|
desc: 'Indexer search service endpoint',
|
|
default: 'http://localhost:9308',
|
|
env: ['AFFINE_INDEXER_SEARCH_ENDPOINT', 'string'],
|
|
validate: val => {
|
|
// allow to be nullable and empty string
|
|
if (!val) {
|
|
return { success: true, data: val };
|
|
}
|
|
|
|
return z.string().url().safeParse(val);
|
|
},
|
|
},
|
|
'provider.apiKey': {
|
|
desc: 'Indexer search service api key. Optional for elasticsearch',
|
|
link: 'https://www.elastic.co/guide/server/current/api-key.html',
|
|
default: '',
|
|
env: ['AFFINE_INDEXER_SEARCH_API_KEY', 'string'],
|
|
},
|
|
'provider.username': {
|
|
desc: 'Indexer search service auth username, if not set, basic auth will be disabled. Optional for elasticsearch',
|
|
link: 'https://www.elastic.co/guide/en/elasticsearch/reference/current/http-clients.html',
|
|
default: '',
|
|
env: ['AFFINE_INDEXER_SEARCH_USERNAME', 'string'],
|
|
},
|
|
'provider.password': {
|
|
desc: 'Indexer search service auth password, if not set, basic auth will be disabled. Optional for elasticsearch',
|
|
default: '',
|
|
env: ['AFFINE_INDEXER_SEARCH_PASSWORD', 'string'],
|
|
},
|
|
'autoIndex.batchSize': {
|
|
desc: 'Number of workspaces automatically indexed per batch',
|
|
default: 10,
|
|
shape: z.number().int().positive().max(1000),
|
|
},
|
|
});
|