changed types around

This commit is contained in:
Bojan Kucera 2025-06-03 17:52:02 -04:00
parent 24e82bbb78
commit f61d1aa0c3
75 changed files with 3625 additions and 34314 deletions

File diff suppressed because one or more lines are too long

View file

@ -218,7 +218,7 @@ WS /ws # WebSocket for strategy updates
### **3. Shared Packages**
#### **Shared Types** (`packages/shared-types`)
#### **Shared Types** (`packages/types`)
```typescript
export interface MarketData {
symbol: string;

View file

@ -54,7 +54,7 @@ apps/
### **Shared Packages**
```
packages/
├── shared-types/ # TypeScript type definitions
├── types/ # TypeScript type definitions
├── config/ # Configuration management
├── database/ # Database utilities (planned)
└── trading-core/ # Core trading logic (planned)

View file

@ -77,7 +77,7 @@ apps/
### Shared Packages
```
packages/
├── shared-types/ # TypeScript definitions
├── types/ # TypeScript definitions
├── config/ # Configuration management
├── database/ # (Future) Database utilities
└── trading-core/ # (Future) Core trading logic

View file

@ -10,7 +10,7 @@ This document outlines the changes made to improve separation of concerns in the
## New Libraries
### 1. `@stock-bot/shared-types`
### 1. `@stock-bot/types`
Domain-specific type definitions organized by functional area:
- `market/` - Market data structures (OHLCV, OrderBook, etc.)
- `trading/` - Trading types (Orders, Positions, etc.)

View file

@ -30,7 +30,7 @@
"dotenv": "^16.3.0",
"@stock-bot/http-client": "*",
"@stock-bot/config": "*",
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"@stock-bot/event-bus": "*",
"@stock-bot/utils": "*"
},

View file

@ -1,6 +1,6 @@
import Redis from 'ioredis';
import { databaseConfig } from '@stock-bot/config';
import type { MarketDataEvent, SignalEvent, TradingEvent } from '@stock-bot/shared-types';
import type { MarketDataEvent, SignalEvent, TradingEvent } from '@stock-bot/types';
export class EventPublisher {
private dragonfly: Redis;

View file

@ -1,4 +1,4 @@
import type { MarketData, OHLCV, MarketDataEvent } from '@stock-bot/shared-types';
import type { MarketData, OHLCV, MarketDataEvent } from '@stock-bot/types';
import { dataProviderConfigs } from '@stock-bot/config';
import { EventPublisher } from './EventPublisher';
import { DataNormalizer } from './DataNormalizer';

View file

@ -1,3 +1,5 @@
// Market Data Gateway Types - Consolidated and organized
// Market Data Types
export interface MarketDataTick {
symbol: string;
@ -34,6 +36,18 @@ export interface MarketDataCandle {
trades?: number;
}
export interface MarketDataTrade {
id: string;
symbol: string;
timestamp: number;
price: number;
size: number;
side: 'buy' | 'sell';
source: string;
exchange?: string;
conditions?: string[];
}
export interface MarketDataOrder {
id: string;
symbol: string;
@ -47,18 +61,6 @@ export interface MarketDataOrder {
level?: number;
}
export interface MarketDataTrade {
id: string;
symbol: string;
timestamp: number;
price: number;
size: number;
side: 'buy' | 'sell';
source: string;
exchange?: string;
conditions?: string[];
}
// Data Source Configuration
export interface DataSourceConfig {
id: string;
@ -129,6 +131,36 @@ export interface ProcessingPipeline {
};
}
// Data Processing Pipeline
export interface DataProcessor {
id: string;
name: string;
type: 'enrichment' | 'validation' | 'normalization' | 'aggregation' | 'filter';
enabled: boolean;
priority: number;
config: Record<string, any>;
process(data: MarketDataTick | MarketDataCandle | MarketDataTrade): Promise<any>;
}
export interface ProcessingPipeline {
id: string;
name: string;
processors: DataProcessor[];
inputFilter: {
symbols?: string[];
sources?: string[];
dataTypes?: string[];
};
outputTargets: {
eventBus?: boolean;
database?: boolean;
cache?: boolean;
websocket?: boolean;
dataProcessor?: boolean;
featureStore?: boolean;
};
}
// Subscription Management
export interface SubscriptionRequest {
id: string;
@ -200,94 +232,29 @@ export interface GatewayConfig {
monitoring: {
metrics: {
enabled: boolean;
port: number;
path: string;
};
logging: {
level: 'debug' | 'info' | 'warn' | 'error';
format: 'json' | 'text';
outputs: ('console' | 'file' | 'elasticsearch')[];
intervalMs: number;
retention: string;
};
alerts: {
enabled: boolean;
thresholds: {
latencyMs: number;
errorRate: number;
latency: number;
connectionLoss: number;
};
};
};
}
// WebSocket Message Types
export interface WebSocketMessage {
type: 'subscribe' | 'unsubscribe' | 'data' | 'error' | 'heartbeat' | 'status';
id?: string;
timestamp: number;
payload: any;
}
export interface WebSocketSubscribeMessage extends WebSocketMessage {
type: 'subscribe';
payload: {
symbols: string[];
dataTypes: string[];
filters?: Record<string, any>;
};
}
export interface WebSocketDataMessage extends WebSocketMessage {
type: 'data';
payload: {
dataType: string;
data: MarketDataTick | MarketDataCandle | MarketDataTrade | MarketDataOrder;
};
}
// Error Handling
export interface DataSourceError {
sourceId: string;
timestamp: Date;
type: 'connection' | 'authentication' | 'ratelimit' | 'data' | 'timeout';
message: string;
details?: Record<string, any>;
severity: 'low' | 'medium' | 'high' | 'critical';
}
export interface ProcessingError {
processorId: string;
pipelineId: string;
timestamp: Date;
data: any;
error: string;
stackTrace?: string;
}
// Metrics and Monitoring
export interface DataSourceMetrics {
sourceId: string;
timestamp: Date;
connections: {
active: number;
total: number;
failed: number;
};
messages: {
received: number;
processed: number;
errors: number;
dropped: number;
};
latency: {
avgMs: number;
p50Ms: number;
p95Ms: number;
p99Ms: number;
};
bandwidth: {
inboundBytesPerSecond: number;
outboundBytesPerSecond: number;
};
status: 'connected' | 'disconnected' | 'error';
messagesReceived: number;
bytesReceived: number;
latencyMs: number;
errorCount: number;
lastUpdate: Date;
}
export interface GatewayMetrics {
@ -316,52 +283,6 @@ export interface GatewayMetrics {
};
}
// Service Integration
export interface ServiceIntegration {
serviceName: string;
endpoint: string;
healthCheck: string;
authentication?: {
type: 'apikey' | 'jwt' | 'basic';
credentials: Record<string, string>;
};
retryPolicy: {
maxRetries: number;
backoffMs: number;
};
}
export interface DataProcessorIntegration extends ServiceIntegration {
serviceName: 'data-processor';
supportedOperations: ('ingest' | 'transform' | 'validate' | 'quality')[];
}
export interface FeatureStoreIntegration extends ServiceIntegration {
serviceName: 'feature-store';
supportedOperations: ('compute' | 'store' | 'retrieve')[];
}
export interface DataCatalogIntegration extends ServiceIntegration {
serviceName: 'data-catalog';
supportedOperations: ('register' | 'lineage' | 'quality' | 'governance')[];
}
// Event Bus Integration
export interface EventBusMessage {
id: string;
type: string;
source: string;
timestamp: Date;
data: any;
metadata?: Record<string, any>;
}
export interface MarketDataEvent extends EventBusMessage {
type: 'market.tick' | 'market.trade' | 'market.candle' | 'market.orderbook';
source: 'market-data-gateway';
data: MarketDataTick | MarketDataTrade | MarketDataCandle | MarketDataOrder;
}
// Health Check
export interface HealthStatus {
service: string;
@ -382,3 +303,42 @@ export interface HealthStatus {
avgLatencyMs: number;
};
}
// WebSocket Types
export interface WebSocketMessage {
type: string;
payload: any;
timestamp: number;
id?: string;
}
export interface WebSocketSubscribeMessage extends WebSocketMessage {
type: 'subscribe';
payload: SubscriptionRequest;
}
export interface WebSocketDataMessage extends WebSocketMessage {
type: 'data';
payload: MarketDataTick | MarketDataTrade | MarketDataCandle | MarketDataOrder;
}
// Error Types
export interface DataSourceError {
sourceId: string;
timestamp: Date;
type: 'connection' | 'authentication' | 'ratelimit' | 'data' | 'timeout';
message: string;
details?: Record<string, any>;
severity: 'low' | 'medium' | 'high' | 'critical';
recoverable: boolean;
}
// Event Types
export interface MarketDataEvent {
id: string;
type: 'market.tick' | 'market.trade' | 'market.candle' | 'market.orderbook';
source: 'market-data-gateway';
timestamp: Date;
data: MarketDataTick | MarketDataTrade | MarketDataCandle | MarketDataOrder;
metadata?: Record<string, any>;
}

View file

@ -12,7 +12,7 @@
"hono": "^4.6.3",
"ioredis": "^5.4.1",
"@stock-bot/config": "*",
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"ws": "^8.18.0"
},
"devDependencies": {

View file

@ -13,7 +13,7 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@stock-bot/shared-types": "workspace:*",
"@stock-bot/types": "workspace:*",
"@stock-bot/utils": "workspace:*",
"@stock-bot/event-bus": "workspace:*",
"@stock-bot/api-client": "workspace:*",

View file

@ -12,7 +12,7 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"@stock-bot/event-bus": "*",
"@stock-bot/utils": "*",
"@stock-bot/api-client": "*",

View file

@ -12,7 +12,7 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"@stock-bot/event-bus": "*",
"@stock-bot/utils": "*",
"@stock-bot/api-client": "*",

View file

@ -10,7 +10,7 @@
"test:watch": "bun test --watch src/tests/**/*.test.ts"
}, "dependencies": {
"hono": "^4.6.3",
"@stock-bot/shared-types": "workspace:*",
"@stock-bot/types": "workspace:*",
"@stock-bot/utils": "workspace:*",
"@stock-bot/event-bus": "workspace:*",
"@stock-bot/api-client": "workspace:*",

View file

@ -1,12 +1,12 @@
import { EventEmitter } from 'events';
import { OHLCV } from '@stock-bot/shared-types';
import { Order, Position } from '@stock-bot/shared-types';
import { OHLCV } from '@stock-bot/types';
import { Order, Position } from '@stock-bot/types';
import { createLogger } from '@stock-bot/utils';
import { financialUtils } from '@stock-bot/utils';
const logger = createLogger('backtest-engine');
// Use OHLCV from shared-types as BarData equivalent
// Use OHLCV from types as BarData equivalent
export type BarData = OHLCV;
// Strategy interface to match existing pattern

View file

@ -12,7 +12,7 @@
"dependencies": {
"hono": "^4.6.3",
"@stock-bot/config": "*",
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"ws": "^8.18.0"
},
"devDependencies": {

View file

@ -11,7 +11,7 @@
"hono": "^4.6.3",
"ioredis": "^5.4.1",
"@stock-bot/config": "*",
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"ws": "^8.18.0",
"node-cron": "^3.0.3",
"axios": "^1.6.2"

View file

@ -20,7 +20,7 @@
"@stock-bot/config": "*",
"@stock-bot/event-bus": "*",
"@stock-bot/http-client": "*",
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"@stock-bot/utils": "*",
"bull": "^4.12.0",
"compression": "^1.7.4",
@ -55,7 +55,7 @@
"version": "1.0.0",
"dependencies": {
"@stock-bot/config": "*",
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"hono": "^4.6.3",
"ioredis": "^5.4.1",
"ws": "^8.18.0",
@ -71,7 +71,7 @@
"dependencies": {
"@stock-bot/api-client": "workspace:*",
"@stock-bot/event-bus": "workspace:*",
"@stock-bot/shared-types": "workspace:*",
"@stock-bot/types": "workspace:*",
"@stock-bot/utils": "workspace:*",
"cron": "^3.1.6",
"elasticsearch": "^16.7.3",
@ -93,7 +93,7 @@
"dependencies": {
"@stock-bot/api-client": "*",
"@stock-bot/event-bus": "*",
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"@stock-bot/utils": "*",
"axios": "^1.6.2",
"bull": "^4.12.2",
@ -118,7 +118,7 @@
"dependencies": {
"@stock-bot/api-client": "*",
"@stock-bot/event-bus": "*",
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"@stock-bot/utils": "*",
"compression": "^1.7.4",
"cors": "^2.8.5",
@ -150,7 +150,7 @@
"@stock-bot/api-client": "workspace:*",
"@stock-bot/config": "*",
"@stock-bot/event-bus": "workspace:*",
"@stock-bot/shared-types": "workspace:*",
"@stock-bot/types": "workspace:*",
"@stock-bot/utils": "workspace:*",
"axios": "^1.6.2",
"hono": "^4.6.3",
@ -166,7 +166,7 @@
"version": "1.0.0",
"dependencies": {
"@stock-bot/config": "*",
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"hono": "^4.6.3",
"ws": "^8.18.0",
},
@ -180,7 +180,7 @@
"version": "1.0.0",
"dependencies": {
"@stock-bot/config": "*",
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"axios": "^1.6.2",
"hono": "^4.6.3",
"ioredis": "^5.4.1",
@ -232,7 +232,7 @@
"name": "@stock-bot/api-client",
"version": "1.0.0",
"dependencies": {
"@stock-bot/shared-types": "workspace:*",
"@stock-bot/types": "workspace:*",
"axios": "^1.6.0",
},
"devDependencies": {
@ -262,7 +262,7 @@
"name": "@stock-bot/event-bus",
"version": "1.0.0",
"dependencies": {
"@stock-bot/shared-types": "workspace:*",
"@stock-bot/types": "workspace:*",
"ioredis": "^5.3.2",
},
"devDependencies": {
@ -286,8 +286,8 @@
"typescript": "^5.3.0",
},
},
"libs/shared-types": {
"name": "@stock-bot/shared-types",
"libs/types": {
"name": "@stock-bot/types",
"version": "1.0.0",
"devDependencies": {
"typescript": "^5.4.5",
@ -298,7 +298,7 @@
"version": "1.0.0",
"dependencies": {
"@stock-bot/config": "workspace:*",
"@stock-bot/shared-types": "workspace:*",
"@stock-bot/types": "workspace:*",
"date-fns": "^2.30.0",
},
"devDependencies": {
@ -763,7 +763,7 @@
"@stock-bot/market-data-gateway": ["@stock-bot/market-data-gateway@workspace:apps/core-services/market-data-gateway"],
"@stock-bot/shared-types": ["@stock-bot/shared-types@workspace:libs/shared-types"],
"@stock-bot/types": ["@stock-bot/types@workspace:libs/types"],
"@stock-bot/utils": ["@stock-bot/utils@workspace:libs/utils"],

View file

@ -157,7 +157,7 @@ Market Data Gateway
├── ✅ Hono (Web framework)
├── ✅ ioredis (Redis client)
├── ✅ @stock-bot/config (Workspace package)
├── ✅ @stock-bot/shared-types (Workspace package)
├── ✅ @stock-bot/types (Workspace package)
└── ✅ ws (WebSocket library)
Trading Dashboard

View file

@ -6,12 +6,12 @@ This guide describes how the project architecture has been improved to better se
We've reorganized the project's shared libraries for improved maintainability:
### 1. Shared Types (`@stock-bot/shared-types`)
### 1. Shared Types (`@stock-bot/types`)
Types are now organized by domain:
```
libs/shared-types/
libs/types/
├── src/
│ ├── market/ # Market data types (OHLCV, OrderBook)
│ ├── trading/ # Trading types (Orders, Positions)

View file

@ -8,8 +8,8 @@ This guide will help you migrate your service to use the new library structure f
```diff
"dependencies": {
- "@stock-bot/shared-types": "workspace:*",
+ "@stock-bot/shared-types": "workspace:*",
- "@stock-bot/types": "workspace:*",
+ "@stock-bot/types": "workspace:*",
+ "@stock-bot/utils": "workspace:*",
+ "@stock-bot/event-bus": "workspace:*",
+ "@stock-bot/api-client": "workspace:*",
@ -20,10 +20,10 @@ This guide will help you migrate your service to use the new library structure f
2. Update your imports to use the domain-specific modules:
```diff
- import { OHLCV, Strategy, Order } from '@stock-bot/shared-types';
+ import { OHLCV } from '@stock-bot/shared-types';
+ import { Strategy } from '@stock-bot/shared-types';
+ import { Order } from '@stock-bot/shared-types';
- import { OHLCV, Strategy, Order } from '@stock-bot/types';
+ import { OHLCV } from '@stock-bot/types';
+ import { Strategy } from '@stock-bot/types';
+ import { Order } from '@stock-bot/types';
```
For logging:
@ -48,7 +48,7 @@ For event-based communication:
```diff
- // Manual Redis/Dragonfly usage
+ import { createEventBus } from '@stock-bot/event-bus';
+ import { MarketDataEvent } from '@stock-bot/shared-types';
+ import { MarketDataEvent } from '@stock-bot/types';
+
+ const eventBus = createEventBus({
+ redisHost: process.env.REDIS_HOST || 'localhost',
@ -64,12 +64,12 @@ For event-based communication:
```typescript
// Before
import { Strategy, BacktestConfig } from '@stock-bot/shared-types';
import { Strategy, BacktestConfig } from '@stock-bot/types';
import Redis from 'ioredis';
// After
import { Strategy } from '@stock-bot/shared-types';
import { BacktestConfig } from '@stock-bot/shared-types';
import { Strategy } from '@stock-bot/types';
import { BacktestConfig } from '@stock-bot/types';
import { createLogger } from '@stock-bot/utils';
import { createEventBus } from '@stock-bot/event-bus';
@ -88,8 +88,8 @@ If your turbo.json configuration references specific packages, update the depend
"backtest": {
"dependsOn": [
"^build",
- "packages/shared-types#build"
+ "libs/shared-types#build",
- "packages/types#build"
+ "libs/types#build",
+ "libs/utils#build",
+ "libs/event-bus#build",
+ "libs/api-client#build"

View file

@ -11,7 +11,7 @@
"test": "jest"
},
"dependencies": {
"@stock-bot/shared-types": "workspace:*",
"@stock-bot/types": "workspace:*",
"axios": "^1.6.0"
},
"devDependencies": {

View file

@ -1,5 +1,5 @@
import { BaseApiClient } from './BaseApiClient';
import { ApiResponse, BacktestConfig, BacktestResult } from '@stock-bot/shared-types';
import { ApiResponse, BacktestConfig, BacktestResult } from '@stock-bot/types';
/**
* Client for interacting with the Backtest Engine service

View file

@ -1,5 +1,5 @@
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
import { ApiResponse } from '@stock-bot/shared-types';
import { ApiResponse } from '@stock-bot/types';
/**
* Base API client that all service clients extend

View file

@ -1,5 +1,5 @@
import { BaseApiClient } from './BaseApiClient';
import { ApiResponse, Strategy } from '@stock-bot/shared-types';
import { ApiResponse, Strategy } from '@stock-bot/types';
/**
* Client for interacting with the Strategy Orchestrator service

View file

@ -5,7 +5,7 @@ A Redis-based event bus implementation for inter-service communication in the st
## Features
- Publish/subscribe pattern for asynchronous messaging
- Support for typed events based on `@stock-bot/shared-types`
- Support for typed events based on `@stock-bot/types`
- Reliable message delivery
- Channel-based subscriptions
@ -13,7 +13,7 @@ A Redis-based event bus implementation for inter-service communication in the st
```typescript
import { createEventBus } from '@stock-bot/event-bus';
import { MarketDataEvent } from '@stock-bot/shared-types';
import { MarketDataEvent } from '@stock-bot/types';
// Create an event bus instance
const eventBus = createEventBus({

View file

@ -11,7 +11,7 @@
"test": "jest"
},
"dependencies": {
"@stock-bot/shared-types": "workspace:*",
"@stock-bot/types": "workspace:*",
"ioredis": "^5.3.2"
},
"devDependencies": {

View file

@ -1,5 +1,5 @@
import Redis from 'ioredis';
import { Event } from '@stock-bot/shared-types';
import { Event } from '@stock-bot/types';
export type EventHandler<T extends Event = Event> = (event: T) => Promise<void> | void;

View file

@ -3,8 +3,10 @@
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src",
"declaration": true
"declaration": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": false,
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
"exclude": ["node_modules", "dist", "**/*.test.ts"]
}

View file

@ -1,5 +1,5 @@
import { EventEmitter } from 'eventemitter3';
import type {
import {
HttpClientConfig,
RequestConfig,
HttpResponse,
@ -123,12 +123,12 @@ export class BunHttpClient extends EventEmitter {
private mergeConfig(config: RequestConfig): RequestConfig {
return {
...config,
timeout: this.defaultConfig.timeout,
retries: this.defaultConfig.retries,
headers: { ...this.defaultConfig.headers, ...config.headers },
validateStatus: this.defaultConfig.validateStatus,
url: this.buildUrl(config.url),
...config
};
}

View file

@ -1,12 +1,11 @@
import { EventEmitter } from 'eventemitter3';
import type {
import {
RetryConfig,
RequestConfig,
HttpResponse,
HttpClientError,
TimeoutError,
RetryExhaustedError
} from './types';
import { TimeoutError } from './types';
export class RetryHandler extends EventEmitter {
private config: Required<RetryConfig>;

View file

@ -14,7 +14,7 @@ This library contains domain-specific TypeScript type definitions used across th
## Usage
```typescript
import { OHLCV, MarketData } from '@stock-bot/shared-types';
import { OHLCV, MarketData } from '@stock-bot/types';
// Use the types
const marketData: MarketData = {

View file

@ -1,5 +1,5 @@
{
"name": "@stock-bot/shared-types",
"name": "@stock-bot/types",
"version": "1.0.0",
"description": "Domain-specific shared TypeScript definitions for the trading bot",
"main": "dist/index.js",

View file

@ -7,7 +7,7 @@ export interface ServiceConfig {
dependencies?: string[];
}
export interface HealthStatus {
export interface ApiHealthStatus {
service: string;
status: 'healthy' | 'unhealthy' | 'degraded';
timestamp: Date;

View file

@ -0,0 +1,5 @@
// Communication and Messaging Types
export * from './websocket';
export * from './subscriptions';
export * from './messages';
export * from './protocols';

View file

@ -0,0 +1,152 @@
// Message Queue and Event Types
export interface EventBusMessage {
id: string;
type: string;
source: string;
timestamp: Date;
data: any;
metadata?: MessageMetadata;
headers?: Record<string, string>;
correlationId?: string;
causationId?: string;
}
export interface MessageMetadata {
version?: string;
schemaVersion?: string;
contentType?: string;
encoding?: string;
priority?: MessagePriority;
retryCount?: number;
maxRetries?: number;
expiresAt?: Date;
partitionKey?: string;
}
export enum MessagePriority {
LOW = 'low',
NORMAL = 'normal',
HIGH = 'high',
CRITICAL = 'critical'
}
export interface QueueMessage extends EventBusMessage {
queueName: string;
routingKey?: string;
deliveryAttempts: number;
firstDeliveryAt?: Date;
lastDeliveryAt?: Date;
deadLetterReason?: string;
}
export interface MessageBatch {
id: string;
messages: EventBusMessage[];
batchSize: number;
createdAt: Date;
expiresAt?: Date;
metadata?: Record<string, any>;
}
export interface MessageHandler {
id: string;
name: string;
eventTypes: string[];
handler: (message: EventBusMessage) => Promise<void>;
config: HandlerConfig;
status: HandlerStatus;
metrics: HandlerMetrics;
}
export interface HandlerConfig {
concurrency?: number;
retryAttempts?: number;
retryDelay?: number;
deadLetterQueue?: string;
timeout?: number;
batchSize?: number;
filters?: MessageFilter[];
}
export enum HandlerStatus {
ACTIVE = 'active',
PAUSED = 'paused',
ERROR = 'error',
STOPPED = 'stopped'
}
export interface HandlerMetrics {
messagesProcessed: number;
messagesSuccess: number;
messagesError: number;
avgProcessingTime: number;
lastProcessed: Date;
errorRate: number;
}
export interface MessageFilter {
field: string;
operator: 'equals' | 'not_equals' | 'contains' | 'regex' | 'in' | 'not_in';
value: any;
logicalOperator?: 'AND' | 'OR';
}
export interface DeadLetterMessage extends QueueMessage {
originalQueue: string;
failureReason: string;
failureTimestamp: Date;
retryHistory: RetryAttempt[];
}
export interface RetryAttempt {
attemptNumber: number;
timestamp: Date;
error: string;
duration: number;
}
export interface MessageProducer {
id: string;
name: string;
producerType: 'service' | 'scheduler' | 'webhook' | 'batch';
config: ProducerConfig;
status: ProducerStatus;
metrics: ProducerMetrics;
}
export interface ProducerConfig {
batchSize?: number;
batchTimeout?: number;
compression?: boolean;
partitioning?: PartitioningConfig;
serialization?: SerializationConfig;
}
export interface PartitioningConfig {
enabled: boolean;
keyField?: string;
strategy: 'hash' | 'round_robin' | 'custom';
partitionCount?: number;
}
export interface SerializationConfig {
format: 'json' | 'avro' | 'protobuf' | 'msgpack';
compression?: 'gzip' | 'snappy' | 'lz4';
schema?: string;
}
export enum ProducerStatus {
ACTIVE = 'active',
PAUSED = 'paused',
ERROR = 'error',
STOPPED = 'stopped'
}
export interface ProducerMetrics {
messagesSent: number;
messagesSuccess: number;
messagesError: number;
avgLatency: number;
throughputPerSecond: number;
lastSent: Date;
}

View file

@ -0,0 +1,163 @@
// Protocol and Integration Types
export interface HttpRequest {
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
url: string;
headers?: Record<string, string>;
body?: any;
timeout?: number;
retries?: number;
metadata?: Record<string, any>;
validateStatus?: (status: number) => boolean;
}
export interface HttpResponse<T = any> {
data: T;
status: number;
statusText: string;
headers: Record<string, string>;
config: HttpRequest;
timing: RequestTiming;
}
export interface RequestTiming {
start: number;
end: number;
duration: number;
dns?: number;
tcp?: number;
tls?: number;
request?: number;
firstByte?: number;
download?: number;
}
export interface ApiEndpoint {
id: string;
name: string;
baseUrl: string;
path: string;
method: string;
authentication?: ProtocolAuthenticationMethod;
rateLimit?: RateLimitInfo;
timeout: number;
retryPolicy: RetryPolicy;
headers?: Record<string, string>;
queryParams?: Record<string, string>;
}
export interface ProtocolAuthenticationMethod {
type: 'none' | 'apikey' | 'bearer' | 'basic' | 'oauth2' | 'custom';
config: AuthConfig;
}
export interface AuthConfig {
apiKey?: string;
token?: string;
username?: string;
password?: string;
clientId?: string;
clientSecret?: string;
scope?: string[];
tokenUrl?: string;
refreshToken?: string;
customHeaders?: Record<string, string>;
}
export interface RateLimitInfo {
requestsPerSecond: number;
requestsPerMinute: number;
requestsPerHour: number;
burstLimit: number;
windowMs: number;
}
export interface RetryPolicy {
enabled: boolean;
maxRetries: number;
baseDelayMs: number;
maxDelayMs: number;
backoffMultiplier: number;
jitter: boolean;
retryOn: RetryCondition[];
}
export interface RetryCondition {
type: 'status_code' | 'timeout' | 'network_error' | 'rate_limit' | 'custom';
values?: number[];
condition?: string;
}
export interface ProtocolConfig {
name: string;
version: string;
transport: 'http' | 'websocket' | 'tcp' | 'udp' | 'grpc';
serialization: 'json' | 'protobuf' | 'avro' | 'msgpack' | 'xml';
compression?: 'gzip' | 'deflate' | 'brotli' | 'snappy'; encryption?: EncryptionConfig;
healthCheck: ProtocolHealthCheckConfig;
}
export interface EncryptionConfig {
enabled: boolean;
algorithm?: string;
keySize?: number;
mode?: string;
certificatePath?: string;
privateKeyPath?: string;
}
export interface ProtocolHealthCheckConfig {
enabled: boolean;
path?: string;
interval: number;
timeout: number;
healthyThreshold: number;
unhealthyThreshold: number;
}
export interface ServiceEndpointConfig {
serviceName: string;
version: string;
endpoints: ApiEndpoint[];
baseConfig: ProtocolServiceConfig;
healthCheck: ProtocolHealthCheckConfig;
}
export interface ProtocolServiceConfig {
timeout: number;
retries: number;
circuitBreaker?: CircuitBreakerConfig;
loadBalancer?: LoadBalancerConfig;
monitoring?: MonitoringConfig;
}
export interface CircuitBreakerConfig {
enabled: boolean;
failureThreshold: number;
timeout: number;
halfOpenMaxCalls: number;
halfOpenTimeout: number;
}
export interface LoadBalancerConfig {
strategy: 'round_robin' | 'weighted' | 'least_connections' | 'random';
healthCheckEnabled: boolean;
targets: LoadBalancerTarget[];
}
export interface LoadBalancerTarget {
url: string;
weight?: number;
enabled: boolean;
metadata?: Record<string, any>;
}
export interface MonitoringConfig {
metricsEnabled: boolean;
tracingEnabled: boolean;
loggingEnabled: boolean;
alertingEnabled: boolean;
customMetrics?: string[];
}
// Re-export from config for convenience
export type { HttpClientConfig } from '../config/networking';

View file

@ -0,0 +1,200 @@
// Subscription Management Types
export type DataType = 'tick' | 'candle' | 'trade' | 'order' | 'quote' | 'level2' | 'quotes' | 'trades' | 'orderbook' | 'candles' | 'news' | 'fundamentals' | 'options' | 'futures' | 'crypto';
export enum SubscriptionPriority {
LOW = 'low',
MEDIUM = 'medium',
HIGH = 'high',
CRITICAL = 'critical'
}
export interface SubscriptionRequest {
id: string;
clientId: string;
symbols: string[];
dataTypes: DataType[];
filters?: SubscriptionFilter;
throttle?: ThrottleConfig;
delivery: DeliveryConfig;
priority?: SubscriptionPriority;
metadata?: Record<string, any>;
}
export interface SubscriptionFilter {
symbols?: string[];
priceRange?: PriceRange;
volumeRange?: VolumeRange;
timeRange?: TimeRange;
custom?: Record<string, any>;
}
export interface PriceRange {
min?: number;
max?: number;
}
export interface VolumeRange {
min?: number;
max?: number;
}
export interface TimeRange {
start?: Date;
end?: Date;
}
export interface ThrottleConfig {
maxMessagesPerSecond?: number;
maxBatchSize?: number;
bufferTimeMs?: number;
}
export interface DeliveryConfig {
method: DeliveryMethod;
endpoint?: string;
options?: DeliveryOptions;
}
export enum DeliveryMethod {
WEBSOCKET = 'websocket',
HTTP_PUSH = 'http_push',
QUEUE = 'queue',
STREAM = 'stream'
}
export interface DeliveryOptions {
guaranteedDelivery?: boolean;
compression?: boolean;
encryption?: boolean;
authentication?: AuthenticationMethod;
headers?: Record<string, string>;
}
export enum AuthenticationMethod {
NONE = 'none',
API_KEY = 'api_key',
BEARER_TOKEN = 'bearer_token',
OAUTH = 'oauth',
MUTUAL_TLS = 'mutual_tls'
}
export interface SubscriptionResponse {
id: string;
status: SubscriptionStatus;
message?: string;
details?: SubscriptionDetails;
}
export enum SubscriptionStatus {
ACTIVE = 'active',
PENDING = 'pending',
PAUSED = 'paused',
CANCELLED = 'cancelled',
FAILED = 'failed'
}
export interface SubscriptionDetails {
subscribedSymbols: string[];
subscribedDataTypes: DataType[];
activeFilters: SubscriptionFilter;
performance: CommunicationSubscriptionMetrics;
}
export interface CommunicationSubscriptionMetrics {
messagesReceived: number;
messagesDropped: number;
averageLatency: number;
throughput: number;
errorRate: number;
lastActivity: Date;
}
export interface SubscriptionConfig {
maxSubscriptionsPerClient: number;
defaultThrottleConfig: ThrottleConfig;
allowedDataTypes: DataType[];
supportedDeliveryMethods: DeliveryMethod[];
subscriptionTimeout: number;
}
export interface UnsubscribeRequest {
subscriptionId: string;
clientId: string;
reason?: string;
}
export interface BulkSubscriptionRequest {
requests: SubscriptionRequest[];
batchId?: string;
failurePolicy: BatchFailurePolicy;
}
export enum BatchFailurePolicy {
FAIL_ALL = 'fail_all',
FAIL_PARTIAL = 'fail_partial',
IGNORE_ERRORS = 'ignore_errors'
}
export interface BatchSubscriptionResponse {
batchId: string;
responses: SubscriptionResponse[];
summary: BatchSummary;
}
export interface BatchSummary {
totalRequests: number;
successfulSubscriptions: number;
failedSubscriptions: number;
errors: string[];
}
export interface SubscriptionUpdate {
subscriptionId: string;
updates: Partial<SubscriptionRequest>;
clientId: string;
}
export interface SubscriptionEvent {
type: SubscriptionEventType;
subscriptionId: string;
clientId: string;
timestamp: Date;
data?: any;
}
export enum SubscriptionEventType {
CREATED = 'created',
UPDATED = 'updated',
CANCELLED = 'cancelled',
ERROR = 'error',
DATA_RECEIVED = 'data_received'
}
export interface FilterRule {
field: string;
operator: FilterOperator;
value: any;
validation?: ValidationRule;
}
export enum FilterOperator {
EQUALS = 'equals',
NOT_EQUALS = 'not_equals',
GREATER_THAN = 'greater_than',
LESS_THAN = 'less_than',
GREATER_EQUAL = 'greater_equal',
LESS_EQUAL = 'less_equal',
IN = 'in',
NOT_IN = 'not_in',
CONTAINS = 'contains',
REGEX = 'regex'
}
export interface ValidationRule {
pattern?: string;
min?: number;
max?: number;
enum?: any[];
custom?: string;
}

View file

@ -0,0 +1,134 @@
// WebSocket Communication Types
export interface WebSocketMessage {
type: MessageType;
id?: string;
timestamp: number;
payload: any;
metadata?: Record<string, any>;
correlationId?: string;
}
export enum MessageType {
SUBSCRIBE = 'subscribe',
UNSUBSCRIBE = 'unsubscribe',
DATA = 'data',
ERROR = 'error',
HEARTBEAT = 'heartbeat',
STATUS = 'status',
ACK = 'ack',
PING = 'ping',
PONG = 'pong'
}
export interface WebSocketSubscribeMessage extends WebSocketMessage {
type: MessageType.SUBSCRIBE;
payload: SubscriptionPayload;
}
export interface WebSocketUnsubscribeMessage extends WebSocketMessage {
type: MessageType.UNSUBSCRIBE;
payload: UnsubscriptionPayload;
}
export interface WebSocketDataMessage extends WebSocketMessage {
type: MessageType.DATA;
payload: DataPayload;
}
export interface WebSocketErrorMessage extends WebSocketMessage {
type: MessageType.ERROR;
payload: ErrorPayload;
}
export interface WebSocketStatusMessage extends WebSocketMessage {
type: MessageType.STATUS;
payload: StatusPayload;
}
export interface SubscriptionPayload {
symbols: string[];
dataTypes: string[];
filters?: WebSocketSubscriptionFilter;
throttle?: WebSocketThrottleConfig;
delivery?: WebSocketDeliveryConfig;
}
export interface UnsubscriptionPayload {
subscriptionId?: string;
symbols?: string[];
dataTypes?: string[];
}
export interface DataPayload {
dataType: string;
symbol?: string;
data: any;
sequence?: number;
source?: string;
}
export interface ErrorPayload {
code: string;
message: string;
details?: Record<string, any>;
retryable?: boolean;
}
export interface StatusPayload {
status: 'connected' | 'disconnected' | 'reconnecting' | 'error';
message?: string;
timestamp: number;
metadata?: Record<string, any>;
}
export interface WebSocketSubscriptionFilter {
priceRange?: { min: number; max: number };
volumeThreshold?: number;
exchanges?: string[];
symbols?: string[];
timeframe?: string;
custom?: Record<string, any>;
}
export interface WebSocketThrottleConfig {
maxUpdatesPerSecond: number;
aggregationWindow?: number;
bufferSize?: number;
}
export interface WebSocketDeliveryConfig {
method: 'websocket' | 'webhook' | 'eventbus' | 'queue';
endpoint?: string;
format: 'json' | 'protobuf' | 'avro' | 'msgpack';
compression?: 'gzip' | 'deflate' | 'brotli';
batchSize?: number;
batchDelay?: number;
}
export interface WebSocketConnection {
id: string;
clientId: string;
sessionId: string;
connectedAt: Date;
lastActivity: Date;
status: ConnectionStatus;
subscriptions: Set<string>;
metadata: ConnectionMetadata;
}
export enum ConnectionStatus {
CONNECTING = 'connecting',
CONNECTED = 'connected',
DISCONNECTING = 'disconnecting',
DISCONNECTED = 'disconnected',
ERROR = 'error'
}
export interface ConnectionMetadata {
userAgent?: string;
ipAddress?: string;
origin?: string;
protocol?: string;
version?: string;
features?: string[];
}

View file

@ -0,0 +1,60 @@
// Database Configuration Types
export interface DatabaseConfig {
host: string;
port: number;
database: string;
username?: string;
password?: string;
connectionTimeout?: number;
ssl?: boolean;
}
export interface PostgresConfig extends DatabaseConfig {
maxConnections?: number;
idleTimeoutMs?: number;
connectionTimeoutMs?: number;
statementTimeout?: number;
schema?: string;
}
export interface MongoDbConfig extends DatabaseConfig {
authSource?: string;
replicaSet?: string;
readPreference?: 'primary' | 'primaryPreferred' | 'secondary' | 'secondaryPreferred' | 'nearest';
writeConcern?: string;
retryWrites?: boolean;
journal?: boolean;
}
export interface QuestDbConfig extends DatabaseConfig {
httpPort?: number;
pgPort?: number;
requestTimeout?: number;
retryAttempts?: number;
tlsEnabled?: boolean;
defaultDatabase?: string;
}
export interface RedisConfig {
host: string;
port: number;
password?: string;
database?: number;
maxRetries?: number;
retryDelay?: number;
connectTimeout?: number;
commandTimeout?: number;
poolSize?: number;
tls?: boolean;
enableKeepAlive?: boolean;
}
export interface ConnectionPoolConfig {
minConnections: number;
maxConnections: number;
acquireTimeoutMs: number;
createTimeoutMs: number;
destroyTimeoutMs: number;
idleTimeoutMs: number;
reapIntervalMs: number;
}

View file

@ -0,0 +1,6 @@
// Configuration Types - Shared across all services
export * from './database';
export * from './monitoring';
export * from './logging';
export * from './security';
export * from './networking';

View file

@ -0,0 +1,48 @@
// Logging Configuration Types
export interface LoggingConfig {
level: 'error' | 'warn' | 'info' | 'http' | 'verbose' | 'debug' | 'silly';
format: 'json' | 'simple' | 'combined';
console: boolean;
file: boolean;
filePath?: string;
maxSize?: string;
maxFiles?: number;
timestamp?: boolean;
callerInfo?: boolean;
silentModules?: string[];
verboseModules?: string[];
serviceName?: string;
serviceVersion?: string;
environment?: string;
}
export interface LokiConfig {
host: string;
port: number;
url?: string;
username?: string;
password?: string;
tenantId?: string;
pushTimeout?: number;
batchSize?: number;
batchWait?: number;
retentionPeriod?: string;
maxChunkAge?: string;
tlsEnabled?: boolean;
tlsInsecure?: boolean;
defaultLabels?: Record<string, string>;
serviceLabel?: string;
environmentLabel?: string;
flushIntervalMs?: number;
}
export interface LogEntry {
timestamp: Date;
level: string;
message: string;
service: string;
environment: string;
metadata?: Record<string, any>;
error?: string;
stackTrace?: string;
}

View file

@ -0,0 +1,48 @@
// Monitoring and Metrics Configuration Types
export interface PrometheusConfig {
host: string;
port: number;
url?: string;
username?: string;
password?: string;
scrapeInterval: string;
evaluationInterval: string;
retentionTime: string;
tlsEnabled?: boolean;
tlsInsecure?: boolean;
}
export interface GrafanaConfig {
host: string;
port: number;
url?: string;
adminUser: string;
adminPassword: string;
allowSignUp?: boolean;
secretKey?: string;
databaseType: 'mysql' | 'postgres' | 'sqlite3';
databaseUrl?: string;
disableGravatar?: boolean;
enableGzip?: boolean;
}
export interface AlertManagerConfig {
host: string;
port: number;
webhookUrl?: string;
smtpHost?: string;
smtpPort?: number;
smtpUsername?: string;
smtpPassword?: string;
slackWebhookUrl?: string;
}
export interface MetricsConfig {
enabled: boolean;
port: number;
path: string;
collectDefaultMetrics?: boolean;
prefix?: string;
labels?: Record<string, string>;
buckets?: number[];
}

View file

@ -0,0 +1,50 @@
// Networking and Communication Configuration Types
import { CorsConfig } from './security';
export interface ServerConfig {
host: string;
port: number;
maxConnections?: number;
keepAliveTimeout?: number;
bodyParserLimit?: string;
compression?: boolean;
gracefulShutdownTimeout?: number;
}
export interface WebSocketConfig {
enabled: boolean;
port?: number;
path?: string;
heartbeatInterval?: number;
maxConnections?: number;
compression?: boolean;
cors?: CorsConfig;
}
export interface HttpClientConfig {
baseURL?: string;
timeout?: number;
headers?: Record<string, string>;
retries?: number;
retryDelay?: number;
maxConcurrency?: number;
keepAlive?: boolean;
validateStatus?: (status: number) => boolean;
}
export interface RetryConfig {
maxRetries: number;
baseDelay: number;
maxDelay: number;
exponentialBackoff: boolean;
retryCondition?: (error: any) => boolean;
}
export interface CircuitBreakerConfig {
enabled: boolean;
failureThreshold: number;
recoveryTimeout: number;
monitoringPeriod: number;
expectedFailureRate: number;
}

View file

@ -0,0 +1,46 @@
// Security Configuration Types
export interface AuthenticationConfig {
jwtSecret: string;
jwtExpiresIn: string;
refreshTokenExpiresIn: string;
passwordMinLength: number;
passwordRequireNumbers: boolean;
passwordRequireSpecialChars: boolean;
passwordRequireUppercase: boolean;
passwordRequireLowercase: boolean;
maxLoginAttempts: number;
lockoutDurationMinutes: number;
}
export interface TlsConfig {
enabled: boolean;
certFile?: string;
keyFile?: string;
caFile?: string;
skipVerify?: boolean;
minVersion?: string;
cipherSuites?: string[];
}
export interface ApiKeyConfig {
type: 'apikey' | 'oauth' | 'basic' | 'jwt';
credentials: Record<string, string>;
expiresIn?: string;
permissions?: string[];
}
export interface CorsConfig {
origins: string[];
methods: string[];
headers: string[];
credentials?: boolean;
maxAge?: number;
}
export interface RateLimitConfig {
windowMs: number;
maxRequests: number;
skipSuccessfulRequests?: boolean;
skipFailedRequests?: boolean;
keyGenerator?: string;
}

View file

@ -0,0 +1,79 @@
/**
* Application-specific error types
*/
import { BaseError, ErrorCategory, ErrorSeverity } from './base';
export interface ApplicationError extends BaseError {
applicationName: string;
version: string;
environment: string;
}
export interface ServiceError extends ApplicationError {
serviceName: string;
serviceVersion: string;
endpoint?: string;
}
export interface MarketDataError extends ServiceError {
symbol?: string;
exchange?: string;
dataType?: string;
timeframe?: string;
}
export interface TradingError extends ServiceError {
orderId?: string;
symbol?: string;
side?: 'buy' | 'sell';
quantity?: number;
price?: number;
}
export interface StrategyError extends ServiceError {
strategyId: string;
strategyName: string;
phase: StrategyPhase;
signal?: string;
}
export enum StrategyPhase {
INITIALIZATION = 'initialization',
ANALYSIS = 'analysis',
SIGNAL_GENERATION = 'signal_generation',
EXECUTION = 'execution',
MONITORING = 'monitoring',
CLEANUP = 'cleanup'
}
export interface DataProcessingError extends ServiceError {
pipelineId?: string;
stepId?: string;
inputData?: string;
processingStage: ProcessingStage;
}
export enum ProcessingStage {
INGESTION = 'ingestion',
VALIDATION = 'validation',
TRANSFORMATION = 'transformation',
ENRICHMENT = 'enrichment',
STORAGE = 'storage',
PUBLISHING = 'publishing'
}
export interface FeatureStoreError extends ServiceError {
featureGroupId?: string;
featureName?: string;
operation: FeatureOperation;
}
export enum FeatureOperation {
CREATE = 'create',
READ = 'read',
UPDATE = 'update',
DELETE = 'delete',
COMPUTE = 'compute',
SERVE = 'serve'
}

View file

@ -0,0 +1,85 @@
/**
* Base error handling types and interfaces
*/
export interface ErrorCode {
code: string;
category: ErrorCategory;
severity: ErrorSeverity;
retryable: boolean;
}
export enum ErrorCategory {
VALIDATION = 'validation',
AUTHENTICATION = 'authentication',
AUTHORIZATION = 'authorization',
NOT_FOUND = 'not_found',
CONFLICT = 'conflict',
RATE_LIMIT = 'rate_limit',
INTERNAL = 'internal',
EXTERNAL = 'external',
NETWORK = 'network',
TIMEOUT = 'timeout',
CONFIGURATION = 'configuration',
DATA = 'data'
}
export enum ErrorSeverity {
LOW = 'low',
MEDIUM = 'medium',
HIGH = 'high',
CRITICAL = 'critical'
}
export interface BaseError {
id: string;
code: string;
message: string;
details?: Record<string, any>;
timestamp: Date;
category: ErrorCategory;
severity: ErrorSeverity;
retryable: boolean;
context?: ErrorContext;
stack?: string;
}
export interface ErrorContext {
service: string;
component: string;
operation: string;
userId?: string;
sessionId?: string;
requestId?: string;
traceId?: string;
correlationId?: string;
metadata?: Record<string, any>;
}
export interface ErrorResponse {
error: BaseError;
timestamp: Date;
path: string;
method: string;
statusCode: number;
}
export interface ErrorHandler {
handle(error: BaseError): Promise<void>;
canHandle(error: BaseError): boolean;
}
export interface ErrorRecovery {
strategy: RecoveryStrategy;
maxRetries: number;
backoffMs: number;
timeout: number;
}
export enum RecoveryStrategy {
RETRY = 'retry',
FALLBACK = 'fallback',
CIRCUIT_BREAKER = 'circuit_breaker',
GRACEFUL_DEGRADATION = 'graceful_degradation',
FAIL_FAST = 'fail_fast'
}

View file

@ -0,0 +1,85 @@
/**
* Business domain error types
*/
import { BaseError } from './base';
export interface BusinessError extends BaseError {
domain: BusinessDomain;
operation: string;
entityId?: string;
entityType?: string;
}
export enum BusinessDomain {
TRADING = 'trading',
MARKET_DATA = 'market_data',
PORTFOLIO = 'portfolio',
RISK_MANAGEMENT = 'risk_management',
STRATEGY = 'strategy',
EXECUTION = 'execution',
COMPLIANCE = 'compliance',
REPORTING = 'reporting'
}
export interface TradingBusinessError extends BusinessError {
symbol: string;
orderId?: string;
errorType: TradingErrorType;
}
export enum TradingErrorType {
INSUFFICIENT_FUNDS = 'insufficient_funds',
INVALID_SYMBOL = 'invalid_symbol',
MARKET_CLOSED = 'market_closed',
ORDER_REJECTED = 'order_rejected',
POSITION_LIMIT_EXCEEDED = 'position_limit_exceeded',
PRICE_OUT_OF_RANGE = 'price_out_of_range',
DUPLICATE_ORDER = 'duplicate_order'
}
export interface RiskManagementError extends BusinessError {
riskType: RiskType;
threshold?: number;
currentValue?: number;
riskLevel: RiskLevel;
}
export enum RiskType {
POSITION_SIZE = 'position_size',
CONCENTRATION = 'concentration',
VOLATILITY = 'volatility',
DRAWDOWN = 'drawdown',
EXPOSURE = 'exposure',
LEVERAGE = 'leverage',
VAR = 'var'
}
export enum RiskLevel {
LOW = 'low',
MEDIUM = 'medium',
HIGH = 'high',
CRITICAL = 'critical'
}
export interface ComplianceError extends BusinessError {
ruleId: string;
ruleName: string;
violationType: ComplianceViolationType;
complianceSeverity: BusinessComplianceSeverity;
}
export enum ComplianceViolationType {
REGULATORY = 'regulatory',
INTERNAL_POLICY = 'internal_policy',
RISK_LIMIT = 'risk_limit',
TRADING_RESTRICTION = 'trading_restriction',
REPORTING_REQUIREMENT = 'reporting_requirement'
}
export enum BusinessComplianceSeverity {
INFO = 'info',
WARNING = 'warning',
VIOLATION = 'violation',
BREACH = 'breach'
}

View file

@ -0,0 +1,6 @@
// Error handling types
export * from './base';
export * from './application';
export * from './validation';
export * from './network';
export * from './business';

View file

@ -0,0 +1,75 @@
/**
* Network and communication error types
*/
import { BaseError } from './base';
export interface NetworkError extends BaseError {
endpoint: string;
method: string;
statusCode?: number;
networkCode: NetworkErrorCode;
}
export enum NetworkErrorCode {
CONNECTION_TIMEOUT = 'connection_timeout',
READ_TIMEOUT = 'read_timeout',
CONNECTION_REFUSED = 'connection_refused',
DNS_RESOLUTION = 'dns_resolution',
SSL_HANDSHAKE = 'ssl_handshake',
PROXY_ERROR = 'proxy_error',
NETWORK_UNREACHABLE = 'network_unreachable',
RATE_LIMITED = 'rate_limited',
SERVICE_UNAVAILABLE = 'service_unavailable'
}
export interface HttpError extends NetworkError {
statusCode: number;
statusText: string;
headers?: Record<string, string>;
responseBody?: string;
}
export interface WebSocketError extends NetworkError {
connectionState: WebSocketState;
closeCode?: number;
closeReason?: string;
}
export enum WebSocketState {
CONNECTING = 'connecting',
OPEN = 'open',
CLOSING = 'closing',
CLOSED = 'closed',
ERROR = 'error'
}
export interface ApiError extends HttpError {
apiName: string;
apiVersion: string;
endpoint: string;
requestId?: string;
errorCode?: string;
errorMessage?: string;
}
export interface ExternalServiceError extends NetworkError {
serviceName: string;
serviceVersion?: string;
providerName: string;
circuitBreakerState?: CircuitBreakerState;
}
export enum CircuitBreakerState {
CLOSED = 'closed',
OPEN = 'open',
HALF_OPEN = 'half_open'
}
export interface RetryConfig {
maxRetries: number;
baseDelayMs: number;
maxDelayMs: number;
backoffMultiplier: number;
retryableErrors: NetworkErrorCode[];
}

View file

@ -0,0 +1,72 @@
/**
* Validation error types
*/
import { BaseError, ErrorCategory, ErrorSeverity } from './base';
export interface ValidationError extends BaseError {
field: string;
value?: any;
constraint: string;
validationType: ValidationType;
}
export enum ValidationType {
REQUIRED = 'required',
TYPE = 'type',
FORMAT = 'format',
RANGE = 'range',
LENGTH = 'length',
PATTERN = 'pattern',
CUSTOM = 'custom',
BUSINESS_RULE = 'business_rule'
}
export interface SchemaValidationError extends ValidationError {
schema: string;
schemaVersion: string;
path: string;
}
export interface DataValidationError extends ValidationError {
dataType: string;
expectedFormat: string;
actualFormat?: string;
}
export interface BusinessRuleValidationError extends ValidationError {
ruleId: string;
ruleName: string;
ruleDescription: string;
businessContext?: Record<string, any>;
}
export interface ValidationResult {
valid: boolean;
errors: ValidationError[];
warnings: ValidationWarning[];
}
export interface ValidationWarning {
field: string;
message: string;
code: string;
severity: 'low' | 'medium';
}
export interface ValidationRule {
id: string;
name: string;
description: string;
type: ValidationType;
constraint: any;
message: string;
enabled: boolean;
}
export interface ValidationConfig {
strict: boolean;
stopOnFirstError: boolean;
rules: ValidationRule[];
customValidators: Record<string, Function>;
}

View file

@ -0,0 +1,110 @@
/**
* Base feature store types
*/
export interface Feature {
id: string;
name: string;
description?: string;
dataType: FeatureDataType;
valueType: FeatureValueType;
tags: string[];
metadata: Record<string, any>;
createdAt: Date;
updatedAt: Date;
version: string;
status: FeatureStatus;
owner: string;
}
export enum FeatureDataType {
NUMERICAL = 'numerical',
CATEGORICAL = 'categorical',
BOOLEAN = 'boolean',
TEXT = 'text',
TIMESTAMP = 'timestamp',
ARRAY = 'array',
OBJECT = 'object'
}
export enum FeatureValueType {
INT32 = 'int32',
INT64 = 'int64',
FLOAT32 = 'float32',
FLOAT64 = 'float64',
STRING = 'string',
BYTES = 'bytes',
BOOL = 'bool',
UNIX_TIMESTAMP = 'unix_timestamp'
}
export enum FeatureStatus {
DRAFT = 'draft',
ACTIVE = 'active',
DEPRECATED = 'deprecated',
ARCHIVED = 'archived',
ERROR = 'error'
}
export interface FeatureValue {
featureId: string;
value: any;
timestamp: Date;
version?: string;
confidence?: number;
metadata?: Record<string, any>;
}
export interface FeatureVector {
entityId: string;
features: FeatureValue[];
timestamp: Date;
version?: string;
}
export interface FeatureQuery {
featureIds: string[];
entityIds: string[];
timestamp?: Date;
version?: string;
includeMetadata?: boolean;
}
export interface FeatureResponse {
vectors: FeatureVector[];
metadata: {
totalCount: number;
retrievedAt: Date;
version: string;
};
}
export interface FeatureComputation {
id: string;
featureId: string;
expression: string;
dependencies: string[];
schedule?: ComputationSchedule;
resources: ComputationResources;
status: ComputationStatus;
}
export interface ComputationSchedule {
cron: string;
timezone: string;
enabled: boolean;
}
export interface ComputationResources {
cpu: string;
memory: string;
timeout: number;
}
export enum ComputationStatus {
PENDING = 'pending',
RUNNING = 'running',
COMPLETED = 'completed',
FAILED = 'failed',
CANCELLED = 'cancelled'
}

View file

@ -0,0 +1,124 @@
/**
* Feature group types
*/
import { Feature, FeatureStatus } from './base';
export interface FeatureGroup {
id: string;
name: string;
description?: string;
features: Feature[];
tags: string[];
metadata: Record<string, any>;
createdAt: Date;
updatedAt: Date;
version: string;
status: FeatureStatus;
owner: string;
entityIdColumns: string[];
eventTimeColumn?: string;
source: FeatureGroupSource;
}
export interface FeatureGroupSource {
type: SourceType;
config: SourceConfig;
schedule?: SourceSchedule;
}
export enum SourceType {
BATCH = 'batch',
STREAMING = 'streaming',
REQUEST_RESPONSE = 'request_response',
PUSH = 'push'
}
export interface SourceConfig {
// Base source configuration
[key: string]: any;
}
export interface BatchSourceConfig extends SourceConfig {
dataSource: string;
query?: string;
path?: string;
format: DataFormat;
options?: Record<string, any>;
}
export interface StreamingSourceConfig extends SourceConfig {
topic: string;
bootstrapServers: string[];
consumerGroup: string;
format: DataFormat;
deserializer?: string;
}
export enum DataFormat {
PARQUET = 'parquet',
AVRO = 'avro',
JSON = 'json',
CSV = 'csv',
DELTA = 'delta',
ICEBERG = 'iceberg'
}
export interface SourceSchedule {
cron: string;
timezone: string;
enabled: boolean;
retryConfig: RetryConfig;
}
export interface RetryConfig {
maxRetries: number;
backoffMs: number;
maxBackoffMs: number;
backoffMultiplier: number;
}
export interface FeatureGroupStats {
featureGroupId: string;
totalFeatures: number;
activeFeatures: number;
lastUpdated: Date;
dataFreshness: Date;
recordCount: number;
storageSize: number;
computeCost: number;
}
export interface FeatureGroupVersion {
version: string;
featureGroupId: string;
createdAt: Date;
createdBy: string;
changes: FeatureGroupChange[];
status: VersionStatus;
}
export interface FeatureGroupChange {
type: ChangeType;
featureId?: string;
field: string;
oldValue?: any;
newValue?: any;
description?: string;
}
export enum ChangeType {
FEATURE_ADDED = 'feature_added',
FEATURE_REMOVED = 'feature_removed',
FEATURE_MODIFIED = 'feature_modified',
SCHEMA_CHANGED = 'schema_changed',
SOURCE_CHANGED = 'source_changed',
METADATA_UPDATED = 'metadata_updated'
}
export enum VersionStatus {
DRAFT = 'draft',
ACTIVE = 'active',
DEPRECATED = 'deprecated',
ARCHIVED = 'archived'
}

View file

@ -0,0 +1,6 @@
// Feature store and feature engineering types
export * from './base';
export * from './groups';
export * from './serving';
export * from './lineage';
export * from './monitoring';

View file

@ -0,0 +1,131 @@
/**
* Feature lineage and dependency tracking types
*/
export interface FeatureLineage {
featureId: string;
upstreamDependencies: LineageDependency[];
downstreamDependents: LineageDependency[];
dataFlow: DataFlowNode[];
lastUpdated: Date;
}
export interface LineageDependency {
id: string;
name: string;
type: DependencyType;
relationship: RelationshipType;
metadata?: Record<string, any>;
}
export enum DependencyType {
FEATURE = 'feature',
FEATURE_GROUP = 'feature_group',
DATA_SOURCE = 'data_source',
TRANSFORMATION = 'transformation',
MODEL = 'model',
PIPELINE = 'pipeline'
}
export enum RelationshipType {
DERIVES_FROM = 'derives_from',
DEPENDS_ON = 'depends_on',
TRANSFORMS = 'transforms',
AGGREGATES = 'aggregates',
JOINS = 'joins',
FILTERS = 'filters'
}
export interface DataFlowNode {
id: string;
name: string;
type: NodeType;
operation: string;
inputs: string[];
outputs: string[];
properties: Record<string, any>;
}
export enum NodeType {
SOURCE = 'source',
TRANSFORMATION = 'transformation',
AGGREGATION = 'aggregation',
JOIN = 'join',
FILTER = 'filter',
SINK = 'sink'
}
export interface LineageQuery {
featureId: string;
direction: LineageDirection;
depth?: number;
includeMetadata?: boolean;
filters?: LineageFilter[];
}
export enum LineageDirection {
UPSTREAM = 'upstream',
DOWNSTREAM = 'downstream',
BOTH = 'both'
}
export interface LineageFilter {
field: string;
operator: FilterOperator;
value: any;
}
export enum FilterOperator {
EQUALS = 'equals',
NOT_EQUALS = 'not_equals',
CONTAINS = 'contains',
STARTS_WITH = 'starts_with',
IN = 'in',
NOT_IN = 'not_in'
}
export interface LineageAnalysis {
featureId: string;
impactAnalysis: ImpactAnalysis;
riskAssessment: RiskAssessment;
recommendations: LineageRecommendation[];
}
export interface ImpactAnalysis {
affectedFeatures: string[];
affectedModels: string[];
affectedPipelines: string[];
estimatedImpactScore: number;
criticalityLevel: CriticalityLevel;
}
export enum CriticalityLevel {
LOW = 'low',
MEDIUM = 'medium',
HIGH = 'high',
CRITICAL = 'critical'
}
export interface RiskAssessment {
breakageRisk: number;
dataQualityRisk: number;
performanceRisk: number;
complianceRisk: number;
overallRisk: number;
}
export interface LineageRecommendation {
type: RecommendationType;
priority: number;
description: string;
actionItems: string[];
estimatedEffort: string;
}
export enum RecommendationType {
OPTIMIZATION = 'optimization',
RISK_MITIGATION = 'risk_mitigation',
REFACTORING = 'refactoring',
DEPRECATION = 'deprecation',
ENHANCEMENT = 'enhancement'
}

View file

@ -0,0 +1,157 @@
/**
* Feature monitoring and observability types
*/
export interface FeatureMonitoring {
featureId: string;
monitoringConfig: MonitoringConfig;
alerts: FeatureAlert[];
metrics: FeatureMetrics;
status: MonitoringStatus;
}
export interface MonitoringConfig {
enabled: boolean;
samplingRate: number;
alertThresholds: AlertThreshold[];
monitoringWindows: MonitoringWindow[];
customChecks: CustomCheck[];
}
export interface AlertThreshold {
metric: string;
operator: ThresholdOperator;
value: number;
severity: AlertSeverity;
window: string;
}
export enum ThresholdOperator {
GREATER_THAN = 'gt',
LESS_THAN = 'lt',
GREATER_THAN_OR_EQUAL = 'gte',
LESS_THAN_OR_EQUAL = 'lte',
EQUALS = 'eq',
NOT_EQUALS = 'ne'
}
export enum AlertSeverity {
INFO = 'info',
WARNING = 'warning',
ERROR = 'error',
CRITICAL = 'critical'
}
export interface MonitoringWindow {
name: string;
duration: string;
aggregation: AggregationType;
}
export enum AggregationType {
SUM = 'sum',
AVERAGE = 'average',
MIN = 'min',
MAX = 'max',
COUNT = 'count',
PERCENTILE = 'percentile'
}
export interface CustomCheck {
id: string;
name: string;
expression: string;
frequency: string;
enabled: boolean;
}
export interface FeatureAlert {
id: string;
featureId: string;
type: AlertType;
severity: AlertSeverity;
message: string;
triggeredAt: Date;
resolvedAt?: Date;
status: AlertStatus;
metadata: Record<string, any>;
}
export enum AlertType {
DATA_DRIFT = 'data_drift',
SCHEMA_CHANGE = 'schema_change',
QUALITY_DEGRADATION = 'quality_degradation',
PERFORMANCE_ISSUE = 'performance_issue',
FRESHNESS_VIOLATION = 'freshness_violation',
CUSTOM = 'custom'
}
export enum AlertStatus {
ACTIVE = 'active',
ACKNOWLEDGED = 'acknowledged',
RESOLVED = 'resolved',
SUPPRESSED = 'suppressed'
}
export interface FeatureMetrics {
featureId: string;
timestamp: Date;
qualityMetrics: QualityMetrics;
performanceMetrics: PerformanceMetrics;
usageMetrics: UsageMetrics;
distributionMetrics: DistributionMetrics;
}
export interface QualityMetrics {
completeness: number;
accuracy: number;
consistency: number;
validity: number;
uniqueness: number;
nullRate: number;
outlierRate: number;
}
export interface PerformanceMetrics {
computeTimeMs: number;
memoryUsageMB: number;
throughputRps: number;
errorRate: number;
p50LatencyMs: number;
p95LatencyMs: number;
p99LatencyMs: number;
}
export interface UsageMetrics {
requestCount: number;
uniqueConsumers: number;
avgRequestsPerConsumer: number;
popularityScore: number;
lastAccessedAt: Date;
}
export interface DistributionMetrics {
mean: number;
median: number;
stddev: number;
min: number;
max: number;
skewness: number;
kurtosis: number;
percentiles: Record<string, number>;
histogram: HistogramBin[];
}
export interface HistogramBin {
lowerBound: number;
upperBound: number;
count: number;
frequency: number;
}
export enum MonitoringStatus {
ACTIVE = 'active',
PAUSED = 'paused',
ERROR = 'error',
DISABLED = 'disabled'
}

View file

@ -0,0 +1,134 @@
/**
* Feature serving and retrieval types
*/
import { FeatureVector, FeatureQuery } from './base';
export interface FeatureStore {
name: string;
type: FeatureStoreType;
config: FeatureStoreConfig;
capabilities: FeatureStoreCapabilities;
}
export enum FeatureStoreType {
ONLINE = 'online',
OFFLINE = 'offline',
HYBRID = 'hybrid'
}
export interface FeatureStoreConfig {
connectionString?: string;
credentials?: Record<string, any>;
caching?: CachingConfig;
performance?: PerformanceConfig;
}
export interface CachingConfig {
enabled: boolean;
ttlSeconds: number;
maxSize: number;
strategy: CacheStrategy;
}
export enum CacheStrategy {
LRU = 'lru',
LFU = 'lfu',
TTL = 'ttl',
WRITE_THROUGH = 'write_through',
WRITE_BEHIND = 'write_behind'
}
export interface PerformanceConfig {
maxConcurrentRequests: number;
timeoutMs: number;
batchSize: number;
compressionEnabled: boolean;
}
export interface FeatureStoreCapabilities {
supportsPointInTimeCorrectness: boolean;
supportsStreaming: boolean;
supportsBatch: boolean;
supportsTransactions: boolean;
supportsVersioning: boolean;
maxFeatureVectorSize: number;
}
export interface FeatureServingRequest {
query: FeatureQuery;
options?: ServingOptions;
metadata?: Record<string, any>;
}
export interface ServingOptions {
consistencyLevel: ConsistencyLevel;
maxLatencyMs?: number;
fallbackStrategy?: FallbackStrategy;
includeStatistics?: boolean;
}
export enum ConsistencyLevel {
EVENTUAL = 'eventual',
STRONG = 'strong',
BOUNDED_STALENESS = 'bounded_staleness'
}
export enum FallbackStrategy {
DEFAULT_VALUES = 'default_values',
CACHED_VALUES = 'cached_values',
COMPUTED_VALUES = 'computed_values',
FAIL_FAST = 'fail_fast'
}
export interface FeatureServingResponse {
vectors: FeatureVector[];
statistics?: ServingStatistics;
metadata: {
requestId: string;
servedAt: Date;
latencyMs: number;
sourceStore: string;
};
}
export interface ServingStatistics {
cacheHitRate: number;
avgLatencyMs: number;
errorRate: number;
throughputRps: number;
}
export interface OnlineServingConfig {
lowLatencyStores: string[];
fallbackStores: string[];
caching: CachingConfig;
circuitBreaker: CircuitBreakerConfig;
}
export interface CircuitBreakerConfig {
enabled: boolean;
failureThreshold: number;
timeoutMs: number;
resetTimeoutMs: number;
}
export interface OfflineServingConfig {
batchSize: number;
parallelism: number;
outputFormat: string;
partitioning: PartitioningConfig;
}
export interface PartitioningConfig {
columns: string[];
strategy: PartitioningStrategy;
buckets?: number;
}
export enum PartitioningStrategy {
HASH = 'hash',
RANGE = 'range',
LIST = 'list',
TIME = 'time'
}

View file

@ -0,0 +1,282 @@
// Access Control and Security Types
export interface AccessPolicy {
id: string;
name: string;
description?: string;
rules: AccessRule[];
scope: AccessScope;
enabled: boolean;
metadata?: Record<string, any>;
}
export interface AccessRule {
id: string;
name: string;
subjects: AccessSubject[];
actions: AccessAction[];
resources: AccessResource[];
conditions?: AccessCondition[];
effect: AccessEffect;
priority: number;
}
export interface AccessSubject {
type: SubjectType;
identifier: string;
attributes?: Record<string, any>;
}
export enum SubjectType {
USER = 'user',
GROUP = 'group',
ROLE = 'role',
SERVICE = 'service',
APPLICATION = 'application'
}
export interface AccessAction {
type: ActionType;
scope?: string[];
}
export enum ActionType {
READ = 'read',
WRITE = 'write',
DELETE = 'delete',
EXECUTE = 'execute',
ADMIN = 'admin',
AUDIT = 'audit'
}
export interface AccessResource {
type: ResourceType;
identifier: string;
attributes?: Record<string, any>;
}
export enum ResourceType {
DATASET = 'dataset',
TABLE = 'table',
COLUMN = 'column',
FILE = 'file',
API = 'api',
SERVICE = 'service',
FUNCTION = 'function'
}
export interface AccessCondition {
type: ConditionType;
operator: ConditionOperator;
value: any;
}
export enum ConditionType {
TIME = 'time',
IP_ADDRESS = 'ip_address',
LOCATION = 'location',
DEVICE = 'device',
CLASSIFICATION = 'classification',
CUSTOM = 'custom'
}
export enum ConditionOperator {
EQUALS = 'equals',
NOT_EQUALS = 'not_equals',
IN = 'in',
NOT_IN = 'not_in',
GREATER_THAN = 'greater_than',
LESS_THAN = 'less_than',
CONTAINS = 'contains',
REGEX = 'regex'
}
export enum AccessEffect {
ALLOW = 'allow',
DENY = 'deny'
}
export interface AccessScope {
environments: string[];
regions: string[];
organizations: string[];
projects: string[];
}
export interface AccessRequest {
id: string;
subject: AccessSubject;
action: AccessAction;
resource: AccessResource;
context: AccessContext;
timestamp: Date;
status: RequestStatus;
}
export interface AccessContext {
ipAddress?: string;
userAgent?: string;
location?: GeoLocation;
device?: DeviceInfo;
session?: SessionInfo;
additional?: Record<string, any>;
}
export interface GeoLocation {
country: string;
region: string;
city: string;
latitude: number;
longitude: number;
}
export interface DeviceInfo {
id: string;
type: DeviceType;
os: string;
browser?: string;
trusted: boolean;
}
export enum DeviceType {
DESKTOP = 'desktop',
MOBILE = 'mobile',
TABLET = 'tablet',
SERVER = 'server',
IOT = 'iot'
}
export interface SessionInfo {
id: string;
startTime: Date;
lastActivity: Date;
authenticated: boolean;
mfaVerified: boolean;
}
export enum RequestStatus {
PENDING = 'pending',
APPROVED = 'approved',
DENIED = 'denied',
EXPIRED = 'expired',
REVOKED = 'revoked'
}
export interface AccessAuditLog {
id: string;
timestamp: Date;
subject: AccessSubject;
action: AccessAction;
resource: AccessResource;
decision: AccessDecision;
reason: string;
context: AccessContext;
}
export interface AccessDecision {
effect: AccessEffect;
policies: string[];
evaluationTime: number;
cached: boolean;
}
export interface AccessDataClassification {
level: ClassificationLevel;
categories: DataCategory[];
handling: HandlingRequirement[];
retention: AccessRetentionPolicy;
sensitivity: SensitivityMarking[];
}
export enum ClassificationLevel {
PUBLIC = 'public',
INTERNAL = 'internal',
CONFIDENTIAL = 'confidential',
RESTRICTED = 'restricted',
SECRET = 'secret',
TOP_SECRET = 'top_secret'
}
export enum DataCategory {
PII = 'pii',
PHI = 'phi',
FINANCIAL = 'financial',
TRADE_SECRET = 'trade_secret',
INTELLECTUAL_PROPERTY = 'intellectual_property',
REGULATORY = 'regulatory'
}
export interface HandlingRequirement {
type: HandlingType;
mandatory: boolean;
description: string;
}
export enum HandlingType {
ENCRYPTION_AT_REST = 'encryption_at_rest',
ENCRYPTION_IN_TRANSIT = 'encryption_in_transit',
ACCESS_LOGGING = 'access_logging',
BACKUP_RESTRICTION = 'backup_restriction',
GEOGRAPHIC_RESTRICTION = 'geographic_restriction',
TIME_RESTRICTION = 'time_restriction'
}
export interface AccessRetentionPolicy {
period: RetentionPeriod;
disposal: DisposalMethod;
exceptions: RetentionException[];
}
export interface RetentionPeriod {
duration: number;
unit: AccessTimeUnit;
triggers: RetentionTrigger[];
}
export enum AccessTimeUnit {
DAYS = 'days',
WEEKS = 'weeks',
MONTHS = 'months',
YEARS = 'years'
}
export enum RetentionTrigger {
CREATION_DATE = 'creation_date',
LAST_ACCESS = 'last_access',
BUSINESS_EVENT = 'business_event',
LEGAL_HOLD = 'legal_hold'
}
export enum DisposalMethod {
SOFT_DELETE = 'soft_delete',
HARD_DELETE = 'hard_delete',
ANONYMIZATION = 'anonymization',
ENCRYPTION_KEY_DESTRUCTION = 'encryption_key_destruction'
}
export interface RetentionException {
reason: string;
period: RetentionPeriod;
approver: string;
expiration: Date;
}
export interface SensitivityMarking {
type: MarkingType;
value: string;
scope: MarkingScope;
}
export enum MarkingType {
CLASSIFICATION = 'classification',
HANDLING = 'handling',
DISSEMINATION = 'dissemination',
CUSTOM = 'custom'
}
export enum MarkingScope {
DATASET = 'dataset',
FIELD = 'field',
RECORD = 'record',
VALUE = 'value'
}

View file

@ -0,0 +1,253 @@
/**
* Data catalog and metadata types
*/
export interface DataAsset {
id: string;
name: string;
type: AssetType;
description?: string;
tags: string[];
schema: DataSchema;
location: AssetLocation;
metadata: AssetMetadata;
governance: GovernanceInfo;
createdAt: Date;
updatedAt: Date;
version: string;
}
export enum AssetType {
TABLE = 'table',
VIEW = 'view',
DATASET = 'dataset',
FEATURE_GROUP = 'feature_group',
MODEL = 'model',
PIPELINE = 'pipeline',
REPORT = 'report',
API = 'api'
}
export interface DataSchema {
columns: ColumnDefinition[];
primaryKeys: string[];
foreignKeys: ForeignKey[];
indexes: IndexDefinition[];
constraints: ConstraintDefinition[];
}
export interface ColumnDefinition {
name: string;
dataType: string;
nullable: boolean;
defaultValue?: any;
description?: string;
tags: string[];
constraints: string[];
statistics?: ColumnStatistics;
}
export interface ColumnStatistics {
distinctCount: number;
nullCount: number;
minValue?: any;
maxValue?: any;
avgLength?: number;
topValues: ValueCount[];
}
export interface ValueCount {
value: any;
count: number;
frequency: number;
}
export interface ForeignKey {
columnNames: string[];
referencedTable: string;
referencedColumns: string[];
name?: string;
}
export interface IndexDefinition {
name: string;
columns: string[];
type: IndexType;
unique: boolean;
}
export enum IndexType {
BTREE = 'btree',
HASH = 'hash',
BITMAP = 'bitmap',
FULLTEXT = 'fulltext'
}
export interface ConstraintDefinition {
name: string;
type: ConstraintType;
columns: string[];
expression?: string;
}
export enum ConstraintType {
PRIMARY_KEY = 'primary_key',
FOREIGN_KEY = 'foreign_key',
UNIQUE = 'unique',
CHECK = 'check',
NOT_NULL = 'not_null'
}
export interface AssetLocation {
type: LocationType;
uri: string;
connection: string;
path?: string;
format?: string;
options?: Record<string, any>;
}
export enum LocationType {
DATABASE = 'database',
FILE_SYSTEM = 'file_system',
OBJECT_STORE = 'object_store',
STREAMING = 'streaming',
API_ENDPOINT = 'api_endpoint'
}
export interface AssetMetadata {
businessContext: BusinessContext;
technicalContext: TechnicalContext;
qualityProfile: QualityProfile;
usage: UsageProfile;
lineage: LineageInfo;
}
export interface QualityProfile {
completeness: number;
accuracy: number;
consistency: number;
validity: number;
freshness: number;
lastAssessed: Date;
}
export interface UsageProfile {
accessCount: number;
lastAccessed: Date;
popularQueries: string[];
topUsers: string[];
usagePattern: UsagePattern;
}
export enum UsagePattern {
BATCH = 'batch',
STREAMING = 'streaming',
INTERACTIVE = 'interactive',
MIXED = 'mixed'
}
export interface LineageInfo {
upstream: DataLineageNode[];
downstream: DataLineageNode[];
transformations: TransformationInfo[];
lastUpdated: Date;
}
export interface DataLineageNode {
id: string;
type: NodeType;
name: string;
path: string;
system: string;
}
export enum NodeType {
SOURCE = 'source',
TARGET = 'target',
TRANSFORM = 'transform',
VIEW = 'view',
TABLE = 'table',
FILE = 'file'
}
export interface TransformationInfo {
id: string;
type: string;
description: string;
code?: string;
parameters?: Record<string, any>;
}
export interface BusinessContext {
domain: string;
subdomain?: string;
businessOwner: string;
businessDescription?: string;
businessRules: string[];
criticalityLevel: CriticalityLevel;
}
export enum CriticalityLevel {
LOW = 'low',
MEDIUM = 'medium',
HIGH = 'high',
CRITICAL = 'critical'
}
export interface TechnicalContext {
dataOwner: string;
maintainer: string;
technology: string;
updateFrequency: UpdateFrequency;
retentionPolicy: RetentionPolicy;
backupPolicy: BackupPolicy;
}
export enum UpdateFrequency {
REAL_TIME = 'real_time',
STREAMING = 'streaming',
HOURLY = 'hourly',
DAILY = 'daily',
WEEKLY = 'weekly',
MONTHLY = 'monthly',
YEARLY = 'yearly',
MANUAL = 'manual'
}
export interface RetentionPolicy {
retentionPeriod: string;
archiveAfter?: string;
deleteAfter?: string;
retentionReason: string;
}
export interface BackupPolicy {
enabled: boolean;
frequency: string;
retentionPeriod: string;
location: string;
}
export interface GovernanceInfo {
classification: DataClassification;
sensitivityLevel: SensitivityLevel;
accessPolicy: string;
complianceRequirements: string[];
dataProtectionMeasures: string[];
approvalWorkflow?: string;
}
export enum DataClassification {
PUBLIC = 'public',
INTERNAL = 'internal',
CONFIDENTIAL = 'confidential',
RESTRICTED = 'restricted'
}
export enum SensitivityLevel {
LOW = 'low',
MEDIUM = 'medium',
HIGH = 'high',
CRITICAL = 'critical'
}

View file

@ -0,0 +1,183 @@
// Compliance and Regulatory Types
export interface CompliancePolicy {
id: string;
name: string;
description?: string;
regulation: RegulationType;
requirements: ComplianceRequirement[];
scope: ComplianceScope;
enabled: boolean;
metadata?: Record<string, any>;
}
export enum RegulationType {
SOX = 'sox',
GDPR = 'gdpr',
CCPA = 'ccpa',
HIPAA = 'hipaa',
PCI_DSS = 'pci_dss',
SOC2 = 'soc2',
ISO27001 = 'iso27001',
CUSTOM = 'custom'
}
export interface ComplianceRequirement {
id: string;
name: string;
description: string;
controls: ComplianceControl[];
severity: ComplianceSeverity;
mandatory: boolean;
}
export enum ComplianceSeverity {
LOW = 'low',
MEDIUM = 'medium',
HIGH = 'high',
CRITICAL = 'critical'
}
export interface ComplianceControl {
id: string;
type: ControlType;
implementation: ControlImplementation;
verification: ControlVerification;
status: ControlStatus;
}
export enum ControlType {
PREVENTIVE = 'preventive',
DETECTIVE = 'detective',
CORRECTIVE = 'corrective',
COMPENSATING = 'compensating'
}
export interface ControlImplementation {
automated: boolean;
frequency: ControlFrequency;
responsible: string[];
documentation: string[];
}
export enum ControlFrequency {
CONTINUOUS = 'continuous',
DAILY = 'daily',
WEEKLY = 'weekly',
MONTHLY = 'monthly',
QUARTERLY = 'quarterly',
ANNUALLY = 'annually',
ON_DEMAND = 'on_demand'
}
export interface ControlVerification {
method: VerificationMethod;
evidence: EvidenceType[];
frequency: ControlFrequency;
responsible: string[];
}
export enum VerificationMethod {
AUTOMATED_TEST = 'automated_test',
MANUAL_REVIEW = 'manual_review',
AUDIT = 'audit',
WALKTHROUGH = 'walkthrough',
OBSERVATION = 'observation'
}
export enum EvidenceType {
SCREENSHOT = 'screenshot',
LOG_FILE = 'log_file',
DOCUMENT = 'document',
REPORT = 'report',
ATTESTATION = 'attestation',
SYSTEM_OUTPUT = 'system_output'
}
export enum ControlStatus {
EFFECTIVE = 'effective',
INEFFECTIVE = 'ineffective',
NOT_TESTED = 'not_tested',
DEFICIENT = 'deficient',
NOT_APPLICABLE = 'not_applicable'
}
export interface ComplianceScope {
systems: string[];
processes: string[];
dataTypes: string[];
locations: string[];
timeframe: TimeFrame;
}
export interface TimeFrame {
start: Date;
end: Date;
ongoing: boolean;
}
export interface ComplianceAssessment {
id: string;
policyId: string;
timestamp: Date;
assessor: string;
status: AssessmentStatus;
findings: ComplianceFinding[];
recommendations: ComplianceRecommendation[];
score: number;
}
export enum AssessmentStatus {
COMPLIANT = 'compliant',
NON_COMPLIANT = 'non_compliant',
PARTIALLY_COMPLIANT = 'partially_compliant',
NOT_ASSESSED = 'not_assessed'
}
export interface ComplianceFinding {
id: string;
requirementId: string;
controlId: string;
severity: ComplianceSeverity;
description: string;
evidence: string[];
remediation: string;
dueDate?: Date;
status: FindingStatus;
}
export enum FindingStatus {
OPEN = 'open',
IN_PROGRESS = 'in_progress',
CLOSED = 'closed',
DEFERRED = 'deferred',
ACCEPTED_RISK = 'accepted_risk'
}
export interface ComplianceRecommendation {
id: string;
priority: RecommendationPriority;
description: string;
implementation: string;
effort: EffortLevel;
impact: ImpactLevel;
}
export enum RecommendationPriority {
LOW = 'low',
MEDIUM = 'medium',
HIGH = 'high',
URGENT = 'urgent'
}
export enum EffortLevel {
LOW = 'low',
MEDIUM = 'medium',
HIGH = 'high'
}
export enum ImpactLevel {
LOW = 'low',
MEDIUM = 'medium',
HIGH = 'high'
}

View file

@ -0,0 +1,6 @@
// Data governance and metadata management types
export * from './catalog';
export * from './quality';
export * from './lifecycle';
export * from './compliance';
export * from './access';

View file

@ -0,0 +1,160 @@
// Data Lifecycle Management Types
export interface LifecyclePolicy {
id: string;
name: string;
description?: string;
rules: LifecycleRule[];
scope: LifecycleScope;
enabled: boolean;
metadata?: Record<string, any>;
}
export interface LifecycleRule {
id: string;
name: string;
condition: LifecycleCondition;
actions: LifecycleAction[];
priority: number;
enabled: boolean;
}
export interface LifecycleCondition {
age?: AgeCriteria;
size?: SizeCriteria;
usage?: UsageCriteria;
tags?: TagCriteria;
custom?: string;
}
export interface AgeCriteria {
unit: LifecycleTimeUnit;
value: number;
}
export enum LifecycleTimeUnit {
DAYS = 'days',
WEEKS = 'weeks',
MONTHS = 'months',
YEARS = 'years'
}
export interface SizeCriteria {
unit: SizeUnit;
value: number;
}
export enum SizeUnit {
BYTES = 'bytes',
KB = 'kb',
MB = 'mb',
GB = 'gb',
TB = 'tb'
}
export interface UsageCriteria {
accessCount: number;
lastAccessed: Date;
}
export interface TagCriteria {
tags: Record<string, string>;
operator: TagOperator;
}
export enum TagOperator {
AND = 'and',
OR = 'or',
NOT = 'not'
}
export interface LifecycleAction {
type: LifecycleActionType;
config: LifecycleActionConfig;
}
export enum LifecycleActionType {
ARCHIVE = 'archive',
DELETE = 'delete',
COMPRESS = 'compress',
MIGRATE = 'migrate',
NOTIFY = 'notify',
CUSTOM = 'custom'
}
export interface LifecycleActionConfig {
destination?: string;
notification?: NotificationConfig;
compression?: CompressionConfig;
migration?: MigrationConfig;
custom?: Record<string, any>;
}
export interface NotificationConfig {
recipients: string[];
subject: string;
template: string;
}
export interface CompressionConfig {
algorithm: CompressionAlgorithm;
level: number;
}
export enum CompressionAlgorithm {
GZIP = 'gzip',
BZIP2 = 'bzip2',
LZ4 = 'lz4',
ZSTD = 'zstd'
}
export interface MigrationConfig {
destination: string;
preserveMetadata: boolean;
verification: boolean;
}
export interface LifecycleScope {
datasets?: string[];
collections?: string[];
tags?: Record<string, string>;
pattern?: string;
}
export interface LifecycleExecution {
id: string;
policyId: string;
timestamp: Date;
status: ExecutionStatus;
summary: ExecutionSummary;
details: ExecutionDetail[];
}
export enum ExecutionStatus {
PENDING = 'pending',
RUNNING = 'running',
COMPLETED = 'completed',
FAILED = 'failed',
CANCELLED = 'cancelled'
}
export interface ExecutionSummary {
totalItems: number;
processedItems: number;
failedItems: number;
duration: number;
}
export interface ExecutionDetail {
itemId: string;
action: LifecycleActionType;
status: ItemStatus;
message?: string;
timestamp: Date;
}
export enum ItemStatus {
SUCCESS = 'success',
FAILED = 'failed',
SKIPPED = 'skipped'
}

View file

@ -0,0 +1,107 @@
// Data Quality Management Types
export interface DataQualityProfile {
id: string;
name: string;
description?: string;
rules: DataQualityRule[];
thresholds: QualityThreshold[];
schedule?: QualitySchedule;
enabled: boolean;
metadata?: Record<string, any>;
}
export interface DataQualityRule {
id: string;
name: string;
type: QualityRuleType;
condition: string;
severity: QualitySeverity;
message?: string;
enabled: boolean;
}
export enum QualityRuleType {
COMPLETENESS = 'completeness',
UNIQUENESS = 'uniqueness',
VALIDITY = 'validity',
CONSISTENCY = 'consistency',
ACCURACY = 'accuracy',
TIMELINESS = 'timeliness',
CUSTOM = 'custom'
}
export enum QualitySeverity {
LOW = 'low',
MEDIUM = 'medium',
HIGH = 'high',
CRITICAL = 'critical'
}
export interface QualityThreshold {
metric: string;
operator: ThresholdOperator;
value: number;
severity: QualitySeverity;
}
export enum ThresholdOperator {
GREATER_THAN = 'gt',
GREATER_THAN_EQUAL = 'gte',
LESS_THAN = 'lt',
LESS_THAN_EQUAL = 'lte',
EQUAL = 'eq',
NOT_EQUAL = 'ne'
}
export interface QualitySchedule {
cron: string;
timezone: string;
enabled: boolean;
}
export interface QualityReport {
id: string;
profileId: string;
datasetId: string;
timestamp: Date;
status: QualityStatus;
metrics: QualityMetrics;
violations: QualityViolation[];
summary: QualitySummary;
}
export enum QualityStatus {
PASSED = 'passed',
WARNING = 'warning',
FAILED = 'failed',
ERROR = 'error'
}
export interface QualityMetrics {
completeness: number;
uniqueness: number;
validity: number;
consistency: number;
accuracy: number;
timeliness: number;
overall: number;
}
export interface QualityViolation {
ruleId: string;
ruleName: string;
severity: QualitySeverity;
count: number;
percentage: number;
samples?: any[];
message: string;
}
export interface QualitySummary {
totalRecords: number;
validRecords: number;
invalidRecords: number;
score: number;
status: QualityStatus;
}

View file

@ -13,5 +13,103 @@ export * from './strategy/backtest';
// Events
export * from './events/events';
// API Types
export * from './api/api';
// API Types - Use aliases to avoid conflicts
export {
ServiceConfig,
ApiHealthStatus,
ApiResponse,
PaginatedResponse,
ErrorResponse as ApiErrorResponse,
SuccessResponse
} from './api/api';
// Configuration Types (Core config only to avoid conflicts)
export * from './config/database';
export * from './config/logging';
export * from './config/security';
// Monitoring Types - Use aliases to avoid conflicts
export {
HealthStatus,
HealthCheckConfig as MonitoringHealthCheckConfig,
DependencyHealth,
HealthMetrics,
ReadinessCheck,
LivenessCheck
} from './monitoring/health';
export * from './monitoring/metrics';
// Data Processing Types - Use aliases to avoid conflicts
export {
DataSourceConfig,
DataRateLimitConfig,
DataConnectionConfig,
DataAuthenticationConfig,
SubscriptionConfig as DataSubscriptionConfig,
RetryPolicyConfig
} from './data/sources';
export * from './data/processors';
// Communication Types - Main subscription system preferred
export * from './communication/subscriptions';
export * from './communication/messages';
// Error Handling Types - Use aliases to avoid conflicts
export {
BaseError,
ErrorContext,
ErrorResponse as BaseErrorResponse,
ErrorCode,
ErrorSeverity as BaseErrorSeverity
} from './errors/base';
export {
ValidationError,
ValidationRule as ErrorValidationRule,
SchemaValidationError,
BusinessRuleValidationError
} from './errors/validation';
export * from './errors/network';
export * from './errors/business';
export * from './errors/application';
// Governance Types - Catalog types with alias to avoid conflicts
export {
DataAsset,
AssetType,
DataSchema as CatalogDataSchema,
ColumnDefinition,
ColumnStatistics,
ValueCount,
ForeignKey as CatalogForeignKey,
IndexDefinition,
IndexType,
ConstraintDefinition,
ConstraintType,
AssetLocation,
LocationType,
AssetMetadata,
QualityProfile,
UsageProfile,
UsagePattern,
LineageInfo,
DataLineageNode,
NodeType,
TransformationInfo,
BusinessContext,
CriticalityLevel,
TechnicalContext,
UpdateFrequency,
RetentionPolicy as CatalogRetentionPolicy,
BackupPolicy,
GovernanceInfo,
DataClassification as CatalogDataClassification,
SensitivityLevel
} from './governance/catalog';
// All modules successfully enabled - conflicts resolved with type renaming and aliases
export * from './communication/websocket';
export * from './communication/protocols';
export * from './governance/quality';
export * from './governance/lifecycle';
export * from './governance/compliance';
export * from './governance/access';

View file

@ -1,4 +1,65 @@
// Market Data Types
export interface MarketDataTick {
symbol: string;
timestamp: number;
price: number;
volume: number;
bid?: number;
ask?: number;
bidSize?: number;
askSize?: number;
source: string;
exchange?: string;
lastTradeSize?: number;
dayHigh?: number;
dayLow?: number;
dayOpen?: number;
prevClose?: number;
change?: number;
changePercent?: number;
}
export interface MarketDataCandle {
symbol: string;
timestamp: number;
open: number;
high: number;
low: number;
close: number;
volume: number;
timeframe: string;
source: string;
exchange?: string;
vwap?: number;
trades?: number;
}
export interface MarketDataTrade {
id: string;
symbol: string;
timestamp: number;
price: number;
size: number;
side: 'buy' | 'sell';
source: string;
exchange?: string;
conditions?: string[];
}
export interface MarketDataOrder {
id: string;
symbol: string;
timestamp: number;
side: 'buy' | 'sell';
price: number;
size: number;
source: string;
exchange?: string;
orderType?: 'market' | 'limit' | 'stop';
level?: number;
}
// Legacy types for backward compatibility
export interface OHLCV {
symbol: string;
timestamp: Date;

View file

@ -0,0 +1,83 @@
// Alert and Notification Types
export interface Alert {
id: string;
ruleId: string;
severity: 'info' | 'warning' | 'error' | 'critical';
title: string;
message: string;
timestamp: Date;
resolved: boolean;
resolvedAt?: Date;
metadata?: Record<string, any>;
source: string;
tags?: string[];
}
export interface AlertRule {
id: string;
name: string;
metric: string;
condition: 'gt' | 'lt' | 'eq' | 'ne' | 'gte' | 'lte';
threshold: number;
duration: number;
enabled: boolean;
severity?: 'info' | 'warning' | 'error' | 'critical';
description?: string;
labels?: Record<string, string>;
annotations?: Record<string, string>;
}
export interface AlertChannel {
id: string;
name: string;
type: 'email' | 'slack' | 'webhook' | 'pagerduty' | 'discord';
config: AlertChannelConfig;
enabled: boolean;
filters?: AlertFilter[];
}
export interface AlertChannelConfig {
url?: string;
token?: string;
channel?: string;
username?: string;
password?: string;
headers?: Record<string, string>;
template?: string;
}
export interface AlertFilter {
field: string;
operator: 'equals' | 'contains' | 'regex' | 'not_equals';
value: string;
}
export interface NotificationConfig {
enabled: boolean;
channels: AlertChannel[];
defaultChannel: string;
retryAttempts: number;
retryDelay: number;
batchSize: number;
batchDelay: number;
}
export interface AlertHistory {
alertId: string;
action: 'triggered' | 'resolved' | 'acknowledged' | 'silenced';
timestamp: Date;
user?: string;
reason?: string;
metadata?: Record<string, any>;
}
export interface AlertSummary {
total: number;
critical: number;
error: number;
warning: number;
info: number;
resolved: number;
active: number;
timeRange: string;
}

View file

@ -0,0 +1,52 @@
// Health Check Types
export interface HealthStatus {
service: string;
status: 'healthy' | 'degraded' | 'unhealthy';
timestamp: Date;
uptime: number;
version: string;
dependencies: DependencyHealth[];
metrics: HealthMetrics;
message?: string;
details?: Record<string, any>;
}
export interface DependencyHealth {
name: string;
status: 'healthy' | 'unhealthy';
latencyMs?: number;
error?: string;
lastChecked?: Date;
version?: string;
}
export interface HealthMetrics {
connectionsActive: number;
messagesPerSecond: number;
errorRate: number;
avgLatencyMs: number;
memoryUsageMB?: number;
cpuUsagePercent?: number;
}
export interface HealthCheckConfig {
intervalMs: number;
timeoutMs: number;
retries: number;
enabledChecks: string[];
endpoints: Record<string, string>;
}
export interface ReadinessCheck {
name: string;
check: () => Promise<boolean>;
timeout: number;
critical: boolean;
}
export interface LivenessCheck {
name: string;
check: () => Promise<boolean>;
timeout: number;
restartOnFailure: boolean;
}

View file

@ -0,0 +1,5 @@
// Health Check and Monitoring Types
export * from './health';
export * from './metrics';
export * from './alerts';
export * from './system';

View file

@ -0,0 +1,131 @@
// Metrics Collection Types
export interface Metric {
name: string;
type: 'counter' | 'gauge' | 'histogram' | 'summary';
value: number;
labels?: Record<string, string>;
timestamp: Date;
unit?: string;
description?: string;
}
export interface MetricPoint {
timestamp: number;
value: number;
labels?: Record<string, string>;
}
export interface TimeSeriesMetric {
name: string;
points: MetricPoint[];
retentionMs: number;
}
export interface AggregatedMetrics {
totalMessages: number;
messagesPerSecond: number;
averageLatency: number;
errorRate: number;
activeConnections: number;
activeSubscriptions: number;
cacheHitRate: number;
uptime: number;
timestamp: string;
dataSources: Map<string, DataSourceMetrics>;
processing: ProcessingMetrics;
subscriptions: MonitoringSubscriptionMetrics;
}
export interface DataSourceMetrics {
sourceId: string;
timestamp: Date;
connections: ConnectionMetrics;
messages: MessageMetrics;
latency: LatencyMetrics;
bandwidth: BandwidthMetrics;
}
export interface ConnectionMetrics {
active: number;
total: number;
failed: number;
}
export interface MessageMetrics {
received: number;
processed: number;
errors: number;
dropped: number;
}
export interface LatencyMetrics {
avgMs: number;
p50Ms: number;
p95Ms: number;
p99Ms: number;
}
export interface BandwidthMetrics {
inboundBytesPerSecond: number;
outboundBytesPerSecond: number;
}
export interface ProcessingMetrics {
totalProcessed: number;
processedPerSecond: number;
processingLatency: number;
errorCount: number;
queueDepth: number;
processorMetrics: Map<string, any>;
}
export interface MonitoringSubscriptionMetrics {
totalSubscriptions: number;
activeClients: number;
messagesSent: number;
sendRate: number;
bandwidthUsage: number;
}
export interface SystemMetrics {
uptime: number;
memory: MemoryMetrics;
cpu: CpuMetrics;
network: NetworkMetrics;
disk: DiskMetrics;
timestamp: string;
}
export interface MemoryMetrics {
used: number;
total: number;
free: number;
heapUsed: number;
heapTotal: number;
external: number;
}
export interface CpuMetrics {
user: number;
system: number;
idle: number;
usage: number;
}
export interface NetworkMetrics {
bytesIn: number;
bytesOut: number;
packetsIn: number;
packetsOut: number;
errors: number;
}
export interface DiskMetrics {
used: number;
total: number;
free: number;
readOps: number;
writeOps: number;
readBytes: number;
writeBytes: number;
}

View file

@ -0,0 +1,57 @@
import { ApiKeyConfig } from '../config/security';
import { RetryConfig } from '../config/networking';
// System and Service Integration Types
export interface ServiceHealth {
serviceId: string;
status: 'healthy' | 'degraded' | 'unhealthy' | 'unreachable';
lastCheck: number;
responseTime: number;
errorCount: number;
version?: string;
metadata?: Record<string, any>;
}
export interface IntegrationMetrics {
totalRequests: number;
successfulRequests: number;
failedRequests: number;
averageResponseTime: number;
lastRequestTime: number;
errorRate: number;
uptime: number;
}
export interface ServiceIntegration {
serviceName: string;
endpoint: string;
healthCheck: string;
authentication?: ApiKeyConfig;
retryPolicy: RetryConfig;
timeout?: number;
enabled: boolean;
}
export interface ServiceEndpoint {
id: string;
name: string;
url: string;
method: string;
headers?: Record<string, string>;
timeout: number;
retries: number;
healthCheck?: boolean;
}
export interface ServiceRegistry {
services: Map<string, ServiceEndpoint>;
lastUpdated: Date;
version: string;
}
export interface ServiceDiscovery {
provider: 'consul' | 'etcd' | 'kubernetes' | 'static';
config: Record<string, any>;
refreshInterval: number;
healthCheckInterval: number;
}

View file

@ -10,7 +10,7 @@
"clean": "rm -rf dist",
"test": "jest"
}, "dependencies": {
"@stock-bot/shared-types": "workspace:*",
"@stock-bot/types": "workspace:*",
"@stock-bot/config": "workspace:*",
"date-fns": "^2.30.0"
},

16
package-lock.json generated
View file

@ -25,7 +25,7 @@
"version": "1.0.0",
"dependencies": {
"@stock-bot/config": "*",
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"hono": "^4.6.3",
"ioredis": "^5.4.1",
"ws": "^8.18.0"
@ -39,7 +39,7 @@
"version": "1.0.0",
"dependencies": {
"@stock-bot/config": "*",
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"hono": "^4.6.3",
"ioredis": "^5.4.1",
"ws": "^8.18.0"
@ -53,7 +53,7 @@
"version": "1.0.0",
"dependencies": {
"@stock-bot/config": "*",
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"hono": "^4.6.3",
"ioredis": "^5.4.1",
"node-cron": "^3.0.3",
@ -1886,8 +1886,8 @@
"resolved": "packages/config",
"link": true
},
"node_modules/@stock-bot/shared-types": {
"resolved": "packages/shared-types",
"node_modules/@stock-bot/types": {
"resolved": "packages/types",
"link": true
},
"node_modules/@tailwindcss/node": {
@ -7960,7 +7960,7 @@
"name": "@stock-bot/config",
"version": "1.0.0",
"dependencies": {
"@stock-bot/shared-types": "*",
"@stock-bot/types": "*",
"dotenv": "^16.4.5"
},
"devDependencies": {
@ -7968,8 +7968,8 @@
"typescript": "^5.4.5"
}
},
"packages/shared-types": {
"name": "@stock-bot/shared-types",
"packages/types": {
"name": "@stock-bot/types",
"version": "1.0.0",
"devDependencies": {
"typescript": "^5.4.5"

View file

@ -4,7 +4,7 @@ Write-Host "Building and installing new libraries..." -ForegroundColor Cyan
# Build order is important due to dependencies
$libs = @(
"shared-types",
"types",
"utils",
"event-bus",
"api-client"

View file

@ -78,7 +78,7 @@ You don't need to change your imports yet, but this path will be removed in a fu
# Create aliases for each library
Write-ColorOutput "Yellow" "Creating package aliases for backward compatibility..."
Create-PackageAlias "shared-types"
Create-PackageAlias "types"
# Create additional aliases as needed for other libraries

View file

@ -45,7 +45,7 @@
{ "path": "./libs/config" },
{ "path": "./libs/event-bus" },
{ "path": "./libs/http-client" },
{ "path": "./libs/shared-types" },
{ "path": "./libs/types" },
{ "path": "./libs/utils" },
]