ADD new frontend
This commit is contained in:
@@ -1,126 +0,0 @@
|
||||
// frontend/src/types/alerts.ts
|
||||
/**
|
||||
* TypeScript types for the unified alert and recommendation system
|
||||
*/
|
||||
|
||||
export type ItemType = 'alert' | 'recommendation';
|
||||
|
||||
export type ItemSeverity = 'urgent' | 'high' | 'medium' | 'low';
|
||||
|
||||
export type ItemStatus = 'active' | 'acknowledged' | 'resolved';
|
||||
|
||||
export interface AlertItem {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
item_type: ItemType;
|
||||
type: string; // Specific alert/recommendation type
|
||||
severity: ItemSeverity;
|
||||
status: ItemStatus;
|
||||
service: string;
|
||||
title: string;
|
||||
message: string;
|
||||
actions: string[];
|
||||
metadata: Record<string, any>;
|
||||
created_at: string;
|
||||
acknowledged_at?: string;
|
||||
acknowledged_by?: string;
|
||||
resolved_at?: string;
|
||||
resolved_by?: string;
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
export interface SSEEvent {
|
||||
event: string;
|
||||
data: string;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export interface ItemFilters {
|
||||
item_type: ItemType | 'all';
|
||||
severity: ItemSeverity | 'all';
|
||||
status: ItemStatus | 'all';
|
||||
service: string | 'all';
|
||||
search: string;
|
||||
}
|
||||
|
||||
export interface ItemCounts {
|
||||
total: number;
|
||||
alerts: {
|
||||
urgent: number;
|
||||
high: number;
|
||||
medium: number;
|
||||
low: number;
|
||||
};
|
||||
recommendations: {
|
||||
high: number;
|
||||
medium: number;
|
||||
low: number;
|
||||
};
|
||||
by_status: {
|
||||
active: number;
|
||||
acknowledged: number;
|
||||
resolved: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface NotificationSettings {
|
||||
browser_notifications: boolean;
|
||||
sound_enabled: boolean;
|
||||
auto_acknowledge_timeout: number; // minutes
|
||||
show_recommendations: boolean;
|
||||
urgent_only: boolean;
|
||||
}
|
||||
|
||||
export interface SSEConnectionState {
|
||||
status: 'connecting' | 'connected' | 'disconnected' | 'error';
|
||||
lastConnected?: Date;
|
||||
reconnectAttempts: number;
|
||||
latency?: number;
|
||||
}
|
||||
|
||||
// Notification permission states
|
||||
export type NotificationPermission = 'default' | 'granted' | 'denied';
|
||||
|
||||
// UI state
|
||||
export interface AlertUIState {
|
||||
filters: ItemFilters;
|
||||
selectedItems: string[];
|
||||
sortBy: 'created_at' | 'severity' | 'type';
|
||||
sortOrder: 'asc' | 'desc';
|
||||
viewMode: 'list' | 'grid' | 'compact';
|
||||
sidebarOpen: boolean;
|
||||
bulkActionsOpen: boolean;
|
||||
}
|
||||
|
||||
// Action types for alert responses
|
||||
export interface AlertAction {
|
||||
id: string;
|
||||
label: string;
|
||||
type: 'acknowledge' | 'resolve' | 'custom';
|
||||
icon?: string;
|
||||
variant?: 'primary' | 'secondary' | 'danger';
|
||||
requires_confirmation?: boolean;
|
||||
}
|
||||
|
||||
// Metrics for dashboard
|
||||
export interface AlertMetrics {
|
||||
response_time_avg: number; // seconds
|
||||
false_positive_rate: number;
|
||||
recommendation_adoption_rate: number;
|
||||
items_last_24h: number;
|
||||
top_alert_types: Array<{
|
||||
type: string;
|
||||
count: number;
|
||||
}>;
|
||||
service_health: Record<string, boolean>;
|
||||
}
|
||||
|
||||
// Template for creating new alerts (development/testing)
|
||||
export interface AlertTemplate {
|
||||
type: string;
|
||||
severity: ItemSeverity;
|
||||
title: string;
|
||||
message: string;
|
||||
actions: string[];
|
||||
metadata?: Record<string, any>;
|
||||
}
|
||||
565
frontend/src/types/api.types.ts
Normal file
565
frontend/src/types/api.types.ts
Normal file
@@ -0,0 +1,565 @@
|
||||
// API and common response types
|
||||
|
||||
// Base API response structure
|
||||
export interface ApiResponse<T = any> {
|
||||
data: T;
|
||||
success: boolean;
|
||||
message?: string;
|
||||
error?: string;
|
||||
timestamp?: string;
|
||||
}
|
||||
|
||||
// Error response structure
|
||||
export interface ApiError {
|
||||
success: false;
|
||||
error: ErrorDetail;
|
||||
timestamp: string;
|
||||
request_id?: string;
|
||||
}
|
||||
|
||||
export interface ErrorDetail {
|
||||
message: string;
|
||||
code?: string;
|
||||
field?: string;
|
||||
details?: Record<string, any>;
|
||||
}
|
||||
|
||||
// Pagination types
|
||||
export interface PaginatedResponse<T> {
|
||||
items: T[];
|
||||
total: number;
|
||||
page: number;
|
||||
size: number;
|
||||
pages: number;
|
||||
has_next: boolean;
|
||||
has_prev: boolean;
|
||||
}
|
||||
|
||||
export interface PaginationParams {
|
||||
page?: number;
|
||||
size?: number;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
}
|
||||
|
||||
// Sorting and filtering
|
||||
export interface SortParams {
|
||||
sort_by?: string;
|
||||
sort_order?: SortOrder;
|
||||
order_by?: string;
|
||||
order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
export interface FilterParams {
|
||||
search?: string;
|
||||
q?: string;
|
||||
filters?: Record<string, any>;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface QueryParams extends PaginationParams, SortParams, FilterParams {}
|
||||
|
||||
// File upload types
|
||||
export interface FileUploadResponse {
|
||||
file_id: string;
|
||||
filename: string;
|
||||
size: number;
|
||||
mime_type: string;
|
||||
url?: string;
|
||||
download_url?: string;
|
||||
expires_at?: string;
|
||||
}
|
||||
|
||||
export interface FileUploadProgress {
|
||||
loaded: number;
|
||||
total: number;
|
||||
percentage: number;
|
||||
speed?: number;
|
||||
estimated_time?: number;
|
||||
}
|
||||
|
||||
export interface BulkOperationResponse {
|
||||
total: number;
|
||||
processed: number;
|
||||
successful: number;
|
||||
failed: number;
|
||||
errors: BulkOperationError[];
|
||||
warnings?: BulkOperationWarning[];
|
||||
}
|
||||
|
||||
export interface BulkOperationError {
|
||||
index: number;
|
||||
item_id?: string;
|
||||
error_code: string;
|
||||
message: string;
|
||||
field?: string;
|
||||
details?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface BulkOperationWarning {
|
||||
index: number;
|
||||
item_id?: string;
|
||||
warning_code: string;
|
||||
message: string;
|
||||
suggestion?: string;
|
||||
}
|
||||
|
||||
// Task/Job status types
|
||||
export interface TaskStatus {
|
||||
task_id: string;
|
||||
status: TaskStatusType;
|
||||
progress: number;
|
||||
message: string;
|
||||
result?: any;
|
||||
error?: string;
|
||||
created_at: string;
|
||||
started_at?: string;
|
||||
completed_at?: string;
|
||||
estimated_completion?: string;
|
||||
}
|
||||
|
||||
export interface LongRunningTask {
|
||||
id: string;
|
||||
name: string;
|
||||
type: TaskType;
|
||||
status: TaskStatusType;
|
||||
progress: number;
|
||||
total_steps?: number;
|
||||
current_step?: number;
|
||||
step_description?: string;
|
||||
result_data?: any;
|
||||
error_details?: TaskError;
|
||||
created_by: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface TaskError {
|
||||
code: string;
|
||||
message: string;
|
||||
stack_trace?: string;
|
||||
context?: Record<string, any>;
|
||||
}
|
||||
|
||||
// Health check types
|
||||
export interface HealthCheckResponse {
|
||||
status: HealthStatus;
|
||||
timestamp: string;
|
||||
version: string;
|
||||
uptime: number;
|
||||
services: ServiceHealth[];
|
||||
system_info?: SystemInfo;
|
||||
}
|
||||
|
||||
export interface ServiceHealth {
|
||||
name: string;
|
||||
status: HealthStatus;
|
||||
response_time_ms?: number;
|
||||
error_message?: string;
|
||||
dependencies?: ServiceHealth[];
|
||||
}
|
||||
|
||||
export interface SystemInfo {
|
||||
memory_usage: MemoryUsage;
|
||||
cpu_usage?: number;
|
||||
disk_usage?: DiskUsage;
|
||||
network_stats?: NetworkStats;
|
||||
}
|
||||
|
||||
export interface MemoryUsage {
|
||||
used: number;
|
||||
available: number;
|
||||
total: number;
|
||||
percentage: number;
|
||||
}
|
||||
|
||||
export interface DiskUsage {
|
||||
used: number;
|
||||
available: number;
|
||||
total: number;
|
||||
percentage: number;
|
||||
}
|
||||
|
||||
export interface NetworkStats {
|
||||
bytes_sent: number;
|
||||
bytes_received: number;
|
||||
packets_sent: number;
|
||||
packets_received: number;
|
||||
}
|
||||
|
||||
// Audit and logging types
|
||||
export interface AuditLog {
|
||||
id: string;
|
||||
user_id: string;
|
||||
user_email: string;
|
||||
tenant_id: string;
|
||||
action: AuditAction;
|
||||
resource_type: ResourceType;
|
||||
resource_id: string;
|
||||
changes?: AuditChange[];
|
||||
metadata?: Record<string, any>;
|
||||
ip_address: string;
|
||||
user_agent: string;
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
export interface AuditChange {
|
||||
field: string;
|
||||
old_value?: any;
|
||||
new_value?: any;
|
||||
change_type: ChangeType;
|
||||
}
|
||||
|
||||
// Cache types
|
||||
export interface CacheInfo {
|
||||
key: string;
|
||||
size: number;
|
||||
hits: number;
|
||||
misses: number;
|
||||
hit_rate: number;
|
||||
created_at: string;
|
||||
expires_at?: string;
|
||||
last_accessed: string;
|
||||
}
|
||||
|
||||
export interface CacheStats {
|
||||
total_keys: number;
|
||||
total_size: number;
|
||||
hit_rate: number;
|
||||
memory_usage: number;
|
||||
cache_by_type: Record<string, CacheTypeStats>;
|
||||
}
|
||||
|
||||
export interface CacheTypeStats {
|
||||
count: number;
|
||||
size: number;
|
||||
hit_rate: number;
|
||||
avg_ttl: number;
|
||||
}
|
||||
|
||||
// Webhook types
|
||||
export interface WebhookConfig {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
name: string;
|
||||
url: string;
|
||||
events: WebhookEvent[];
|
||||
secret?: string;
|
||||
is_active: boolean;
|
||||
retry_count: number;
|
||||
timeout_seconds: number;
|
||||
headers?: Record<string, string>;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface WebhookDelivery {
|
||||
id: string;
|
||||
webhook_id: string;
|
||||
event_type: WebhookEvent;
|
||||
payload: Record<string, any>;
|
||||
status: DeliveryStatus;
|
||||
http_status?: number;
|
||||
response_body?: string;
|
||||
error_message?: string;
|
||||
attempts: number;
|
||||
delivered_at?: string;
|
||||
created_at: string;
|
||||
next_retry_at?: string;
|
||||
}
|
||||
|
||||
// Rate limiting types
|
||||
export interface RateLimit {
|
||||
requests_per_minute: number;
|
||||
requests_per_hour: number;
|
||||
requests_per_day: number;
|
||||
current_usage: RateLimitUsage;
|
||||
reset_time: string;
|
||||
}
|
||||
|
||||
export interface RateLimitUsage {
|
||||
minute: number;
|
||||
hour: number;
|
||||
day: number;
|
||||
percentage_used: number;
|
||||
}
|
||||
|
||||
// Search types
|
||||
export interface SearchRequest {
|
||||
query: string;
|
||||
filters?: SearchFilter[];
|
||||
sort?: SearchSort[];
|
||||
facets?: string[];
|
||||
highlight?: SearchHighlight;
|
||||
size?: number;
|
||||
from?: number;
|
||||
}
|
||||
|
||||
export interface SearchFilter {
|
||||
field: string;
|
||||
operator: FilterOperator;
|
||||
value: any;
|
||||
values?: any[];
|
||||
}
|
||||
|
||||
export interface SearchSort {
|
||||
field: string;
|
||||
order: SortOrder;
|
||||
}
|
||||
|
||||
export interface SearchHighlight {
|
||||
fields: string[];
|
||||
pre_tag?: string;
|
||||
post_tag?: string;
|
||||
}
|
||||
|
||||
export interface SearchResponse<T> {
|
||||
results: T[];
|
||||
total: number;
|
||||
facets?: SearchFacet[];
|
||||
highlights?: Record<string, string[]>;
|
||||
suggestions?: SearchSuggestion[];
|
||||
took_ms: number;
|
||||
}
|
||||
|
||||
export interface SearchFacet {
|
||||
field: string;
|
||||
values: FacetValue[];
|
||||
}
|
||||
|
||||
export interface FacetValue {
|
||||
value: any;
|
||||
count: number;
|
||||
selected: boolean;
|
||||
}
|
||||
|
||||
export interface SearchSuggestion {
|
||||
text: string;
|
||||
highlighted: string;
|
||||
score: number;
|
||||
}
|
||||
|
||||
// Export/Import types
|
||||
export interface ExportRequest {
|
||||
format: ExportFormat;
|
||||
filters?: Record<string, any>;
|
||||
fields?: string[];
|
||||
include_metadata?: boolean;
|
||||
compression?: CompressionType;
|
||||
}
|
||||
|
||||
export interface ExportResponse {
|
||||
export_id: string;
|
||||
status: ExportStatus;
|
||||
download_url?: string;
|
||||
file_size?: number;
|
||||
expires_at?: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface ImportRequest {
|
||||
file_url?: string;
|
||||
file_data?: string;
|
||||
format: ImportFormat;
|
||||
options?: ImportOptions;
|
||||
mapping?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface ImportOptions {
|
||||
skip_validation?: boolean;
|
||||
update_existing?: boolean;
|
||||
batch_size?: number;
|
||||
dry_run?: boolean;
|
||||
}
|
||||
|
||||
export interface ImportResponse {
|
||||
import_id: string;
|
||||
status: ImportStatus;
|
||||
total_records?: number;
|
||||
processed_records?: number;
|
||||
successful_records?: number;
|
||||
failed_records?: number;
|
||||
errors?: ImportError[];
|
||||
warnings?: ImportWarning[];
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface ImportError {
|
||||
row: number;
|
||||
field?: string;
|
||||
value?: any;
|
||||
error_code: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface ImportWarning {
|
||||
row: number;
|
||||
field?: string;
|
||||
value?: any;
|
||||
warning_code: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
// Enums
|
||||
export enum SortOrder {
|
||||
ASC = 'asc',
|
||||
DESC = 'desc',
|
||||
}
|
||||
|
||||
export enum TaskStatusType {
|
||||
PENDING = 'pending',
|
||||
RUNNING = 'running',
|
||||
COMPLETED = 'completed',
|
||||
FAILED = 'failed',
|
||||
CANCELLED = 'cancelled',
|
||||
PAUSED = 'paused',
|
||||
}
|
||||
|
||||
export enum TaskType {
|
||||
DATA_IMPORT = 'data_import',
|
||||
DATA_EXPORT = 'data_export',
|
||||
REPORT_GENERATION = 'report_generation',
|
||||
MODEL_TRAINING = 'model_training',
|
||||
DATA_PROCESSING = 'data_processing',
|
||||
BULK_OPERATION = 'bulk_operation',
|
||||
SYNC_OPERATION = 'sync_operation',
|
||||
}
|
||||
|
||||
export enum HealthStatus {
|
||||
HEALTHY = 'healthy',
|
||||
DEGRADED = 'degraded',
|
||||
UNHEALTHY = 'unhealthy',
|
||||
UNKNOWN = 'unknown',
|
||||
}
|
||||
|
||||
export enum AuditAction {
|
||||
CREATE = 'create',
|
||||
READ = 'read',
|
||||
UPDATE = 'update',
|
||||
DELETE = 'delete',
|
||||
LOGIN = 'login',
|
||||
LOGOUT = 'logout',
|
||||
EXPORT = 'export',
|
||||
IMPORT = 'import',
|
||||
}
|
||||
|
||||
export enum ResourceType {
|
||||
USER = 'user',
|
||||
TENANT = 'tenant',
|
||||
INGREDIENT = 'ingredient',
|
||||
STOCK = 'stock',
|
||||
PRODUCTION_BATCH = 'production_batch',
|
||||
SALES_RECORD = 'sales_record',
|
||||
FORECAST = 'forecast',
|
||||
ORDER = 'order',
|
||||
SUPPLIER = 'supplier',
|
||||
RECIPE = 'recipe',
|
||||
NOTIFICATION = 'notification',
|
||||
}
|
||||
|
||||
export enum ChangeType {
|
||||
CREATED = 'created',
|
||||
UPDATED = 'updated',
|
||||
DELETED = 'deleted',
|
||||
ARCHIVED = 'archived',
|
||||
RESTORED = 'restored',
|
||||
}
|
||||
|
||||
export enum WebhookEvent {
|
||||
USER_CREATED = 'user.created',
|
||||
USER_UPDATED = 'user.updated',
|
||||
USER_DELETED = 'user.deleted',
|
||||
INVENTORY_LOW_STOCK = 'inventory.low_stock',
|
||||
PRODUCTION_COMPLETED = 'production.completed',
|
||||
ORDER_CREATED = 'order.created',
|
||||
ORDER_UPDATED = 'order.updated',
|
||||
FORECAST_GENERATED = 'forecast.generated',
|
||||
ALERT_TRIGGERED = 'alert.triggered',
|
||||
}
|
||||
|
||||
export enum DeliveryStatus {
|
||||
PENDING = 'pending',
|
||||
DELIVERED = 'delivered',
|
||||
FAILED = 'failed',
|
||||
RETRYING = 'retrying',
|
||||
CANCELLED = 'cancelled',
|
||||
}
|
||||
|
||||
export enum FilterOperator {
|
||||
EQUALS = 'eq',
|
||||
NOT_EQUALS = 'ne',
|
||||
GREATER_THAN = 'gt',
|
||||
GREATER_THAN_OR_EQUAL = 'gte',
|
||||
LESS_THAN = 'lt',
|
||||
LESS_THAN_OR_EQUAL = 'lte',
|
||||
CONTAINS = 'contains',
|
||||
STARTS_WITH = 'starts_with',
|
||||
ENDS_WITH = 'ends_with',
|
||||
IN = 'in',
|
||||
NOT_IN = 'not_in',
|
||||
IS_NULL = 'is_null',
|
||||
IS_NOT_NULL = 'is_not_null',
|
||||
BETWEEN = 'between',
|
||||
}
|
||||
|
||||
export enum ExportFormat {
|
||||
CSV = 'csv',
|
||||
EXCEL = 'excel',
|
||||
JSON = 'json',
|
||||
PDF = 'pdf',
|
||||
XML = 'xml',
|
||||
}
|
||||
|
||||
export enum ImportFormat {
|
||||
CSV = 'csv',
|
||||
EXCEL = 'excel',
|
||||
JSON = 'json',
|
||||
XML = 'xml',
|
||||
}
|
||||
|
||||
export enum CompressionType {
|
||||
NONE = 'none',
|
||||
ZIP = 'zip',
|
||||
GZIP = 'gzip',
|
||||
}
|
||||
|
||||
export enum ExportStatus {
|
||||
PENDING = 'pending',
|
||||
PROCESSING = 'processing',
|
||||
COMPLETED = 'completed',
|
||||
FAILED = 'failed',
|
||||
EXPIRED = 'expired',
|
||||
}
|
||||
|
||||
export enum ImportStatus {
|
||||
PENDING = 'pending',
|
||||
PROCESSING = 'processing',
|
||||
COMPLETED = 'completed',
|
||||
FAILED = 'failed',
|
||||
CANCELLED = 'cancelled',
|
||||
PARTIALLY_COMPLETED = 'partially_completed',
|
||||
}
|
||||
|
||||
// Utility types for HTTP methods
|
||||
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
||||
|
||||
// Generic type for API endpoints
|
||||
export type ApiEndpoint<TRequest = any, TResponse = any> = {
|
||||
method: HttpMethod;
|
||||
path: string;
|
||||
request?: TRequest;
|
||||
response: TResponse;
|
||||
};
|
||||
|
||||
// Type guards
|
||||
export const isApiError = (obj: any): obj is ApiError => {
|
||||
return obj && obj.success === false && obj.error && typeof obj.error.message === 'string';
|
||||
};
|
||||
|
||||
export const isPaginatedResponse = <T>(obj: any): obj is PaginatedResponse<T> => {
|
||||
return obj && Array.isArray(obj.items) && typeof obj.total === 'number';
|
||||
};
|
||||
|
||||
export const isTaskStatus = (obj: any): obj is TaskStatus => {
|
||||
return obj && typeof obj.task_id === 'string' && typeof obj.status === 'string';
|
||||
};
|
||||
256
frontend/src/types/auth.types.ts
Normal file
256
frontend/src/types/auth.types.ts
Normal file
@@ -0,0 +1,256 @@
|
||||
// Authentication related types
|
||||
export interface User {
|
||||
id: string;
|
||||
email: string;
|
||||
full_name: string;
|
||||
is_active: boolean;
|
||||
is_verified: boolean;
|
||||
created_at: string;
|
||||
last_login?: string;
|
||||
phone?: string;
|
||||
language?: string;
|
||||
timezone?: string;
|
||||
tenant_id?: string;
|
||||
role?: UserRole;
|
||||
avatar_url?: string;
|
||||
}
|
||||
|
||||
export interface UserRegistration {
|
||||
email: string;
|
||||
password: string;
|
||||
full_name: string;
|
||||
tenant_name?: string;
|
||||
role?: UserRole;
|
||||
phone?: string;
|
||||
language?: string;
|
||||
timezone?: string;
|
||||
}
|
||||
|
||||
export interface UserLogin {
|
||||
email: string;
|
||||
password: string;
|
||||
remember_me?: boolean;
|
||||
}
|
||||
|
||||
export interface TokenResponse {
|
||||
access_token: string;
|
||||
refresh_token?: string;
|
||||
token_type: string;
|
||||
expires_in: number;
|
||||
user?: User;
|
||||
}
|
||||
|
||||
export interface RefreshTokenRequest {
|
||||
refresh_token: string;
|
||||
}
|
||||
|
||||
export interface PasswordChange {
|
||||
current_password: string;
|
||||
new_password: string;
|
||||
}
|
||||
|
||||
export interface PasswordReset {
|
||||
email: string;
|
||||
}
|
||||
|
||||
export interface PasswordResetConfirm {
|
||||
token: string;
|
||||
new_password: string;
|
||||
}
|
||||
|
||||
export interface TokenVerification {
|
||||
valid: boolean;
|
||||
user_id?: string;
|
||||
email?: string;
|
||||
exp?: number;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface UserUpdate {
|
||||
full_name?: string;
|
||||
phone?: string;
|
||||
language?: string;
|
||||
timezone?: string;
|
||||
avatar_url?: string;
|
||||
}
|
||||
|
||||
export interface AuthState {
|
||||
isAuthenticated: boolean;
|
||||
user: User | null;
|
||||
token: string | null;
|
||||
refreshToken: string | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export interface LoginFormData {
|
||||
email: string;
|
||||
password: string;
|
||||
remember_me: boolean;
|
||||
}
|
||||
|
||||
export interface RegisterFormData {
|
||||
email: string;
|
||||
password: string;
|
||||
confirmPassword: string;
|
||||
full_name: string;
|
||||
tenant_name: string;
|
||||
phone?: string;
|
||||
acceptTerms: boolean;
|
||||
}
|
||||
|
||||
export interface ProfileFormData {
|
||||
full_name: string;
|
||||
email: string;
|
||||
phone?: string;
|
||||
language: string;
|
||||
timezone: string;
|
||||
}
|
||||
|
||||
export interface PasswordChangeFormData {
|
||||
current_password: string;
|
||||
new_password: string;
|
||||
confirm_password: string;
|
||||
}
|
||||
|
||||
export interface EmailVerificationRequest {
|
||||
email: string;
|
||||
}
|
||||
|
||||
export interface EmailVerificationConfirm {
|
||||
token: string;
|
||||
}
|
||||
|
||||
export interface UserContext {
|
||||
user_id: string;
|
||||
email: string;
|
||||
tenant_id?: string;
|
||||
roles: string[];
|
||||
is_verified: boolean;
|
||||
permissions: string[];
|
||||
}
|
||||
|
||||
export interface TokenClaims {
|
||||
sub: string;
|
||||
email: string;
|
||||
full_name: string;
|
||||
user_id: string;
|
||||
is_verified: boolean;
|
||||
tenant_id?: string;
|
||||
iat: number;
|
||||
exp: number;
|
||||
iss: string;
|
||||
roles?: string[];
|
||||
permissions?: string[];
|
||||
}
|
||||
|
||||
export interface AuthError {
|
||||
code: string;
|
||||
message: string;
|
||||
field?: string;
|
||||
}
|
||||
|
||||
export interface MFASetup {
|
||||
enabled: boolean;
|
||||
secret?: string;
|
||||
backup_codes?: string[];
|
||||
qr_code?: string;
|
||||
}
|
||||
|
||||
export interface MFAVerification {
|
||||
token: string;
|
||||
backup_code?: string;
|
||||
}
|
||||
|
||||
export interface SessionInfo {
|
||||
id: string;
|
||||
user_id: string;
|
||||
ip_address: string;
|
||||
user_agent: string;
|
||||
created_at: string;
|
||||
last_activity: string;
|
||||
is_current: boolean;
|
||||
location?: string;
|
||||
device_type?: string;
|
||||
}
|
||||
|
||||
export interface OAuthProvider {
|
||||
name: string;
|
||||
display_name: string;
|
||||
icon: string;
|
||||
color: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
// Enums
|
||||
export enum UserRole {
|
||||
USER = 'user',
|
||||
ADMIN = 'admin',
|
||||
MANAGER = 'manager',
|
||||
OWNER = 'owner',
|
||||
VIEWER = 'viewer',
|
||||
}
|
||||
|
||||
export enum AuthProvider {
|
||||
EMAIL = 'email',
|
||||
GOOGLE = 'google',
|
||||
MICROSOFT = 'microsoft',
|
||||
APPLE = 'apple',
|
||||
}
|
||||
|
||||
export enum Permission {
|
||||
// User management
|
||||
USER_READ = 'user:read',
|
||||
USER_WRITE = 'user:write',
|
||||
USER_DELETE = 'user:delete',
|
||||
|
||||
// Inventory
|
||||
INVENTORY_READ = 'inventory:read',
|
||||
INVENTORY_WRITE = 'inventory:write',
|
||||
INVENTORY_DELETE = 'inventory:delete',
|
||||
|
||||
// Production
|
||||
PRODUCTION_READ = 'production:read',
|
||||
PRODUCTION_WRITE = 'production:write',
|
||||
PRODUCTION_DELETE = 'production:delete',
|
||||
|
||||
// Sales
|
||||
SALES_READ = 'sales:read',
|
||||
SALES_WRITE = 'sales:write',
|
||||
SALES_DELETE = 'sales:delete',
|
||||
|
||||
// Forecasting
|
||||
FORECASTING_READ = 'forecasting:read',
|
||||
FORECASTING_WRITE = 'forecasting:write',
|
||||
FORECASTING_DELETE = 'forecasting:delete',
|
||||
|
||||
// Orders
|
||||
ORDERS_READ = 'orders:read',
|
||||
ORDERS_WRITE = 'orders:write',
|
||||
ORDERS_DELETE = 'orders:delete',
|
||||
|
||||
// Procurement
|
||||
PROCUREMENT_READ = 'procurement:read',
|
||||
PROCUREMENT_WRITE = 'procurement:write',
|
||||
PROCUREMENT_DELETE = 'procurement:delete',
|
||||
|
||||
// Settings
|
||||
SETTINGS_READ = 'settings:read',
|
||||
SETTINGS_WRITE = 'settings:write',
|
||||
|
||||
// Analytics
|
||||
ANALYTICS_READ = 'analytics:read',
|
||||
ANALYTICS_EXPORT = 'analytics:export',
|
||||
|
||||
// Admin
|
||||
ADMIN_ALL = 'admin:all',
|
||||
}
|
||||
|
||||
// Type guards
|
||||
export const isUser = (obj: any): obj is User => {
|
||||
return obj && typeof obj.id === 'string' && typeof obj.email === 'string';
|
||||
};
|
||||
|
||||
export const isTokenResponse = (obj: any): obj is TokenResponse => {
|
||||
return obj && typeof obj.access_token === 'string' && typeof obj.token_type === 'string';
|
||||
};
|
||||
107
frontend/src/types/common.types.ts
Normal file
107
frontend/src/types/common.types.ts
Normal file
@@ -0,0 +1,107 @@
|
||||
// Common types shared across multiple modules
|
||||
|
||||
export enum AlertSeverity {
|
||||
LOW = 'low',
|
||||
MEDIUM = 'medium',
|
||||
HIGH = 'high',
|
||||
CRITICAL = 'critical'
|
||||
}
|
||||
|
||||
export enum DayOfWeek {
|
||||
MONDAY = 'monday',
|
||||
TUESDAY = 'tuesday',
|
||||
WEDNESDAY = 'wednesday',
|
||||
THURSDAY = 'thursday',
|
||||
FRIDAY = 'friday',
|
||||
SATURDAY = 'saturday',
|
||||
SUNDAY = 'sunday'
|
||||
}
|
||||
|
||||
export enum ResourceType {
|
||||
EQUIPMENT = 'equipment',
|
||||
STAFF = 'staff',
|
||||
INGREDIENT = 'ingredient',
|
||||
UTILITY = 'utility'
|
||||
}
|
||||
|
||||
export enum DateRange {
|
||||
TODAY = 'today',
|
||||
YESTERDAY = 'yesterday',
|
||||
LAST_7_DAYS = 'last_7_days',
|
||||
LAST_30_DAYS = 'last_30_days',
|
||||
LAST_90_DAYS = 'last_90_days',
|
||||
THIS_MONTH = 'this_month',
|
||||
LAST_MONTH = 'last_month',
|
||||
THIS_YEAR = 'this_year',
|
||||
LAST_YEAR = 'last_year',
|
||||
CUSTOM = 'custom'
|
||||
}
|
||||
|
||||
export enum SeasonalPattern {
|
||||
NONE = 'none',
|
||||
DAILY = 'daily',
|
||||
WEEKLY = 'weekly',
|
||||
MONTHLY = 'monthly',
|
||||
SEASONAL = 'seasonal',
|
||||
HOLIDAY = 'holiday'
|
||||
}
|
||||
|
||||
export enum SeasonalPeriod {
|
||||
SPRING = 'spring',
|
||||
SUMMER = 'summer',
|
||||
FALL = 'fall',
|
||||
WINTER = 'winter'
|
||||
}
|
||||
|
||||
export enum TemperatureRange {
|
||||
VERY_COLD = 'very_cold',
|
||||
COLD = 'cold',
|
||||
MILD = 'mild',
|
||||
WARM = 'warm',
|
||||
HOT = 'hot'
|
||||
}
|
||||
|
||||
export enum TrendDirection {
|
||||
UP = 'up',
|
||||
DOWN = 'down',
|
||||
STABLE = 'stable',
|
||||
VOLATILE = 'volatile'
|
||||
}
|
||||
|
||||
export interface ImportError {
|
||||
row: number;
|
||||
column?: string;
|
||||
message: string;
|
||||
severity: AlertSeverity;
|
||||
}
|
||||
|
||||
export interface ImportWarning {
|
||||
row: number;
|
||||
column?: string;
|
||||
message: string;
|
||||
suggestion?: string;
|
||||
}
|
||||
|
||||
export enum SortOrder {
|
||||
ASC = 'asc',
|
||||
DESC = 'desc'
|
||||
}
|
||||
|
||||
export interface QueryParams {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
sort?: string;
|
||||
order?: SortOrder;
|
||||
search?: string;
|
||||
filters?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface PaginatedResponse<T = any> {
|
||||
data: T[];
|
||||
total: number;
|
||||
page: number;
|
||||
limit: number;
|
||||
totalPages: number;
|
||||
hasNextPage: boolean;
|
||||
hasPrevPage: boolean;
|
||||
}
|
||||
563
frontend/src/types/forecasting.types.ts
Normal file
563
frontend/src/types/forecasting.types.ts
Normal file
@@ -0,0 +1,563 @@
|
||||
// Forecasting and prediction types
|
||||
|
||||
export interface ForecastRequest {
|
||||
product_name: string;
|
||||
days_ahead: number;
|
||||
start_date?: string;
|
||||
include_confidence_intervals?: boolean;
|
||||
external_factors?: ExternalFactors;
|
||||
model_parameters?: ModelParameters;
|
||||
}
|
||||
|
||||
export interface ExternalFactors {
|
||||
weather?: WeatherFactor[];
|
||||
events?: EventFactor[];
|
||||
holidays?: boolean;
|
||||
promotions?: PromotionFactor[];
|
||||
seasonal_adjustments?: SeasonalAdjustment[];
|
||||
}
|
||||
|
||||
export interface WeatherFactor {
|
||||
condition: WeatherCondition;
|
||||
temperature_range?: TemperatureRange;
|
||||
impact_weight?: number;
|
||||
}
|
||||
|
||||
export interface EventFactor {
|
||||
event_type: EventType;
|
||||
expected_attendance?: number;
|
||||
impact_radius_km?: number;
|
||||
impact_weight?: number;
|
||||
}
|
||||
|
||||
export interface PromotionFactor {
|
||||
promotion_type: PromotionType;
|
||||
discount_percentage?: number;
|
||||
start_date: string;
|
||||
end_date: string;
|
||||
affected_products?: string[];
|
||||
}
|
||||
|
||||
export interface SeasonalAdjustment {
|
||||
period: SeasonalPeriod;
|
||||
adjustment_factor: number;
|
||||
confidence: number;
|
||||
}
|
||||
|
||||
export interface ModelParameters {
|
||||
confidence_level?: number;
|
||||
seasonality_mode?: SeasonalityMode;
|
||||
trend_flexibility?: number;
|
||||
include_outliers?: boolean;
|
||||
cross_validation_periods?: number;
|
||||
}
|
||||
|
||||
export interface ForecastResponse {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
product_name: string;
|
||||
forecast_date: string;
|
||||
predicted_demand: number;
|
||||
confidence_lower: number;
|
||||
confidence_upper: number;
|
||||
confidence_level: number;
|
||||
trend_component?: number;
|
||||
seasonal_component?: number;
|
||||
external_factors_impact: Record<string, number>;
|
||||
model_version: string;
|
||||
model_accuracy?: number;
|
||||
created_at: string;
|
||||
actual_demand?: number;
|
||||
accuracy_score?: number;
|
||||
prediction_interval: PredictionInterval;
|
||||
}
|
||||
|
||||
export interface PredictionInterval {
|
||||
lower_bound: number;
|
||||
upper_bound: number;
|
||||
confidence_level: number;
|
||||
}
|
||||
|
||||
export interface PredictionBatch {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
parameters: BatchParameters;
|
||||
status: BatchStatus;
|
||||
progress: number;
|
||||
total_predictions: number;
|
||||
completed_predictions: number;
|
||||
failed_predictions: number;
|
||||
error_predictions: number;
|
||||
average_accuracy?: number;
|
||||
created_at: string;
|
||||
started_at?: string;
|
||||
completed_at?: string;
|
||||
error_message?: string;
|
||||
created_by: string;
|
||||
}
|
||||
|
||||
export interface BatchParameters {
|
||||
products: string[];
|
||||
days_ahead: number;
|
||||
start_date: string;
|
||||
end_date?: string;
|
||||
model_type?: ModelType;
|
||||
external_factors?: ExternalFactors;
|
||||
confidence_level?: number;
|
||||
}
|
||||
|
||||
export interface ModelPerformance {
|
||||
model_id: string;
|
||||
model_name: string;
|
||||
model_type: ModelType;
|
||||
version: string;
|
||||
accuracy_metrics: AccuracyMetrics;
|
||||
training_data_info: TrainingDataInfo;
|
||||
validation_results: ValidationResults;
|
||||
feature_importance: FeatureImportance[];
|
||||
last_training_date: string;
|
||||
performance_trend: TrendDirection;
|
||||
deployment_status: DeploymentStatus;
|
||||
}
|
||||
|
||||
export interface AccuracyMetrics {
|
||||
mape: number; // Mean Absolute Percentage Error
|
||||
rmse: number; // Root Mean Square Error
|
||||
mae: number; // Mean Absolute Error
|
||||
r2_score: number;
|
||||
smape: number; // Symmetric Mean Absolute Percentage Error
|
||||
mase: number; // Mean Absolute Scaled Error
|
||||
directional_accuracy: number;
|
||||
}
|
||||
|
||||
export interface TrainingDataInfo {
|
||||
start_date: string;
|
||||
end_date: string;
|
||||
total_records: number;
|
||||
products_count: number;
|
||||
features_used: string[];
|
||||
data_quality_score: number;
|
||||
}
|
||||
|
||||
export interface ValidationResults {
|
||||
validation_type: ValidationType;
|
||||
cross_validation_scores: number[];
|
||||
holdout_accuracy?: number;
|
||||
backtesting_results?: BacktestingResult[];
|
||||
}
|
||||
|
||||
export interface BacktestingResult {
|
||||
test_period: string;
|
||||
accuracy: number;
|
||||
predictions: number;
|
||||
average_error: number;
|
||||
}
|
||||
|
||||
export interface FeatureImportance {
|
||||
feature_name: string;
|
||||
importance_score: number;
|
||||
category: FeatureCategory;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface ForecastAccuracy {
|
||||
overall_accuracy: number;
|
||||
product_accuracy: ProductAccuracy[];
|
||||
accuracy_trends: AccuracyTrend[];
|
||||
accuracy_by_horizon: HorizonAccuracy[];
|
||||
accuracy_by_season: SeasonalAccuracy[];
|
||||
model_comparison: ModelComparison[];
|
||||
}
|
||||
|
||||
export interface ProductAccuracy {
|
||||
product_name: string;
|
||||
accuracy: number;
|
||||
total_predictions: number;
|
||||
recent_trend: TrendDirection;
|
||||
accuracy_by_horizon: Record<string, number>;
|
||||
last_updated: string;
|
||||
}
|
||||
|
||||
export interface AccuracyTrend {
|
||||
date: string;
|
||||
accuracy: number;
|
||||
predictions_count: number;
|
||||
model_version?: string;
|
||||
}
|
||||
|
||||
export interface HorizonAccuracy {
|
||||
days_ahead: number;
|
||||
accuracy: number;
|
||||
predictions_count: number;
|
||||
confidence_interval_coverage: number;
|
||||
}
|
||||
|
||||
export interface SeasonalAccuracy {
|
||||
season: Season;
|
||||
accuracy: number;
|
||||
predictions_count: number;
|
||||
typical_error_patterns: string[];
|
||||
}
|
||||
|
||||
export interface ModelComparison {
|
||||
model_name: string;
|
||||
model_type: ModelType;
|
||||
accuracy: number;
|
||||
training_time_hours: number;
|
||||
prediction_time_ms: number;
|
||||
memory_usage_mb: number;
|
||||
complexity_score: number;
|
||||
}
|
||||
|
||||
export interface DemandTrend {
|
||||
date: string;
|
||||
actual_demand: number;
|
||||
predicted_demand: number;
|
||||
confidence_lower: number;
|
||||
confidence_upper: number;
|
||||
accuracy: number;
|
||||
trend_direction: TrendDirection;
|
||||
seasonal_factor: number;
|
||||
anomaly_score?: number;
|
||||
}
|
||||
|
||||
export interface SeasonalPattern {
|
||||
product_name: string;
|
||||
seasonal_components: SeasonalComponent[];
|
||||
holiday_effects: HolidayEffect[];
|
||||
weekly_patterns: WeeklyPattern[];
|
||||
yearly_trends: YearlyTrend[];
|
||||
confidence_score: number;
|
||||
}
|
||||
|
||||
export interface SeasonalComponent {
|
||||
period: SeasonalPeriod;
|
||||
strength: number;
|
||||
pattern: number[];
|
||||
peak_periods: string[];
|
||||
low_periods: string[];
|
||||
}
|
||||
|
||||
export interface HolidayEffect {
|
||||
holiday_name: string;
|
||||
impact_factor: number;
|
||||
confidence: number;
|
||||
duration_days: number;
|
||||
affected_products: string[];
|
||||
}
|
||||
|
||||
export interface WeeklyPattern {
|
||||
day_of_week: DayOfWeek;
|
||||
average_multiplier: number;
|
||||
variance: number;
|
||||
peak_hours?: number[];
|
||||
}
|
||||
|
||||
export interface YearlyTrend {
|
||||
year: number;
|
||||
growth_rate: number;
|
||||
seasonal_strength: number;
|
||||
anomalies_detected: number;
|
||||
}
|
||||
|
||||
export interface ForecastAlert {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
alert_type: ForecastAlertType;
|
||||
severity: AlertSeverity;
|
||||
title: string;
|
||||
message: string;
|
||||
product_name?: string;
|
||||
forecast_date?: string;
|
||||
predicted_value?: number;
|
||||
threshold_value?: number;
|
||||
model_accuracy?: number;
|
||||
confidence_level?: number;
|
||||
is_active: boolean;
|
||||
acknowledged_at?: string;
|
||||
resolved_at?: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface ModelTrainingJob {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
job_name: string;
|
||||
model_type: ModelType;
|
||||
status: TrainingStatus;
|
||||
progress: number;
|
||||
training_parameters: TrainingParameters;
|
||||
data_range: DateRange;
|
||||
metrics?: AccuracyMetrics;
|
||||
training_duration_seconds?: number;
|
||||
model_size_mb?: number;
|
||||
error_message?: string;
|
||||
created_at: string;
|
||||
started_at?: string;
|
||||
completed_at?: string;
|
||||
created_by: string;
|
||||
}
|
||||
|
||||
export interface TrainingParameters {
|
||||
algorithm: AlgorithmType;
|
||||
hyperparameters: Record<string, any>;
|
||||
feature_selection: string[];
|
||||
validation_method: ValidationType;
|
||||
cross_validation_folds?: number;
|
||||
test_size?: number;
|
||||
}
|
||||
|
||||
export interface DateRange {
|
||||
start_date: string;
|
||||
end_date: string;
|
||||
}
|
||||
|
||||
export interface ForecastSettings {
|
||||
default_forecast_horizon: number;
|
||||
confidence_level: number;
|
||||
retraining_frequency: number;
|
||||
external_data_sources: string[];
|
||||
notification_preferences: NotificationPreferences;
|
||||
model_selection_criteria: ModelSelectionCriteria;
|
||||
data_quality_thresholds: DataQualityThresholds;
|
||||
}
|
||||
|
||||
export interface NotificationPreferences {
|
||||
accuracy_drop_threshold: number;
|
||||
high_demand_alerts: boolean;
|
||||
low_demand_alerts: boolean;
|
||||
model_retraining_notifications: boolean;
|
||||
data_quality_alerts: boolean;
|
||||
weekly_accuracy_reports: boolean;
|
||||
}
|
||||
|
||||
export interface ModelSelectionCriteria {
|
||||
primary_metric: AccuracyMetric;
|
||||
minimum_accuracy: number;
|
||||
maximum_training_time_hours: number;
|
||||
complexity_preference: ComplexityPreference;
|
||||
interpretability_weight: number;
|
||||
}
|
||||
|
||||
export interface DataQualityThresholds {
|
||||
minimum_data_points: number;
|
||||
maximum_missing_percentage: number;
|
||||
outlier_threshold: number;
|
||||
minimum_variance: number;
|
||||
}
|
||||
|
||||
// Form interfaces
|
||||
export interface ForecastRequestFormData {
|
||||
product_name: string;
|
||||
days_ahead: number;
|
||||
start_date: string;
|
||||
include_confidence_intervals: boolean;
|
||||
confidence_level: number;
|
||||
include_external_factors: boolean;
|
||||
weather_factors?: string[];
|
||||
event_factors?: string[];
|
||||
include_holidays: boolean;
|
||||
}
|
||||
|
||||
export interface BatchForecastFormData {
|
||||
name: string;
|
||||
description?: string;
|
||||
products: string[];
|
||||
days_ahead: number;
|
||||
start_date: string;
|
||||
end_date?: string;
|
||||
model_type: ModelType;
|
||||
confidence_level: number;
|
||||
}
|
||||
|
||||
// Enums
|
||||
export enum ModelType {
|
||||
PROPHET = 'prophet',
|
||||
ARIMA = 'arima',
|
||||
SEASONAL_DECOMPOSITION = 'seasonal_decomposition',
|
||||
LINEAR_REGRESSION = 'linear_regression',
|
||||
RANDOM_FOREST = 'random_forest',
|
||||
XGBOOST = 'xgboost',
|
||||
LSTM = 'lstm',
|
||||
ENSEMBLE = 'ensemble',
|
||||
}
|
||||
|
||||
export enum BatchStatus {
|
||||
PENDING = 'pending',
|
||||
PROCESSING = 'processing',
|
||||
COMPLETED = 'completed',
|
||||
FAILED = 'failed',
|
||||
CANCELLED = 'cancelled',
|
||||
PARTIALLY_COMPLETED = 'partially_completed',
|
||||
}
|
||||
|
||||
export enum TrendDirection {
|
||||
INCREASING = 'increasing',
|
||||
DECREASING = 'decreasing',
|
||||
STABLE = 'stable',
|
||||
VOLATILE = 'volatile',
|
||||
SEASONAL = 'seasonal',
|
||||
}
|
||||
|
||||
export enum DeploymentStatus {
|
||||
TRAINING = 'training',
|
||||
DEPLOYED = 'deployed',
|
||||
DEPRECATED = 'deprecated',
|
||||
ARCHIVED = 'archived',
|
||||
FAILED = 'failed',
|
||||
}
|
||||
|
||||
export enum ValidationType {
|
||||
CROSS_VALIDATION = 'cross_validation',
|
||||
TIME_SERIES_SPLIT = 'time_series_split',
|
||||
HOLDOUT = 'holdout',
|
||||
WALK_FORWARD = 'walk_forward',
|
||||
}
|
||||
|
||||
export enum FeatureCategory {
|
||||
HISTORICAL_SALES = 'historical_sales',
|
||||
WEATHER = 'weather',
|
||||
CALENDAR = 'calendar',
|
||||
EVENTS = 'events',
|
||||
PRICING = 'pricing',
|
||||
INVENTORY = 'inventory',
|
||||
MARKETING = 'marketing',
|
||||
EXTERNAL_ECONOMIC = 'external_economic',
|
||||
}
|
||||
|
||||
export enum Season {
|
||||
SPRING = 'spring',
|
||||
SUMMER = 'summer',
|
||||
FALL = 'fall',
|
||||
WINTER = 'winter',
|
||||
}
|
||||
|
||||
export enum SeasonalPeriod {
|
||||
DAILY = 'daily',
|
||||
WEEKLY = 'weekly',
|
||||
MONTHLY = 'monthly',
|
||||
QUARTERLY = 'quarterly',
|
||||
YEARLY = 'yearly',
|
||||
}
|
||||
|
||||
export enum DayOfWeek {
|
||||
MONDAY = 'monday',
|
||||
TUESDAY = 'tuesday',
|
||||
WEDNESDAY = 'wednesday',
|
||||
THURSDAY = 'thursday',
|
||||
FRIDAY = 'friday',
|
||||
SATURDAY = 'saturday',
|
||||
SUNDAY = 'sunday',
|
||||
}
|
||||
|
||||
export enum WeatherCondition {
|
||||
SUNNY = 'sunny',
|
||||
CLOUDY = 'cloudy',
|
||||
RAINY = 'rainy',
|
||||
STORMY = 'stormy',
|
||||
SNOWY = 'snowy',
|
||||
FOGGY = 'foggy',
|
||||
WINDY = 'windy',
|
||||
}
|
||||
|
||||
export enum EventType {
|
||||
FESTIVAL = 'festival',
|
||||
CONCERT = 'concert',
|
||||
SPORTS_EVENT = 'sports_event',
|
||||
CONFERENCE = 'conference',
|
||||
HOLIDAY = 'holiday',
|
||||
SCHOOL_EVENT = 'school_event',
|
||||
CONSTRUCTION = 'construction',
|
||||
WEATHER_EVENT = 'weather_event',
|
||||
}
|
||||
|
||||
export enum PromotionType {
|
||||
DISCOUNT = 'discount',
|
||||
BUY_ONE_GET_ONE = 'buy_one_get_one',
|
||||
BUNDLE = 'bundle',
|
||||
SEASONAL_SPECIAL = 'seasonal_special',
|
||||
LOYALTY_REWARD = 'loyalty_reward',
|
||||
}
|
||||
|
||||
export enum SeasonalityMode {
|
||||
ADDITIVE = 'additive',
|
||||
MULTIPLICATIVE = 'multiplicative',
|
||||
AUTO = 'auto',
|
||||
}
|
||||
|
||||
export enum ForecastAlertType {
|
||||
HIGH_DEMAND_PREDICTED = 'high_demand_predicted',
|
||||
LOW_DEMAND_PREDICTED = 'low_demand_predicted',
|
||||
ACCURACY_DROP = 'accuracy_drop',
|
||||
MODEL_DRIFT = 'model_drift',
|
||||
DATA_ANOMALY = 'data_anomaly',
|
||||
MISSING_DATA = 'missing_data',
|
||||
SEASONAL_SHIFT = 'seasonal_shift',
|
||||
}
|
||||
|
||||
export enum AlertSeverity {
|
||||
LOW = 'low',
|
||||
MEDIUM = 'medium',
|
||||
HIGH = 'high',
|
||||
CRITICAL = 'critical',
|
||||
}
|
||||
|
||||
export enum TrainingStatus {
|
||||
PENDING = 'pending',
|
||||
INITIALIZING = 'initializing',
|
||||
TRAINING = 'training',
|
||||
VALIDATING = 'validating',
|
||||
COMPLETED = 'completed',
|
||||
FAILED = 'failed',
|
||||
CANCELLED = 'cancelled',
|
||||
}
|
||||
|
||||
export enum AlgorithmType {
|
||||
PROPHET = 'prophet',
|
||||
ARIMA = 'arima',
|
||||
EXPONENTIAL_SMOOTHING = 'exponential_smoothing',
|
||||
LINEAR_REGRESSION = 'linear_regression',
|
||||
POLYNOMIAL_REGRESSION = 'polynomial_regression',
|
||||
RANDOM_FOREST = 'random_forest',
|
||||
GRADIENT_BOOSTING = 'gradient_boosting',
|
||||
XGBOOST = 'xgboost',
|
||||
LSTM_NEURAL_NETWORK = 'lstm_neural_network',
|
||||
CNN_LSTM = 'cnn_lstm',
|
||||
}
|
||||
|
||||
export enum AccuracyMetric {
|
||||
MAPE = 'mape',
|
||||
RMSE = 'rmse',
|
||||
MAE = 'mae',
|
||||
R2_SCORE = 'r2_score',
|
||||
SMAPE = 'smape',
|
||||
MASE = 'mase',
|
||||
}
|
||||
|
||||
export enum ComplexityPreference {
|
||||
SIMPLE = 'simple',
|
||||
BALANCED = 'balanced',
|
||||
COMPLEX = 'complex',
|
||||
ACCURACY_FIRST = 'accuracy_first',
|
||||
}
|
||||
|
||||
export interface TemperatureRange {
|
||||
min: number;
|
||||
max: number;
|
||||
unit: 'celsius' | 'fahrenheit';
|
||||
}
|
||||
|
||||
// Type guards
|
||||
export const isForecastResponse = (obj: any): obj is ForecastResponse => {
|
||||
return obj && typeof obj.id === 'string' && typeof obj.predicted_demand === 'number';
|
||||
};
|
||||
|
||||
export const isPredictionBatch = (obj: any): obj is PredictionBatch => {
|
||||
return obj && typeof obj.id === 'string' && Array.isArray(obj.parameters?.products);
|
||||
};
|
||||
|
||||
export const isModelPerformance = (obj: any): obj is ModelPerformance => {
|
||||
return obj && typeof obj.model_id === 'string' && obj.accuracy_metrics && typeof obj.accuracy_metrics.mape === 'number';
|
||||
};
|
||||
58
frontend/src/types/global.d.ts
vendored
Normal file
58
frontend/src/types/global.d.ts
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
// Global type declarations for missing modules and Vite environment variables
|
||||
|
||||
// Vite environment variables
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_ENABLE_PWA?: string;
|
||||
readonly VITE_API_BASE_URL?: string;
|
||||
readonly VITE_WS_URL?: string;
|
||||
readonly VITE_SSE_URL?: string;
|
||||
readonly VITE_TENANT_ID?: string;
|
||||
// Add other environment variables as needed
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
// Module declarations for missing packages
|
||||
declare module 'event-source-polyfill' {
|
||||
export class EventSourcePolyfill extends EventTarget {
|
||||
constructor(url: string, options?: any);
|
||||
readonly readyState: number;
|
||||
readonly url: string;
|
||||
close(): void;
|
||||
static readonly CONNECTING: number;
|
||||
static readonly OPEN: number;
|
||||
static readonly CLOSED: number;
|
||||
}
|
||||
}
|
||||
|
||||
// Common types that are referenced but might be missing
|
||||
type SortOrder = 'asc' | 'desc';
|
||||
|
||||
interface QueryParams {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
sort?: string;
|
||||
order?: SortOrder;
|
||||
search?: string;
|
||||
filters?: Record<string, any>;
|
||||
}
|
||||
|
||||
interface PaginatedResponse<T = any> {
|
||||
data: T[];
|
||||
total: number;
|
||||
page: number;
|
||||
limit: number;
|
||||
totalPages: number;
|
||||
hasNextPage: boolean;
|
||||
hasPrevPage: boolean;
|
||||
}
|
||||
|
||||
// Declare global types that might be used across the app
|
||||
declare global {
|
||||
interface Window {
|
||||
// Add any global window properties if needed
|
||||
}
|
||||
}
|
||||
361
frontend/src/types/index.ts
Normal file
361
frontend/src/types/index.ts
Normal file
@@ -0,0 +1,361 @@
|
||||
// Export all types from different modules
|
||||
|
||||
// Common types (shared enums and interfaces)
|
||||
export * from './common.types';
|
||||
|
||||
// Authentication types
|
||||
export * from './auth.types';
|
||||
|
||||
// Inventory types
|
||||
export type {
|
||||
Ingredient,
|
||||
Stock,
|
||||
StockMovement,
|
||||
InventorySummary,
|
||||
UnitOfMeasure,
|
||||
ProductType,
|
||||
StockMovementType,
|
||||
StockAlert,
|
||||
InventorySettings,
|
||||
StockHistory,
|
||||
StockLevel,
|
||||
InventoryReport,
|
||||
BulkUpdateResult
|
||||
} from './inventory.types';
|
||||
|
||||
// Production types
|
||||
export type {
|
||||
ProductionBatch,
|
||||
Recipe,
|
||||
QualityCheck,
|
||||
ProductionSchedule,
|
||||
ProductionBatchStatus,
|
||||
QualityCheckStatus,
|
||||
Equipment,
|
||||
RecipeIngredient,
|
||||
ProductionStep,
|
||||
ProductionAlert,
|
||||
BatchHistory,
|
||||
ScheduleSlot,
|
||||
ProductionSettings,
|
||||
ProductionReport,
|
||||
CapacityPlan,
|
||||
MaintenanceSchedule,
|
||||
QualityStandard,
|
||||
ProductionMetrics
|
||||
} from './production.types';
|
||||
|
||||
// Sales types
|
||||
export type {
|
||||
SalesRecord,
|
||||
SalesSummary,
|
||||
ProductPerformance,
|
||||
SalesAnalytics,
|
||||
SalesChannel,
|
||||
WeatherCondition,
|
||||
Customer,
|
||||
Order,
|
||||
OrderItem,
|
||||
Payment,
|
||||
SalesReport,
|
||||
CustomerSegment,
|
||||
SalesForecast,
|
||||
PricingStrategy
|
||||
} from './sales.types';
|
||||
|
||||
// Forecasting types
|
||||
export type {
|
||||
ForecastRequest,
|
||||
ForecastResponse,
|
||||
ModelPerformance,
|
||||
PredictionBatch,
|
||||
ModelType,
|
||||
BatchStatus,
|
||||
ForecastModel,
|
||||
TrainingData,
|
||||
ValidationResults,
|
||||
ModelConfig,
|
||||
PredictionResult,
|
||||
FeatureImportance,
|
||||
ModelMetrics,
|
||||
DataPreprocessing
|
||||
} from './forecasting.types';
|
||||
|
||||
// API and common types
|
||||
export type {
|
||||
ApiResponse,
|
||||
ApiError,
|
||||
TaskStatus,
|
||||
HealthCheckResponse
|
||||
} from './api.types';
|
||||
|
||||
// Re-export commonly used types for convenience
|
||||
export type {
|
||||
User,
|
||||
UserLogin,
|
||||
UserRegistration,
|
||||
TokenResponse,
|
||||
AuthState,
|
||||
} from './auth.types';
|
||||
|
||||
export type {
|
||||
Ingredient,
|
||||
Stock,
|
||||
StockMovement,
|
||||
InventorySummary,
|
||||
UnitOfMeasure,
|
||||
ProductType,
|
||||
StockMovementType,
|
||||
} from './inventory.types';
|
||||
|
||||
export type {
|
||||
ProductionBatch,
|
||||
Recipe,
|
||||
QualityCheck,
|
||||
ProductionSchedule,
|
||||
ProductionBatchStatus,
|
||||
QualityCheckStatus,
|
||||
} from './production.types';
|
||||
|
||||
export type {
|
||||
SalesRecord,
|
||||
SalesSummary,
|
||||
ProductPerformance,
|
||||
SalesAnalytics,
|
||||
SalesChannel,
|
||||
WeatherCondition,
|
||||
} from './sales.types';
|
||||
|
||||
export type {
|
||||
ForecastRequest,
|
||||
ForecastResponse,
|
||||
ModelPerformance,
|
||||
PredictionBatch,
|
||||
ModelType,
|
||||
BatchStatus,
|
||||
} from './forecasting.types';
|
||||
|
||||
export type {
|
||||
ApiResponse,
|
||||
ApiError,
|
||||
TaskStatus,
|
||||
HealthCheckResponse
|
||||
} from './api.types';
|
||||
|
||||
// Common interfaces that might be used across modules
|
||||
export interface BaseEntity {
|
||||
id: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface TenantEntity extends BaseEntity {
|
||||
tenant_id: string;
|
||||
}
|
||||
|
||||
export interface AuditableEntity extends TenantEntity {
|
||||
created_by?: string;
|
||||
updated_by?: string;
|
||||
}
|
||||
|
||||
// Form state interfaces
|
||||
export interface FormState<T = any> {
|
||||
values: T;
|
||||
errors: Record<keyof T, string>;
|
||||
touched: Record<keyof T, boolean>;
|
||||
isSubmitting: boolean;
|
||||
isValid: boolean;
|
||||
}
|
||||
|
||||
// Loading and error states
|
||||
export interface LoadingState {
|
||||
isLoading: boolean;
|
||||
error: string | null;
|
||||
lastUpdated?: string;
|
||||
}
|
||||
|
||||
export interface AsyncState<T = any> extends LoadingState {
|
||||
data: T | null;
|
||||
hasData: boolean;
|
||||
}
|
||||
|
||||
// Table/List interfaces
|
||||
export interface TableColumn<T = any> {
|
||||
key: keyof T;
|
||||
title: string;
|
||||
sortable?: boolean;
|
||||
filterable?: boolean;
|
||||
render?: (value: any, record: T) => React.ReactNode;
|
||||
width?: string | number;
|
||||
align?: 'left' | 'center' | 'right';
|
||||
}
|
||||
|
||||
export interface TableState<T = any> {
|
||||
data: T[];
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
pagination: {
|
||||
current: number;
|
||||
pageSize: number;
|
||||
total: number;
|
||||
};
|
||||
sorting: {
|
||||
field?: keyof T;
|
||||
order?: import('./common.types').SortOrder;
|
||||
};
|
||||
filters: Record<string, any>;
|
||||
}
|
||||
|
||||
// Chart/Analytics interfaces
|
||||
export interface ChartDataPoint {
|
||||
x: string | number;
|
||||
y: number;
|
||||
label?: string;
|
||||
color?: string;
|
||||
}
|
||||
|
||||
export interface TimeSeriesDataPoint {
|
||||
date: string;
|
||||
value: number;
|
||||
label?: string;
|
||||
metadata?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface MetricCard {
|
||||
title: string;
|
||||
value: number | string;
|
||||
change?: number;
|
||||
changeType?: 'increase' | 'decrease' | 'neutral';
|
||||
format?: 'number' | 'currency' | 'percentage';
|
||||
subtitle?: string;
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
// Navigation and routing
|
||||
export interface NavItem {
|
||||
key: string;
|
||||
title: string;
|
||||
path?: string;
|
||||
icon?: string;
|
||||
children?: NavItem[];
|
||||
permissions?: string[];
|
||||
badge?: string | number;
|
||||
}
|
||||
|
||||
export interface BreadcrumbItem {
|
||||
title: string;
|
||||
path?: string;
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
// Notification interfaces
|
||||
export interface ToastNotification {
|
||||
id: string;
|
||||
type: 'success' | 'error' | 'warning' | 'info';
|
||||
title: string;
|
||||
message?: string;
|
||||
duration?: number;
|
||||
actions?: NotificationAction[];
|
||||
}
|
||||
|
||||
export interface NotificationAction {
|
||||
label: string;
|
||||
action: () => void;
|
||||
style?: 'primary' | 'secondary' | 'danger';
|
||||
}
|
||||
|
||||
// Modal interfaces
|
||||
export interface ModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
title?: string;
|
||||
size?: 'small' | 'medium' | 'large' | 'fullscreen';
|
||||
closable?: boolean;
|
||||
maskClosable?: boolean;
|
||||
}
|
||||
|
||||
// File handling
|
||||
export interface FileInfo {
|
||||
name: string;
|
||||
size: number;
|
||||
type: string;
|
||||
lastModified: number;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export interface UploadFile extends FileInfo {
|
||||
uid: string;
|
||||
status: 'uploading' | 'done' | 'error';
|
||||
progress?: number;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
// Search and filter
|
||||
export interface SearchState {
|
||||
query: string;
|
||||
filters: Record<string, any>;
|
||||
suggestions: string[];
|
||||
results: any[];
|
||||
loading: boolean;
|
||||
hasMore: boolean;
|
||||
}
|
||||
|
||||
// Settings and preferences
|
||||
export interface UserPreferences {
|
||||
theme: 'light' | 'dark' | 'auto';
|
||||
language: string;
|
||||
timezone: string;
|
||||
dateFormat: string;
|
||||
timeFormat: '12h' | '24h';
|
||||
currency: string;
|
||||
notifications: {
|
||||
email: boolean;
|
||||
push: boolean;
|
||||
sms: boolean;
|
||||
};
|
||||
dashboard: {
|
||||
layout: string;
|
||||
widgets: string[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface AppSettings {
|
||||
app_name: string;
|
||||
version: string;
|
||||
features: Record<string, boolean>;
|
||||
limits: Record<string, number>;
|
||||
integrations: Record<string, any>;
|
||||
}
|
||||
|
||||
// Generic utility types
|
||||
export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
||||
export type RequiredKeys<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
||||
export type PartialExcept<T, K extends keyof T> = Partial<T> & Pick<T, K>;
|
||||
|
||||
// Event handler types
|
||||
export type EventHandler<T = any> = (event: T) => void;
|
||||
export type ChangeHandler<T = any> = (value: T) => void;
|
||||
export type SubmitHandler<T = any> = (data: T) => void | Promise<void>;
|
||||
|
||||
// Generic CRUD operations
|
||||
export interface CrudOperations<T, TCreate = Omit<T, 'id'>, TUpdate = Partial<T>> {
|
||||
list: (params?: import('./common.types').QueryParams) => Promise<import('./common.types').PaginatedResponse<T>>;
|
||||
get: (id: string) => Promise<T>;
|
||||
create: (data: TCreate) => Promise<T>;
|
||||
update: (id: string, data: TUpdate) => Promise<T>;
|
||||
delete: (id: string) => Promise<void>;
|
||||
}
|
||||
|
||||
// Generic store state
|
||||
export interface StoreState<T = any> {
|
||||
items: T[];
|
||||
selectedItem: T | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
filters: Record<string, any>;
|
||||
pagination: {
|
||||
current: number;
|
||||
pageSize: number;
|
||||
total: number;
|
||||
};
|
||||
}
|
||||
440
frontend/src/types/inventory.types.ts
Normal file
440
frontend/src/types/inventory.types.ts
Normal file
@@ -0,0 +1,440 @@
|
||||
// Inventory management types
|
||||
|
||||
// Base inventory interfaces
|
||||
export interface Ingredient {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
name: string;
|
||||
product_type: ProductType;
|
||||
sku?: string;
|
||||
barcode?: string;
|
||||
category?: string;
|
||||
subcategory?: string;
|
||||
description?: string;
|
||||
brand?: string;
|
||||
unit_of_measure: UnitOfMeasure;
|
||||
package_size?: number;
|
||||
average_cost?: number;
|
||||
last_purchase_price?: number;
|
||||
standard_cost?: number;
|
||||
low_stock_threshold: number;
|
||||
reorder_point: number;
|
||||
reorder_quantity: number;
|
||||
max_stock_level?: number;
|
||||
requires_refrigeration: boolean;
|
||||
requires_freezing: boolean;
|
||||
storage_temperature_min?: number;
|
||||
storage_temperature_max?: number;
|
||||
storage_humidity_max?: number;
|
||||
shelf_life_days?: number;
|
||||
storage_instructions?: string;
|
||||
is_active: boolean;
|
||||
is_perishable: boolean;
|
||||
allergen_info?: AllergenInfo;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
created_by?: string;
|
||||
current_stock?: number;
|
||||
is_low_stock?: boolean;
|
||||
needs_reorder?: boolean;
|
||||
}
|
||||
|
||||
export interface Stock {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
ingredient_id: string;
|
||||
batch_number?: string;
|
||||
lot_number?: string;
|
||||
supplier_batch_ref?: string;
|
||||
current_quantity: number;
|
||||
reserved_quantity: number;
|
||||
available_quantity: number;
|
||||
received_date?: string;
|
||||
expiration_date?: string;
|
||||
best_before_date?: string;
|
||||
unit_cost?: number;
|
||||
total_cost?: number;
|
||||
storage_location?: string;
|
||||
warehouse_zone?: string;
|
||||
shelf_position?: string;
|
||||
is_available: boolean;
|
||||
is_expired: boolean;
|
||||
quality_status: QualityStatus;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
ingredient?: Ingredient;
|
||||
}
|
||||
|
||||
export interface StockMovement {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
ingredient_id: string;
|
||||
stock_id?: string;
|
||||
movement_type: StockMovementType;
|
||||
quantity: number;
|
||||
unit_cost?: number;
|
||||
total_cost?: number;
|
||||
quantity_before?: number;
|
||||
quantity_after?: number;
|
||||
reference_number?: string;
|
||||
supplier_id?: string;
|
||||
notes?: string;
|
||||
reason_code?: string;
|
||||
movement_date: string;
|
||||
created_at: string;
|
||||
created_by?: string;
|
||||
ingredient?: Ingredient;
|
||||
}
|
||||
|
||||
export interface StockAlert {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
ingredient_id: string;
|
||||
stock_id?: string;
|
||||
alert_type: AlertType;
|
||||
severity: AlertSeverity;
|
||||
title: string;
|
||||
message: string;
|
||||
current_quantity?: number;
|
||||
threshold_value?: number;
|
||||
expiration_date?: string;
|
||||
is_active: boolean;
|
||||
is_acknowledged: boolean;
|
||||
acknowledged_by?: string;
|
||||
acknowledged_at?: string;
|
||||
is_resolved: boolean;
|
||||
resolved_by?: string;
|
||||
resolved_at?: string;
|
||||
resolution_notes?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
ingredient?: Ingredient;
|
||||
}
|
||||
|
||||
export interface InventorySummary {
|
||||
total_ingredients: number;
|
||||
total_stock_value: number;
|
||||
low_stock_alerts: number;
|
||||
expiring_soon_items: number;
|
||||
expired_items: number;
|
||||
out_of_stock_items: number;
|
||||
stock_by_category: Record<string, CategoryStats>;
|
||||
recent_movements: number;
|
||||
recent_purchases: number;
|
||||
recent_waste: number;
|
||||
}
|
||||
|
||||
export interface CategoryStats {
|
||||
total_items: number;
|
||||
total_value: number;
|
||||
low_stock_count: number;
|
||||
percentage_of_total: number;
|
||||
}
|
||||
|
||||
export interface StockLevelSummary {
|
||||
ingredient_id: string;
|
||||
ingredient_name: string;
|
||||
unit_of_measure: string;
|
||||
total_quantity: number;
|
||||
available_quantity: number;
|
||||
reserved_quantity: number;
|
||||
is_low_stock: boolean;
|
||||
needs_reorder: boolean;
|
||||
has_expired_stock: boolean;
|
||||
total_batches: number;
|
||||
oldest_batch_date?: string;
|
||||
newest_batch_date?: string;
|
||||
next_expiration_date?: string;
|
||||
average_unit_cost?: number;
|
||||
total_stock_value?: number;
|
||||
}
|
||||
|
||||
export interface AllergenInfo {
|
||||
contains_gluten?: boolean;
|
||||
contains_dairy?: boolean;
|
||||
contains_eggs?: boolean;
|
||||
contains_nuts?: boolean;
|
||||
contains_soy?: boolean;
|
||||
contains_shellfish?: boolean;
|
||||
other_allergens?: string[];
|
||||
allergen_notes?: string;
|
||||
}
|
||||
|
||||
export interface FoodSafetyRecord {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
ingredient_id?: string;
|
||||
stock_id?: string;
|
||||
check_type: FoodSafetyCheckType;
|
||||
temperature_recorded?: number;
|
||||
humidity_recorded?: number;
|
||||
ph_level?: number;
|
||||
visual_inspection_notes?: string;
|
||||
compliance_status: ComplianceStatus;
|
||||
inspector: string;
|
||||
inspection_date: string;
|
||||
corrective_actions?: string[];
|
||||
follow_up_required: boolean;
|
||||
follow_up_date?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface InventoryTransaction {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
transaction_type: TransactionType;
|
||||
reference_number: string;
|
||||
items: InventoryTransactionItem[];
|
||||
total_cost: number;
|
||||
supplier_id?: string;
|
||||
customer_id?: string;
|
||||
notes?: string;
|
||||
status: TransactionStatus;
|
||||
created_at: string;
|
||||
created_by: string;
|
||||
}
|
||||
|
||||
export interface InventoryTransactionItem {
|
||||
ingredient_id: string;
|
||||
ingredient_name: string;
|
||||
quantity: number;
|
||||
unit_cost: number;
|
||||
total_cost: number;
|
||||
batch_number?: string;
|
||||
expiration_date?: string;
|
||||
}
|
||||
|
||||
// Form interfaces
|
||||
export interface IngredientFormData {
|
||||
name: string;
|
||||
product_type: ProductType;
|
||||
sku?: string;
|
||||
barcode?: string;
|
||||
category?: string;
|
||||
subcategory?: string;
|
||||
description?: string;
|
||||
brand?: string;
|
||||
unit_of_measure: UnitOfMeasure;
|
||||
package_size?: number;
|
||||
standard_cost?: number;
|
||||
low_stock_threshold: number;
|
||||
reorder_point: number;
|
||||
reorder_quantity: number;
|
||||
max_stock_level?: number;
|
||||
requires_refrigeration: boolean;
|
||||
requires_freezing: boolean;
|
||||
storage_temperature_min?: number;
|
||||
storage_temperature_max?: number;
|
||||
storage_humidity_max?: number;
|
||||
shelf_life_days?: number;
|
||||
storage_instructions?: string;
|
||||
is_perishable: boolean;
|
||||
allergen_info?: AllergenInfo;
|
||||
}
|
||||
|
||||
export interface StockFormData {
|
||||
ingredient_id: string;
|
||||
batch_number?: string;
|
||||
lot_number?: string;
|
||||
supplier_batch_ref?: string;
|
||||
current_quantity: number;
|
||||
received_date?: string;
|
||||
expiration_date?: string;
|
||||
best_before_date?: string;
|
||||
unit_cost?: number;
|
||||
storage_location?: string;
|
||||
warehouse_zone?: string;
|
||||
shelf_position?: string;
|
||||
quality_status: QualityStatus;
|
||||
}
|
||||
|
||||
export interface StockMovementFormData {
|
||||
ingredient_id: string;
|
||||
stock_id?: string;
|
||||
movement_type: StockMovementType;
|
||||
quantity: number;
|
||||
unit_cost?: number;
|
||||
reference_number?: string;
|
||||
supplier_id?: string;
|
||||
notes?: string;
|
||||
reason_code?: string;
|
||||
movement_date?: string;
|
||||
}
|
||||
|
||||
// Filter interfaces
|
||||
export interface InventoryFilters {
|
||||
search?: string;
|
||||
category?: string;
|
||||
is_active?: boolean;
|
||||
is_low_stock?: boolean;
|
||||
needs_reorder?: boolean;
|
||||
product_type?: ProductType;
|
||||
is_perishable?: boolean;
|
||||
requires_refrigeration?: boolean;
|
||||
sort_by?: InventorySortField;
|
||||
sort_order?: SortOrder;
|
||||
}
|
||||
|
||||
export interface StockFilters {
|
||||
ingredient_id?: string;
|
||||
is_available?: boolean;
|
||||
is_expired?: boolean;
|
||||
expiring_within_days?: number;
|
||||
storage_location?: string;
|
||||
quality_status?: QualityStatus;
|
||||
batch_number?: string;
|
||||
sort_by?: StockSortField;
|
||||
sort_order?: SortOrder;
|
||||
}
|
||||
|
||||
export interface MovementFilters {
|
||||
ingredient_id?: string;
|
||||
movement_type?: StockMovementType;
|
||||
start_date?: string;
|
||||
end_date?: string;
|
||||
reference_number?: string;
|
||||
supplier_id?: string;
|
||||
created_by?: string;
|
||||
sort_by?: MovementSortField;
|
||||
sort_order?: SortOrder;
|
||||
}
|
||||
|
||||
// Enums
|
||||
export enum ProductType {
|
||||
INGREDIENT = 'ingredient',
|
||||
FINISHED_PRODUCT = 'finished_product',
|
||||
}
|
||||
|
||||
export enum UnitOfMeasure {
|
||||
KILOGRAM = 'kg',
|
||||
GRAM = 'g',
|
||||
LITER = 'l',
|
||||
MILLILITER = 'ml',
|
||||
PIECE = 'piece',
|
||||
PACKAGE = 'package',
|
||||
BAG = 'bag',
|
||||
BOX = 'box',
|
||||
DOZEN = 'dozen',
|
||||
CUP = 'cup',
|
||||
TABLESPOON = 'tbsp',
|
||||
TEASPOON = 'tsp',
|
||||
POUND = 'lb',
|
||||
OUNCE = 'oz',
|
||||
}
|
||||
|
||||
export enum StockMovementType {
|
||||
PURCHASE = 'purchase',
|
||||
SALE = 'sale',
|
||||
USAGE = 'usage',
|
||||
WASTE = 'waste',
|
||||
ADJUSTMENT = 'adjustment',
|
||||
TRANSFER = 'transfer',
|
||||
RETURN = 'return',
|
||||
PRODUCTION_INPUT = 'production_input',
|
||||
PRODUCTION_OUTPUT = 'production_output',
|
||||
}
|
||||
|
||||
export enum QualityStatus {
|
||||
EXCELLENT = 'excellent',
|
||||
GOOD = 'good',
|
||||
FAIR = 'fair',
|
||||
POOR = 'poor',
|
||||
DAMAGED = 'damaged',
|
||||
EXPIRED = 'expired',
|
||||
QUARANTINE = 'quarantine',
|
||||
}
|
||||
|
||||
export enum AlertType {
|
||||
LOW_STOCK = 'low_stock',
|
||||
OUT_OF_STOCK = 'out_of_stock',
|
||||
EXPIRING_SOON = 'expiring_soon',
|
||||
EXPIRED = 'expired',
|
||||
QUALITY_ISSUE = 'quality_issue',
|
||||
TEMPERATURE_VIOLATION = 'temperature_violation',
|
||||
OVERSTOCKED = 'overstocked',
|
||||
}
|
||||
|
||||
export enum AlertSeverity {
|
||||
LOW = 'low',
|
||||
MEDIUM = 'medium',
|
||||
HIGH = 'high',
|
||||
CRITICAL = 'critical',
|
||||
}
|
||||
|
||||
export enum FoodSafetyCheckType {
|
||||
TEMPERATURE_CHECK = 'temperature_check',
|
||||
VISUAL_INSPECTION = 'visual_inspection',
|
||||
PH_TEST = 'ph_test',
|
||||
HUMIDITY_CHECK = 'humidity_check',
|
||||
CONTAMINATION_CHECK = 'contamination_check',
|
||||
PEST_INSPECTION = 'pest_inspection',
|
||||
}
|
||||
|
||||
export enum ComplianceStatus {
|
||||
COMPLIANT = 'compliant',
|
||||
NON_COMPLIANT = 'non_compliant',
|
||||
NEEDS_ATTENTION = 'needs_attention',
|
||||
UNDER_REVIEW = 'under_review',
|
||||
}
|
||||
|
||||
export enum TransactionType {
|
||||
PURCHASE = 'purchase',
|
||||
SALE = 'sale',
|
||||
TRANSFER = 'transfer',
|
||||
ADJUSTMENT = 'adjustment',
|
||||
WASTE = 'waste',
|
||||
PRODUCTION = 'production',
|
||||
}
|
||||
|
||||
export enum TransactionStatus {
|
||||
PENDING = 'pending',
|
||||
PROCESSING = 'processing',
|
||||
COMPLETED = 'completed',
|
||||
CANCELLED = 'cancelled',
|
||||
FAILED = 'failed',
|
||||
}
|
||||
|
||||
export enum InventorySortField {
|
||||
NAME = 'name',
|
||||
CATEGORY = 'category',
|
||||
CURRENT_STOCK = 'current_stock',
|
||||
TOTAL_VALUE = 'total_value',
|
||||
LAST_UPDATED = 'updated_at',
|
||||
CREATED_DATE = 'created_at',
|
||||
}
|
||||
|
||||
export enum StockSortField {
|
||||
QUANTITY = 'current_quantity',
|
||||
EXPIRATION_DATE = 'expiration_date',
|
||||
RECEIVED_DATE = 'received_date',
|
||||
UNIT_COST = 'unit_cost',
|
||||
TOTAL_COST = 'total_cost',
|
||||
QUALITY_STATUS = 'quality_status',
|
||||
}
|
||||
|
||||
export enum MovementSortField {
|
||||
DATE = 'movement_date',
|
||||
QUANTITY = 'quantity',
|
||||
TYPE = 'movement_type',
|
||||
COST = 'total_cost',
|
||||
CREATED_DATE = 'created_at',
|
||||
}
|
||||
|
||||
export enum SortOrder {
|
||||
ASC = 'asc',
|
||||
DESC = 'desc',
|
||||
}
|
||||
|
||||
// Type guards
|
||||
export const isIngredient = (obj: any): obj is Ingredient => {
|
||||
return obj && typeof obj.id === 'string' && typeof obj.name === 'string';
|
||||
};
|
||||
|
||||
export const isStock = (obj: any): obj is Stock => {
|
||||
return obj && typeof obj.id === 'string' && typeof obj.ingredient_id === 'string';
|
||||
};
|
||||
|
||||
export const isStockMovement = (obj: any): obj is StockMovement => {
|
||||
return obj && typeof obj.id === 'string' && obj.movement_type && obj.quantity !== undefined;
|
||||
};
|
||||
543
frontend/src/types/production.types.ts
Normal file
543
frontend/src/types/production.types.ts
Normal file
@@ -0,0 +1,543 @@
|
||||
// Production management types
|
||||
|
||||
export enum DifficultyLevel {
|
||||
BEGINNER = 'beginner',
|
||||
INTERMEDIATE = 'intermediate',
|
||||
ADVANCED = 'advanced',
|
||||
EXPERT = 'expert',
|
||||
}
|
||||
|
||||
export interface ProductionBatch {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
recipe_id: string;
|
||||
batch_number: string;
|
||||
planned_quantity: number;
|
||||
actual_quantity?: number;
|
||||
planned_start_date: string;
|
||||
planned_end_date?: string;
|
||||
actual_start_date?: string;
|
||||
actual_end_date?: string;
|
||||
status: ProductionBatchStatus;
|
||||
priority: ProductionPriority;
|
||||
notes?: string;
|
||||
assigned_staff: string[];
|
||||
equipment_required: string[];
|
||||
cost_per_unit?: number;
|
||||
total_cost?: number;
|
||||
yield_percentage?: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
created_by: string;
|
||||
recipe?: Recipe;
|
||||
quality_checks?: QualityCheck[];
|
||||
}
|
||||
|
||||
export interface Recipe {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
category: string;
|
||||
version: string;
|
||||
yield_quantity: number;
|
||||
yield_unit: string;
|
||||
prep_time_minutes: number;
|
||||
cook_time_minutes: number;
|
||||
total_time_minutes: number;
|
||||
difficulty_level: DifficultyLevel;
|
||||
ingredients: RecipeIngredient[];
|
||||
instructions: RecipeInstruction[];
|
||||
equipment_needed: string[];
|
||||
nutritional_info?: NutritionalInfo;
|
||||
allergen_warnings: string[];
|
||||
storage_instructions?: string;
|
||||
shelf_life_hours?: number;
|
||||
cost_per_unit?: number;
|
||||
is_active: boolean;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
created_by: string;
|
||||
}
|
||||
|
||||
export interface RecipeIngredient {
|
||||
ingredient_id: string;
|
||||
ingredient_name: string;
|
||||
quantity: number;
|
||||
unit: string;
|
||||
cost_per_unit?: number;
|
||||
preparation_notes?: string;
|
||||
is_optional: boolean;
|
||||
substitutions?: RecipeSubstitution[];
|
||||
}
|
||||
|
||||
export interface RecipeSubstitution {
|
||||
ingredient_id: string;
|
||||
ingredient_name: string;
|
||||
quantity: number;
|
||||
unit: string;
|
||||
conversion_ratio: number;
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
export interface RecipeInstruction {
|
||||
step_number: number;
|
||||
instruction: string;
|
||||
duration_minutes?: number;
|
||||
temperature?: number;
|
||||
equipment?: string[];
|
||||
tips?: string;
|
||||
critical_control_point?: boolean;
|
||||
}
|
||||
|
||||
export interface NutritionalInfo {
|
||||
calories_per_serving?: number;
|
||||
protein_g?: number;
|
||||
carbohydrates_g?: number;
|
||||
fat_g?: number;
|
||||
fiber_g?: number;
|
||||
sugar_g?: number;
|
||||
sodium_mg?: number;
|
||||
serving_size?: string;
|
||||
servings_per_batch?: number;
|
||||
}
|
||||
|
||||
export interface ProductionSchedule {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
batch_id: string;
|
||||
scheduled_date: string;
|
||||
scheduled_start_time: string;
|
||||
scheduled_end_time: string;
|
||||
estimated_duration_minutes: number;
|
||||
equipment_reservations: EquipmentReservation[];
|
||||
staff_assignments: StaffAssignment[];
|
||||
dependencies: string[];
|
||||
is_locked: boolean;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
batch?: ProductionBatch;
|
||||
}
|
||||
|
||||
export interface EquipmentReservation {
|
||||
equipment_id: string;
|
||||
equipment_name: string;
|
||||
reserved_from: string;
|
||||
reserved_until: string;
|
||||
usage_type: EquipmentUsageType;
|
||||
}
|
||||
|
||||
export interface StaffAssignment {
|
||||
user_id: string;
|
||||
user_name: string;
|
||||
role: ProductionRole;
|
||||
assigned_from: string;
|
||||
assigned_until: string;
|
||||
hourly_rate?: number;
|
||||
}
|
||||
|
||||
export interface QualityCheck {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
batch_id: string;
|
||||
check_type: QualityCheckType;
|
||||
status: QualityCheckStatus;
|
||||
criteria: QualityCheckCriteria;
|
||||
results: QualityCheckResults;
|
||||
inspector?: string;
|
||||
scheduled_date?: string;
|
||||
completed_date?: string;
|
||||
notes?: string;
|
||||
corrective_actions?: string[];
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
batch?: ProductionBatch;
|
||||
}
|
||||
|
||||
export interface QualityCheckCriteria {
|
||||
visual_inspection?: VisualCriteria;
|
||||
weight_check?: WeightCriteria;
|
||||
temperature_check?: TemperatureCriteria;
|
||||
texture_assessment?: TextureCriteria;
|
||||
taste_test?: TasteCriteria;
|
||||
packaging_quality?: PackagingCriteria;
|
||||
}
|
||||
|
||||
export interface VisualCriteria {
|
||||
color_standard: string;
|
||||
texture_description: string;
|
||||
size_requirements: string;
|
||||
acceptable_defects: string[];
|
||||
rejection_criteria: string[];
|
||||
}
|
||||
|
||||
export interface WeightCriteria {
|
||||
target_weight: number;
|
||||
tolerance_percentage: number;
|
||||
minimum_weight: number;
|
||||
maximum_weight: number;
|
||||
unit: string;
|
||||
}
|
||||
|
||||
export interface TemperatureCriteria {
|
||||
target_temperature: number;
|
||||
tolerance_range: number;
|
||||
minimum_temperature: number;
|
||||
maximum_temperature: number;
|
||||
measurement_point: string;
|
||||
}
|
||||
|
||||
export interface TextureCriteria {
|
||||
firmness_level: number;
|
||||
moisture_content?: number;
|
||||
crumb_structure?: string;
|
||||
acceptable_variations: string[];
|
||||
}
|
||||
|
||||
export interface TasteCriteria {
|
||||
flavor_profile: string[];
|
||||
sweetness_level: number;
|
||||
saltiness_level: number;
|
||||
overall_rating_scale: number;
|
||||
off_flavor_detection: string[];
|
||||
}
|
||||
|
||||
export interface PackagingCriteria {
|
||||
seal_integrity: boolean;
|
||||
label_accuracy: boolean;
|
||||
appearance_standards: string[];
|
||||
weight_accuracy: boolean;
|
||||
}
|
||||
|
||||
export interface QualityCheckResults {
|
||||
passed: boolean;
|
||||
overall_score: number;
|
||||
individual_scores: Record<string, number>;
|
||||
measurements: Record<string, number>;
|
||||
observations: string[];
|
||||
defects_found: string[];
|
||||
recommendations: string[];
|
||||
}
|
||||
|
||||
export interface ProductionCapacity {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
resource_type: ResourceType;
|
||||
resource_id: string;
|
||||
resource_name: string;
|
||||
daily_capacity: number;
|
||||
hourly_capacity?: number;
|
||||
current_utilization: number;
|
||||
available_capacity: number;
|
||||
maintenance_schedule: MaintenanceWindow[];
|
||||
availability_windows: AvailabilityWindow[];
|
||||
efficiency_rating: number;
|
||||
last_updated: string;
|
||||
}
|
||||
|
||||
export interface MaintenanceWindow {
|
||||
id: string;
|
||||
start_date: string;
|
||||
end_date: string;
|
||||
maintenance_type: MaintenanceType;
|
||||
description: string;
|
||||
impact_level: MaintenanceImpact;
|
||||
scheduled_by: string;
|
||||
}
|
||||
|
||||
export interface AvailabilityWindow {
|
||||
day_of_week: DayOfWeek;
|
||||
start_time: string;
|
||||
end_time: string;
|
||||
capacity_percentage: number;
|
||||
}
|
||||
|
||||
export interface ProductionMetrics {
|
||||
total_batches: number;
|
||||
completed_batches: number;
|
||||
in_progress_batches: number;
|
||||
cancelled_batches: number;
|
||||
average_yield: number;
|
||||
on_time_delivery_rate: number;
|
||||
quality_pass_rate: number;
|
||||
equipment_utilization: number;
|
||||
staff_utilization: number;
|
||||
production_efficiency: number;
|
||||
waste_percentage: number;
|
||||
cost_per_unit_average: number;
|
||||
total_production_cost: number;
|
||||
energy_consumption?: number;
|
||||
water_usage?: number;
|
||||
}
|
||||
|
||||
export interface ProductionAlert {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
alert_type: ProductionAlertType;
|
||||
severity: AlertSeverity;
|
||||
title: string;
|
||||
message: string;
|
||||
batch_id?: string;
|
||||
equipment_id?: string;
|
||||
recipe_id?: string;
|
||||
related_data?: Record<string, any>;
|
||||
is_active: boolean;
|
||||
acknowledged_at?: string;
|
||||
acknowledged_by?: string;
|
||||
resolved_at?: string;
|
||||
resolved_by?: string;
|
||||
resolution_notes?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface ProductionEfficiency {
|
||||
period: string;
|
||||
planned_output: number;
|
||||
actual_output: number;
|
||||
efficiency_percentage: number;
|
||||
downtime_minutes: number;
|
||||
setup_time_minutes: number;
|
||||
production_time_minutes: number;
|
||||
waste_percentage: number;
|
||||
quality_issues_count: number;
|
||||
cost_variance_percentage: number;
|
||||
}
|
||||
|
||||
export interface WorkOrder {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
work_order_number: string;
|
||||
type: WorkOrderType;
|
||||
title: string;
|
||||
description: string;
|
||||
priority: WorkOrderPriority;
|
||||
status: WorkOrderStatus;
|
||||
assigned_to?: string;
|
||||
equipment_id?: string;
|
||||
estimated_duration_hours: number;
|
||||
actual_duration_hours?: number;
|
||||
scheduled_start: string;
|
||||
scheduled_end: string;
|
||||
actual_start?: string;
|
||||
actual_end?: string;
|
||||
materials_needed: WorkOrderMaterial[];
|
||||
labor_cost?: number;
|
||||
material_cost?: number;
|
||||
total_cost?: number;
|
||||
completion_notes?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
created_by: string;
|
||||
}
|
||||
|
||||
export interface WorkOrderMaterial {
|
||||
material_name: string;
|
||||
quantity: number;
|
||||
unit: string;
|
||||
cost_per_unit?: number;
|
||||
supplier?: string;
|
||||
}
|
||||
|
||||
// Form interfaces
|
||||
export interface ProductionBatchFormData {
|
||||
recipe_id: string;
|
||||
planned_quantity: number;
|
||||
planned_start_date: string;
|
||||
planned_end_date?: string;
|
||||
priority: ProductionPriority;
|
||||
notes?: string;
|
||||
assigned_staff: string[];
|
||||
equipment_required: string[];
|
||||
}
|
||||
|
||||
export interface QualityCheckFormData {
|
||||
batch_id: string;
|
||||
check_type: QualityCheckType;
|
||||
criteria: QualityCheckCriteria;
|
||||
inspector?: string;
|
||||
scheduled_date?: string;
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
export interface RecipeFormData {
|
||||
name: string;
|
||||
description?: string;
|
||||
category: string;
|
||||
yield_quantity: number;
|
||||
yield_unit: string;
|
||||
prep_time_minutes: number;
|
||||
cook_time_minutes: number;
|
||||
difficulty_level: DifficultyLevel;
|
||||
ingredients: RecipeIngredientFormData[];
|
||||
instructions: RecipeInstructionFormData[];
|
||||
equipment_needed: string[];
|
||||
allergen_warnings: string[];
|
||||
storage_instructions?: string;
|
||||
shelf_life_hours?: number;
|
||||
}
|
||||
|
||||
export interface RecipeIngredientFormData {
|
||||
ingredient_id: string;
|
||||
quantity: number;
|
||||
unit: string;
|
||||
preparation_notes?: string;
|
||||
is_optional: boolean;
|
||||
}
|
||||
|
||||
export interface RecipeInstructionFormData {
|
||||
step_number: number;
|
||||
instruction: string;
|
||||
duration_minutes?: number;
|
||||
temperature?: number;
|
||||
equipment?: string[];
|
||||
tips?: string;
|
||||
critical_control_point?: boolean;
|
||||
}
|
||||
|
||||
// Enums
|
||||
export enum ProductionBatchStatus {
|
||||
PLANNED = 'planned',
|
||||
READY_TO_START = 'ready_to_start',
|
||||
IN_PROGRESS = 'in_progress',
|
||||
QUALITY_CHECK = 'quality_check',
|
||||
COMPLETED = 'completed',
|
||||
CANCELLED = 'cancelled',
|
||||
ON_HOLD = 'on_hold',
|
||||
FAILED = 'failed',
|
||||
}
|
||||
|
||||
export enum ProductionPriority {
|
||||
LOW = 'low',
|
||||
NORMAL = 'normal',
|
||||
HIGH = 'high',
|
||||
URGENT = 'urgent',
|
||||
RUSH = 'rush',
|
||||
}
|
||||
|
||||
export enum QualityCheckType {
|
||||
VISUAL_INSPECTION = 'visual_inspection',
|
||||
WEIGHT_CHECK = 'weight_check',
|
||||
TEMPERATURE_CHECK = 'temperature_check',
|
||||
TEXTURE_ASSESSMENT = 'texture_assessment',
|
||||
TASTE_TEST = 'taste_test',
|
||||
PACKAGING_QUALITY = 'packaging_quality',
|
||||
FOOD_SAFETY = 'food_safety',
|
||||
ALLERGEN_VERIFICATION = 'allergen_verification',
|
||||
}
|
||||
|
||||
export enum QualityCheckStatus {
|
||||
SCHEDULED = 'scheduled',
|
||||
IN_PROGRESS = 'in_progress',
|
||||
PASSED = 'passed',
|
||||
FAILED = 'failed',
|
||||
REQUIRES_REVIEW = 'requires_review',
|
||||
CANCELLED = 'cancelled',
|
||||
}
|
||||
|
||||
export enum ResourceType {
|
||||
EQUIPMENT = 'equipment',
|
||||
STAFF = 'staff',
|
||||
FACILITY = 'facility',
|
||||
UTILITY = 'utility',
|
||||
}
|
||||
|
||||
export enum EquipmentUsageType {
|
||||
PRIMARY = 'primary',
|
||||
SECONDARY = 'secondary',
|
||||
CLEANING = 'cleaning',
|
||||
MAINTENANCE = 'maintenance',
|
||||
}
|
||||
|
||||
export enum ProductionRole {
|
||||
BAKER = 'baker',
|
||||
ASSISTANT = 'assistant',
|
||||
DECORATOR = 'decorator',
|
||||
PACKAGER = 'packager',
|
||||
QUALITY_INSPECTOR = 'quality_inspector',
|
||||
SUPERVISOR = 'supervisor',
|
||||
CLEANER = 'cleaner',
|
||||
}
|
||||
|
||||
export enum MaintenanceType {
|
||||
PREVENTIVE = 'preventive',
|
||||
CORRECTIVE = 'corrective',
|
||||
EMERGENCY = 'emergency',
|
||||
CALIBRATION = 'calibration',
|
||||
CLEANING = 'cleaning',
|
||||
}
|
||||
|
||||
export enum MaintenanceImpact {
|
||||
LOW = 'low',
|
||||
MEDIUM = 'medium',
|
||||
HIGH = 'high',
|
||||
CRITICAL = 'critical',
|
||||
}
|
||||
|
||||
export enum DayOfWeek {
|
||||
MONDAY = 'monday',
|
||||
TUESDAY = 'tuesday',
|
||||
WEDNESDAY = 'wednesday',
|
||||
THURSDAY = 'thursday',
|
||||
FRIDAY = 'friday',
|
||||
SATURDAY = 'saturday',
|
||||
SUNDAY = 'sunday',
|
||||
}
|
||||
|
||||
export enum ProductionAlertType {
|
||||
BATCH_DELAYED = 'batch_delayed',
|
||||
QUALITY_FAILURE = 'quality_failure',
|
||||
EQUIPMENT_FAILURE = 'equipment_failure',
|
||||
INGREDIENT_SHORTAGE = 'ingredient_shortage',
|
||||
STAFF_SHORTAGE = 'staff_shortage',
|
||||
TEMPERATURE_VIOLATION = 'temperature_violation',
|
||||
WASTE_THRESHOLD_EXCEEDED = 'waste_threshold_exceeded',
|
||||
COST_OVERRUN = 'cost_overrun',
|
||||
SCHEDULE_CONFLICT = 'schedule_conflict',
|
||||
}
|
||||
|
||||
export enum AlertSeverity {
|
||||
LOW = 'low',
|
||||
MEDIUM = 'medium',
|
||||
HIGH = 'high',
|
||||
CRITICAL = 'critical',
|
||||
}
|
||||
|
||||
export enum WorkOrderType {
|
||||
MAINTENANCE = 'maintenance',
|
||||
REPAIR = 'repair',
|
||||
INSTALLATION = 'installation',
|
||||
CALIBRATION = 'calibration',
|
||||
CLEANING = 'cleaning',
|
||||
INSPECTION = 'inspection',
|
||||
}
|
||||
|
||||
export enum WorkOrderPriority {
|
||||
LOW = 'low',
|
||||
MEDIUM = 'medium',
|
||||
HIGH = 'high',
|
||||
URGENT = 'urgent',
|
||||
EMERGENCY = 'emergency',
|
||||
}
|
||||
|
||||
export enum WorkOrderStatus {
|
||||
PENDING = 'pending',
|
||||
ASSIGNED = 'assigned',
|
||||
IN_PROGRESS = 'in_progress',
|
||||
ON_HOLD = 'on_hold',
|
||||
COMPLETED = 'completed',
|
||||
CANCELLED = 'cancelled',
|
||||
}
|
||||
|
||||
// Type guards
|
||||
export const isProductionBatch = (obj: any): obj is ProductionBatch => {
|
||||
return obj && typeof obj.id === 'string' && typeof obj.recipe_id === 'string';
|
||||
};
|
||||
|
||||
export const isQualityCheck = (obj: any): obj is QualityCheck => {
|
||||
return obj && typeof obj.id === 'string' && typeof obj.batch_id === 'string';
|
||||
};
|
||||
|
||||
export const isRecipe = (obj: any): obj is Recipe => {
|
||||
return obj && typeof obj.id === 'string' && typeof obj.name === 'string' && Array.isArray(obj.ingredients);
|
||||
};
|
||||
602
frontend/src/types/sales.types.ts
Normal file
602
frontend/src/types/sales.types.ts
Normal file
@@ -0,0 +1,602 @@
|
||||
// Sales and analytics types
|
||||
|
||||
export interface SalesRecord {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
date: string;
|
||||
product_id?: string;
|
||||
product_name: string;
|
||||
category?: string;
|
||||
quantity_sold: number;
|
||||
unit_price: number;
|
||||
total_revenue: number;
|
||||
cost_of_goods: number;
|
||||
gross_profit: number;
|
||||
profit_margin: number;
|
||||
discount_applied: number;
|
||||
tax_amount: number;
|
||||
net_revenue: number;
|
||||
weather_condition?: WeatherCondition;
|
||||
temperature?: number;
|
||||
day_of_week: DayOfWeek;
|
||||
is_holiday: boolean;
|
||||
special_event?: string;
|
||||
customer_id?: string;
|
||||
sales_channel: SalesChannel;
|
||||
payment_method?: PaymentMethod;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface SalesSummary {
|
||||
total_revenue: number;
|
||||
total_quantity: number;
|
||||
total_orders: number;
|
||||
average_order_value: number;
|
||||
gross_profit: number;
|
||||
profit_margin: number;
|
||||
discount_percentage: number;
|
||||
tax_percentage: number;
|
||||
growth_rate?: number;
|
||||
period_comparison?: PeriodComparison;
|
||||
best_selling_products: ProductPerformance[];
|
||||
revenue_by_channel: ChannelRevenue[];
|
||||
}
|
||||
|
||||
export interface PeriodComparison {
|
||||
revenue_change: number;
|
||||
quantity_change: number;
|
||||
order_change: number;
|
||||
profit_change: number;
|
||||
comparison_period: string;
|
||||
}
|
||||
|
||||
export interface ProductPerformance {
|
||||
product_id?: string;
|
||||
product_name: string;
|
||||
category?: string;
|
||||
total_revenue: number;
|
||||
total_quantity: number;
|
||||
total_orders: number;
|
||||
average_price: number;
|
||||
profit_margin: number;
|
||||
growth_rate: number;
|
||||
rank: number;
|
||||
trend: TrendDirection;
|
||||
}
|
||||
|
||||
export interface ChannelRevenue {
|
||||
channel: SalesChannel;
|
||||
revenue: number;
|
||||
orders: number;
|
||||
percentage: number;
|
||||
growth_rate: number;
|
||||
}
|
||||
|
||||
export interface SalesAnalytics {
|
||||
overview: SalesSummary;
|
||||
daily_trends: DailyTrend[];
|
||||
hourly_patterns: HourlyPattern[];
|
||||
product_performance: ProductPerformance[];
|
||||
customer_segments: CustomerSegment[];
|
||||
weather_impact: WeatherImpact[];
|
||||
seasonal_patterns: SeasonalPattern[];
|
||||
forecast: SalesForecast[];
|
||||
}
|
||||
|
||||
export interface DailyTrend {
|
||||
date: string;
|
||||
revenue: number;
|
||||
quantity: number;
|
||||
orders: number;
|
||||
average_order_value: number;
|
||||
new_customers: number;
|
||||
weather_condition?: WeatherCondition;
|
||||
temperature?: number;
|
||||
day_type: DayType;
|
||||
}
|
||||
|
||||
export interface HourlyPattern {
|
||||
hour: number;
|
||||
average_sales: number;
|
||||
peak_day: DayOfWeek;
|
||||
orders_count: number;
|
||||
revenue_percentage: number;
|
||||
staff_recommendation: number;
|
||||
}
|
||||
|
||||
export interface CustomerSegment {
|
||||
segment_name: string;
|
||||
customer_count: number;
|
||||
total_revenue: number;
|
||||
average_order_value: number;
|
||||
order_frequency: number;
|
||||
retention_rate: number;
|
||||
growth_rate: number;
|
||||
}
|
||||
|
||||
export interface WeatherImpact {
|
||||
condition: WeatherCondition;
|
||||
temperature_range?: TemperatureRange;
|
||||
average_revenue: number;
|
||||
average_quantity: number;
|
||||
impact_factor: number;
|
||||
confidence: number;
|
||||
affected_products: string[];
|
||||
}
|
||||
|
||||
export interface TemperatureRange {
|
||||
min: number;
|
||||
max: number;
|
||||
unit: TemperatureUnit;
|
||||
}
|
||||
|
||||
export interface SeasonalPattern {
|
||||
period_type: SeasonalPeriod;
|
||||
period_name: string;
|
||||
revenue_multiplier: number;
|
||||
popular_products: string[];
|
||||
marketing_recommendations: string[];
|
||||
}
|
||||
|
||||
export interface SalesForecast {
|
||||
date: string;
|
||||
predicted_revenue: number;
|
||||
predicted_quantity: number;
|
||||
confidence_interval: ConfidenceInterval;
|
||||
factors_considered: string[];
|
||||
}
|
||||
|
||||
export interface ConfidenceInterval {
|
||||
lower: number;
|
||||
upper: number;
|
||||
confidence_level: number;
|
||||
}
|
||||
|
||||
export interface SalesTarget {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
target_type: TargetType;
|
||||
target_period: TargetPeriod;
|
||||
target_value: number;
|
||||
current_value: number;
|
||||
achievement_percentage: number;
|
||||
start_date: string;
|
||||
end_date: string;
|
||||
assigned_to?: string;
|
||||
category?: string;
|
||||
product_id?: string;
|
||||
is_active: boolean;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface SalesReport {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
report_name: string;
|
||||
report_type: ReportType;
|
||||
parameters: ReportParameters;
|
||||
data: any;
|
||||
generated_at: string;
|
||||
generated_by: string;
|
||||
expires_at?: string;
|
||||
download_url?: string;
|
||||
status: ReportStatus;
|
||||
}
|
||||
|
||||
export interface ReportParameters {
|
||||
date_range: DateRange;
|
||||
products?: string[];
|
||||
categories?: string[];
|
||||
channels?: SalesChannel[];
|
||||
group_by?: GroupByField;
|
||||
metrics?: MetricType[];
|
||||
format?: ReportFormat;
|
||||
}
|
||||
|
||||
export interface DateRange {
|
||||
start_date: string;
|
||||
end_date: string;
|
||||
period_type?: PeriodType;
|
||||
}
|
||||
|
||||
export interface SalesImportResult {
|
||||
imported_records: number;
|
||||
failed_records: number;
|
||||
duplicate_records: number;
|
||||
warnings: ImportWarning[];
|
||||
errors: ImportError[];
|
||||
summary: SalesSummary;
|
||||
data_quality_score: number;
|
||||
}
|
||||
|
||||
export interface ImportWarning {
|
||||
row: number;
|
||||
field?: string;
|
||||
message: string;
|
||||
suggested_fix?: string;
|
||||
}
|
||||
|
||||
export interface ImportError {
|
||||
row: number;
|
||||
field?: string;
|
||||
message: string;
|
||||
error_code: string;
|
||||
actual_value?: any;
|
||||
expected_format?: string;
|
||||
}
|
||||
|
||||
export interface DataQualityReport {
|
||||
overall_score: number;
|
||||
completeness_score: number;
|
||||
accuracy_score: number;
|
||||
consistency_score: number;
|
||||
timeliness_score: number;
|
||||
issues: DataQualityIssue[];
|
||||
recommendations: string[];
|
||||
last_assessment: string;
|
||||
}
|
||||
|
||||
export interface DataQualityIssue {
|
||||
type: QualityIssueType;
|
||||
severity: IssueSeverity;
|
||||
description: string;
|
||||
affected_records: number;
|
||||
suggested_actions: string[];
|
||||
impact_score: number;
|
||||
}
|
||||
|
||||
export interface OnboardingAnalysis {
|
||||
task_id: string;
|
||||
status: AnalysisStatus;
|
||||
progress: number;
|
||||
message: string;
|
||||
results?: OnboardingResults;
|
||||
error_message?: string;
|
||||
started_at: string;
|
||||
completed_at?: string;
|
||||
}
|
||||
|
||||
export interface OnboardingResults {
|
||||
data_quality_score: number;
|
||||
total_records: number;
|
||||
date_range: DateRange;
|
||||
products_identified: ProductIdentification[];
|
||||
patterns_detected: PatternDetection[];
|
||||
recommendations: OnboardingRecommendation[];
|
||||
suggested_categories: string[];
|
||||
anomalies_detected: AnomalyDetection[];
|
||||
}
|
||||
|
||||
export interface ProductIdentification {
|
||||
original_name: string;
|
||||
suggested_name: string;
|
||||
category: string;
|
||||
confidence: number;
|
||||
similar_products: string[];
|
||||
}
|
||||
|
||||
export interface PatternDetection {
|
||||
pattern_type: PatternType;
|
||||
description: string;
|
||||
confidence: number;
|
||||
impact: PatternImpact;
|
||||
examples: string[];
|
||||
}
|
||||
|
||||
export interface OnboardingRecommendation {
|
||||
type: RecommendationType;
|
||||
title: string;
|
||||
description: string;
|
||||
priority: RecommendationPriority;
|
||||
implementation_effort: ImplementationEffort;
|
||||
expected_benefit: string;
|
||||
action_items: string[];
|
||||
}
|
||||
|
||||
export interface AnomalyDetection {
|
||||
date: string;
|
||||
product_name?: string;
|
||||
anomaly_type: AnomalyType;
|
||||
description: string;
|
||||
severity: AnommalySeverity;
|
||||
actual_value: number;
|
||||
expected_range: ExpectedRange;
|
||||
confidence: number;
|
||||
}
|
||||
|
||||
export interface ExpectedRange {
|
||||
min: number;
|
||||
max: number;
|
||||
mean: number;
|
||||
}
|
||||
|
||||
// Form interfaces
|
||||
export interface SalesRecordFormData {
|
||||
date: string;
|
||||
product_name: string;
|
||||
category?: string;
|
||||
quantity_sold: number;
|
||||
unit_price: number;
|
||||
discount_applied?: number;
|
||||
tax_amount?: number;
|
||||
weather_condition?: WeatherCondition;
|
||||
temperature?: number;
|
||||
special_event?: string;
|
||||
sales_channel: SalesChannel;
|
||||
payment_method?: PaymentMethod;
|
||||
}
|
||||
|
||||
export interface SalesTargetFormData {
|
||||
name: string;
|
||||
description?: string;
|
||||
target_type: TargetType;
|
||||
target_period: TargetPeriod;
|
||||
target_value: number;
|
||||
start_date: string;
|
||||
end_date: string;
|
||||
assigned_to?: string;
|
||||
category?: string;
|
||||
product_id?: string;
|
||||
}
|
||||
|
||||
export interface SalesFilters {
|
||||
date_range?: DateRange;
|
||||
product_name?: string;
|
||||
category?: string;
|
||||
sales_channel?: SalesChannel;
|
||||
payment_method?: PaymentMethod;
|
||||
weather_condition?: WeatherCondition;
|
||||
day_of_week?: DayOfWeek;
|
||||
is_holiday?: boolean;
|
||||
min_revenue?: number;
|
||||
max_revenue?: number;
|
||||
sort_by?: SalesSortField;
|
||||
sort_order?: SortOrder;
|
||||
}
|
||||
|
||||
// Enums
|
||||
export enum SalesChannel {
|
||||
STORE_FRONT = 'store_front',
|
||||
ONLINE = 'online',
|
||||
PHONE_ORDER = 'phone_order',
|
||||
DELIVERY = 'delivery',
|
||||
CATERING = 'catering',
|
||||
WHOLESALE = 'wholesale',
|
||||
FARMERS_MARKET = 'farmers_market',
|
||||
THIRD_PARTY = 'third_party',
|
||||
}
|
||||
|
||||
export enum PaymentMethod {
|
||||
CASH = 'cash',
|
||||
CREDIT_CARD = 'credit_card',
|
||||
DEBIT_CARD = 'debit_card',
|
||||
DIGITAL_WALLET = 'digital_wallet',
|
||||
BANK_TRANSFER = 'bank_transfer',
|
||||
CHECK = 'check',
|
||||
STORE_CREDIT = 'store_credit',
|
||||
}
|
||||
|
||||
export enum WeatherCondition {
|
||||
SUNNY = 'sunny',
|
||||
CLOUDY = 'cloudy',
|
||||
RAINY = 'rainy',
|
||||
STORMY = 'stormy',
|
||||
SNOWY = 'snowy',
|
||||
FOGGY = 'foggy',
|
||||
WINDY = 'windy',
|
||||
HOT = 'hot',
|
||||
COLD = 'cold',
|
||||
}
|
||||
|
||||
export enum TemperatureUnit {
|
||||
CELSIUS = 'celsius',
|
||||
FAHRENHEIT = 'fahrenheit',
|
||||
}
|
||||
|
||||
export enum DayOfWeek {
|
||||
MONDAY = 'monday',
|
||||
TUESDAY = 'tuesday',
|
||||
WEDNESDAY = 'wednesday',
|
||||
THURSDAY = 'thursday',
|
||||
FRIDAY = 'friday',
|
||||
SATURDAY = 'saturday',
|
||||
SUNDAY = 'sunday',
|
||||
}
|
||||
|
||||
export enum DayType {
|
||||
WEEKDAY = 'weekday',
|
||||
WEEKEND = 'weekend',
|
||||
HOLIDAY = 'holiday',
|
||||
SPECIAL_EVENT = 'special_event',
|
||||
}
|
||||
|
||||
export enum TrendDirection {
|
||||
UP = 'up',
|
||||
DOWN = 'down',
|
||||
STABLE = 'stable',
|
||||
VOLATILE = 'volatile',
|
||||
}
|
||||
|
||||
export enum SeasonalPeriod {
|
||||
MONTHLY = 'monthly',
|
||||
QUARTERLY = 'quarterly',
|
||||
SEASONAL = 'seasonal',
|
||||
YEARLY = 'yearly',
|
||||
}
|
||||
|
||||
export enum TargetType {
|
||||
REVENUE = 'revenue',
|
||||
QUANTITY = 'quantity',
|
||||
ORDERS = 'orders',
|
||||
PROFIT_MARGIN = 'profit_margin',
|
||||
CUSTOMER_ACQUISITION = 'customer_acquisition',
|
||||
MARKET_SHARE = 'market_share',
|
||||
}
|
||||
|
||||
export enum TargetPeriod {
|
||||
DAILY = 'daily',
|
||||
WEEKLY = 'weekly',
|
||||
MONTHLY = 'monthly',
|
||||
QUARTERLY = 'quarterly',
|
||||
YEARLY = 'yearly',
|
||||
}
|
||||
|
||||
export enum ReportType {
|
||||
SALES_SUMMARY = 'sales_summary',
|
||||
PRODUCT_PERFORMANCE = 'product_performance',
|
||||
CUSTOMER_ANALYSIS = 'customer_analysis',
|
||||
TREND_ANALYSIS = 'trend_analysis',
|
||||
WEATHER_IMPACT = 'weather_impact',
|
||||
CHANNEL_ANALYSIS = 'channel_analysis',
|
||||
PROFIT_ANALYSIS = 'profit_analysis',
|
||||
}
|
||||
|
||||
export enum ReportFormat {
|
||||
PDF = 'pdf',
|
||||
CSV = 'csv',
|
||||
EXCEL = 'excel',
|
||||
JSON = 'json',
|
||||
}
|
||||
|
||||
export enum ReportStatus {
|
||||
GENERATING = 'generating',
|
||||
COMPLETED = 'completed',
|
||||
FAILED = 'failed',
|
||||
EXPIRED = 'expired',
|
||||
}
|
||||
|
||||
export enum GroupByField {
|
||||
DATE = 'date',
|
||||
PRODUCT = 'product',
|
||||
CATEGORY = 'category',
|
||||
CHANNEL = 'channel',
|
||||
CUSTOMER = 'customer',
|
||||
DAY_OF_WEEK = 'day_of_week',
|
||||
HOUR = 'hour',
|
||||
}
|
||||
|
||||
export enum MetricType {
|
||||
REVENUE = 'revenue',
|
||||
QUANTITY = 'quantity',
|
||||
ORDERS = 'orders',
|
||||
PROFIT = 'profit',
|
||||
MARGIN = 'margin',
|
||||
DISCOUNT = 'discount',
|
||||
TAX = 'tax',
|
||||
}
|
||||
|
||||
export enum PeriodType {
|
||||
DAILY = 'daily',
|
||||
WEEKLY = 'weekly',
|
||||
MONTHLY = 'monthly',
|
||||
QUARTERLY = 'quarterly',
|
||||
YEARLY = 'yearly',
|
||||
CUSTOM = 'custom',
|
||||
}
|
||||
|
||||
export enum QualityIssueType {
|
||||
MISSING_DATA = 'missing_data',
|
||||
INVALID_DATA = 'invalid_data',
|
||||
DUPLICATE_DATA = 'duplicate_data',
|
||||
INCONSISTENT_DATA = 'inconsistent_data',
|
||||
OUTDATED_DATA = 'outdated_data',
|
||||
FORMATTING_ERROR = 'formatting_error',
|
||||
}
|
||||
|
||||
export enum IssueSeverity {
|
||||
LOW = 'low',
|
||||
MEDIUM = 'medium',
|
||||
HIGH = 'high',
|
||||
CRITICAL = 'critical',
|
||||
}
|
||||
|
||||
export enum AnalysisStatus {
|
||||
PENDING = 'pending',
|
||||
PROCESSING = 'processing',
|
||||
COMPLETED = 'completed',
|
||||
FAILED = 'failed',
|
||||
}
|
||||
|
||||
export enum PatternType {
|
||||
SEASONAL = 'seasonal',
|
||||
WEEKLY = 'weekly',
|
||||
DAILY = 'daily',
|
||||
WEATHER_CORRELATION = 'weather_correlation',
|
||||
PRODUCT_CORRELATION = 'product_correlation',
|
||||
PRICE_SENSITIVITY = 'price_sensitivity',
|
||||
}
|
||||
|
||||
export enum PatternImpact {
|
||||
LOW = 'low',
|
||||
MEDIUM = 'medium',
|
||||
HIGH = 'high',
|
||||
}
|
||||
|
||||
export enum RecommendationType {
|
||||
DATA_QUALITY = 'data_quality',
|
||||
PRICING = 'pricing',
|
||||
INVENTORY = 'inventory',
|
||||
MARKETING = 'marketing',
|
||||
OPERATIONS = 'operations',
|
||||
STAFFING = 'staffing',
|
||||
}
|
||||
|
||||
export enum RecommendationPriority {
|
||||
LOW = 'low',
|
||||
MEDIUM = 'medium',
|
||||
HIGH = 'high',
|
||||
URGENT = 'urgent',
|
||||
}
|
||||
|
||||
export enum ImplementationEffort {
|
||||
LOW = 'low',
|
||||
MEDIUM = 'medium',
|
||||
HIGH = 'high',
|
||||
}
|
||||
|
||||
export enum AnomalyType {
|
||||
SPIKE = 'spike',
|
||||
DROP = 'drop',
|
||||
MISSING_DATA = 'missing_data',
|
||||
UNUSUAL_PATTERN = 'unusual_pattern',
|
||||
OUTLIER = 'outlier',
|
||||
}
|
||||
|
||||
export enum AnommalySeverity {
|
||||
LOW = 'low',
|
||||
MEDIUM = 'medium',
|
||||
HIGH = 'high',
|
||||
CRITICAL = 'critical',
|
||||
}
|
||||
|
||||
export enum SalesSortField {
|
||||
DATE = 'date',
|
||||
PRODUCT_NAME = 'product_name',
|
||||
REVENUE = 'total_revenue',
|
||||
QUANTITY = 'quantity_sold',
|
||||
PROFIT = 'gross_profit',
|
||||
UNIT_PRICE = 'unit_price',
|
||||
CREATED_AT = 'created_at',
|
||||
}
|
||||
|
||||
export enum SortOrder {
|
||||
ASC = 'asc',
|
||||
DESC = 'desc',
|
||||
}
|
||||
|
||||
// Type guards
|
||||
export const isSalesRecord = (obj: any): obj is SalesRecord => {
|
||||
return obj && typeof obj.id === 'string' && typeof obj.product_name === 'string';
|
||||
};
|
||||
|
||||
export const isProductPerformance = (obj: any): obj is ProductPerformance => {
|
||||
return obj && typeof obj.product_name === 'string' && typeof obj.total_revenue === 'number';
|
||||
};
|
||||
|
||||
export const isSalesSummary = (obj: any): obj is SalesSummary => {
|
||||
return obj && typeof obj.total_revenue === 'number' && typeof obj.total_quantity === 'number';
|
||||
};
|
||||
@@ -1,43 +0,0 @@
|
||||
// Weather data types for the bakery application
|
||||
|
||||
export interface WeatherData {
|
||||
date: string;
|
||||
temperature: number;
|
||||
precipitation: number;
|
||||
humidity: number;
|
||||
wind_speed: number;
|
||||
pressure: number;
|
||||
description: string;
|
||||
source: 'aemet' | 'synthetic' | 'default';
|
||||
}
|
||||
|
||||
export interface HourlyForecast {
|
||||
forecast_datetime: string;
|
||||
generated_at: string;
|
||||
temperature: number;
|
||||
precipitation: number;
|
||||
humidity: number;
|
||||
wind_speed: number;
|
||||
description: string;
|
||||
source: string;
|
||||
hour: number;
|
||||
}
|
||||
|
||||
export interface WeatherForecast {
|
||||
forecast_date: string;
|
||||
generated_at: string;
|
||||
temperature: number;
|
||||
precipitation: number;
|
||||
humidity: number;
|
||||
wind_speed: number;
|
||||
description: string;
|
||||
source: string;
|
||||
}
|
||||
|
||||
export interface WeatherImpact {
|
||||
type: 'sales' | 'operations' | 'inventory' | 'staffing';
|
||||
severity: 'low' | 'medium' | 'high';
|
||||
description: string;
|
||||
recommendation: string;
|
||||
confidence: number;
|
||||
}
|
||||
Reference in New Issue
Block a user