Start integrating the onboarding flow with backend 6
This commit is contained in:
@@ -1,151 +0,0 @@
|
||||
/**
|
||||
* API Response Types - Matching actual backend implementation
|
||||
*/
|
||||
|
||||
// Standard API response structure (matching client.ts transformResponse)
|
||||
export interface ApiResponse<T = any> {
|
||||
data: T;
|
||||
success: boolean;
|
||||
message: string;
|
||||
detail?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
// FastAPI error response structure
|
||||
export interface ApiError {
|
||||
detail: string | ValidationError[];
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export interface ValidationError {
|
||||
loc: (string | number)[];
|
||||
msg: string;
|
||||
type: string;
|
||||
ctx?: Record<string, any>;
|
||||
}
|
||||
|
||||
// Pagination types (used by backend services)
|
||||
export interface PaginatedResponse<T> {
|
||||
items?: T[];
|
||||
records?: T[]; // Some endpoints use 'records'
|
||||
data?: T[]; // Some endpoints use 'data'
|
||||
total?: number;
|
||||
page?: number;
|
||||
size?: number;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
pages?: number;
|
||||
has_next?: boolean;
|
||||
has_prev?: boolean;
|
||||
}
|
||||
|
||||
// Query parameters for API requests
|
||||
export interface PaginationParams {
|
||||
page?: number;
|
||||
size?: number;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
}
|
||||
|
||||
export interface SortParams {
|
||||
sort_by?: string;
|
||||
order_by?: string;
|
||||
order?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
export interface FilterParams {
|
||||
search?: string;
|
||||
search_term?: string;
|
||||
q?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface QueryParams extends PaginationParams, SortParams, FilterParams {}
|
||||
|
||||
// Task/Job status (used in ML training and other async operations)
|
||||
export interface TaskStatus {
|
||||
id: string;
|
||||
task_id: string;
|
||||
status: TaskStatusType;
|
||||
progress?: number;
|
||||
message?: string;
|
||||
result?: any;
|
||||
error?: string;
|
||||
created_at: string;
|
||||
started_at?: string;
|
||||
completed_at?: string;
|
||||
}
|
||||
|
||||
export enum TaskStatusType {
|
||||
PENDING = 'pending',
|
||||
RUNNING = 'running',
|
||||
COMPLETED = 'completed',
|
||||
FAILED = 'failed',
|
||||
CANCELLED = 'cancelled'
|
||||
}
|
||||
|
||||
// Health check types (used by monitoring endpoints)
|
||||
export interface HealthCheckResponse {
|
||||
status: 'healthy' | 'unhealthy' | 'degraded';
|
||||
service: string;
|
||||
version: string;
|
||||
timestamp: string;
|
||||
dependencies?: ServiceHealth[];
|
||||
}
|
||||
|
||||
export interface ServiceHealth {
|
||||
name: string;
|
||||
status: 'healthy' | 'unhealthy' | 'degraded';
|
||||
response_time?: number;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
// File upload types
|
||||
export interface FileUploadResponse {
|
||||
file_id: string;
|
||||
filename: string;
|
||||
size: number;
|
||||
content_type: string;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
// Bulk operation response
|
||||
export interface BulkOperationResponse {
|
||||
total: number;
|
||||
processed: number;
|
||||
successful: number;
|
||||
failed: number;
|
||||
errors?: BulkOperationError[];
|
||||
}
|
||||
|
||||
export interface BulkOperationError {
|
||||
index: number;
|
||||
error: string;
|
||||
details?: any;
|
||||
}
|
||||
|
||||
// Common enums
|
||||
export enum SortOrder {
|
||||
ASC = 'asc',
|
||||
DESC = 'desc'
|
||||
}
|
||||
|
||||
// HTTP methods
|
||||
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
||||
|
||||
// Type guards
|
||||
export const isApiError = (obj: any): obj is ApiError => {
|
||||
return obj && typeof obj.detail === 'string';
|
||||
};
|
||||
|
||||
export const isPaginatedResponse = <T>(obj: any): obj is PaginatedResponse<T> => {
|
||||
return obj && (
|
||||
Array.isArray(obj.items) ||
|
||||
Array.isArray(obj.records) ||
|
||||
Array.isArray(obj.data)
|
||||
);
|
||||
};
|
||||
|
||||
export const isTaskStatus = (obj: any): obj is TaskStatus => {
|
||||
return obj && typeof obj.task_id === 'string' && typeof obj.status === 'string';
|
||||
};
|
||||
@@ -1,190 +0,0 @@
|
||||
/**
|
||||
* Authentication Types - Matching backend schemas exactly
|
||||
* Based on services/auth/app/schemas/auth.py
|
||||
*/
|
||||
|
||||
// ============================================================================
|
||||
// REQUEST TYPES (Frontend -> Backend)
|
||||
// ============================================================================
|
||||
|
||||
export interface UserRegistration {
|
||||
email: string;
|
||||
password: string;
|
||||
full_name: string;
|
||||
tenant_name?: string;
|
||||
role?: 'user' | 'admin' | 'manager';
|
||||
}
|
||||
|
||||
export interface UserLogin {
|
||||
email: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// RESPONSE TYPES (Backend -> Frontend)
|
||||
// ============================================================================
|
||||
|
||||
export interface UserData {
|
||||
id: string;
|
||||
email: string;
|
||||
full_name: string;
|
||||
is_active: boolean;
|
||||
is_verified: boolean;
|
||||
created_at: string;
|
||||
tenant_id?: string;
|
||||
role?: string;
|
||||
}
|
||||
|
||||
export interface TokenResponse {
|
||||
access_token: string;
|
||||
refresh_token?: string;
|
||||
token_type: string; // defaults to "bearer"
|
||||
expires_in: number; // seconds, defaults to 3600
|
||||
user?: UserData;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// JWT TOKEN CLAIMS (Internal)
|
||||
// ============================================================================
|
||||
|
||||
export interface TokenClaims {
|
||||
sub: string; // user ID
|
||||
email: string;
|
||||
full_name: string;
|
||||
user_id: string;
|
||||
is_verified: boolean;
|
||||
tenant_id?: string;
|
||||
role?: string;
|
||||
type: 'access' | 'refresh';
|
||||
iat: number; // issued at
|
||||
exp: number; // expires at
|
||||
iss: string; // issuer
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// FRONTEND STATE TYPES
|
||||
// ============================================================================
|
||||
|
||||
export interface AuthState {
|
||||
isAuthenticated: boolean;
|
||||
user: UserData | null;
|
||||
token: string | null;
|
||||
refreshToken: string | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// AUTH SERVICE SPECIFIC TYPES
|
||||
// ============================================================================
|
||||
|
||||
export interface TokenVerification {
|
||||
valid: boolean;
|
||||
user_id?: string;
|
||||
email?: string;
|
||||
exp?: number;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface UserResponse extends UserData {
|
||||
last_login?: string;
|
||||
phone?: string;
|
||||
language?: string;
|
||||
timezone?: string;
|
||||
}
|
||||
|
||||
export interface UserUpdate {
|
||||
full_name?: string;
|
||||
phone?: string;
|
||||
language?: string;
|
||||
timezone?: string;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// FORM DATA TYPES (Frontend UI)
|
||||
// ============================================================================
|
||||
|
||||
export interface LoginFormData {
|
||||
email: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
export interface RegisterFormData {
|
||||
email: string;
|
||||
password: string;
|
||||
confirmPassword: string;
|
||||
full_name: string;
|
||||
tenant_name?: string;
|
||||
}
|
||||
|
||||
export interface PasswordChangeFormData {
|
||||
current_password: string;
|
||||
new_password: string;
|
||||
confirm_password: string;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// UTILITY TYPES
|
||||
// ============================================================================
|
||||
|
||||
export interface AuthError {
|
||||
detail: string;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
// Keep User as alias for UserData for backward compatibility
|
||||
export interface User extends UserData {}
|
||||
|
||||
// ============================================================================
|
||||
// ENUMS
|
||||
// ============================================================================
|
||||
|
||||
export enum UserRole {
|
||||
USER = 'user',
|
||||
ADMIN = 'admin',
|
||||
MANAGER = 'manager'
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// TYPE GUARDS
|
||||
// ============================================================================
|
||||
|
||||
export const isUser = (obj: any): obj is UserData => {
|
||||
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';
|
||||
};
|
||||
|
||||
export const isAuthError = (obj: any): obj is AuthError => {
|
||||
return obj && typeof obj.detail === 'string';
|
||||
};
|
||||
|
||||
// Onboarding status types (moved from onboarding)
|
||||
export interface OnboardingStatus {
|
||||
completed: boolean;
|
||||
steps_completed: string[];
|
||||
}
|
||||
|
||||
export interface OnboardingProgressRequest {
|
||||
metadata?: any;
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
// 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;
|
||||
}
|
||||
@@ -1,258 +0,0 @@
|
||||
/**
|
||||
* External Data Service Types
|
||||
* Weather, Traffic, and Events data
|
||||
*/
|
||||
|
||||
// ============================================================================
|
||||
// WEATHER TYPES
|
||||
// ============================================================================
|
||||
|
||||
export interface WeatherData {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
location_id: string;
|
||||
date: string;
|
||||
temperature_avg: number;
|
||||
temperature_min: number;
|
||||
temperature_max: number;
|
||||
humidity: number;
|
||||
precipitation: number;
|
||||
wind_speed: number;
|
||||
condition: string;
|
||||
description: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface WeatherCondition {
|
||||
value: string;
|
||||
label: string;
|
||||
impact: 'positive' | 'negative' | 'neutral';
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// TRAFFIC TYPES
|
||||
// ============================================================================
|
||||
|
||||
export interface TrafficData {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
location_id: string;
|
||||
date: string;
|
||||
hour: number;
|
||||
traffic_level: number;
|
||||
congestion_index: number;
|
||||
average_speed: number;
|
||||
incident_count: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface TrafficPattern {
|
||||
period: string;
|
||||
average_traffic_level: number;
|
||||
peak_hours: number[];
|
||||
congestion_patterns: Record<string, number>;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// EVENTS TYPES
|
||||
// ============================================================================
|
||||
|
||||
export interface EventData {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
location_id: string;
|
||||
event_name: string;
|
||||
event_type: string;
|
||||
start_date: string;
|
||||
end_date: string;
|
||||
expected_attendance?: number;
|
||||
impact_radius_km?: number;
|
||||
impact_score: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface EventType {
|
||||
value: string;
|
||||
label: string;
|
||||
typical_impact: 'positive' | 'negative' | 'neutral';
|
||||
}
|
||||
|
||||
export interface CustomEventCreate {
|
||||
location_id: string;
|
||||
event_name: string;
|
||||
event_type: string;
|
||||
start_date: string;
|
||||
end_date: string;
|
||||
expected_attendance?: number;
|
||||
impact_radius_km?: number;
|
||||
impact_score?: number;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// LOCATION TYPES
|
||||
// ============================================================================
|
||||
|
||||
export interface LocationConfig {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
name: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
address: string;
|
||||
city: string;
|
||||
country: string;
|
||||
is_primary: boolean;
|
||||
data_sources: {
|
||||
weather_enabled: boolean;
|
||||
traffic_enabled: boolean;
|
||||
events_enabled: boolean;
|
||||
};
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface LocationCreate {
|
||||
name: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
address: string;
|
||||
city: string;
|
||||
country?: string;
|
||||
is_primary?: boolean;
|
||||
data_sources?: LocationConfig['data_sources'];
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// ANALYTICS TYPES
|
||||
// ============================================================================
|
||||
|
||||
export interface ExternalFactorsImpact {
|
||||
weather_impact: {
|
||||
temperature_correlation: number;
|
||||
precipitation_impact: number;
|
||||
most_favorable_conditions: string;
|
||||
};
|
||||
traffic_impact: {
|
||||
congestion_correlation: number;
|
||||
peak_traffic_effect: number;
|
||||
optimal_traffic_levels: number[];
|
||||
};
|
||||
events_impact: {
|
||||
positive_events: EventData[];
|
||||
negative_events: EventData[];
|
||||
average_event_boost: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface DataQualityReport {
|
||||
overall_score: number;
|
||||
data_sources: Array<{
|
||||
source: 'weather' | 'traffic' | 'events';
|
||||
completeness: number;
|
||||
freshness_hours: number;
|
||||
reliability_score: number;
|
||||
last_update: string;
|
||||
}>;
|
||||
recommendations: Array<{
|
||||
priority: 'high' | 'medium' | 'low';
|
||||
message: string;
|
||||
action: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// CONFIGURATION TYPES
|
||||
// ============================================================================
|
||||
|
||||
export interface DataSettings {
|
||||
auto_refresh_enabled: boolean;
|
||||
refresh_intervals: {
|
||||
weather_minutes: number;
|
||||
traffic_minutes: number;
|
||||
events_hours: number;
|
||||
};
|
||||
data_retention_days: {
|
||||
weather: number;
|
||||
traffic: number;
|
||||
events: number;
|
||||
};
|
||||
external_apis: {
|
||||
weather_provider: string;
|
||||
traffic_provider: string;
|
||||
events_provider: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface DataSettingsUpdate {
|
||||
auto_refresh_enabled?: boolean;
|
||||
refresh_intervals?: {
|
||||
weather_minutes?: number;
|
||||
traffic_minutes?: number;
|
||||
events_hours?: number;
|
||||
};
|
||||
data_retention_days?: {
|
||||
weather?: number;
|
||||
traffic?: number;
|
||||
events?: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface RefreshInterval {
|
||||
value: number;
|
||||
label: string;
|
||||
suitable_for: string[];
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// QUERY PARAMETER TYPES
|
||||
// ============================================================================
|
||||
|
||||
export interface WeatherDataParams {
|
||||
location_id?: string;
|
||||
start_date?: string;
|
||||
end_date?: string;
|
||||
page?: number;
|
||||
size?: number;
|
||||
}
|
||||
|
||||
export interface TrafficDataParams {
|
||||
location_id?: string;
|
||||
start_date?: string;
|
||||
end_date?: string;
|
||||
hour?: number;
|
||||
page?: number;
|
||||
size?: number;
|
||||
}
|
||||
|
||||
export interface TrafficPatternsParams {
|
||||
days_back?: number;
|
||||
granularity?: 'hourly' | 'daily';
|
||||
}
|
||||
|
||||
export interface EventsParams {
|
||||
location_id?: string;
|
||||
start_date?: string;
|
||||
end_date?: string;
|
||||
event_type?: string;
|
||||
page?: number;
|
||||
size?: number;
|
||||
}
|
||||
|
||||
export interface ExternalFactorsParams {
|
||||
location_id?: string;
|
||||
start_date?: string;
|
||||
end_date?: string;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// RESPONSE TYPES
|
||||
// ============================================================================
|
||||
|
||||
export interface RefreshDataResponse {
|
||||
message: string;
|
||||
updated_records: number;
|
||||
}
|
||||
|
||||
export interface DeleteResponse {
|
||||
message: string;
|
||||
}
|
||||
@@ -1,563 +0,0 @@
|
||||
// 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
58
frontend/src/types/global.d.ts
vendored
@@ -1,58 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
}
|
||||
@@ -1,435 +0,0 @@
|
||||
// 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';
|
||||
|
||||
// Suppliers types
|
||||
export type {
|
||||
SupplierCreate,
|
||||
SupplierUpdate,
|
||||
SupplierResponse,
|
||||
SupplierSummary,
|
||||
SupplierSearchParams,
|
||||
SupplierApproval,
|
||||
SupplierStatistics,
|
||||
PurchaseOrderItemCreate,
|
||||
PurchaseOrderItemResponse,
|
||||
PurchaseOrderCreate,
|
||||
PurchaseOrderUpdate,
|
||||
PurchaseOrderResponse,
|
||||
DeliveryItemCreate,
|
||||
DeliveryItemResponse,
|
||||
DeliveryCreate,
|
||||
DeliveryResponse,
|
||||
DeliveryReceiptConfirmation,
|
||||
PurchaseOrderStatus,
|
||||
DeliveryStatus,
|
||||
Supplier
|
||||
} from './suppliers.types';
|
||||
|
||||
// Data types
|
||||
export type {
|
||||
WeatherData,
|
||||
WeatherDataParams,
|
||||
WeatherCondition,
|
||||
TrafficData,
|
||||
TrafficDataParams,
|
||||
TrafficPattern,
|
||||
TrafficPatternsParams,
|
||||
EventData,
|
||||
EventsParams,
|
||||
EventType,
|
||||
CustomEventCreate,
|
||||
LocationConfig,
|
||||
LocationCreate,
|
||||
ExternalFactorsImpact,
|
||||
ExternalFactorsParams,
|
||||
DataQualityReport,
|
||||
DataSettings,
|
||||
DataSettingsUpdate,
|
||||
RefreshDataResponse,
|
||||
DeleteResponse,
|
||||
RefreshInterval
|
||||
} from './data.types';
|
||||
|
||||
// API and common types
|
||||
export type {
|
||||
ApiResponse,
|
||||
ApiError,
|
||||
ValidationError,
|
||||
PaginatedResponse,
|
||||
PaginationParams,
|
||||
SortParams,
|
||||
FilterParams,
|
||||
QueryParams,
|
||||
TaskStatus,
|
||||
TaskStatusType,
|
||||
HealthCheckResponse,
|
||||
ServiceHealth,
|
||||
FileUploadResponse,
|
||||
BulkOperationResponse,
|
||||
SortOrder,
|
||||
HttpMethod
|
||||
} from './api.types';
|
||||
|
||||
// Re-export commonly used types for convenience
|
||||
export type {
|
||||
User,
|
||||
UserData,
|
||||
UserLogin,
|
||||
UserRegistration,
|
||||
TokenResponse,
|
||||
AuthState,
|
||||
AuthError,
|
||||
UserRole
|
||||
} 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 {
|
||||
SupplierResponse,
|
||||
SupplierSummary,
|
||||
SupplierCreate,
|
||||
PurchaseOrderResponse,
|
||||
DeliveryResponse,
|
||||
PurchaseOrderStatus,
|
||||
DeliveryStatus,
|
||||
} from './suppliers.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;
|
||||
};
|
||||
}
|
||||
@@ -1,496 +0,0 @@
|
||||
// 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;
|
||||
};
|
||||
|
||||
// Product classification and suggestion types (moved from onboarding)
|
||||
export interface ProductSuggestion {
|
||||
suggestion_id: string;
|
||||
original_name: string;
|
||||
suggested_name: string;
|
||||
product_type: 'ingredient' | 'finished_product';
|
||||
category: string;
|
||||
unit_of_measure: string;
|
||||
confidence_score: number;
|
||||
estimated_shelf_life_days: number;
|
||||
requires_refrigeration: boolean;
|
||||
requires_freezing: boolean;
|
||||
is_seasonal: boolean;
|
||||
suggested_supplier?: string;
|
||||
notes: string;
|
||||
sales_data: {
|
||||
total_quantity: number;
|
||||
average_daily_sales: number;
|
||||
peak_day: string;
|
||||
frequency: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface BusinessModelAnalysis {
|
||||
model: 'production' | 'retail' | 'hybrid';
|
||||
confidence: number;
|
||||
ingredient_count: number;
|
||||
finished_product_count: number;
|
||||
ingredient_ratio: number;
|
||||
recommendations: string[];
|
||||
}
|
||||
|
||||
export interface ProductSuggestionsResponse {
|
||||
suggestions: ProductSuggestion[];
|
||||
business_model_analysis: BusinessModelAnalysis;
|
||||
total_products: number;
|
||||
high_confidence_count: number;
|
||||
low_confidence_count: number;
|
||||
processing_time_seconds: number;
|
||||
}
|
||||
|
||||
export interface InventoryCreationResponse {
|
||||
created_items: any[];
|
||||
failed_items: any[];
|
||||
total_approved: number;
|
||||
success_rate: number;
|
||||
inventory_mapping?: { [productName: string]: string };
|
||||
}
|
||||
|
||||
export interface BatchClassificationRequest {
|
||||
products: Array<{
|
||||
product_name: string;
|
||||
sales_data?: any;
|
||||
}>;
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
// Orders service types
|
||||
|
||||
export enum OrderStatus {
|
||||
PENDING = 'pending',
|
||||
CONFIRMED = 'confirmed',
|
||||
IN_PREPARATION = 'in_preparation',
|
||||
READY = 'ready',
|
||||
DELIVERED = 'delivered',
|
||||
CANCELLED = 'cancelled',
|
||||
}
|
||||
|
||||
export enum OrderType {
|
||||
DINE_IN = 'dine_in',
|
||||
TAKEAWAY = 'takeaway',
|
||||
DELIVERY = 'delivery',
|
||||
CATERING = 'catering',
|
||||
}
|
||||
|
||||
export interface OrderItem {
|
||||
product_id?: string;
|
||||
product_name: string;
|
||||
quantity: number;
|
||||
unit_price: number;
|
||||
total_price: number;
|
||||
notes?: string;
|
||||
customizations?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface OrderCreate {
|
||||
customer_id?: string;
|
||||
customer_name: string;
|
||||
customer_email?: string;
|
||||
customer_phone?: string;
|
||||
order_type: OrderType;
|
||||
items: OrderItem[];
|
||||
special_instructions?: string;
|
||||
delivery_address?: string;
|
||||
delivery_date?: string;
|
||||
delivery_time?: string;
|
||||
payment_method?: string;
|
||||
}
|
||||
|
||||
export interface OrderUpdate {
|
||||
status?: OrderStatus;
|
||||
customer_name?: string;
|
||||
customer_email?: string;
|
||||
customer_phone?: string;
|
||||
special_instructions?: string;
|
||||
delivery_address?: string;
|
||||
delivery_date?: string;
|
||||
delivery_time?: string;
|
||||
estimated_completion_time?: string;
|
||||
actual_completion_time?: string;
|
||||
}
|
||||
|
||||
export interface OrderResponse {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
order_number: string;
|
||||
customer_id?: string;
|
||||
customer_name: string;
|
||||
customer_email?: string;
|
||||
customer_phone?: string;
|
||||
order_type: OrderType;
|
||||
status: OrderStatus;
|
||||
items: OrderItem[];
|
||||
subtotal: number;
|
||||
tax_amount: number;
|
||||
discount_amount: number;
|
||||
total_amount: number;
|
||||
special_instructions?: string;
|
||||
delivery_address?: string;
|
||||
delivery_date?: string;
|
||||
delivery_time?: string;
|
||||
estimated_completion_time?: string;
|
||||
actual_completion_time?: string;
|
||||
payment_method?: string;
|
||||
payment_status?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
created_by?: string;
|
||||
}
|
||||
|
||||
export interface Customer {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
name: string;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
address?: string;
|
||||
preferences?: Record<string, any>;
|
||||
total_orders: number;
|
||||
total_spent: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface OrderAnalytics {
|
||||
total_orders: number;
|
||||
total_revenue: number;
|
||||
average_order_value: number;
|
||||
order_completion_rate: number;
|
||||
delivery_success_rate: number;
|
||||
customer_satisfaction_score?: number;
|
||||
popular_products: Array<{
|
||||
product_name: string;
|
||||
quantity_sold: number;
|
||||
revenue: number;
|
||||
}>;
|
||||
order_trends: Array<{
|
||||
date: string;
|
||||
orders: number;
|
||||
revenue: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
// Form data interfaces
|
||||
export interface OrderFormData extends OrderCreate {}
|
||||
|
||||
export interface CustomerFormData {
|
||||
name: string;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
address?: string;
|
||||
preferences?: Record<string, any>;
|
||||
}
|
||||
|
||||
// Filter interfaces
|
||||
export interface OrderFilters {
|
||||
page?: number;
|
||||
size?: number;
|
||||
status?: OrderStatus;
|
||||
order_type?: OrderType;
|
||||
customer_id?: string;
|
||||
start_date?: string;
|
||||
end_date?: string;
|
||||
}
|
||||
|
||||
export interface CustomerFilters {
|
||||
page?: number;
|
||||
size?: number;
|
||||
search?: string;
|
||||
}
|
||||
|
||||
// Analytics interfaces
|
||||
export interface OrderTrendsParams {
|
||||
start_date?: string;
|
||||
end_date?: string;
|
||||
granularity?: 'hourly' | 'daily' | 'weekly' | 'monthly';
|
||||
}
|
||||
|
||||
export interface OrderTrendData {
|
||||
period: string;
|
||||
orders: number;
|
||||
revenue: number;
|
||||
avg_order_value: number;
|
||||
}
|
||||
|
||||
// Type guards
|
||||
export const isOrderResponse = (obj: any): obj is OrderResponse => {
|
||||
return obj && typeof obj.id === 'string' && typeof obj.order_number === 'string';
|
||||
};
|
||||
|
||||
export const isCustomer = (obj: any): obj is Customer => {
|
||||
return obj && typeof obj.id === 'string' && typeof obj.name === 'string';
|
||||
};
|
||||
@@ -1,543 +0,0 @@
|
||||
// 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);
|
||||
};
|
||||
@@ -1,622 +0,0 @@
|
||||
// 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';
|
||||
};
|
||||
|
||||
// Business model and onboarding guide types (moved from onboarding)
|
||||
export interface BusinessModelGuide {
|
||||
title: string;
|
||||
description: string;
|
||||
next_steps: string[];
|
||||
recommended_features: string[];
|
||||
sample_workflows: string[];
|
||||
}
|
||||
|
||||
export enum BusinessModelType {
|
||||
PRODUCTION = 'production',
|
||||
RETAIL = 'retail',
|
||||
HYBRID = 'hybrid',
|
||||
}
|
||||
|
||||
// Utility function for downloading templates (moved from onboarding)
|
||||
export interface TemplateData {
|
||||
template: string | any;
|
||||
}
|
||||
@@ -1,379 +0,0 @@
|
||||
/**
|
||||
* Type definitions for Suppliers Service API
|
||||
* Based on backend schemas from services/suppliers/app/schemas/suppliers.py
|
||||
*/
|
||||
|
||||
// ============================================================================
|
||||
// ENUMS
|
||||
// ============================================================================
|
||||
|
||||
export enum PurchaseOrderStatus {
|
||||
DRAFT = 'draft',
|
||||
PENDING = 'pending',
|
||||
APPROVED = 'approved',
|
||||
SENT = 'sent',
|
||||
PARTIALLY_RECEIVED = 'partially_received',
|
||||
RECEIVED = 'received',
|
||||
CANCELLED = 'cancelled',
|
||||
}
|
||||
|
||||
export enum DeliveryStatus {
|
||||
SCHEDULED = 'scheduled',
|
||||
IN_TRANSIT = 'in_transit',
|
||||
DELIVERED = 'delivered',
|
||||
FAILED = 'failed',
|
||||
RETURNED = 'returned',
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// SUPPLIER TYPES
|
||||
// ============================================================================
|
||||
|
||||
export interface SupplierCreate {
|
||||
name: string;
|
||||
supplier_code?: string;
|
||||
tax_id?: string;
|
||||
registration_number?: string;
|
||||
supplier_type: string;
|
||||
contact_person?: string;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
mobile?: string;
|
||||
website?: string;
|
||||
address_line1?: string;
|
||||
address_line2?: string;
|
||||
city?: string;
|
||||
state_province?: string;
|
||||
postal_code?: string;
|
||||
country?: string;
|
||||
payment_terms?: string;
|
||||
credit_limit?: number;
|
||||
currency?: string;
|
||||
standard_lead_time?: number;
|
||||
minimum_order_amount?: number;
|
||||
delivery_area?: string;
|
||||
notes?: string;
|
||||
certifications?: any;
|
||||
business_hours?: any;
|
||||
specializations?: any;
|
||||
}
|
||||
|
||||
export interface SupplierUpdate {
|
||||
name?: string;
|
||||
supplier_code?: string;
|
||||
tax_id?: string;
|
||||
registration_number?: string;
|
||||
supplier_type?: string;
|
||||
status?: string;
|
||||
contact_person?: string;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
mobile?: string;
|
||||
website?: string;
|
||||
address_line1?: string;
|
||||
address_line2?: string;
|
||||
city?: string;
|
||||
state_province?: string;
|
||||
postal_code?: string;
|
||||
country?: string;
|
||||
payment_terms?: string;
|
||||
credit_limit?: number;
|
||||
currency?: string;
|
||||
standard_lead_time?: number;
|
||||
minimum_order_amount?: number;
|
||||
delivery_area?: string;
|
||||
notes?: string;
|
||||
certifications?: any;
|
||||
business_hours?: any;
|
||||
specializations?: any;
|
||||
}
|
||||
|
||||
export interface SupplierResponse {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
name: string;
|
||||
supplier_code?: string;
|
||||
tax_id?: string;
|
||||
registration_number?: string;
|
||||
supplier_type: string;
|
||||
status: string;
|
||||
contact_person?: string;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
mobile?: string;
|
||||
website?: string;
|
||||
address_line1?: string;
|
||||
address_line2?: string;
|
||||
city?: string;
|
||||
state_province?: string;
|
||||
postal_code?: string;
|
||||
country?: string;
|
||||
payment_terms: string;
|
||||
credit_limit?: number;
|
||||
currency: string;
|
||||
standard_lead_time: number;
|
||||
minimum_order_amount?: number;
|
||||
delivery_area?: string;
|
||||
quality_rating?: number;
|
||||
delivery_rating?: number;
|
||||
total_orders: number;
|
||||
total_amount: number;
|
||||
approved_by?: string;
|
||||
approved_at?: string;
|
||||
rejection_reason?: string;
|
||||
notes?: string;
|
||||
certifications?: any;
|
||||
business_hours?: any;
|
||||
specializations?: any;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
created_by: string;
|
||||
updated_by: string;
|
||||
}
|
||||
|
||||
export interface SupplierSummary {
|
||||
id: string;
|
||||
name: string;
|
||||
supplier_code?: string;
|
||||
supplier_type: string;
|
||||
status: string;
|
||||
contact_person?: string;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
city?: string;
|
||||
country?: string;
|
||||
quality_rating?: number;
|
||||
delivery_rating?: number;
|
||||
total_orders: number;
|
||||
total_amount: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface SupplierSearchParams {
|
||||
search_term?: string;
|
||||
supplier_type?: string;
|
||||
status?: string;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
}
|
||||
|
||||
export interface SupplierApproval {
|
||||
action: 'approve' | 'reject';
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
export interface SupplierStatistics {
|
||||
total_suppliers: number;
|
||||
active_suppliers: number;
|
||||
pending_suppliers: number;
|
||||
avg_quality_rating: number;
|
||||
avg_delivery_rating: number;
|
||||
total_spend: number;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// PURCHASE ORDER TYPES
|
||||
// ============================================================================
|
||||
|
||||
export interface PurchaseOrderItemCreate {
|
||||
inventory_product_id: string;
|
||||
product_code?: string;
|
||||
ordered_quantity: number;
|
||||
unit_of_measure: string;
|
||||
unit_price: number;
|
||||
quality_requirements?: string;
|
||||
item_notes?: string;
|
||||
}
|
||||
|
||||
export interface PurchaseOrderItemResponse {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
purchase_order_id: string;
|
||||
price_list_item_id?: string;
|
||||
inventory_product_id: string;
|
||||
product_code?: string;
|
||||
ordered_quantity: number;
|
||||
unit_of_measure: string;
|
||||
unit_price: number;
|
||||
line_total: number;
|
||||
received_quantity: number;
|
||||
remaining_quantity: number;
|
||||
quality_requirements?: string;
|
||||
item_notes?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface PurchaseOrderCreate {
|
||||
supplier_id: string;
|
||||
reference_number?: string;
|
||||
priority?: string;
|
||||
required_delivery_date?: string;
|
||||
delivery_address?: string;
|
||||
delivery_instructions?: string;
|
||||
delivery_contact?: string;
|
||||
delivery_phone?: string;
|
||||
tax_amount?: number;
|
||||
shipping_cost?: number;
|
||||
discount_amount?: number;
|
||||
notes?: string;
|
||||
internal_notes?: string;
|
||||
terms_and_conditions?: string;
|
||||
items: PurchaseOrderItemCreate[];
|
||||
}
|
||||
|
||||
export interface PurchaseOrderUpdate {
|
||||
reference_number?: string;
|
||||
priority?: string;
|
||||
required_delivery_date?: string;
|
||||
estimated_delivery_date?: string;
|
||||
delivery_address?: string;
|
||||
delivery_instructions?: string;
|
||||
delivery_contact?: string;
|
||||
delivery_phone?: string;
|
||||
tax_amount?: number;
|
||||
shipping_cost?: number;
|
||||
discount_amount?: number;
|
||||
notes?: string;
|
||||
internal_notes?: string;
|
||||
terms_and_conditions?: string;
|
||||
supplier_reference?: string;
|
||||
}
|
||||
|
||||
export interface PurchaseOrderResponse {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
supplier_id: string;
|
||||
po_number: string;
|
||||
reference_number?: string;
|
||||
status: PurchaseOrderStatus;
|
||||
priority: string;
|
||||
order_date: string;
|
||||
required_delivery_date?: string;
|
||||
estimated_delivery_date?: string;
|
||||
subtotal: number;
|
||||
tax_amount: number;
|
||||
shipping_cost: number;
|
||||
discount_amount: number;
|
||||
total_amount: number;
|
||||
currency: string;
|
||||
delivery_address?: string;
|
||||
delivery_instructions?: string;
|
||||
delivery_contact?: string;
|
||||
delivery_phone?: string;
|
||||
requires_approval: boolean;
|
||||
approved_by?: string;
|
||||
approved_at?: string;
|
||||
rejection_reason?: string;
|
||||
sent_to_supplier_at?: string;
|
||||
supplier_confirmation_date?: string;
|
||||
supplier_reference?: string;
|
||||
notes?: string;
|
||||
internal_notes?: string;
|
||||
terms_and_conditions?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
created_by: string;
|
||||
updated_by: string;
|
||||
supplier?: SupplierSummary;
|
||||
items?: PurchaseOrderItemResponse[];
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// DELIVERY TYPES
|
||||
// ============================================================================
|
||||
|
||||
export interface DeliveryItemCreate {
|
||||
purchase_order_item_id: string;
|
||||
inventory_product_id: string;
|
||||
ordered_quantity: number;
|
||||
delivered_quantity: number;
|
||||
accepted_quantity: number;
|
||||
rejected_quantity?: number;
|
||||
batch_lot_number?: string;
|
||||
expiry_date?: string;
|
||||
quality_grade?: string;
|
||||
quality_issues?: string;
|
||||
rejection_reason?: string;
|
||||
item_notes?: string;
|
||||
}
|
||||
|
||||
export interface DeliveryItemResponse {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
delivery_id: string;
|
||||
purchase_order_item_id: string;
|
||||
inventory_product_id: string;
|
||||
ordered_quantity: number;
|
||||
delivered_quantity: number;
|
||||
accepted_quantity: number;
|
||||
rejected_quantity: number;
|
||||
batch_lot_number?: string;
|
||||
expiry_date?: string;
|
||||
quality_grade?: string;
|
||||
quality_issues?: string;
|
||||
rejection_reason?: string;
|
||||
item_notes?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface DeliveryCreate {
|
||||
purchase_order_id: string;
|
||||
supplier_id: string;
|
||||
supplier_delivery_note?: string;
|
||||
scheduled_date?: string;
|
||||
estimated_arrival?: string;
|
||||
delivery_address?: string;
|
||||
delivery_contact?: string;
|
||||
delivery_phone?: string;
|
||||
carrier_name?: string;
|
||||
tracking_number?: string;
|
||||
notes?: string;
|
||||
items: DeliveryItemCreate[];
|
||||
}
|
||||
|
||||
export interface DeliveryResponse {
|
||||
id: string;
|
||||
tenant_id: string;
|
||||
purchase_order_id: string;
|
||||
supplier_id: string;
|
||||
delivery_number: string;
|
||||
supplier_delivery_note?: string;
|
||||
status: DeliveryStatus;
|
||||
scheduled_date?: string;
|
||||
estimated_arrival?: string;
|
||||
actual_arrival?: string;
|
||||
completed_at?: string;
|
||||
delivery_address?: string;
|
||||
delivery_contact?: string;
|
||||
delivery_phone?: string;
|
||||
carrier_name?: string;
|
||||
tracking_number?: string;
|
||||
inspection_passed?: boolean;
|
||||
inspection_notes?: string;
|
||||
quality_issues?: any;
|
||||
received_by?: string;
|
||||
received_at?: string;
|
||||
notes?: string;
|
||||
photos?: any;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
created_by: string;
|
||||
supplier?: SupplierSummary;
|
||||
items?: DeliveryItemResponse[];
|
||||
}
|
||||
|
||||
export interface DeliveryReceiptConfirmation {
|
||||
inspection_passed?: boolean;
|
||||
inspection_notes?: string;
|
||||
quality_issues?: any;
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// UTILITY TYPES
|
||||
// ============================================================================
|
||||
|
||||
// Keep legacy Supplier interface for backward compatibility
|
||||
export interface Supplier extends SupplierResponse {}
|
||||
@@ -1,35 +0,0 @@
|
||||
// ML Training service types
|
||||
|
||||
export interface TrainingJob {
|
||||
id: string;
|
||||
model_id: string;
|
||||
status: 'pending' | 'running' | 'completed' | 'failed';
|
||||
progress: number;
|
||||
started_at?: string;
|
||||
completed_at?: string;
|
||||
error_message?: string;
|
||||
parameters: Record<string, any>;
|
||||
metrics?: Record<string, number>;
|
||||
}
|
||||
|
||||
export interface TrainingJobCreate {
|
||||
model_id: string;
|
||||
parameters?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface TrainingJobUpdate {
|
||||
parameters?: Record<string, any>;
|
||||
}
|
||||
|
||||
export enum TrainingJobStatus {
|
||||
PENDING = 'pending',
|
||||
RUNNING = 'running',
|
||||
COMPLETED = 'completed',
|
||||
FAILED = 'failed'
|
||||
}
|
||||
|
||||
// Form data interfaces
|
||||
export interface TrainingJobFormData {
|
||||
model_id: string;
|
||||
parameters: Record<string, any>;
|
||||
}
|
||||
Reference in New Issue
Block a user