refactor(server): plugin modules (#5630)

- [x] separates modules into `fundamental`, `core`, `plugins`
- [x] optional modules with `@OptionalModule` decorator to install modules with requirements met(`requires`, `if`)
- [x] `module.contributesTo` defines optional features that will be enabled if module registered
- [x] `AFFiNE.plugins.use('payment', {})` to enable a optional/plugin module
- [x] `PaymentModule` is the first plugin module
- [x] GraphQLSchema will not be generated for non-included modules
- [x] Frontend can use `ServerConfigType` query to detect which features are enabled
- [x] override existing provider globally
This commit is contained in:
liuyi
2024-01-22 07:40:28 +00:00
parent ae8401b6f4
commit e516e0db23
130 changed files with 1297 additions and 974 deletions
+1 -10
View File
@@ -4,7 +4,6 @@ import { TestingModule } from '@nestjs/testing';
import ava, { type TestFn } from 'ava';
import { CacheModule } from '../src/fundamentals/cache';
import { ConfigModule } from '../src/fundamentals/config';
import { SessionModule, SessionService } from '../src/fundamentals/session';
import { createTestingModule } from './utils';
@@ -15,15 +14,7 @@ const test = ava as TestFn<{
test.beforeEach(async t => {
const module = await createTestingModule({
imports: [
ConfigModule.forRoot({
redis: {
enabled: false,
},
}),
CacheModule,
SessionModule,
],
imports: [CacheModule, SessionModule],
});
const session = module.get(SessionService);
t.context.module = module;