@smartsamurai/krapi-sdk
Version:
KRAPI TypeScript SDK - Easy-to-use client SDK for connecting to self-hosted KRAPI servers (like Appwrite SDK)
125 lines (112 loc) • 3.37 kB
text/typescript
/**
* Project Management Types
*/
import { QueryOptions } from "./core";
export interface Project {
id: string;
name: string;
description?: string;
status: ProjectStatus;
owner_id: string;
created_at: string;
updated_at: string;
settings: ProjectSettings;
metadata?: Record<string, unknown>;
stats?: ProjectStats;
// Additional properties for backend compatibility
storage_used?: number;
allowed_origins?: string[];
total_api_calls?: number;
last_api_call?: string;
// Backend-specific properties
project_url?: string;
active?: boolean;
created_by?: string;
rate_limit?: number;
rate_limit_window?: number;
}
export type ProjectStatus = "active" | "inactive" | "suspended" | "archived";
export interface ProjectSettings {
public: boolean;
allow_registration: boolean;
require_email_verification: boolean;
max_users?: number;
max_collections?: number;
max_documents_per_collection?: number;
max_file_size?: number;
allowed_file_types?: string[];
cors_origins?: string[];
webhook_urls?: string[];
rate_limits?: {
requests_per_minute?: number;
requests_per_hour?: number;
requests_per_day?: number;
};
custom_domain?: string;
timezone?: string;
locale?: string;
email_config?: {
smtp_host: string;
smtp_port: number;
smtp_secure: boolean;
smtp_username: string;
smtp_password: string;
from_email: string;
from_name: string;
};
// Backend-specific properties
authentication_required?: boolean;
cors_enabled?: boolean;
rate_limiting_enabled?: boolean;
logging_enabled?: boolean;
encryption_enabled?: boolean;
backup_enabled?: boolean;
backup_automation?: {
enabled: boolean;
frequency: "hourly" | "daily" | "weekly" | "monthly";
time?: string; // Time of day for daily/weekly/monthly backups (HH:mm format)
day_of_week?: number; // 0-6 for weekly backups (0 = Sunday)
day_of_month?: number; // 1-31 for monthly backups
retention_days?: number; // How many days to keep backups (default: 30)
max_backups?: number; // Maximum number of backups to keep (default: 10)
include_files?: boolean; // Whether to include files in backup
description_template?: string; // Template for backup description (e.g., "Automated backup - {date}")
};
custom_headers?: Record<string, string>;
environment?: "development" | "staging" | "production";
}
export interface ProjectStats {
total_users: number;
total_collections: number;
total_documents: number;
total_files: number;
storage_used: number;
api_requests_today: number;
api_requests_month: number;
// Additional properties for backend compatibility
api_calls_count?: number;
last_api_call?: string;
collections_count?: number;
documents_count?: number;
users_count?: number;
}
// Backward compatibility alias
export type ProjectStatistics = ProjectStats;
export interface CreateProjectRequest {
name: string;
description?: string;
settings?: Partial<ProjectSettings>;
metadata?: Record<string, unknown>;
}
export interface UpdateProjectRequest {
name?: string;
description?: string;
status?: ProjectStatus;
settings?: Partial<ProjectSettings>;
metadata?: Record<string, unknown>;
}
export interface ProjectListOptions extends QueryOptions {
status?: ProjectStatus;
owner_id?: string;
page?: number;
}