1+ export interface UserProfile {
2+ id : string ;
3+ name : string ;
4+ email : string ;
5+ role : string ;
6+ preferences : {
7+ theme : 'light' | 'dark' | 'auto' ;
8+ model : string ;
9+ maxTokens : number ;
10+ temperature : number ;
11+ } ;
12+ apiKey ?: string ;
13+ createdAt : Date ;
14+ lastActive : Date ;
15+ }
16+
17+ export interface ProjectData {
18+ id : string ;
19+ name : string ;
20+ description : string ;
21+ language : string ;
22+ framework ?: string ;
23+ dependencies : string [ ] ;
24+ owner : string ;
25+ collaborators : string [ ] ;
26+ createdAt : Date ;
27+ updatedAt : Date ;
28+ }
29+
30+ export interface ConversationData {
31+ id : string ;
32+ userId : string ;
33+ projectId ?: string ;
34+ title : string ;
35+ messageCount : number ;
36+ tokenUsage : {
37+ input : number ;
38+ output : number ;
39+ total : number ;
40+ } ;
41+ createdAt : Date ;
42+ lastMessageAt : Date ;
43+ }
44+
45+ const NAMES = [
46+ 'Alice Johnson' , 'Bob Smith' , 'Carol Davis' , 'David Wilson' , 'Eve Brown' ,
47+ 'Frank Miller' , 'Grace Lee' , 'Henry Taylor' , 'Ivy Chen' , 'Jack Robinson'
48+ ] ;
49+
50+ const LANGUAGES = [ 'TypeScript' , 'JavaScript' , 'Python' , 'Rust' , 'Go' , 'Java' ] ;
51+ const FRAMEWORKS = [ 'React' , 'Next.js' , 'Express' , 'FastAPI' , 'Gin' , 'Spring' ] ;
52+ const ROLES = [ 'developer' , 'senior-developer' , 'architect' , 'product-manager' ] ;
53+ const MODELS = [ 'claude-3-5-sonnet-20241022' , 'claude-3-opus-20240229' , 'claude-3-haiku-20240307' ] ;
54+
55+ function randomChoice < T > ( array : T [ ] ) : T {
56+ return array [ Math . floor ( Math . random ( ) * array . length ) ] ;
57+ }
58+
59+ function randomInt ( min : number , max : number ) : number {
60+ return Math . floor ( Math . random ( ) * ( max - min + 1 ) ) + min ;
61+ }
62+
63+ function randomDate ( start : Date , end : Date ) : Date {
64+ return new Date ( start . getTime ( ) + Math . random ( ) * ( end . getTime ( ) - start . getTime ( ) ) ) ;
65+ }
66+
67+ function generateId ( ) : string {
68+ return `${ Date . now ( ) } -${ Math . random ( ) . toString ( 36 ) . substr ( 2 , 9 ) } ` ;
69+ }
70+
71+ export function generateUser ( ) : UserProfile {
72+ const name = randomChoice ( NAMES ) ;
73+ const email = `${ name . toLowerCase ( ) . replace ( ' ' , '.' ) } @example.com` ;
74+ const createdAt = randomDate ( new Date ( 2023 , 0 , 1 ) , new Date ( ) ) ;
75+ const lastActive = randomDate ( createdAt , new Date ( ) ) ;
76+
77+ return {
78+ id : generateId ( ) ,
79+ name,
80+ email,
81+ role : randomChoice ( ROLES ) ,
82+ preferences : {
83+ theme : randomChoice ( [ 'light' , 'dark' , 'auto' ] as const ) ,
84+ model : randomChoice ( MODELS ) ,
85+ maxTokens : randomChoice ( [ 1000 , 2000 , 4000 , 8000 ] ) ,
86+ temperature : Math . round ( ( Math . random ( ) * 2 ) * 100 ) / 100
87+ } ,
88+ createdAt,
89+ lastActive
90+ } ;
91+ }
92+
93+ export function generateProject ( ownerId ?: string ) : ProjectData {
94+ const language = randomChoice ( LANGUAGES ) ;
95+ const framework = Math . random ( ) > 0.3 ? randomChoice ( FRAMEWORKS ) : undefined ;
96+ const createdAt = randomDate ( new Date ( 2023 , 0 , 1 ) , new Date ( ) ) ;
97+ const updatedAt = randomDate ( createdAt , new Date ( ) ) ;
98+
99+ const projectNames = [
100+ 'awesome-app' , 'todo-manager' , 'data-processor' , 'web-scraper' ,
101+ 'api-gateway' , 'chat-bot' , 'analytics-dashboard' , 'file-sync' ,
102+ 'code-formatter' , 'build-optimizer'
103+ ] ;
104+
105+ return {
106+ id : generateId ( ) ,
107+ name : randomChoice ( projectNames ) ,
108+ description : `A ${ language } project${ framework ? ` using ${ framework } ` : '' } ` ,
109+ language,
110+ framework,
111+ dependencies : Array . from ( { length : randomInt ( 3 , 10 ) } , ( ) =>
112+ `package-${ Math . random ( ) . toString ( 36 ) . substr ( 2 , 8 ) } `
113+ ) ,
114+ owner : ownerId || generateId ( ) ,
115+ collaborators : Array . from ( { length : randomInt ( 0 , 3 ) } , ( ) => generateId ( ) ) ,
116+ createdAt,
117+ updatedAt
118+ } ;
119+ }
120+
121+ export function generateConversation ( userId ?: string , projectId ?: string ) : ConversationData {
122+ const createdAt = randomDate ( new Date ( 2023 , 0 , 1 ) , new Date ( ) ) ;
123+ const lastMessageAt = randomDate ( createdAt , new Date ( ) ) ;
124+ const messageCount = randomInt ( 1 , 50 ) ;
125+ const inputTokens = messageCount * randomInt ( 50 , 500 ) ;
126+ const outputTokens = messageCount * randomInt ( 100 , 800 ) ;
127+
128+ const conversationTitles = [
129+ 'Help with TypeScript setup' ,
130+ 'Debug async function' ,
131+ 'Optimize database queries' ,
132+ 'Add authentication' ,
133+ 'Implement caching' ,
134+ 'Fix build errors' ,
135+ 'Code review assistance' ,
136+ 'API integration help'
137+ ] ;
138+
139+ return {
140+ id : generateId ( ) ,
141+ userId : userId || generateId ( ) ,
142+ projectId,
143+ title : randomChoice ( conversationTitles ) ,
144+ messageCount,
145+ tokenUsage : {
146+ input : inputTokens ,
147+ output : outputTokens ,
148+ total : inputTokens + outputTokens
149+ } ,
150+ createdAt,
151+ lastMessageAt
152+ } ;
153+ }
154+
155+ export function generateUserDataset ( userCount : number = 10 ) {
156+ const users = Array . from ( { length : userCount } , ( ) => generateUser ( ) ) ;
157+ const projects = users . flatMap ( user =>
158+ Array . from ( { length : randomInt ( 1 , 3 ) } , ( ) => generateProject ( user . id ) )
159+ ) ;
160+ const conversations = users . flatMap ( user =>
161+ Array . from ( { length : randomInt ( 2 , 8 ) } , ( ) => {
162+ const userProjects = projects . filter ( p => p . owner === user . id ) ;
163+ const projectId = Math . random ( ) > 0.5 && userProjects . length > 0
164+ ? randomChoice ( userProjects ) . id
165+ : undefined ;
166+ return generateConversation ( user . id , projectId ) ;
167+ } )
168+ ) ;
169+
170+ return {
171+ users,
172+ projects,
173+ conversations,
174+ summary : {
175+ totalUsers : users . length ,
176+ totalProjects : projects . length ,
177+ totalConversations : conversations . length ,
178+ totalTokens : conversations . reduce ( ( sum , conv ) => sum + conv . tokenUsage . total , 0 )
179+ }
180+ } ;
181+ }
0 commit comments