@riventa/sdk
v1.0.1
Published
Official Riventa.Dev SDK for JavaScript and TypeScript
Maintainers
Readme
@riventa/sdk
Official JavaScript/TypeScript SDK for Riventa.Dev — AI-powered DevOps platform.
Installation
npm install @riventa/sdk
# or
yarn add @riventa/sdkQuick Start
import { RiventaClient } from '@riventa/sdk';
const client = new RiventaClient({
apiKey: 'riv_your_api_key_here',
});
// List your projects
const { data: projects } = await client.projects.list();
console.log(projects);
// Trigger an AI code review
const { data: review } = await client.reviews.trigger({
projectId: 'proj_abc123',
pullRequestNumber: 42,
});
console.log(review.summary);Projects
// List all projects
const { data } = await client.projects.list();
// Get a specific project
const { data: project } = await client.projects.get('proj_abc123');
// Connect a repository
const { data: connected } = await client.projects.connect({
repoUrl: 'https://github.com/user/repo',
provider: 'github',
});
// Get project status
const { data: status } = await client.projects.status('proj_abc123');Reviews
// Trigger an AI code review
const { data: review } = await client.reviews.trigger({
projectId: 'proj_abc123',
pullRequestNumber: 42,
branch: 'feature/new-ui',
});
// List reviews
const { data: reviews } = await client.reviews.list({ projectId: 'proj_abc123' });
// Get a specific review
const { data } = await client.reviews.get('rev_xyz789');
// Send feedback on a review
await client.reviews.feedback('rev_xyz789', {
rating: 'helpful',
comment: 'Great suggestions',
});Deployments
// List deployments
const { data: deployments } = await client.deployments.list({
projectId: 'proj_abc123',
limit: 10,
});
// Trigger a deployment
const { data: deploy } = await client.deployments.trigger({
projectId: 'proj_abc123',
environment: 'production',
branch: 'main',
});
// Get deployment details
const { data } = await client.deployments.get('dep_456');
// Rollback
await client.deployments.rollback({ deploymentId: 'dep_456' });
// Stream logs
const { data: logs } = await client.deployments.logs('dep_456');Security
// Run a security scan
const { data: scan } = await client.security.scan({
projectId: 'proj_abc123',
scanType: 'comprehensive',
});
// Get security score
const { data: score } = await client.security.getScore();
// Dependency scan
const { data } = await client.security.scanDependencies('proj_abc123');
// SAST scan
const { data: sast } = await client.security.scanSast('proj_abc123');Error Handling
The SDK throws typed errors for different HTTP status codes:
import { AuthenticationError, RateLimitError } from '@riventa/sdk';
try {
await client.projects.list();
} catch (error) {
if (error instanceof AuthenticationError) {
// 401 — invalid or expired API key
} else if (error instanceof RateLimitError) {
// 429 — retry after error.retryAfter seconds
}
}| Error Class | Status | Description |
|-------------|--------|-------------|
| AuthenticationError | 401 | Invalid or expired API key |
| ForbiddenError | 403 | Insufficient permissions |
| NotFoundError | 404 | Resource not found |
| RateLimitError | 429 | Rate limit exceeded |
| ServerError | 500 | Internal server error |
Observability
The SDK also includes modules for error tracking, analytics, feature flags, and performance monitoring:
const client = new RiventaClient({
apiKey: 'riv_...',
projectId: 'proj_abc123',
});
// Error tracking
client.errors.setupGlobalHandler();
client.captureError(new Error('Something went wrong'));
// Analytics
client.track('deploy_started', { environment: 'production' });
// Feature flags
const enabled = await client.isEnabled('new-feature');
// Performance
client.performance.startTimer('api-call');
await fetch('/api/data');
client.performance.endTimer('api-call');Configuration
const client = new RiventaClient({
apiKey: 'riv_...', // Required — your API key
projectId: 'proj_...', // Optional — default project
baseUrl: 'https://riventa.dev/api', // Optional — API base URL
environment: 'production', // Optional — 'development' | 'staging' | 'production'
debug: false, // Optional — enable debug logging
});Health Check
// Full health response
const { data } = await client.health();
console.log(data.status, data.version);
// Simple boolean check
const ok = await client.healthCheck();Documentation
Full documentation at riventa.dev/developers/sdk
License
MIT
