Comp AI CRM is an open source, CRM designed for AI agents. Agentic-first CRM.
TypeScript
import { Injectable } from "@nestjs/common";
import {
MICROSOFT_SYNC_SOURCES,
type MicrosoftSyncSource,
} from "../mailbox/mailbox.constants";
import { SyncStateService } from "../mailbox/sync-state.service";
import { OutlookSyncService } from "./outlook-sync.service";
@Injectable()
export class MicrosoftSyncService {
constructor(
private readonly state: SyncStateService,
private readonly outlook: OutlookSyncService,
) {}
async runOne(userId: string, source: MicrosoftSyncSource) {
const row = await this.state.get(userId, source);
if (!row) return null;
return this.outlook.sync(row);
}
async runForUser(userId: string): Promise<void> {
for (const source of MICROSOFT_SYNC_SOURCES) {
await this.runOne(userId, source);
}
}
}