Skip to content

Support include=planName on List User Plans - #201

Open
adecounter wants to merge 2 commits into
smartsheet:mainlinefrom
adecounter:personal/adecounter/add-include-plan-names
Open

Support include=planName on List User Plans#201
adecounter wants to merge 2 commits into
smartsheet:mainlinefrom
adecounter:personal/adecounter/add-include-plan-names

Conversation

@adecounter

@adecounter adecounter commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

GET /2.0/users/{userId}/plans gained an optional include query parameter whose only accepted value is planName, 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.

  • ListUserPlansQueryParameters gains include?: 'planName'.
  • Each item in ListUserPlansResponse.data[] gains planName?: string.

Omitting include is 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: include is a string union, not an array

include is 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 as include[]=planName under axios's default paramsSerializer, 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.

planName is 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 as undefined. The HTTP layer passes the parsed JSON body through untouched, so no deserialization mapping was required.

A TSDoc @remarks note 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.tsinclude on the query parameters, planName on the response plan item, both with TSDoc.
  • test/mock-api/users/common_test_constants.ts — adds TEST_INCLUDE_PLAN_NAME and TEST_PLAN_NAME.
  • test/mock-api/users/list_user_plans.spec.ts — asserts include is sent in the request params, that planName is populated on an enriched plan, and that it is undefined both 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 planName being present in the List User Plans all-properties mapping in smartsheet/smartsheet-sdk-tests. That mapping change has merged, so these tests run green against the current mainline of that repo.

Full suite against the mock API: 2084 passed / 2084 total across 90 suites, 0 skipped, 0 failed. npm run lint reports 0 errors, npm run format passes, and tsc --noEmit and npm run build both succeed.

Summary by CodeRabbit

  • New Features

    • Added support for requesting plan names when listing user plans.
    • List responses can now include an optional plan name for each plan.
  • Bug Fixes

    • Fixed duplicated sharing-request query parameters.
    • Added support for PATCH requests.
  • Security

    • Upgraded Axios and addressed transitive development-dependency security issues.
  • Documentation

    • Updated the unreleased changelog with these improvements.

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.
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

listUserPlans now supports include=planName and can return an optional planName. Mock API tests cover named plans and plans without names. The changelog records this and other unreleased updates.

Changes

User plan name inclusion

Layer / File(s) Summary
Plan listing contract
lib/users/types.ts, CHANGELOG.md
listUserPlans accepts include=planName. Response items can include the optional planName field. The changelog records this and other unreleased updates.
Plan listing test coverage
test/mock-api/users/common_test_constants.ts, test/mock-api/users/list_user_plans.spec.ts
Tests send the new query parameter and validate named plans, omitted names, and required response properties.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • smartsheet/smartsheet-python-sdk#162 — Covers the same include=planName support and optional plan name response field.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding include=planName support to List User Plans.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/mock-api/users/common_test_constants.ts (1)

55-56: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Move these endpoint-specific constants into test/mock-api/users/list_user_plans.spec.ts.

TEST_INCLUDE_PLAN_NAMES and TEST_PLAN_NAME are only referenced by the user-plan list spec, so keep them file-scoped there and reserve test/mock-api/users/common_test_constants.ts for 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5c4fb0e and 5f1c578.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • lib/users/types.ts
  • test/mock-api/users/common_test_constants.ts
  • test/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.
@adecounter adecounter changed the title Support include=planNames on List User Plans Support include=planName on List User Plans Aug 7, 2026
Comment thread lib/users/types.ts
* plan with the name of its owning organization. An unrecognized value, or
* the same value more than once, returns a 400.
*/
include?: 'planName';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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.

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