Update SDK
Goal
Regenerate @relewise/client models and declaration types from the main Swagger source and deliver a validated PR to main.
Required Input
Require a Trello card URL before running SDK update work.
If the prompt does not include a Trello URL, ask for it first and do not continue until provided.
Preflight Git Safety
Run commands from repository root.
- •Require a strict clean worktree:
git status --porcelain
Abort when any output exists.
- •Ensure
originexists:
git remote get-url origin
Abort on failure.
- •Fetch refs:
git fetch origin --prune
Abort on failure.
- •Switch to
main:
git switch main
Abort if switch is not safe.
- •Fast-forward local
main:
git pull --ff-only origin main
Abort if not fast-forward or if pull fails.
Do not continue when any preflight step fails.
Branch Creation
Use a timestamped branch (date + hour + minute):
$stamp = Get-Date -Format 'yyyyMMdd-HHmm' $branchName = "chore/update-sdk-$stamp"
Abort if branch exists locally or remotely:
git show-ref --verify --quiet "refs/heads/$branchName" git ls-remote --exit-code --heads origin $branchName
Create and switch:
git switch -c $branchName
SDK Regeneration (Main Swagger Source)
Run commands from repository root using package-prefixed commands:
- •Install dependencies:
npm --prefix .\packages\client ci
- •Regenerate API models/types from the main Swagger URL:
npm --prefix .\packages\client run gen-api
gen-api must use:
https://api.relewise.com/public/swagger.json
through packages/client/package.json.
Notes:
- •Do not use
gen-api-devfor normal SDK updates. - •
gen-apialso runsfix-exports.js, which patchessrc/models/data-contracts.tsto exportUtilRequiredKeys.
Expected Changes Check
Before validation, inspect changed files and ensure updates are coherent.
Expected change locations:
- •
packages/client/src/models/*generated byswagger-typescript-api - •
packages/client/src/models/data-contracts.tsexport patch effect fromfix-exports.js - •lockfile/package metadata changes only when intentionally caused by install/update work
If unrelated files changed unexpectedly, stop and investigate before proceeding.
Validation (Required)
Run validation in packages/client and treat failures as blocking unless the user explicitly accepts known failures.
- •Build:
npm --prefix .\packages\client run build
- •Build declaration types:
npm --prefix .\packages\client run build:types
- •Unit tests:
npm --prefix .\packages\client test
- •Optional integration tests (when secrets are available or explicitly requested):
npm --prefix .\packages\client run integration-test --DATASET_ID=... --API_KEY=... --SERVER_URL=https://api.relewise.com
If secrets are unavailable, report integration tests as not run.
Acceptance Criteria
Treat the SDK update as successful only when:
- •
npm run gen-apisucceeds using the main Swagger URL - •
npm --prefix .\packages\client run buildsucceeds - •
npm --prefix .\packages\client run build:typessucceeds - •
npm --prefix .\packages\client testsucceeds - •changed files are expected and reviewable
Commit, Push, and Pull Request
- •Commit SDK update changes on the update branch.
- •Push branch:
git push -u origin $branchName
- •Create PR to
main.
Preferred automated flow with GitHub CLI:
$prBodyPath = ".\\update-sdk-pr-body.md"
$prBodyTemplate = @'
__TRELLO_CARD_URL__
## Summary
- Regenerated `@relewise/client` from main Swagger URL
- <key model/type changes>
## Validation
- `npm run gen-api`: <result>
- `npm --prefix .\packages\client run build`: <result>
- `npm --prefix .\packages\client run build:types`: <result>
- `npm --prefix .\packages\client test`: <result>
- `npm --prefix .\packages\client run integration-test`: <result or not run>
## Notes
- <known issues or limitations>
'@
$prBody = $prBodyTemplate -replace '__TRELLO_CARD_URL__', $TrelloCardUrl
Set-Content -Path $prBodyPath -Value $prBody -Encoding utf8
$prUrl = gh pr create --base main --head $branchName --title "chore(client): update sdk from swagger ($stamp)" --body-file $prBodyPath
if ($LASTEXITCODE -ne 0) { throw 'gh pr create failed.' }
Write-Host "PR URL: $prUrl"
Manual fallback:
git push -u origin $branchName Write-Host "Create PR: https://github.com/Relewise/relewise-sdk-javascript/compare/main...$branchName?expand=1" Write-Host "PR title: chore(client): update sdk from swagger ($stamp)" Write-Host "PR body file: $prBodyPath"
Keep the Trello URL as the first line in PR description. Write the PR body file as UTF-8 to avoid symbol corruption in GitHub-rendered text.
Output Expectations
Provide a final summary with:
- •Trello URL used
- •branch name
- •changed file groups
- •key generated model/type updates
- •results for each validation command
- •pushed branch URL
- •PR URL, or exact manual fallback instructions when automated PR creation is unavailable