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:
Nick SzaunigandClaude Opus 5.5 committed 2026-10-14 11:36:38 +02:00
1 parent c01a38835a
commit cdd30cf3ee
288 files changed
+39165 -2853

No files matched your search

@@ -0,0 +1,72 @@
import { plainToInstance } from 'class-transformer';
import { validate, ValidationError } from 'class-validator';
import { BulkCreateVarroaMeasurementDto } from './bulk-create-varroa-measurement.dto';
// Every constraint message, nested entries included.
function messagesOf(errors: ValidationError[]): string[] {
return errors.flatMap((error) => [
...Object.values(error.constraints ?? {}),
...messagesOf(error.children ?? []),
]);
}
async function check(body: Record<string, unknown>): Promise<string[]> {
const dto = plainToInstance(BulkCreateVarroaMeasurementDto, body);
return messagesOf(
await validate(dto, { whitelist: true, forbidNonWhitelisted: true }),
);
}
const shared = {
date: '2026-09-10',
method: 'NATURAL_MITE_FALL',
durationMinutes: 4320,
};
describe('BulkCreateVarroaMeasurementDto', () => {
it('accepts one entry per colony with its own mite count', async () => {
await expect(
check({
...shared,
entries: [
{ colonyId: 'colony-1', miteCount: 30, assessment: 'hoch' },
{ colonyId: 'colony-2', miteCount: 6 },
],
}),
).resolves.toEqual([]);
});
it('rejects an empty colonyId in an entry with the message of the colonyIds path', async () => {
await expect(
check({ ...shared, entries: [{ colonyId: '', miteCount: 3 }] }),
).resolves.toEqual(['colonyId enthält eine leere Volk-ID']);
});
it('rejects a colonyId that is no text', async () => {
await expect(
check({ ...shared, entries: [{ colonyId: 7, miteCount: 3 }] }),
).resolves.toContain('colonyId enthält eine ungültige Volk-ID');
});
it('rejects a colony that appears twice', async () => {
await expect(
check({
...shared,
entries: [
{ colonyId: 'colony-1', miteCount: 3 },
{ colonyId: 'colony-1', miteCount: 4 },
],
}),
).resolves.toEqual(['entries enthält ein Volk doppelt']);
});
it('rejects a shared mite count', async () => {
const messages = await check({
...shared,
miteCount: 5,
entries: [{ colonyId: 'colony-1' }],
});
expect(messages).toEqual(['property miteCount should not exist']);
});
});
@@ -0,0 +1,35 @@
import { OmitType, PickType } from '@nestjs/swagger';
import {
IsBulkEntries,
IsBulkEntryColonyId,
} from '../../common/bulk/bulk-validation';
import { CreateVarroaMeasurementDto } from './create-varroa-measurement.dto';
const OWN_READINGS = ['miteCount', 'calculatedValue', 'assessment'] as const;
/**
* What each colony has of its own in a bulk count: its mites and their
* reading, validated exactly as on a single measurement. The colony id
* follows the bulk rule (non-empty, as in colonyIds).
*/
export class BulkVarroaEntryDto extends PickType(
CreateVarroaMeasurementDto,
OWN_READINGS,
) {
@IsBulkEntryColonyId()
colonyId!: string;
}
/**
* One varroa count for several colonies: date, method, duration and notes
* are shared, every colony brings its own mite count in `entries` - there is
* no shared mite count. calculatedValue is derived per entry as for a single
* measurement unless the entry carries one.
*/
export class BulkCreateVarroaMeasurementDto extends OmitType(
CreateVarroaMeasurementDto,
['colonyId', ...OWN_READINGS] as const,
) {
@IsBulkEntries(BulkVarroaEntryDto)
entries!: BulkVarroaEntryDto[];
}