Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/camera-specs/regional-naming-system.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
## Regional Naming System

Sharply now maintains a single canonical gear record while also surfacing regional aliases for EU and Japan (plus automatic locale-aware fallbacks) in every layer that touches gear naming.
Sharply maintains a single canonical gear record while also surfacing optional regional aliases for the United States, Europe, and Japan in every layer that touches gear naming.

### Schema and search plumbing

- `gear_aliases` (composite PK `gear_id + region`) stores `name` per `GearRegion` (`GLOBAL`, `EU`, `JP`). The alias rows are joined in the core fetchers (`fetchGearBySlug`, browse endpoints, alternatives, popularity/trending queries, comparison data, search results) via the helpers `fetchGearAliasesByGearIds`/`fetchGearAliasesByGearId`.
- `gear_aliases` (composite PK `gear_id + region`) stores `name` per `GearRegion` (`GLOBAL`, `US`, `EU`, `JP`). The alias rows are joined in the core fetchers (`fetchGearBySlug`, browse endpoints, alternatives, popularity/trending queries, comparison data, search results) via the helpers `fetchGearAliasesByGearIds`/`fetchGearAliasesByGearId`.
- Display helpers (`GetGearDisplayName`, `buildGearSearchName`, `normalizeGearSearchText`) consume `regionalAliases` so alias names can influence both the rendered label and the normalized search index. Search suggestions and commands now accept `countryCode`/locale to resolve the right alias.
- Search metadata (`metadata.tsx`, JSON-LD) now uses `GetGearDisplayName`, and rename workflows rebuild `search_name` after alias updates so results stay consistent.

### Locale tooling & regional routing

- `src/lib/locale/locales.ts` defines the supported locale options (US, UK, EU, DE, FR, ES, IT, CN, MY, JP, Global) with explicit MPB routing config and canonical `gearRegion`. `CountryProvider` stores the locale id, resolves geo headers (including `EU`/`UK` pseudo codes), and exposes `locale`, `localeId`, `countryCode`, and `gearRegion`. The legacy `countryCode` setters now resolve to the locale map.
- `src/lib/locale/locales.ts` defines the supported locale options (US, UK, EU, DE, FR, ES, IT, CN, MY, JP, Global) with explicit MPB routing config and canonical `gearRegion`. The US locale maps to `US`; the Global locale remains `GLOBAL`. `CountryProvider` stores the locale id, resolves geo headers, and exposes `locale`, `localeId`, `countryCode`, and `gearRegion`.
- `CountrySelect` consumes this list (minus the Global option) so editors can choose US, UK, EU, or JP — each with consistent labels/flags — while `resolveRegionFromCountryCode` remains tolerant of `EU`/`UK` to keep alias resolution stable.
- Gear commerce links (`gear/_components/gear-links.tsx`) now pass the locale’s MPB market rather than the raw country code so JP or EU selections go through the right storefront.

### Editor experience and alias persistence

- The rename modal (`RenameGearDialog`) now includes EU and JP alias inputs alongside the new name field. Input text is automatically prefixed with the brand name (matching the canonical rename behavior). Submissions are allowed even when only aliases change, and the CTA enables whenever there’s any difference vs. the stored alias values.
- The rename modal (`RenameGearDialog`) includes US, EU, and JP alias inputs alongside the canonical name field. Regional values are complete display names and are trimmed but otherwise stored exactly as entered, so an alias may use a different regional brand such as Rokinon. Canonical renames retain automatic brand prefixing. Submissions are allowed even when only aliases change.
- Alias edits are saved via `actionUpdateGearAliases` → `updateGearAliasesService`, which filters to allowed regions, performs upserts/deletes, and rebuilds `gear.searchName` using `buildGearSearchName` (re-using brand tokens + alias names). This service also revalidates `/admin/gear`, `/gear`, and `/browse`.
- The admin table and gear page pass the current `regionalAliases` + `brandName` into the dialog so existing alias values prefill.
- The admin table and gear page pass current `regionalAliases` into the dialog so existing values prefill.

### Viewer-facing surfaces

