Repository navigation
fix(api): add rest utility for nested visibility models for plan addons - #2676
Conversation
📝 WalkthroughWalkthroughThis change refactors the API models and schemas related to plan add-on updates across multiple languages and specification files. The Changes
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (11)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
api/openapi.cloud.yaml (1)
7044-7044: Plan add-on update schema simplification is correct and improves API clarity.The switch to
PlanAddonUpdatewith onlyfromPlanPhaseandmaxQuantityis a breaking but positive change. It removes unnecessary fields from the update model, aligning the API with best practices and the actual update semantics.If this is a public API, ensure consumers are notified of the breaking change.
Also applies to: 17776-17792
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
api/api.gen.go(3 hunks)api/client/go/client.gen.go(3 hunks)api/client/javascript/src/client/schemas.ts(3 hunks)api/openapi.cloud.yaml(2 hunks)api/openapi.yaml(2 hunks)api/spec/src/app/app.tsp(1 hunks)api/spec/src/app/stripe.tsp(1 hunks)api/spec/src/billing/invoices.tsp(5 hunks)api/spec/src/billing/profile.tsp(2 hunks)api/spec/src/customer.tsp(2 hunks)api/spec/src/debug.tsp(0 hunks)api/spec/src/meters.tsp(2 hunks)api/spec/src/notification/channel.tsp(1 hunks)api/spec/src/productcatalog/planaddon.tsp(1 hunks)api/spec/src/productcatalog/routes.tsp(2 hunks)api/spec/src/rest.tsp(1 hunks)
💤 Files with no reviewable changes (1)
- api/spec/src/debug.tsp
🧰 Additional context used
🧬 Code Graph Analysis (3)
api/client/go/client.gen.go (2)
api/client/javascript/src/client/schemas.ts (1)
PlanAddonUpdate(9786-9786)api/api.gen.go (1)
PlanAddonUpdate(4813-4820)
api/client/javascript/src/client/schemas.ts (2)
api/api.gen.go (1)
PlanAddonUpdate(4813-4820)api/client/go/client.gen.go (1)
PlanAddonUpdate(4509-4516)
api/api.gen.go (2)
api/client/javascript/src/client/schemas.ts (1)
PlanAddonUpdate(9786-9786)api/client/go/client.gen.go (1)
PlanAddonUpdate(4509-4516)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyze (go)
🔇 Additional comments (21)
api/spec/src/rest.tsp (1)
13-43: Well-structured implementation of nested visibility modelsThe new
OpenMeter.Restnamespace introduces three well-designed resource operation models that support lifecycle-based visibility filtering:
ResourceCreateModelwithLifecycle.CreatevisibilityResourceUpdateModelwithLifecycle.UpdatevisibilityResourceReplaceModelwith combinedLifecycle.CreateorLifecycle.UpdatevisibilityThis approach should effectively support nested visibility models as mentioned in the PR objectives, and provides a clean foundation for the planned migration from
TypeSpec.Restmodels.api/spec/src/app/stripe.tsp (1)
174-174: Clean namespace qualificationGood update to use the fully qualified
TypeSpec.Rest.Resourcenamespace instead of the shorter form. This makes the code more explicit and consistent with the changes across the codebase.api/spec/src/notification/channel.tsp (1)
128-128: Consistent namespace qualificationGood update to use the fully qualified
TypeSpec.Rest.Resourcenamespace, maintaining consistency with similar changes throughout the codebase.api/spec/src/app/app.tsp (1)
52-52: Consistent namespace qualificationGood update to use the fully qualified
TypeSpec.Rest.Resourcenamespace, matching the pattern applied across the codebase.api/spec/src/meters.tsp (2)
167-167: Updated namespace reference for MeterCreate modelThe change from
Rest.Resource.ResourceCreateModeltoTypeSpec.Rest.Resource.ResourceCreateModeluses fully qualified namespaces, which is more explicit and avoids ambiguity. This aligns with the broader effort to standardize resource model references across the codebase.
181-181: Updated namespace reference for MeterUpdate modelSimilar to the MeterCreate model change, this updates to a fully qualified namespace reference. This change maintains consistency and prepares for the planned migration to OpenMeter.Rest mentioned in the PR objectives.
api/spec/src/productcatalog/planaddon.tsp (1)
18-18: Added visibility decorator for nested addon objectAdding the
@visibility(Lifecycle.Read, Lifecycle.Create)decorator to the addon property enables lifecycle-based visibility control at the object level, complementing the existing field-level visibility controls within the addon object. This is a key implementation of the PR's goal to support nested visibility models.api/spec/src/customer.tsp (2)
26-26: Updated namespace reference in create method parameterThe change from a shorter namespace reference to the fully qualified
TypeSpec.Rest.Resource.ResourceCreateModel<Customer>ensures consistency with similar changes across the codebase and avoids ambiguity in type resolution.
59-59: Updated namespace reference in update method parameterSimilarly, this change to
TypeSpec.Rest.Resource.ResourceReplaceModel<Customer>maintains consistency in namespace references throughout the API specifications, which is important for the planned migration path described in the PR objectives.api/api.gen.go (1)
4812-4820: PlanAddonUpdate struct and request body alias are correct and consistent with the new API contractThe new
PlanAddonUpdatestruct and the updatedUpdatePlanAddonJSONRequestBodyalias are well-defined, match the intended simplification, and are consistent with the coordinated changes across the codebase. No issues found.Also applies to: 7403-7403
api/client/go/client.gen.go (3)
4508-4512: LGTM: Clean struct definition with good documentationThe new
PlanAddonUpdatestruct definition is well-documented with a clear purpose as a "Resource update operation model." This appears to be part of simplifying the API model by replacing the more complexPlanAddonReplaceUpdatewith this streamlined version.
7035-7036: LGTM: Consistent type alias updateThe update to
UpdatePlanAddonJSONRequestBodycorrectly maps to the newPlanAddonUpdatestruct, maintaining consistency with the model changes.
36602-37056: LGTM: Updated Swagger definition aligns with model changesThe updated embedded Swagger specification string reflects the API model changes, which is necessary for consistent API documentation. This change aligns with the PR's objective to support nested visibility models.
api/spec/src/productcatalog/routes.tsp (2)
189-189: Changes to use the new OpenMeter.Rest namespace for model creationThe request body type changes from
TypeSpec.Rest.Resource.ResourceCreateModel<PlanAddon>toOpenMeter.Rest.ResourceCreateModel<PlanAddon>, which aligns with the new REST utility for nested visibility models that this PR introduces.
210-210: Consistent use of OpenMeter.Rest namespace for model updatesThe request body type changes from
TypeSpec.Rest.Resource.ResourceReplaceModel<PlanAddon>toOpenMeter.Rest.ResourceUpdateModel<PlanAddon>, completing the transition to the custom REST utility that supports nested visibility filtering.api/spec/src/billing/profile.tsp (2)
149-149: Consistent use of fully qualified namespaceThe
workflowproperty type is updated to use the fully qualifiedTypeSpec.Rest.Resourcenamespace, ensuring consistency within this file.
144-144:Details
❓ Verification inconclusive
Different namespace pattern compared to productcatalog routes
While the productcatalog routes file has been updated to use the new
OpenMeter.Restnamespace for resource models, this file explicitly uses the fully qualifiedTypeSpec.Rest.Resourcenamespace.This inconsistency may indicate an incomplete migration. Consider if this file should also be updated to use the new
OpenMeter.Restnamespace in a follow-up PR, as mentioned in the PR objectives about migrating allTypeSpec.Restmodels toOpenMeter.Rest.Also applies to: 168-168
🏁 Script executed:
#!/bin/bash # Check for other files that still use TypeSpec.Rest.Resource vs those using OpenMeter.Rest echo "Files using TypeSpec.Rest.Resource:" rg -l "TypeSpec\.Rest\.Resource\." api/spec/src/ echo -e "\nFiles using OpenMeter.Rest:" rg -l "OpenMeter\.Rest\." api/spec/src/Length of output: 575
ACTION: Update namespace usage for consistency
The file
api/spec/src/billing/profile.tsp(lines 144 and 168) still uses the oldTypeSpec.Rest.Resourcenamespace, whereas theapi/spec/src/productcatalog/routes.tspfile has already migrated to theOpenMeter.Restnamespace. A repository-wide scan confirms that several files (likemeters.tsp,customer.tsp,subscription.tsp, etc.) are still usingTypeSpec.Rest.Resource, with only the productcatalog routes updated.Please verify if the migration objective to update all resource models to
OpenMeter.Restapplies here. If it does, consider updating this file in a follow-up PR to maintain consistency across the codebase.api/client/javascript/src/client/schemas.ts (3)
7237-7237: Schema rename aligns with simplified model structure.This schema rename from
PlanAddonReplaceUpdatetoPlanAddonUpdatereflects the API model simplification described in the PR. The new model only focuses on essential update fields (fromPlanPhaseand optionalmaxQuantity), matching the Go implementation inapi/api.gen.go.
9786-9786: Type alias update is consistent with schema rename.The type alias update correctly reflects the schema name change from
PlanAddonReplaceUpdatetoPlanAddonUpdate, ensuring type consistency throughout the client code.
19023-19023: Request body content type updated properly.The request body content type for the update operation now correctly references the renamed
PlanAddonUpdateschema, completing the model migration.api/spec/src/billing/invoices.tsp (1)
505-505: Namespace qualification refactor is correct and safe.The update from
Rest.ResourcetoTypeSpec.Rest.Resourceis a non-breaking, clarity-improving change. No issues found.Also applies to: 536-536, 555-555, 564-564, 570-570, 624-624
e6e5d31 to
65d2bd7
Compare
TODO in a followup PR: migrate all
TypeSpec.Restmodels toOpenMeter.Restthat supports nested visibilities.Summary by CodeRabbit
New Features
Refactor
Style
Chores