Files
dcrouter/ts_interfaces/readme.md

8.6 KiB

@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/. 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/ account to submit Pull Requests directly.

Installation

pnpm add @serve.zone/dcrouter-interfaces

Or import directly from the main package:

import { data, requests } from '@serve.zone/dcrouter/interfaces';

Usage

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
import * as typedrequest from '@api.global/typedrequest';

const statsClient = new typedrequest.TypedRequest<requests.IReq_GetServerStatistics>(
  'https://your-dcrouter:3000/typedrequest',
  'getServerStatistics'
);

const stats = await statsClient.fire({
  identity,
  includeHistory: true,
  timeRange: '24h'
});

Module Structure

Data Interfaces (data)

Core data types used throughout the DcRouter system:

IIdentity

Authentication identity for API requests:

interface IIdentity {
  jwt: string;           // JWT token
  userId: string;        // Unique user ID
  name: string;          // Display name
  expiresAt: number;     // Token expiration timestamp
  role?: string;         // User role (e.g., 'admin')
  type?: string;         // Identity type
}

Statistics Interfaces

Interface Description
IServerStats Uptime, memory, CPU, connection counts
IEmailStats Sent/received/bounced/queued/failed, delivery & bounce rates
IDnsStats Total queries, cache hits/misses, query types
IRateLimitInfo Domain rate limit status (current rate, limit, remaining)
ISecurityMetrics Blocked IPs, spam/malware/phishing counts
IConnectionInfo Connection ID, remote address, protocol, state, bytes
IQueueStatus Queue name, size, processing/failed/retrying counts
IHealthStatus Healthy flag, uptime, per-service status map
INetworkMetrics Bandwidth, connection counts, top endpoints
ILogEntry Timestamp, level, category, message, metadata

Request Interfaces (requests)

TypedRequest interfaces for the OpsServer API, organized by domain:

🔐 Authentication

Interface Method Description
IReq_AdminLoginWithUsernameAndPassword adminLogin Authenticate as admin
IReq_AdminLogout adminLogout End admin session
IReq_VerifyIdentity verifyIdentity Verify JWT token validity

📊 Statistics

Interface Method Description
IReq_GetServerStatistics getServerStatistics Overall server stats
IReq_GetEmailStatistics getEmailStatistics Email throughput metrics
IReq_GetDnsStatistics getDnsStatistics DNS query stats
IReq_GetRateLimitStatus getRateLimitStatus Rate limit status
IReq_GetSecurityMetrics getSecurityMetrics Security event metrics
IReq_GetActiveConnections getActiveConnections Active connection list
IReq_GetQueueStatus getQueueStatus Email queue status
IReq_GetHealthStatus getHealthStatus System health check
IReq_GetCombinedMetrics getCombinedMetrics All metrics in one request

⚙️ Configuration

Interface Method Description
IReq_GetConfiguration getConfiguration Current config (read-only)

📜 Logs

Interface Method Description
IReq_GetRecentLogs getLogs Retrieve system logs
IReq_GetLogStream getLogStream Stream live logs

📧 Email Operations

Interface Method Description
IReq_GetQueuedEmails getQueuedEmails List queued emails
IReq_GetSentEmails getSentEmails List delivered emails
IReq_GetFailedEmails getFailedEmails List failed emails
IReq_ResendEmail resendEmail Re-queue a failed email
IReq_GetSecurityIncidents getSecurityIncidents Security events
IReq_GetBounceRecords getBounceRecords Bounce records
IReq_RemoveFromSuppressionList removeFromSuppressionList Unsuppress an address

📡 RADIUS

Interface Method Description
IReq_GetRadiusClients getRadiusClients List NAS clients
IReq_SetRadiusClient setRadiusClient Add/update a NAS client
IReq_RemoveRadiusClient removeRadiusClient Remove a NAS client
IReq_GetVlanMappings getVlanMappings List VLAN mappings
IReq_SetVlanMapping setVlanMapping Add/update VLAN mapping
IReq_RemoveVlanMapping removeVlanMapping Remove VLAN mapping
IReq_TestVlanAssignment testVlanAssignment Test what VLAN a MAC gets
IReq_GetRadiusSessions getRadiusSessions List active sessions
IReq_DisconnectRadiusSession disconnectRadiusSession Force disconnect
IReq_GetRadiusStatistics getRadiusStatistics RADIUS stats
IReq_GetRadiusAccountingSummary getRadiusAccountingSummary Accounting summary

Example: Full API Integration

import * as typedrequest from '@api.global/typedrequest';
import { data, requests } from '@serve.zone/dcrouter-interfaces';

// 1. Login
const loginClient = new typedrequest.TypedRequest<requests.IReq_AdminLoginWithUsernameAndPassword>(
  'https://your-dcrouter:3000/typedrequest',
  'adminLogin'
);

const loginResponse = await loginClient.fire({
  username: 'admin',
  password: 'your-password'
});
const identity = loginResponse.identity;

// 2. Fetch combined metrics
const metricsClient = new typedrequest.TypedRequest<requests.IReq_GetCombinedMetrics>(
  'https://your-dcrouter:3000/typedrequest',
  'getCombinedMetrics'
);

const metrics = await metricsClient.fire({ identity });
console.log('Server:', metrics.serverStats);
console.log('Email:', metrics.emailStats);
console.log('DNS:', metrics.dnsStats);
console.log('Security:', metrics.securityMetrics);

// 3. Check email queues
const queueClient = new typedrequest.TypedRequest<requests.IReq_GetQueuedEmails>(
  'https://your-dcrouter:3000/typedrequest',
  'getQueuedEmails'
);

const queued = await queueClient.fire({ identity });
console.log('Queued emails:', queued.emails.length);

This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the 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.