chore(i18n): drop legacy free-text country/nationality columns

Test-data only — no production migration needed (per earlier decision).
Schema is now ISO-only; readers convert ISO codes to localized names where
human-readable output is required (EOI documents, invoices, portal).

Migration 0016 drops:
  - clients.nationality
  - companies.incorporation_country
  - client_addresses.{state_province, country}
  - company_addresses.{state_province, country}

Code paths that previously read free-text values now read the ISO column
and pass through `getCountryName()` / `getSubdivisionName()` for rendering.
Document templates ({{client.nationality}}), portal client view, EOI/
reservation-agreement contexts, and invoice billing addresses all updated.

Public yacht-interest endpoint (/api/public/interests) drops the legacy
fields from its insert path and writes ISO codes only. The Zod validators
no longer accept the legacy fields — older website builds posting raw
'incorporationCountry' / 'country' / 'stateProvince' will get 400s.
Server-side phone normalization is unchanged.

Seed data updated to use ISO codes (GB/FR/ES/GR/SE/IT/GH/MC/PA), spread
across continents to keep test fixtures realistic.

Test assertions updated to match the new render shape (e.g.
'United States' not 'US', 'California' not 'CA').

Vitest: 741 -> 741 (unchanged count; assertions updated, no new tests).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt Ciaccio
2026-04-28 19:00:57 +02:00
parent 31fa3d08ec
commit 27cdbcc695
30 changed files with 9959 additions and 104 deletions

View File

@@ -26,8 +26,6 @@ export const contactSchema = z.object({
export const createClientSchema = z.object({
fullName: z.string().min(1).max(200),
contacts: z.array(contactSchema).min(1, 'At least one contact is required'),
/** Legacy free-text nationality. Kept for backfill only — new edits write `nationalityIso`. */
nationality: z.string().optional(),
/** ISO-3166-1 alpha-2 nationality code. */
nationalityIso: optionalCountryIsoSchema.optional(),
preferredContactMethod: z.enum(['email', 'phone', 'whatsapp']).optional(),

View File

@@ -7,8 +7,6 @@ export const createCompanySchema = z.object({
legalName: z.string().optional(),
taxId: z.string().optional(),
registrationNumber: z.string().optional(),
/** Legacy free-text. New writes use `incorporationCountryIso`. */
incorporationCountry: z.string().optional(),
/** ISO-3166-1 alpha-2 country of incorporation. */
incorporationCountryIso: optionalCountryIsoSchema.optional(),
/** ISO 3166-2 state/province of incorporation. */

View File

@@ -74,13 +74,9 @@ export const generateRecommendationsSchema = z.object({
const addressSchema = z.object({
street: z.string().max(500).optional(),
city: z.string().max(200).optional(),
/** Legacy free-text. New writes use `subdivisionIso`. */
stateProvince: z.string().max(200).optional(),
/** ISO 3166-2 subdivision code (e.g. 'PL-MZ'). */
subdivisionIso: optionalSubdivisionIsoSchema.optional(),
postalCode: z.string().max(50).optional(),
/** Legacy free-text. New writes use `countryIso`. */
country: z.string().max(100).optional(),
/** ISO-3166-1 alpha-2 country code. */
countryIso: optionalCountryIsoSchema.optional(),
});
@@ -105,8 +101,6 @@ const publicCompanySchema = z.object({
name: z.string().min(1).max(200),
legalName: z.string().max(200).optional(),
taxId: z.string().max(100).optional(),
/** Legacy free-text. New website builds should send `incorporationCountryIso`. */
incorporationCountry: z.string().max(100).optional(),
/** ISO-3166-1 alpha-2 country of incorporation. */
incorporationCountryIso: optionalCountryIsoSchema.optional(),
/** ISO 3166-2 state/province of incorporation. */