TypeScript Types Reference
Type definitions for the ReUp frontend.
Core Types
User
interface User {
id: string;
email: string;
name: string;
role: UserRole;
entity_id: string;
permissions: Permission[];
mfa_enabled: boolean;
created_at: string;
updated_at: string;
}
type UserRole = 'owner' | 'admin' | 'manager' | 'viewer';
type Permission =
| 'read:inventory'
| 'write:inventory'
| 'read:orders'
| 'write:orders'
| 'read:products'
| 'write:products'
| 'admin:settings';
Entity
interface Entity {
id: string;
type: EntityType;
name: string;
legal_name: string;
license_number: string;
license_type: string;
license_expiry: string;
address: Address;
contact: Contact;
settings: EntitySettings;
locations: Location[];
created_at: string;
}
type EntityType = 'retailer' | 'wholesaler' | 'cultivator';
interface Address {
street: string;
city: string;
state: string;
zip: string;
country?: string;
}
interface Contact {
email: string;
phone: string;
}
interface EntitySettings {
auto_sync: boolean;
sync_frequency: 'realtime' | 'hourly' | 'daily';
low_stock_threshold: number;
}
Inventory Types
InventoryItem
interface InventoryItem {
id: string;
product_id: string;
product_name: string;
sku: string;
location_id: string;
room_type: RoomType;
quantity: number;
reserved_quantity: number;
available_quantity: number;
unit_cost: number;
unit_price: number;
last_sync: string;
}
type RoomType = 'sales_floor' | 'vault' | 'quarantine' | 'secret_menu';
interface InventoryAdjustment {
id: string;
inventory_id: string;
quantity_change: number;
reason_code: AdjustmentReason;
notes?: string;
created_by: string;
created_at: string;
}
type AdjustmentReason =
| 'SALE'
| 'RETURN'
| 'ADJUSTMENT'
| 'DAMAGE'
| 'THEFT'
| 'TRANSFER'
| 'AUDIT';
Product Types
Product
interface Product {
id: string;
name: string;
brand: string;
category: ProductCategory;
subcategory?: string;
description: string;
thc_percentage?: number;
cbd_percentage?: number;
variants: ProductVariant[];
images: string[];
test_results?: TestResults;
active: boolean;
created_at: string;
updated_at: string;
}
type ProductCategory =
| 'flower'
| 'concentrates'
| 'edibles'
| 'vapes'
| 'topicals'
| 'accessories';
interface ProductVariant {
id: string;
name: string;
sku: string;
weight?: number;
weight_unit?: 'g' | 'oz' | 'mg';
price: number;
wholesale_price: number;
}
interface TestResults {
lab: string;
date: string;
batch_id: string;
coa_url?: string;
}
Order Types
Order
interface Order {
id: string;
order_number: string;
status: OrderStatus;
wholesaler: OrderParty;
retailer: OrderParty;
items: OrderItem[];
subtotal: number;
tax: number;
total: number;
delivery_date: string;
delivery_window?: 'AM' | 'PM';
notes?: string;
created_at: string;
updated_at: string;
}
type OrderStatus =
| 'pending'
| 'accepted'
| 'preparing'
| 'shipped'
| 'delivered'
| 'cancelled';
interface OrderParty {
id: string;
name: string;
}
interface OrderItem {
id: string;
product_id: string;
product_name: string;
variant_id?: string;
variant_name?: string;
quantity: number;
unit_price: number;
total: number;
}
API Response Types
ApiResponse
interface ApiResponse<T> {
data: T;
message?: string;
}
interface PaginatedResponse<T> {
data: T[];
pagination: Pagination;
}
interface Pagination {
page: number;
limit: number;
total: number;
total_pages: number;
}
interface ApiError {
error: {
code: string;
message: string;
details?: Record<string, unknown>;
};
}
Utility Types
// Make all properties optional recursively
type DeepPartial<T> = {
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
};
// Extract the data type from an API response
type ExtractData<T> = T extends ApiResponse<infer U> ? U : never;
// Nullable type helper
type Nullable<T> = T | null;