@dimrev4/audit-core
v0.0.4
Published
OpenAPI client for @dimrev4/audit-core
Downloads
19
Maintainers
Readme
@dimrev4/audit-core SDK
TypeScript SDK for Audit Core API - OpenTelemetry-compliant tracing and audit logging client.
🚀 Features
- 🕵️ Start, Update, and End Traces
- 📝 Add Events to Traces
- 🔐 Secure Access with API Key Authentication
- 💪 100% TypeScript with full type safety
- ⚡ Axios-based with interceptors support
📦 Installation
npm install @dimrev4/audit-core
# or
yarn add @dimrev4/audit-core
# or
pnpm add @dimrev4/audit-core🔧 Quick Start
1. Setup
import { Configuration, TraceV1Api } from '@dimrev4/audit-core';
const config = new Configuration({
basePath: 'https://api.yourdomain.com',
apiKey: 'your-api-key',
});
const traceApi = new TraceV1Api(config);2. Start a Trace
const startResponse = await traceApi.traceControllerStartTrace({
name: 'CheckoutService.charge',
kind: 'server',
attributes: {
'user.id': '12345',
'order.id': 'order-abc',
},
});
const { traceId, spanId } = startResponse.data;
console.log(`Trace started: ${traceId}, Span: ${spanId}`);3. Add an Event
await traceApi.traceControllerAddEvent(traceId, {
name: 'card.validated',
attributes: {
'card.type': 'visa',
},
});4. End a Trace
await traceApi.traceControllerEndTrace(traceId, {
status: 'OK',
});🏗️ API Overview
Trace (TraceV1Api)
POST /v1/traces/start- Start a new tracePOST /v1/traces/{traceId}/event- Add an event to a tracePOST /v1/traces/{traceId}/end- End a trace
🧪 Error Handling
import { AxiosError } from 'axios';
try {
await traceApi.traceControllerStartTrace({ name: 'test-trace' });
} catch (error) {
if (error instanceof AxiosError) {
switch (error.response?.status) {
case 400:
console.error('Validation failed:', error.response.data.message);
break;
case 401:
console.error('Unauthorized: Invalid API Key');
break;
case 404:
console.error('Trace not found');
break;
default:
console.error('API Error:', error.message);
}
}
}⚙️ Advanced Configuration
Custom Axios Instance
import axios from 'axios';
import { Configuration, TraceV1Api } from '@dimrev4/audit-core';
const axiosInstance = axios.create({
timeout: 15000,
});
const config = new Configuration({
apiKey: process.env.AUDIT_API_KEY,
});
const traceApi = new TraceV1Api(config, undefined, axiosInstance);🚨 Common Issues
| Issue | Solution | | ---------------------- | ------------------------------------- | | 401 Unauthorized | Check apiKey in Configuration | | 404 Not Found | Verify traceId is correct and active | | Validation Error (400) | Check request body against DTO schema |
🔗 Resources
- API Docs: Available at /api endpoint (Swagger UI)
- Repository: GitHub
- Issues: GitHub Issues
- License: Unlicense
🤝 Contributing
- Fork the repository
- Update OpenAPI spec for new features
- Run npm run generate to rebuild SDK
- Submit pull request with tests
Auto-generated from Audit Core API | Last Updated: Jan 2026
