feat: platform backbone and field capture complete (checkpoint)
Platform backbone (plan 2026-10-13-plattform-rueckgrat), all tasks reviewed: - webhooks with delivery table, retries and stable delivery id - calendar handlers; a finished task removes its Outlook event - tasks, automations, inspections, varroa, treatments, feedings, harvests, colonies, wintering, stock and bottling record domain events in the same transaction; legacy post-commit calls removed - row locks through one helper (lockRowForUpdate, lockRowsForShare, lockRowsForUpdate) - job framework with JobRun, cli exit codes, cleanup, task templates, daily evaluation, hourly app-backup and the rekey job - system API and page "Verwaltung > System" with retry - @nestjs/schedule removed, guard tests against in-process schedulers Field capture T3 (plan 2026-10-13-t3-erfassung-am-stand), all tasks reviewed: - inspection photo offline without metadata - bulk capture for treatments, feedings and varroa (backend + frontend) - offline stand mode with service worker, offline pages and packs - offline session, cold start and logout on shared devices Docs: ARCHITECTURE.md assumptions and sections updated, TASKS.md. Gates: backend lint, typecheck, 1770 unit, 420 e2e, build, no schema drift; frontend lint, typecheck, 913 tests, build. Not rolled out. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
c01a38835a
commit
cdd30cf3ee
288 files changed
+39165
-2853
No files matched your search
@@ -0,0 +1,77 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import type { AnyDomainEventEnvelope } from '../domain-events/domain-event-types';
|
||||
import { OnDomainEvent } from '../domain-events/on-domain-event.decorator';
|
||||
import { Prisma } from '../../generated/prisma';
|
||||
import { CalendarSyncService } from './calendar-sync.service';
|
||||
|
||||
/**
|
||||
* Puts calendar-relevant records into the M365 outbox. Pure DB writer: the
|
||||
* Graph call itself happens in CalendarSyncService.processOutbox (worker
|
||||
* loop). Errors propagate, so a failed delivery is retried.
|
||||
*/
|
||||
@Injectable()
|
||||
export class CalendarSyncEventHandlers {
|
||||
constructor(private readonly calendarSync: CalendarSyncService) {}
|
||||
|
||||
@OnDomainEvent(
|
||||
['InspectionRecorded', 'InspectionCorrected'],
|
||||
'calendar-sync.inspection',
|
||||
)
|
||||
async inspection(
|
||||
event: AnyDomainEventEnvelope<'InspectionRecorded' | 'InspectionCorrected'>,
|
||||
tx: Prisma.TransactionClient,
|
||||
): Promise<void> {
|
||||
await this.calendarSync.enqueueIn(tx, 'INSPECTION', event.aggregateId);
|
||||
}
|
||||
|
||||
@OnDomainEvent(
|
||||
['TreatmentRecorded', 'TreatmentCorrected'],
|
||||
'calendar-sync.treatment',
|
||||
)
|
||||
async treatment(
|
||||
event: AnyDomainEventEnvelope<'TreatmentRecorded' | 'TreatmentCorrected'>,
|
||||
tx: Prisma.TransactionClient,
|
||||
): Promise<void> {
|
||||
await this.calendarSync.enqueueIn(tx, 'TREATMENT', event.aggregateId);
|
||||
}
|
||||
|
||||
@OnDomainEvent(
|
||||
['FeedingRecorded', 'FeedingCorrected'],
|
||||
'calendar-sync.feeding',
|
||||
)
|
||||
async feeding(
|
||||
event: AnyDomainEventEnvelope<'FeedingRecorded' | 'FeedingCorrected'>,
|
||||
tx: Prisma.TransactionClient,
|
||||
): Promise<void> {
|
||||
await this.calendarSync.enqueueIn(tx, 'FEEDING', event.aggregateId);
|
||||
}
|
||||
|
||||
@OnDomainEvent(
|
||||
['HarvestRecorded', 'HarvestCorrected'],
|
||||
'calendar-sync.harvest',
|
||||
)
|
||||
async harvest(
|
||||
event: AnyDomainEventEnvelope<'HarvestRecorded' | 'HarvestCorrected'>,
|
||||
tx: Prisma.TransactionClient,
|
||||
): Promise<void> {
|
||||
await this.calendarSync.enqueueIn(tx, 'HARVEST', event.aggregateId);
|
||||
}
|
||||
|
||||
// Updated and completed tasks are enqueued even without a due date or
|
||||
// when done: the worker then removes an event created earlier.
|
||||
@OnDomainEvent(
|
||||
['TaskCreated', 'TaskUpdated', 'TaskCompleted'],
|
||||
'calendar-sync.task',
|
||||
)
|
||||
async task(
|
||||
event: AnyDomainEventEnvelope<
|
||||
'TaskCreated' | 'TaskUpdated' | 'TaskCompleted'
|
||||
>,
|
||||
tx: Prisma.TransactionClient,
|
||||
): Promise<void> {
|
||||
if (event.type === 'TaskCreated' && event.payload.dueDate === null) {
|
||||
return;
|
||||
}
|
||||
await this.calendarSync.enqueueIn(tx, 'TASK', event.aggregateId);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user