Skip to content

✨ feat(keys): key metadata and renaming (LOC-4789) - #81

Merged
david-vaclavek merged 3 commits into
mainfrom
LOC-4789_key_metadata
Nov 16, 2026
Merged

david-vaclavek merged 3 commits into
mainfrom
LOC-4789_key_metadata

Conversation

@david-vaclavek

@david-vaclavek david-vaclavek commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Client side of two public API features the Figma plugin needs (LOC-4789):

  • key metadata: localazy/server-backend#1132, merged, on testing, not released yet;
  • key renaming: server-backend#1094, in production since 2026.10.0700.

The plugin will use metadata to record on linked keys where a design uses them, without an import. It will use renaming for Edit key name and for applying a naming pattern to existing keys.

Changes

  • keys.update takes addMetadata and removeMetadata.
    • addMetadata is merged into the key's custom metadata on the top level.
    • Removal is applied first, so a name in both ends up added.
  • New keys.setMetadata over PUT /projects/{p}/keys/metadata: up to 1000 keys, each with its own change. The response gives each key a state: updated, not_found or not_supported.
  • New keys.rename over POST /projects/{p}/keys/rename: up to 1000 keys, each with its new name as a list of segments (['checkout', 'title'] nested, ['checkout.title'] flat).
    • A renamed key keeps its ID and translations.
    • The response gives each key a state: renamed or unchanged, so a retry is safe.
  • Key.metadata: the field files.listKeys() already returns with metadata: true, now typed.
    • It's absent only while the key's metadata was never written.
    • After any write, it stays an object: {} once the last entry is removed. That includes a removal of a name the key didn't have, and writes from the web app or an import.
    • So {} tells that the metadata was edited at some point. The docs say to check entries, not presence.
  • The reference docs cover all three methods. Their links point at sections the public Source Keys docs page doesn't have yet.

Tests

pnpm run check passes: format, lint, typecheck, build and 83 tests. New tests cover:

  • the metadata body of keys.update;
  • the body and response of keys.setMetadata and keys.rename;
  • the rejection of a missing key list.

Also run against testing (testing.localazy.com/pubapi, after #1132 was deployed there on 2026-11-16), with the built client and a real project. All 13 checks passed, and every key was put back afterwards:

  • keys.update adds and removes metadata, and files.listKeys({ metadata: true }) lists it.
  • keys.setMetadata reports the state of a Key object, an ID and a missing key, and rejects a duplicate ID.
  • keys.rename works on a nested key and on a flat iOS key containing a dot:
    • the key keeps its ID and value;
    • a repeat answers unchanged;
    • a name already used in the file is rejected (key_exists) and nothing is renamed;
    • two keys can swap names in one call;
    • a missing key is rejected (401, as the endpoint documents).

Released before server-backend#1132 reaches production, on purpose: the Figma plugin work continues against testing, and nothing waits on these methods.

  • Until #1132 is released, keys.setMetadata and the metadata fields of keys.update work only on testing.
  • In production, they're rejected by the API. A plain keys.update and the listing's metadata are unaffected.
  • keys.rename already works everywhere.

🤖 Generated with Claude Code

## Features
- `keys.update` takes `addMetadata` (merged into the key's custom
  metadata on the top level) and `removeMetadata`
- Add `keys.setMetadata` over `PUT /projects/{p}/keys/metadata`: up to
  1000 keys, each with its own change; the response reports each key as
  `updated`, `not_found` or `not_supported`
- `Key.metadata`, returned by `files.listKeys()` with `metadata: true`

## Tests
- Cover the metadata fields of `keys.update`, the body and response of
  `keys.setMetadata`, and the rejection of a missing key list

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 96.29% 390 / 405
🔵 Statements 96.17% 402 / 418
🔵 Functions 96.07% 98 / 102
🔵 Branches 81.39% 105 / 129
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/main.ts 0% 0% 0% 0%
src/api/methods/api-keys.ts 77.5% 40% 81.81% 77.5% 57-76
src/types/key-rename-request.ts 0% 0% 0% 0%
src/types/key-rename-response.ts 0% 0% 0% 0%
src/types/key-set-metadata-request.ts 0% 0% 0% 0%
src/types/key-set-metadata-response.ts 0% 0% 0% 0%
src/types/key-update-request.ts 0% 0% 0% 0%
src/types/key.ts 0% 0% 0% 0%
tests/fixtures/full-project/index.ts 100% 100% 100% 100%
Generated in workflow #119 for commit 62a6cb7 by the Vitest Coverage Report Action

## Features
- Add `keys.rename` over `POST /projects/{p}/keys/rename`: up to 1000
  keys, each with its new name as a list of segments; a renamed key keeps
  its ID and translations, and the response reports each key as `renamed`
  or `unchanged`

## Tests
- Cover the body and response of `keys.rename` and the rejection of a
  missing key list

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@david-vaclavek david-vaclavek changed the title ✨ feat(keys): add and remove the metadata of keys (LOC-4789) ✨ feat(keys): key metadata and renaming (LOC-4789) Nov 16, 2026
## Documentation
- `Key.metadata` is absent only while the key's metadata was never
  written; after any write, even a removal of a name the key didn't have,
  `files.listKeys()` lists an object, `{}` once the last entry is removed
- The removal fields of `keys.update` and `keys.setMetadata`, and the
  reference docs, say so

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@david-vaclavek
david-vaclavek marked this pull request as ready for review November 16, 2026 14:13
@david-vaclavek
david-vaclavek merged commit 841d5ea into main Nov 16, 2026
3 checks passed
@david-vaclavek
david-vaclavek deleted the LOC-4789_key_metadata branch November 16, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants