Skip to content

fix(api): preserve parameter shapes across CLI inputs - #12

Merged
cb-muthiahm merged 2 commits into
mainfrom
fix/api-parameter-shapes
Oct 12, 2026
Merged

cb-muthiahm merged 2 commits into
mainfrom
fix/api-parameter-shapes

Conversation

@cb-muthiahm

@cb-muthiahm cb-muthiahm commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Build one canonical parameter object from -d flags and JSON stdin, including nested bracket paths, indexed arrays, and Chargebee's field-first indexed format.
  • Preserve form values at indexed leaves and filter arrays; support JSON and simple string array shorthand for scalar arrays. Type JSON-body scalar flags from operation schemas without changing string IDs.
  • Flatten GET parameters immediately before the SDK call to work around the pinned Node SDK's sibling-key serializer bug. Keep canonical nested parameters for code samples.
  • Pass operation metadata from the command generator and regenerate API commands. Document array input forms.

This addresses P1–P6 in the request-parameter reference. The Node SDK bug underlying P4 still needs an upstream fix; the CLI workaround makes its generated GET commands send the intended keys.

Verification

  • bun test src/tests/unit/lib/api/params.test.ts src/tests/unit/lib/api/stdin-params.encoding.test.ts src/tests/unit/lib/codesample/index.test.ts src/tests/integration/stdin-params.test.ts — 86 passed
  • bun run typecheck — passed
  • bun run test:coverage and bun run coverage:gate /private/tmp/chargebee-params-coverage.txt — passed; all 78 covered files meet the 95% gate
  • bun run build and bun run build:npm — passed
  • Verified old/new CLI code samples for nested export filters, JSON array indexes, JSON scalar typing, and scalar array shorthand

Adds shared parsing for -d flags and JSON stdin, including nested paths, indexed arrays, and scalar-array shorthand. Uses operation schemas to type JSON-body values. Flattens GET parameters for SDK requests while preserving nested parameters for code samples. Updates command generation, tests, and README guidance.

@snyk-io

snyk-io Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 37158431-ca2c-4190-9221-07c65dc87e6c

📥 Commits

Reviewing files that changed from the base of the PR and between d7e29ae and 2c93c26.


⛔ Files ignored due to path filters (82)
  • src/commands/generated/addon.ts is excluded by !**/generated/**
  • src/commands/generated/address.ts is excluded by !**/generated/**
  • src/commands/generated/alert.ts is excluded by !**/generated/**
  • src/commands/generated/alert_status.ts is excluded by !**/generated/**
  • src/commands/generated/attached_item.ts is excluded by !**/generated/**
  • src/commands/generated/business_entity.ts is excluded by !**/generated/**
  • src/commands/generated/business_rule.ts is excluded by !**/generated/**
  • src/commands/generated/business_ruleset.ts is excluded by !**/generated/**
  • src/commands/generated/card.ts is excluded by !**/generated/**
  • src/commands/generated/comment.ts is excluded by !**/generated/**
  • src/commands/generated/configuration.ts is excluded by !**/generated/**
  • src/commands/generated/coupon.ts is excluded by !**/generated/**
  • src/commands/generated/coupon_code.ts is excluded by !**/generated/**
  • src/commands/generated/coupon_set.ts is excluded by !**/generated/**
  • src/commands/generated/credit_note.ts is excluded by !**/generated/**
  • src/commands/generated/credit_unit.ts is excluded by !**/generated/**
  • src/commands/generated/currency.ts is excluded by !**/generated/**
  • src/commands/generated/customer.ts is excluded by !**/generated/**
  • src/commands/generated/customer_entitlement.ts is excluded by !**/generated/**
  • src/commands/generated/differential_price.ts is excluded by !**/generated/**
  • src/commands/generated/dispute.ts is excluded by !**/generated/**
  • src/commands/generated/einvoice.ts is excluded by !**/generated/**
  • src/commands/generated/email_log.ts is excluded by !**/generated/**
  • src/commands/generated/entitlement.ts is excluded by !**/generated/**
  • src/commands/generated/entitlement_override.ts is excluded by !**/generated/**
  • src/commands/generated/estimate.ts is excluded by !**/generated/**
  • src/commands/generated/event.ts is excluded by !**/generated/**
  • src/commands/generated/export.ts is excluded by !**/generated/**
  • src/commands/generated/feature.ts is excluded by !**/generated/**
  • src/commands/generated/gift.ts is excluded by !**/generated/**
  • src/commands/generated/grant_block.ts is excluded by !**/generated/**
  • src/commands/generated/hosted_page.ts is excluded by !**/generated/**
  • src/commands/generated/in_app_subscription.ts is excluded by !**/generated/**
  • src/commands/generated/invoice.ts is excluded by !**/generated/**
  • src/commands/generated/item.ts is excluded by !**/generated/**
  • src/commands/generated/item_entitlement.ts is excluded by !**/generated/**
  • src/commands/generated/item_family.ts is excluded by !**/generated/**
  • src/commands/generated/item_price.ts is excluded by !**/generated/**
  • src/commands/generated/ledger_account_balance.ts is excluded by !**/generated/**
  • src/commands/generated/ledger_operation.ts is excluded by !**/generated/**
  • src/commands/generated/meter.ts is excluded by !**/generated/**
  • src/commands/generated/metered_feature.ts is excluded by !**/generated/**
  • src/commands/generated/non_subscription.ts is excluded by !**/generated/**
  • src/commands/generated/offer_event.ts is excluded by !**/generated/**
  • src/commands/generated/offer_fulfillment.ts is excluded by !**/generated/**
  • src/commands/generated/omnichannel_one_time_order.ts is excluded by !**/generated/**
  • src/commands/generated/omnichannel_subscription.ts is excluded by !**/generated/**
  • src/commands/generated/omnichannel_subscription_item.ts is excluded by !**/generated/**
  • src/commands/generated/order.ts is excluded by !**/generated/**
  • src/commands/generated/payment_intent.ts is excluded by !**/generated/**
  • src/commands/generated/payment_schedule.ts is excluded by !**/generated/**
  • src/commands/generated/payment_schedule_scheme.ts is excluded by !**/generated/**
  • src/commands/generated/payment_source.ts is excluded by !**/generated/**
  • src/commands/generated/payment_voucher.ts is excluded by !**/generated/**
  • src/commands/generated/personalized_offer.ts is excluded by !**/generated/**
  • src/commands/generated/plan.ts is excluded by !**/generated/**
  • src/commands/generated/portal_session.ts is excluded by !**/generated/**
  • src/commands/generated/price_variant.ts is excluded by !**/generated/**
  • src/commands/generated/pricing_page_session.ts is excluded by !**/generated/**
  • src/commands/generated/promotional_credit.ts is excluded by !**/generated/**
  • src/commands/generated/promotional_grant.ts is excluded by !**/generated/**
  • src/commands/generated/purchase.ts is excluded by !**/generated/**
  • src/commands/generated/quote.ts is excluded by !**/generated/**
  • src/commands/generated/quote_entitlement.ts is excluded by !**/generated/**
  • src/commands/generated/ramp.ts is excluded by !**/generated/**
  • src/commands/generated/recorded_purchase.ts is excluded by !**/generated/**
  • src/commands/generated/resource_migration.ts is excluded by !**/generated/**
  • src/commands/generated/rule.ts is excluded by !**/generated/**
  • src/commands/generated/site_migration_detail.ts is excluded by !**/generated/**
  • src/commands/generated/subscription.ts is excluded by !**/generated/**
  • src/commands/generated/subscription_entitlement.ts is excluded by !**/generated/**
  • src/commands/generated/time_machine.ts is excluded by !**/generated/**
  • src/commands/generated/transaction.ts is excluded by !**/generated/**
  • src/commands/generated/unbilled_charge.ts is excluded by !**/generated/**
  • src/commands/generated/usage.ts is excluded by !**/generated/**
  • src/commands/generated/usage_charge.ts is excluded by !**/generated/**
  • src/commands/generated/usage_event.ts is excluded by !**/generated/**
  • src/commands/generated/usage_file.ts is excluded by !**/generated/**
  • src/commands/generated/usage_summary.ts is excluded by !**/generated/**
  • src/commands/generated/vaulted_payment_method.ts is excluded by !**/generated/**
  • src/commands/generated/virtual_bank_account.ts is excluded by !**/generated/**
  • src/commands/generated/webhook_endpoint.ts is excluded by !**/generated/**

📒 Files selected for processing (9)
  • README.md
  • src/lib/api/params.ts
  • src/lib/api/stdin-params.ts
  • src/lib/codesample/index.ts
  • src/tests/integration/stdin-params.test.ts
  • src/tests/unit/lib/api/params.test.ts
  • src/tests/unit/lib/api/stdin-params.encoding.test.ts
  • src/tests/unit/lib/codesample/index.test.ts
  • src/tools/generate.ts

🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:


Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.



Walkthrough

The CLI now shares parameter-path parsing and nested-value construction across data flags and stdin. Operation metadata enables schema-based typing for JSON input, while generated GET calls flatten parameters and encode selected arrays for SDK requests. README instructions were revised for setup, JSON output, code samples, listeners, and feedback.

Changes

Parameter parsing and SDK calls

Layer / File(s) Summary
Canonical parameter parsing
src/lib/api/params.ts, src/lib/api/stdin-params.ts, src/lib/codesample/index.ts, src/tests/unit/lib/api/params.test.ts, src/tests/unit/lib/api/stdin-params.encoding.test.ts, src/tests/unit/lib/codesample/index.test.ts
Shared helpers validate bracket paths and build nested parameter values. Code-sample and stdin parsing use the shared helpers. Tests cover array shorthand, indexed values, conflicts, duplicate paths, and invalid indexes.
Operation-aware JSON typing
src/lib/api/params.ts, src/lib/api/stdin-params.ts, src/tools/generate.ts, src/tests/unit/lib/api/params.test.ts, src/tests/unit/lib/api/stdin-params.encoding.test.ts
Operation options select catalog parameter schemas for JSON-input scalar typing. Generated operations pass method, JSON-input, operation-ID, and catalog-version metadata when loading parameters.
GET parameter adaptation and generated calls
src/lib/api/params.ts, src/tools/generate.ts, src/tests/unit/lib/api/params.test.ts, src/tests/unit/lib/api/stdin-params.encoding.test.ts, src/tests/integration/stdin-params.test.ts
GET parameters flatten into bracketed keys. Arrays for selected filters and list requests are JSON-encoded. Generated GET calls use the adapter; tests cover query and export filters.

README instructions

Layer / File(s) Summary
Command and setup documentation
README.md
The README revises installation and credential instructions, adds JSON-output and webhook-listener examples, and updates code-sample, configuration, and feedback guidance. It removes detailed operation-help, code-sample validation, and JSON output-format documentation.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GeneratedOperation
  participant loadOperationParams
  participant resolveOperationParams
  participant buildParams
  participant toSdkParams
  participant SDK
  GeneratedOperation->>loadOperationParams: pass operation options and data flags
  loadOperationParams->>resolveOperationParams: resolve parameters
  resolveOperationParams->>buildParams: assemble bracket paths
  buildParams-->>resolveOperationParams: return nested parameters
  resolveOperationParams-->>loadOperationParams: return resolved parameters
  loadOperationParams-->>GeneratedOperation: return loaded parameters
  GeneratedOperation->>toSdkParams: adapt GET parameters
  toSdkParams-->>GeneratedOperation: return SDK parameters
  GeneratedOperation->>SDK: call operation
Loading

Suggested reviewers: cb-logesh

Merge Risk: ⚪ Minimal · up to 2c93c

The change preserves parameter shapes across CLI inputs and no concrete merge-blocking risk was identified.

🚥 Pre-merge checks | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 8 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 8 files. (1 skipped: 1 unsupported.)



  • Fix all pre-merge checks with AI
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Test coverage

✅ Gate passed — all 78 files are at or above the 95% floor.

Status Metric Coverage Threshold
✅ Functions 99.90% 95%
✅ Lines 99.50% 95%

@cb-muthiahm cb-muthiahm reopened this Oct 12, 2026
@cb-muthiahm
cb-muthiahm merged commit 224ed2f into main Oct 12, 2026
60 checks passed
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