This repository was archived by the owner on Feb 3, 2026. It is now read-only.
Commit 2a19fa0
feat(SAPP-2780): Use dedicated language field instead of _key for language identification (#112)
* feat(SAPP-2780): add language field to type definitions and update schema validation
Phase 1 of _key to language pivot:
- Add `language: string` field to Value type (src/types.ts)
- Add `language: string` field to InternationalizedValue type
- Update array.ts validation to check `language` instead of `_key`
- Add hidden `language` field to object schema definition
- Update object preview to display `language` as subtitle
Key design decisions:
- `_key` remains for Sanity's array item tracking (UUID)
- `language` is the new semantic identifier for language matching
- Error paths still use `_key` for Sanity to locate items
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(SAPP-2780): add validation for missing/empty language values
Address review feedback from @sapphire:
- Add explicit check for missing or empty `language` field
- Clear error message: "Language is required for each array item"
- Checks before invalid language validation (fail-fast)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(SAPP-2780): scaffold migration script for _key to language transition
- Add migrations/keyToLanguage.ts with full structure
- Configurable document types and field names
- Batch processing with optimistic locking (ifRevisionID)
- Dry run mode enabled by default for safety
- Idempotent GROQ query finds docs without language field
- Transform logic copies _key to language, generates new nanoid _key
The transformation logic is complete but will be tested once all phases
are merged into the feature branch.
* docs(SAPP-2780): update README for v4 language field changes
- Update intro to reference language field instead of _key
- Update 'Shape of stored data' section with new format
- Update 'Querying data' section with language-based queries
- Add 'Migrate from v3 to v4' section with migration guide
- Update table of contents
- Update @sanity/language-filter example for new data structure
* feat(SAPP-2780): integrate Phase 2 and Phase 3 changes
Phase 3 (Utils - from @charlie):
- createAddLanguagePatches.ts: Use nanoid() for _key, add language field
- checkAllLanguagesArePresent.ts: Check v.language instead of v._key
- fieldActions/index.ts: Update disabled check to use item.language
Phase 2 (Components - from @charlie):
- InternationalizedArray.tsx: Update 4 _key references to language
- InternationalizedInput.tsx: Update 7 _key references to language
- DocumentAddButtons.tsx: Add nanoid import, use language for checks
- getDocumentsToTranslate.ts: Add language to interface
Shared:
- package.json: Add nanoid ^5.0.7 dependency
- keyToLanguage.ts: Fix lint issues with eslint-disable
Note: Pre-existing type error in schema/array.ts:35 is unrelated to these changes.
* fix(SAPP-2780): Add type assertion for InternationalizedArray component
The stricter Value type (with required `language` field) surfaced a latent
type mismatch between InternationalizedArray's ArrayOfObjectsInputProps
and defineField's expected ArrayOfPrimitivesInputProps.
The component works correctly at runtime - this is a type system limitation
where Sanity's types can't express that our array contains objects, not primitives.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent 714f6a7 commit 2a19fa0
File tree
14 files changed
+552
-74
lines changed- migrations
- src
- components
- fieldActions
- schema
- utils
14 files changed
+552
-74
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
308 | 309 | | |
309 | 310 | | |
310 | 311 | | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | | - | |
| 342 | + | |
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
346 | | - | |
347 | | - | |
| 346 | + | |
| 347 | + | |
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| 351 | + | |
| 352 | + | |
351 | 353 | | |
352 | 354 | | |
353 | | - | |
| 355 | + | |
354 | 356 | | |
355 | 357 | | |
356 | 358 | | |
357 | | - | |
| 359 | + | |
358 | 360 | | |
359 | 361 | | |
360 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
361 | 429 | | |
362 | 430 | | |
363 | 431 | | |
| |||
0 commit comments