Support include=planName on List User Plans - #201
Conversation
GET /2.0/users/{userId}/plans gained an optional `include` query
parameter whose only accepted value is `planNames`. When requested, each
returned plan carries the name of its owning organization.
- `ListUserPlansQueryParameters` gains `include`, typed as the string
literal union `'planNames'` rather than an array. The published contract
is a single comma-separated parameter, and an array type would imply
repeating the parameter instead. Axios serializes the value verbatim, so
no per-call handling is needed.
- Each plan in `ListUserPlansResponse` gains `planName`. It is optional:
absent unless the enrichment is requested, and absent for a plan whose
owning organization has no name, so it is undefined in both cases. The
HTTP layer passes the parsed JSON body through untouched, so no
deserialization mapping is required. A TSDoc note records that
organization names are cached for roughly four hours downstream, so a
recently renamed organization may briefly report its previous name.
Mock tests cover the query parameter, a plan with a name, and a plan
without one, plus the required-properties case where the field is absent.
They depend on `planName` being added to the List User Plans
all-properties mapping in smartsheet-sdk-tests, which must merge first.
📝 WalkthroughWalkthrough
ChangesUser plan name inclusion
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/mock-api/users/common_test_constants.ts (1)
55-56: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMove these endpoint-specific constants into
test/mock-api/users/list_user_plans.spec.ts.
TEST_INCLUDE_PLAN_NAMESandTEST_PLAN_NAMEare only referenced by the user-plan list spec, so keep them file-scoped there and reservetest/mock-api/users/common_test_constants.tsfor constants shared by multiple users endpoint tests.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/mock-api/users/common_test_constants.ts` around lines 55 - 56, Move TEST_INCLUDE_PLAN_NAMES and TEST_PLAN_NAME from common_test_constants.ts into list_user_plans.spec.ts, keeping them file-scoped there. Remove their shared-file exports and update any references in the list-user-plans spec to use the local constants, while leaving genuinely shared constants unchanged.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/mock-api/users/common_test_constants.ts`:
- Around line 55-56: Move TEST_INCLUDE_PLAN_NAMES and TEST_PLAN_NAME from
common_test_constants.ts into list_user_plans.spec.ts, keeping them file-scoped
there. Remove their shared-file exports and update any references in the
list-user-plans spec to use the local constants, while leaving genuinely shared
constants unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: d0fcebe6-ecc5-4770-a046-14ac44708584
📒 Files selected for processing (4)
CHANGELOG.mdlib/users/types.tstest/mock-api/users/common_test_constants.tstest/mock-api/users/list_user_plans.spec.ts
The public API's include value is singular `planName`, matching the response field it controls. The gateway rewrites it to the downstream's plural spelling, so no SDK-side bridging is needed.
| * plan with the name of its owning organization. An unrecognized value, or | ||
| * the same value more than once, returns a 400. | ||
| */ | ||
| include?: 'planName'; |
There was a problem hiding this comment.
We cannot define include as a string with a strict value because once we add more options to it then we won't be able to cleanly upgrade it. The better approach is to define it as:
| include?: 'planName'; | |
| include?: string | list[ListUserPlansInclusion]; |
where ListUserPlansInclusion is enum with the available options.
Then in the list user plans function we need to manually join the values if include is a list.
Summary
GET /2.0/users/{userId}/plansgained an optionalincludequery parameter whose only accepted value isplanName, matching the response field it controls. When requested, each returned plan carries the name of the organization that owns it. This adds SDK type support for both halves of that change.ListUserPlansQueryParametersgainsinclude?: 'planName'.ListUserPlansResponse.data[]gainsplanName?: string.Omitting
includeis byte-identical to today's behavior: the parameter is optional, nothing is added to the query string, and the response type only gains an optional field. This is purely additive and backward compatible.Design note:
includeis a string union, not an arrayincludeis typed as the string literal union'planName'rather than'planName'[]. This is deliberate. The published contract is a single comma-separated parameter (?include=planName). An array type would serialize asinclude[]=planNameunder axios's defaultparamsSerializer, which this repo does not override — the wrong wire format. Typing it as a string keeps serialization correct with no per-call handling, since axios passes the value through verbatim.planNameis optional because it is absent in two distinct cases: when the enrichment is not requested, and when the owning organization has no name. Both surface asundefined. The HTTP layer passes the parsed JSON body through untouched, so no deserialization mapping was required.A TSDoc
@remarksnote records that organization names are cached for roughly four hours downstream, so a recently renamed organization may briefly report its previous name. This is expected behavior rather than an SDK issue, and callers who cache or display the value should know about it.Files changed
lib/users/types.ts—includeon the query parameters,planNameon the response plan item, both with TSDoc.test/mock-api/users/common_test_constants.ts— addsTEST_INCLUDE_PLAN_NAMEandTEST_PLAN_NAME.test/mock-api/users/list_user_plans.spec.ts— assertsincludeis sent in the request params, thatplanNameis populated on an enriched plan, and that it isundefinedboth for a plan whose organization has no name and in the required-properties case.CHANGELOG.md— two entries under Unreleased / Added.Testing
Mock API tests depend on
planNamebeing present in the List User Plans all-properties mapping insmartsheet/smartsheet-sdk-tests. That mapping change has merged, so these tests run green against the currentmainlineof that repo.Full suite against the mock API: 2084 passed / 2084 total across 90 suites, 0 skipped, 0 failed.
npm run lintreports 0 errors,npm run formatpasses, andtsc --noEmitandnpm run buildboth succeed.Summary by CodeRabbit
New Features
Bug Fixes
Security
Documentation