This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
TypeScript SDK library for interacting with the Replicated Vendor Portal API. Published as replicated-lib on npm. Used by GitHub Actions and other automation tools to manage applications, releases, channels, customers, and test clusters in the Replicated platform.
Build
npm run build # Compile TypeScript to dist/Testing
npm test # Run all tests with coverageCode Formatting
npm run prettier # Format all TypeScript filesRunning Examples
Examples demonstrate SDK usage and are in examples/. They compile to JS and run:
npm run create-object-store # Create object store addon on cluster
npm run create-postgres # Create postgres addon
npm run expose-port # Expose cluster port
npm run poll-airgap # Poll for airgap build status
npm run test-list-customers # Test customer listingExamples require REPLICATED_API_TOKEN environment variable and command-line arguments (e.g., cluster ID).
VendorPortalApi - Central configuration class for all API interactions:
endpoint: API base URL (default:https://api.replicated.com/vendor/v3)apiToken: Authentication token (required)client(): Returns configured HTTP client with headers
All API modules receive a VendorPortalApi instance as their first parameter. The client automatically adds GitHub Actions metadata headers when running in CI.
Each domain has its own file in src/ with:
- Type definitions and classes
- Async functions that take
VendorPortalApias first param - Error handling with descriptive messages
applications.ts - Application management
getApplicationDetails(): Get app ID from slug
channels.ts - Release channel operations
createChannel(),getChannelDetails(),archiveChannel()pollForAirgapReleaseStatus(),getDownloadUrlAirgapBuildRelease()
clusters.ts - Test cluster lifecycle
createCluster(),createClusterWithLicense(),removeCluster(),upgradeCluster()pollForStatus(): Wait for cluster readinessgetKubeconfig(): Download cluster kubeconfigcreateAddonObjectStore(),exposeClusterPort(): Cluster addonsgetClusterVersions(): List available versions
customers.ts - Customer and license management
createCustomer(),archiveCustomer()listCustomersByName(),listCustomersByEmail()getUsedKubernetesDistributions(): Analytics data
releases.ts - Release management
createRelease(),createReleaseFromChart(): Create releasespromoteRelease(): Promote to channelreportCompatibilityResult(): Report cluster compatibility
All exports are re-exported through src/index.ts.
Unit Tests - Co-located with source (*.spec.ts)
- Use Jest with esbuild-jest for fast TypeScript compilation
- Run with
npm test
Contract Tests - Pact framework in pacts/
- Consumer:
npm_consumer - Provider:
vp_service - Configuration in
pacts/configuration.tssets up global provider - Contract file:
pacts/npm_consumer-vp_service.json
Tests run with --setupFiles ./pacts/configuration.ts to initialize Pact globally.
API Call Pattern:
export async function someFunction(vendorPortalApi: VendorPortalApi, ...args): Promise<ReturnType> {
const http = await vendorPortalApi.client();
const uri = `${vendorPortalApi.endpoint}/some/path`;
const res = await http.get(uri);
if (res.message.statusCode != 200) {
await res.readBody(); // discard body
throw new Error(`Failed to ...: Server responded with ${res.message.statusCode}`);
}
const body = JSON.parse(await res.readBody());
return body;
}Polling Pattern:
Functions like pollForStatus() and pollForAddonStatus() use async loops with delays to wait for resource readiness. They throw errors on timeout or failure states.
- Node Version: Requires Node.js >=20.0.0
- HTTP Client: Uses
@actions/http-client(GitHub Actions toolkit) - Output: CommonJS modules in
dist/directory - Entry Point:
dist/index.jswith types atdist/index.d.ts - Prettier Config: 300 char line width, 2 space tabs, no trailing commas
- TypeScript: ES2017 target, CommonJS modules, declaration files generated