feat(interests): wire yachtId, enforce ownership + stage-gate

- Add yachtId (optional) to createInterestSchema + listInterestsSchema
  (updateInterestSchema inherits it via partial() automatically).
- Add assertYachtBelongsToClient helper that accepts direct client
  ownership OR company-represented clients with an active membership
  in the owning company.
- createInterest + updateInterest validate yacht ownership whenever
  yachtId is supplied/changed.
- changeInterestStage rejects moving out of stage=open with yachtId
  null (ValidationError).
- listInterests filter supports yachtId.
- Integration tests cover all 7 paths; validator test for yachtId.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt Ciaccio
2026-04-24 15:34:44 +02:00
parent 3b0421aa81
commit f9cb8003b5
4 changed files with 351 additions and 43 deletions

View File

@@ -131,6 +131,14 @@ describe('createInterestSchema', () => {
const result = createInterestSchema.safeParse({ clientId: 'c1', reminderDays: 0 });
expect(result.success).toBe(false);
});
it('createInterestSchema accepts yachtId', () => {
const result = createInterestSchema.safeParse({
clientId: 'c1',
yachtId: 'y1',
});
expect(result.success).toBe(true);
});
});
describe('changeStageSchema', () => {