watchtower-node-sdk
Version:
A TypeScript Node.js SDK for the Watchtower API, providing API key management, connection string generation, and more
325 lines (324 loc) • 7.54 kB
TypeScript
export interface WatchtowerConfig {
timeout?: number;
}
export interface WatchtowerOptions {
timeout?: number;
headers?: Record<string, string>;
}
export interface WatchtowerResponse<T> {
data: T;
status: number;
headers: Record<string, string>;
}
export interface HealthResponse {
status: 'ok' | 'error';
supabase: 'connected' | 'disconnected';
timestamp: string;
}
export interface VerifyOrganizationApiKeyRequest {
apiKey: string;
}
export interface VerifyOrganizationApiKeyResponse {
organization_id: string;
}
export interface VerifyAppApiKeyRequest {
apiKey: string;
}
export interface VerifyAppApiKeyResponse {
app_id: string;
}
export interface Metric {
name: string;
friendly_name: string;
value: any;
unit: string;
}
export interface LogEntry {
item_id: string;
timestamp: string;
purpose?: string;
context?: string;
level?: string;
message?: string;
friendly_name?: string;
metadata?: Record<string, any>;
metrics?: Metric[];
}
export interface CreateLogRequest {
organization_apikey: string;
app_apikey: string;
tenant_apikey?: string;
log_entry: LogEntry;
}
export interface CreateLogResponse {
status: 'created';
event_id: string;
}
export interface GetLogsRequest {
organization_apikey: string;
app_apikey: string;
tenant_apikey?: string;
item_id: string;
limit?: number;
days?: number;
}
export interface LogData extends LogEntry {
item_id: string;
}
export interface Log {
id: number;
app_id: string;
tenant_id: string;
item_id: string;
log_data: LogData;
created_at: string;
}
export interface GetLogsResponse {
logs: LogResponse[];
total_count: number;
page_size: number;
page: number;
total_pages: number;
has_more: boolean;
}
export interface AnalyzeRequest {
organization_apikey: string;
app_apikey: string;
tenant_apikey?: string;
item_id: string;
limit?: number;
days?: number;
}
export interface MetricSummary {
min: number;
max: number;
average: number;
standard_deviation: number;
}
export interface TimeSeriesMetric {
blade_angle: number;
efficiency: number;
humidity: number;
is_connected: boolean;
is_running: boolean;
maintenance_mode: boolean;
operation_mode: string;
power_output: number;
rotor_speed: number;
safety_checks_passed: boolean;
temperature: number;
weather: string;
wind_condition: string;
wind_speed: number;
windmill_state: string;
}
export interface TimeSeriesEntry {
timestamp: string;
metrics: TimeSeriesMetric;
}
export interface Alert {
level: string;
title: string;
description: string;
metric: string;
value: string;
threshold: string;
}
export interface MetricStatus {
status: string;
value: string;
unit?: string;
description: string;
}
export interface ContextInfo {
context: string;
count: number;
first_seen: string;
last_seen: string;
relevance: string;
description: string;
impact: string;
}
export interface CurrentStatus {
status: string;
description: string;
alerts: Alert[] | null;
metrics: Record<string, MetricStatus>;
}
export interface Pattern {
type: string;
title: string;
description: string;
confidence: number;
}
export interface Insight {
category: string;
title: string;
description: string;
impact: string;
}
export interface Recommendation {
priority: 'low' | 'medium' | 'high';
title: string;
description: string;
action: string;
}
export interface MetricAnalysis {
status: string;
trend: string;
summary: string;
anomalies: any[];
recommendations: Recommendation[];
}
export interface HistoricalAnalysis {
patterns: Pattern[];
anomalies: any[];
insights: Insight[];
recommendations: Recommendation[];
metrics: Record<string, MetricAnalysis>;
}
export interface AIAnalysis {
timestamp: string;
overview: string;
status_summary: string;
current_status: CurrentStatus;
historical_analysis: HistoricalAnalysis;
}
export interface AnalyzeResponse {
summary: {
total_logs: number;
time_range: string;
first_log_time: string;
last_log_time: string;
average_interval: string;
item_id: string;
};
metrics: Record<string, MetricSummary>;
time_series: TimeSeriesEntry[];
ai_analysis: AIAnalysis;
}
export interface Location {
farm: string;
turbine_number: string;
coordinates: {
latitude: number;
longitude: number;
};
}
export interface Maintenance {
last_service_date: string;
next_service_due: number;
total_operation_hours: number;
maintenance_status: string;
}
export interface LogMetadata {
windmill_id: string;
model: string;
manufacturer: string;
serial_number: string;
installation_date: string;
location: Location;
maintenance: Maintenance;
}
export interface BatchLogEntry {
item_id: string;
timestamp: string;
purpose?: string;
context?: string;
level?: string;
message?: string;
friendly_name?: string;
metadata?: Record<string, any>;
metrics?: Metric[];
}
export interface CreateBatchLogsRequest {
organization_apikey: string;
app_apikey: string;
tenant_apikey?: string;
log_entries: BatchLogEntry[];
}
export interface CreateBatchLogsResponse {
status: 'created';
event_ids: string[];
}
export interface CreateTenantRequest {
org_apikey: string;
app_apikey: string;
client_email: string;
}
export interface CreateTenantResponse {
tenant_apikey: string;
}
export interface ValidateTenantRequest {
apikey: string;
}
export interface ValidateTenantResponse {
valid: boolean;
organization_id: string;
app_id: string;
tenant_id: string;
}
export interface LogResponse {
id: number;
app_id: string;
tenant_id?: string;
item_id: string;
friendly_name?: string;
log_data: BatchLogEntry;
created_at: string;
}
export interface ItemStatus {
item_id: string;
friendly_name: string;
status_summary: string;
}
export interface AppStatusOverviewRequest {
organization_apikey: string;
app_apikey: string;
tenant_apikey?: string;
}
export interface AppStatusOverviewResponse {
timestamp: string;
overview: string;
status: string;
item_statuses: ItemStatus[];
recommendations: Recommendation[];
}
export interface AnalyzeCurrentRequest {
organization_apikey: string;
app_apikey: string;
tenant_apikey?: string;
log_entry: LogEntry;
}
export interface AnalyzeCurrentResponse {
timestamp: string;
overview: string;
status_summary: string;
current_status: CurrentStatus;
historical_analysis: HistoricalAnalysis;
}
export interface GetItemsRequest {
organization_apikey: string;
app_apikey: string;
tenant_apikey?: string;
}
export interface Item {
item_id: string;
friendly_name: string;
}
export interface GetItemsResponse {
items: Item[];
}
export interface GetLatestAnalysisRequest {
organization_apikey: string;
app_apikey: string;
tenant_apikey?: string;
item_id: string;
}
export interface GetLatestAnalysisResponse {
timestamp: string;
overview: string;
status_summary: string;
current_status: CurrentStatus;
historical_analysis: HistoricalAnalysis;
}