Files
dcrouter/ts_interfaces/readme.md

175 lines
6.5 KiB
Markdown

# @serve.zone/dcrouter-interfaces
TypeScript interfaces and type definitions for the DCRouter OpsServer API. 📡
This module provides strongly-typed interfaces for communicating with the DCRouter OpsServer via TypedRequest. Use these interfaces for type-safe API interactions in your frontend applications or integration code.
## Issue Reporting and Security
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
## Installation
```bash
npm install @serve.zone/dcrouter-interfaces --save
# or
pnpm add @serve.zone/dcrouter-interfaces
```
## Usage
```typescript
import { data, requests } from '@serve.zone/dcrouter-interfaces';
// Use data interfaces for type definitions
const identity: data.IIdentity = {
jwt: 'your-jwt-token',
userId: 'user-123',
name: 'Admin User',
expiresAt: Date.now() + 3600000,
role: 'admin'
};
// Use request interfaces for API calls
const statsRequest: requests.IReq_GetServerStatistics = {
method: 'getServerStatistics',
request: {
identity,
includeHistory: true,
timeRange: '24h'
},
response: null // Will be populated by the response
};
```
## Module Structure
### Data Interfaces (`data`)
Core data types used throughout the DCRouter system:
#### `IIdentity`
Authentication identity for API requests:
```typescript
interface IIdentity {
jwt: string; // JWT token for authentication
userId: string; // Unique user identifier
name: string; // Display name
expiresAt: number; // Token expiration timestamp
role?: string; // User role (e.g., 'admin')
type?: string; // Identity type
}
```
#### Statistics Interfaces
- `IServerStats` - Overall server statistics
- `IEmailStats` - Email throughput and delivery metrics
- `IDnsStats` - DNS query statistics
- `IRateLimitInfo` - Rate limiting status
- `ISecurityMetrics` - Security event metrics
- `IConnectionInfo` - Active connection details
- `IQueueStatus` - Email queue status
- `IHealthStatus` - System health information
### Request Interfaces (`requests`)
TypedRequest interfaces for the OpsServer API:
#### Statistics Requests
| Interface | Method | Description |
|-----------|--------|-------------|
| `IReq_GetServerStatistics` | `getServerStatistics` | Get overall server stats |
| `IReq_GetEmailStatistics` | `getEmailStatistics` | Get email throughput stats |
| `IReq_GetDnsStatistics` | `getDnsStatistics` | Get DNS query stats |
| `IReq_GetRateLimitStatus` | `getRateLimitStatus` | Check rate limit status |
| `IReq_GetSecurityMetrics` | `getSecurityMetrics` | Get security event metrics |
| `IReq_GetActiveConnections` | `getActiveConnections` | List active connections |
| `IReq_GetQueueStatus` | `getQueueStatus` | Get email queue status |
| `IReq_GetHealthStatus` | `getHealthStatus` | System health check |
#### Admin Requests
| Interface | Method | Description |
|-----------|--------|-------------|
| `IReq_AdminLogin` | `adminLogin` | Authenticate as admin |
| `IReq_AdminLogout` | `adminLogout` | End admin session |
| `IReq_VerifyIdentity` | `verifyIdentity` | Verify JWT token |
#### Configuration Requests
| Interface | Method | Description |
|-----------|--------|-------------|
| `IReq_GetConfiguration` | `getConfiguration` | Get current config (read-only) |
#### Log Requests
| Interface | Method | Description |
|-----------|--------|-------------|
| `IReq_GetLogs` | `getLogs` | Retrieve system logs |
#### RADIUS Requests
| Interface | Method | Description |
|-----------|--------|-------------|
| `IReq_GetRadiusSessions` | `getRadiusSessions` | List RADIUS sessions |
| `IReq_GetRadiusClients` | `getRadiusClients` | List RADIUS clients |
#### Email Operations
| Interface | Method | Description |
|-----------|--------|-------------|
| `IReq_GetEmailQueues` | `getEmailQueues` | Get email queue details |
| `IReq_RetryEmail` | `retryEmail` | Retry failed email |
## Example: Complete API Integration
```typescript
import * as typedrequest from '@api.global/typedrequest';
import { data, requests } from '@serve.zone/dcrouter-interfaces';
// Create typed request client
const client = new typedrequest.TypedRequest<requests.IReq_AdminLogin>(
'https://your-dcrouter:3000/typedrequest',
'adminLogin'
);
// Login to get identity
const loginResponse = await client.fire({
username: 'admin',
password: 'your-password'
});
const identity = loginResponse.identity;
// Now use identity for authenticated requests
const statsClient = new typedrequest.TypedRequest<requests.IReq_GetServerStatistics>(
'https://your-dcrouter:3000/typedrequest',
'getServerStatistics'
);
const stats = await statsClient.fire({
identity,
includeHistory: true,
timeRange: '24h'
});
console.log('Server stats:', stats.stats);
console.log('History:', stats.history);
```
## License and Legal Information
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](../LICENSE) file.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
### Company Information
Task Venture Capital GmbH
Registered at District Court Bremen HRB 35230 HB, Germany
For any legal inquiries or further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.