- Gear cards, hero sections, horizontal lists, browse/trending tables, alternatives, compare pages, wishlist/collection lists, price/metadata sections, reviews/news cards, and image carousel alt text now rely on `GetGearDisplayName` + `regionalAliases`, so EU/Japan viewers automatically see the correct name.
- Specs table now includes a dedicated “Regional Names” row that mirrors the spacing/typography of other rows. It lists the EU alias, Japan alias, and (for non-global viewers) the base name so editors can verify all names at a glance.
- Gear cards, hero sections, horizontal lists, browse/trending tables, alternatives, compare pages, wishlist/collection lists, price/metadata sections, reviews/news cards, and image carousel alt text rely on `GetGearDisplayName` + `regionalAliases`, so US/EU/JP viewers automatically receive an exact regional alias when one exists and otherwise receive the canonical name.
- Specs table includes a dedicated “Regional Names” row so editors can verify stored aliases and the canonical fallback.
- Metadata/JSON-LD, compare metadata, and command palette/search suggestions use the region-aware display name to keep sharing/search consistent.

### Outcome
Expand Down
4 changes: 4 additions & 0 deletions docs/developer-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ Returns a ranked page of published results:
}
```

### `GET /api/v1/search/suggestions`

Required query parameter: `q` (2–200 characters). Optional `limit` defaults to 8 (maximum 10). Optional `region` defaults to `GLOBAL` and accepts `GLOBAL`, `US`, `EU`, or `JP`. A regional alias is returned when the requested region has one; otherwise the canonical name is used.

### `GET /api/v1/catalog`

Downloads one shared, lightweight snapshot of every published gear record. It is
Expand Down
5 changes: 3 additions & 2 deletions docs/gear-specification-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ Stores alternate consumer-facing names used in specific regions (aliases, not lo

- **Primary Key**: Composite (`gearId`, `region`) to enforce one alias per region
- **Gear Reference**: Foreign key to `gear.id` (cascade on delete)
- **Region**: `gear_region` enum (`GLOBAL`, `EU`, `JP`)
- **Name**: Alternate display name for that region
- **Region**: `gear_region` enum (`GLOBAL`, `US`, `EU`, `JP`)
- **Name**: Complete alternate display name for that region, stored without canonical-brand prefix enforcement
- **Use Cases**:
- Canon "Kiss" line in Japan
- Canon EU variants (secondary)
- Rokinon branding for Samyang products in the United States
- **Search**: Aliases are denormalized into `gear.search_name` for query performance

#### `gear_exif_aliases` - EXIF Metadata Model Aliases
Expand Down
2 changes: 1 addition & 1 deletion docs/mapping-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Regional aliases are resolved through a single helper to keep UI consistent:

- **Helper**: `GetGearDisplayName(item)` in `src/lib/gear/naming.ts`
- **Inputs**: canonical `name` plus optional `regionalAliases`
- **Resolution**: country → region (GLOBAL/EU/JP), then alias match, else canonical
- **Resolution**: country → region (GLOBAL/US/EU/JP), then exact alias match, else canonical; US does not inherit a `GLOBAL` alias
- **Usage**: all gear name surfaces should use the helper or `useGearDisplayName`

## Routing note: Mount shortName
Expand Down
2 changes: 1 addition & 1 deletion docs/search-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The key-authenticated developer API has separate public endpoints at `/api/v1/se
- Migration: `drizzle/0006_search_trgm.sql`
- Creates extension if missing
- Adds a GIN trigram index on `sharply_gear.search_name`
- `gear.search_name` is denormalized to include canonical names plus any regional aliases.
- `gear.search_name` is denormalized to include canonical names plus any US, EU, JP, or Global aliases. Aliases may contain a different regional brand, while search normalization retains canonical-brand tokens so either name can match.

## Core algorithm

Expand Down
1 change: 1 addition & 0 deletions drizzle/0025_ordinary_valeria_richards.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TYPE "public"."gear_region" ADD VALUE 'US' BEFORE 'EU';
Comment thread
Flohhhhh marked this conversation as resolved.
Loading
Loading