Control plane wiring (plan §5-§11): - PageService create/update/movePage now honor provenance actor 'git-sync' (stamp lastUpdatedSource='git-sync'), closing the A.4a gap. - EnvironmentService: GIT_SYNC_ENABLED / DATA_DIR / REMOTE_TEMPLATE / POLL_INTERVAL_MS / DEBOUNCE_MS / SERVICE_USER_ID (required-if-enabled) / SSH_KEY_PATH + validation. - VaultRegistryService: per-space vault path + cached VaultGit. - GitSyncOrchestrator: per-space Redis leader-lock (SET NX PX + CAS-Lua release, randomUUID instanceId) + in-process mutex; runOnce drives the vendored engine PULL (readExisting->computePullActions->applyPullActions) then PUSH (runPush) with the bound native GitSyncClient + VaultGit; @Interval poll-safety gated on GIT_SYNC_ENABLED; imports plain ScheduleModule (TelemetryModule owns forRoot). - PageChangeListener: @OnEvent PAGE_* -> per-space debounce -> runOnce, with a best-effort lastUpdatedSource==='git-sync' loop-guard. - GitSyncController: admin POST /api/git-sync/trigger + GET /status (ops/e2e). - GitSyncModule registered in app.module. Enabled-space enumeration uses settings.gitSync.enabled, falling back to all live spaces until Phase C writes the flag (master gate = GIT_SYNC_ENABLED). tsc clean; 713 tests/71 suites pass; dev server hot-reloaded the module (route live, DI graph boots). Live pull/push round-trip verified next. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
108 lines
3.7 KiB
TypeScript
108 lines
3.7 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { APP_INTERCEPTOR } from '@nestjs/core';
|
|
import { AppController } from './app.controller';
|
|
import { AppService } from './app.service';
|
|
import { EnvironmentService } from './integrations/environment/environment.service';
|
|
import { AuditActorInterceptor } from './common/interceptors/audit-actor.interceptor';
|
|
import { CoreModule } from './core/core.module';
|
|
import { EnvironmentModule } from './integrations/environment/environment.module';
|
|
import { CollaborationModule } from './collaboration/collaboration.module';
|
|
import { WsModule } from './ws/ws.module';
|
|
import { DatabaseModule } from '@docmost/db/database.module';
|
|
import { StorageModule } from './integrations/storage/storage.module';
|
|
import { MailModule } from './integrations/mail/mail.module';
|
|
import { QueueModule } from './integrations/queue/queue.module';
|
|
import { StaticModule } from './integrations/static/static.module';
|
|
import { EventEmitterModule } from '@nestjs/event-emitter';
|
|
import { HealthModule } from './integrations/health/health.module';
|
|
import { ExportModule } from './integrations/export/export.module';
|
|
import { ImportModule } from './integrations/import/import.module';
|
|
import { SecurityModule } from './integrations/security/security.module';
|
|
import { TelemetryModule } from './integrations/telemetry/telemetry.module';
|
|
import { RedisModule } from '@nestjs-labs/nestjs-ioredis';
|
|
import { RedisConfigService } from './integrations/redis/redis-config.service';
|
|
import { CacheModule } from '@nestjs/cache-manager';
|
|
import KeyvRedis from '@keyv/redis';
|
|
import { LoggerModule } from './common/logger/logger.module';
|
|
import { ClsModule } from 'nestjs-cls';
|
|
import { NoopAuditModule } from './integrations/audit/audit.module';
|
|
import { ThrottleModule } from './integrations/throttle/throttle.module';
|
|
import { McpModule } from './integrations/mcp/mcp.module';
|
|
import { GitSyncModule } from './integrations/git-sync/git-sync.module';
|
|
import { AiModule } from './integrations/ai/ai.module';
|
|
import { AiChatModule } from './core/ai-chat/ai-chat.module';
|
|
|
|
const enterpriseModules = [];
|
|
try {
|
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
if (require('./ee/ee.module')?.EeModule) {
|
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
enterpriseModules.push(require('./ee/ee.module')?.EeModule);
|
|
}
|
|
} catch (err) {
|
|
if (process.env.CLOUD === 'true') {
|
|
console.warn('Failed to load enterprise modules. Exiting program.\n', err);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
@Module({
|
|
imports: [
|
|
ClsModule.forRoot({
|
|
global: true,
|
|
middleware: { mount: true },
|
|
}),
|
|
LoggerModule,
|
|
NoopAuditModule,
|
|
CoreModule,
|
|
DatabaseModule,
|
|
EnvironmentModule,
|
|
RedisModule.forRootAsync({
|
|
useClass: RedisConfigService,
|
|
}),
|
|
CacheModule.registerAsync({
|
|
isGlobal: true,
|
|
useFactory: async (environmentService: EnvironmentService) => {
|
|
const redisUrl = environmentService.getRedisUrl();
|
|
|
|
return {
|
|
ttl: 5 * 1000,
|
|
stores: [new KeyvRedis(redisUrl)],
|
|
};
|
|
},
|
|
inject: [EnvironmentService],
|
|
}),
|
|
CollaborationModule,
|
|
WsModule,
|
|
QueueModule,
|
|
StaticModule,
|
|
HealthModule,
|
|
ImportModule,
|
|
ExportModule,
|
|
StorageModule.forRootAsync({
|
|
imports: [EnvironmentModule],
|
|
}),
|
|
MailModule.forRootAsync({
|
|
imports: [EnvironmentModule],
|
|
}),
|
|
EventEmitterModule.forRoot(),
|
|
SecurityModule,
|
|
TelemetryModule,
|
|
ThrottleModule,
|
|
McpModule,
|
|
GitSyncModule,
|
|
AiModule,
|
|
AiChatModule,
|
|
...enterpriseModules,
|
|
],
|
|
controllers: [AppController],
|
|
providers: [
|
|
AppService,
|
|
{
|
|
provide: APP_INTERCEPTOR,
|
|
useClass: AuditActorInterceptor,
|
|
},
|
|
],
|
|
})
|
|
export class AppModule {}
|