Skip to content

fix(sdk): add missing methods - #4501

Merged
tothandras merged 1 commit into
mainfrom
feat/typescript-sdk-methods
Jun 10, 2026
Merged

tothandras merged 1 commit into
mainfrom
feat/typescript-sdk-methods

Conversation

@tothandras

@tothandras tothandras commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added CSV export option for meter query results.
    • Added ability to update external settlement for credit grants.
    • Introduced settlement mode option for subscriptions (credit-only or credit-then-invoice billing).
  • Documentation

    • Updated README with new operations and improved formatting.

@tothandras
tothandras requested a review from a team as a code owner June 10, 2026 12:16
@tothandras tothandras added the release-note/bug-fix Release note: Bug Fixes label Jun 10, 2026
@coderabbitai

coderabbitai Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR enhances the TypeSpec SDK generator to support text-based responses (enabling CSV exports) and adds three new API features: meter CSV querying, credit grant external settlement updates, and subscription settlement mode. The core infrastructure work refactors operation generation to properly handle friendly names, body overrides, and content-type variants across the generated JavaScript client.

Changes

SDK Generation and API Client Enhancements

Layer / File(s) Summary
Text response support in SDK generator
api/spec/packages/typespec-typescript/src/sdk-operations.ts, src/request-types.ts, src/sdk-files.ts
SDK operations now expose textResponseContentType for text payloads (e.g., text/csv). Request generation conditionally adds Accept headers, response parsing switches to .text(), and response type declarations become string for text-based operations.
Core operation generation with body overrides and naming
api/spec/packages/typespec-typescript/src/sdk-operations.ts
sdkOperation accepts a bodyOverrides map to handle JSON body variants across content-type splits, uses getFriendlyName for operation identity precedence, and improves method name tokenization via resource-word logic. successBody helper now returns both type and content type for downstream processing.
Operation base naming with friendly name support
api/spec/packages/typespec-typescript/src/ZodOperations.tsx, src/emitter.tsx
operationBaseName prioritizes @friendlyName over operationId to ensure content-type variants map to distinct SDK operations. Emitter now passes bodyOverrides to operation generation.
Meter CSV query feature
api/spec/packages/aip-client-javascript/src/funcs/meters.ts, src/models/operations/meters.ts, src/models/schemas.ts, src/sdk/meters.ts, README.md
New queryMeterCsv operation POSTs to /openmeter/meters/{meterId}/query with Accept: text/csv header and returns the CSV response as a string. Includes operation types, Zod schemas, function, SDK wrapper, and docs.
Credit grant external settlement feature
api/spec/packages/aip-client-javascript/src/funcs/customers.ts, src/models/operations/customers.ts, src/sdk/customers.ts, README.md
New updateCreditGrantExternalSettlement operation POSTs to /credits/grants/{creditGrantId}/settlement/external with response typed as CreditGrant. Includes operation types, function, SDK wrapper, and docs.
Subscription and plan settlement_mode field
api/spec/packages/aip-client-javascript/src/models/types.ts, src/models/schemas.ts, src/models/operations/subscriptions.ts, src/index.ts
Adds required settlement_mode enum (credit_then_invoice | credit_only) to SubscriptionCreate, Subscription, SubscriptionChange, and Plan. Introduces optional *Input variants. Zod schemas include defaults. Operation type aliases updated to use Input types, and public exports extended.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • openmeterio/openmeter#4205: Main PR adding JS client support for queryMeterCsv targeting the same /openmeter/meters/{meterId}/query endpoint for CSV output.
  • openmeterio/openmeter#4196: Server-side implementation adding the QueryMeterCSV handler and Accept-based routing for text/csv responses that this PR's client code consumes.

Suggested labels

kind/feature

Suggested reviewers

  • rolosp
  • chrisgacsal
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(sdk): add missing methods' accurately summarizes the core changes—new SDK methods were added for customer credit grant settlements, meter CSV queries, and subscription input type exports across the JavaScript SDK.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/typescript-sdk-methods

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.

@tothandras
tothandras enabled auto-merge (squash) June 10, 2026 12:25
@tothandras
tothandras merged commit dc07897 into main Jun 10, 2026
28 of 32 checks passed
@tothandras
tothandras deleted the feat/typescript-sdk-methods branch June 10, 2026 12:25

This branch was previously deployed

1 inactive deployment
dev — 7136bd09 Deployed Jun 10, 2026 by tothandras via Migration Checks #14903
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants