openmeter icon indicating copy to clipboard operation
openmeter copied to clipboard

fix(api): use external key for feature

Open hekike opened this issue 3 months ago • 1 comments

This PR replaces the key in the Feature API with the ExternalKey type, which allows for UUIDs.

Summary by CodeRabbit

  • New Features

    • Feature keys now support up to 256 characters and no longer require a specific pattern, enabling external IDs.
  • Documentation

    • Added clearer descriptions for feature name and optional metadata.
    • Clarified meter association text to explain how usage is calculated.
  • Refactor

    • Public API inputs updated to accept an external-friendly feature key; removed the deprecated meterKey field while keeping meterSlug supported.

hekike avatar Sep 17 '25 21:09 hekike

📝 Walkthrough

Walkthrough

OpenAPI and client schema docs expand and relax validation for feature keys, add descriptions for name and metadata, and update meter/meterSlug descriptions. TypeSpec changes adjust public inputs: FeatureCreateInputs.key becomes ExternalKey and meterKey is removed. Zod runtime validation is updated to match the new constraints.

Changes

Cohort / File(s) Summary of changes
OpenAPI spec updates
api/openapi.yaml, api/openapi.cloud.yaml
Feature key maxLength increased 64→256; feature key pattern removed in openapi.cloud.yaml; key, name, and metadata descriptions expanded/added; meterSlug/meter descriptions updated to reference associated meter and usage calculation.
TypeSpec feature inputs
api/spec/src/entitlements/feature.tsp
FeatureCreateInputs.key type changed from KeyExternalKey. meterKey?: Key property removed. Feature (which extends FeatureCreateInputs) is implicitly updated.
Client JS JSDoc updates
api/client/javascript/src/client/schemas.ts
JSDoc descriptions for key, name, metadata, and meterSlug updated to longer/multiline descriptions; no type or signature changes.
Client Zod validation
api/client/javascript/src/zod/index.ts
createFeatureBodyKeyMax changed 64→256; exported regex constant removed; .regex(...) on key removed; key, name, metadata, and meterSlug .describe(...) text updated to match OpenAPI docs.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "fix(api): use external key for feature" is concise and accurately captures the primary change—replacing the feature key with an ExternalKey (to allow UUIDs)—and follows conventional commit style and scope, making it clear to reviewers scanning the history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • [ ] 📝 Generate Docstrings
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch fix/feature-external-key

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Sep 17 '25 21:09 coderabbitai[bot]