-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
176 lines (146 loc) · 4.26 KB
/
types.ts
File metadata and controls
176 lines (146 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
export type ColumnType = 'text' | 'number' | 'select' | 'multiSelect' | 'date' | 'checkbox' | 'switch' | 'url' | 'rating' | 'image' | 'file' | 'person' | 'phone' | 'email' | 'location' | 'relation';
// UserRole is now a string ID, but we keep constants for system roles
export type UserRole = string;
export interface RoleCapabilities {
canManageSheets: boolean; // Create/Delete/Rename sheets/folders
canEditSchema: boolean; // Add/Edit columns
canEditData: boolean; // Add/Edit rows
}
export interface RoleDef {
id: string;
name: string;
description: string;
isSystem: boolean; // If true, cannot be deleted/renamed
capabilities: RoleCapabilities;
}
export interface RolePermissionConfig {
sheetVisibility: Record<string, boolean>; // sheetId -> visible?
columnVisibility: Record<string, boolean>; // colId -> visible?
columnReadonly: Record<string, boolean>; // colId -> readonly?
}
export type AppPermissions = Record<string, RolePermissionConfig>;
export interface SelectOption {
id: string;
label: string;
color: string; // tailwind color class e.g. 'bg-red-100 text-red-700'
}
export interface RelationConfig {
targetSheetId: string;
targetColumnId?: string; // The "linked" column in the other sheet (for bidirectional)
bidirectional?: boolean; // Whether to create/maintain a back-link in the target sheet
}
export interface Column {
id: string;
label: string;
type: ColumnType;
width?: number;
options?: SelectOption[]; // For 'select' type
relationConfig?: RelationConfig; // For 'relation' type
defaultValue?: any; // Configured default value for new rows
}
export interface RowData {
id: string;
[key: string]: any; // flexible type for boolean, number, string
}
export interface Sheet {
id: string;
name: string;
type: 'sheet' | 'folder' | 'document'; // Updated to include 'document'
parentId?: string; // Supports nesting
isOpen?: boolean; // For folder expansion
content?: string; // For documents
// Spreadsheet specific
columns: Column[];
rows: RowData[];
views: View[];
activeViewId: string;
selectedRowIds: Set<string>;
}
// --- Analysis & AI ---
export interface AnalysisResult {
summary: string;
keyTrends: string[];
suggestedChartType: 'bar' | 'line' | 'pie' | 'area';
}
export enum AIStatus {
IDLE = 'IDLE',
LOADING = 'LOADING',
SUCCESS = 'SUCCESS',
ERROR = 'ERROR',
}
// Toolbar Types
export type RowHeight = 'small' | 'medium' | 'large' | 'extra-large';
export type FilterOperator =
| 'contains' | 'equals' | 'doesNotContain' // Text/General
| 'gt' | 'lt' | 'gte' | 'lte' // Number
| 'isBefore' | 'isAfter' | 'isSame' // Date
| 'isEmpty' | 'isNotEmpty'; // General
export type FilterMatchType = 'and' | 'or';
export interface Filter {
id: string;
columnId: string;
operator: FilterOperator;
value: any;
}
export interface SortRule {
columnId: string;
direction: 'asc' | 'desc';
}
// --- New Types for Views & Chat ---
export type ViewType = 'grid' | 'kanban' | 'gallery' | 'gantt';
export interface View {
id: string;
name: string;
type: ViewType;
config: {
filters: Filter[];
filterMatchType: FilterMatchType;
sortRule: SortRule | null;
groupBy: string | null;
hiddenColumnIds: string[];
rowHeight: RowHeight;
}
}
export interface ChatMessage {
id: string;
role: 'user' | 'ai' | 'system';
content: string;
timestamp: number;
isError?: boolean;
}
// --- App & Project Types ---
export interface Team {
id: string;
name: string;
memberCount: number;
role: string;
description?: string;
}
export interface Project {
id: string;
name: string;
updatedAt: number;
createdAt: number;
owner: string;
description: string;
projectType: 'spreadsheet' | 'document';
isStarred?: boolean;
}
export interface TeamMember {
id: string;
name: string;
role: string;
email: string;
avatar: string; // Initials or URL
status: 'Active' | 'Pending';
joinedAt: string;
}
export interface AppTemplate {
id: string;
name: string;
description: string;
category: string;
color: string;
icon: any; // Lucide Icon component
popularity: number;
}