-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshowcase.knot
More file actions
458 lines (427 loc) · 19.6 KB
/
Copy pathshowcase.knot
File metadata and controls
458 lines (427 loc) · 19.6 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
with {
-- Showcase: exercises many data types, ADTs, nested relations, and bulk data
-- Run: knot build examples/showcase.knot && ./examples/showcase
-- Then: ./examples/showcase db
-- ── Types ────────────────────────────────────────────────────────
data Priority = Low {} | Medium {} | High {} | Critical {}
data Status = Open {} | InProgress {assignee: Text} | Done {} | Blocked {reason: Text}
data Department = Engineering {} | Design {} | Marketing {} | Sales {} | Support {}
data Active = Yes {} | No {}
type Employee = {name: Text, age: Int 1, salary: Float 1, dept: Department, active: Active}
type Project = {name: Text, lead: Text, budget: Float 1, priority: Priority}
type Ticket = {title: Text, project: Text, status: Status, priority: Priority, points: Int 1}
type Customer = {name: Text, email: Text, tier: Tier}
data Tier = Free {} | Pro {} | Enterprise {}
type Order = {customer: Text, product: Text, quantity: Int 1, total: Float 1}
type Product = {name: Text, price: Float 1, category: Category, inStock: Active}
data Category = Electronics {} | Books {} | Clothing {} | Food {} | Software {}
type Team = {name: Text, members: [{name: Text, role: Text}]}
type LogEntry = {timestamp: Int 1, level: Level, message: Text, source: Text}
data Level = Debug {} | Info {} | Warn {} | Error {}
type Metric = {name: Text, value: Float 1, tags: Text}
-- ── Sources ──────────────────────────────────────────────────────
*employees : [Employee]
*projects : [Project]
*tickets : [Ticket]
*customers : [Customer]
*orders : [Order]
*products : [Product]
*teams : [Team]
*logs : [LogEntry]
*metrics : [Metric]
-- ── Seed data ────────────────────────────────────────────────────
seedEmployees (do
full *employees = [
{name "Alice Chen" age 34 salary 142000.0 dept (Department.Engineering {}) active (Active.Yes {})}
{name "Bob Martinez" age 28 salary 95000.0 dept (Department.Engineering {}) active (Active.Yes {})}
{name "Carol Davis" age 41 salary 155000.0 dept (Department.Engineering {}) active (Active.Yes {})}
{name "Dan Wilson" age 25 salary 78000.0 dept (Department.Engineering {}) active (Active.Yes {})}
{name "Eve Johnson" age 37 salary 130000.0 dept (Department.Design {}) active (Active.Yes {})}
{name "Frank Lee" age 45 salary 160000.0 dept (Department.Engineering {}) active (Active.Yes {})}
{name "Grace Kim" age 30 salary 112000.0 dept (Department.Marketing {}) active (Active.Yes {})}
{name "Hank Brown" age 52 salary 175000.0 dept (Department.Engineering {}) active (Active.No {})}
{name "Iris Patel" age 29 salary 98000.0 dept (Department.Support {}) active (Active.Yes {})}
{name "Jack Thompson" age 33 salary 125000.0 dept (Department.Sales {}) active (Active.Yes {})}
{name "Kate White" age 38 salary 140000.0 dept (Department.Design {}) active (Active.Yes {})}
{name "Leo Garcia" age 26 salary 85000.0 dept (Department.Engineering {}) active (Active.Yes {})}
{name "Mia Robinson" age 44 salary 168000.0 dept (Department.Engineering {}) active (Active.Yes {})}
{name "Noah Clark" age 31 salary 105000.0 dept (Department.Marketing {}) active (Active.Yes {})}
{name "Olivia Hall" age 36 salary 138000.0 dept (Department.Sales {}) active (Active.Yes {})}
{name "Pat Young" age 48 salary 152000.0 dept (Department.Support {}) active (Active.Yes {})}
{name "Quinn Adams" age 27 salary 92000.0 dept (Department.Design {}) active (Active.Yes {})}
{name "Rita Baker" age 39 salary 145000.0 dept (Department.Engineering {}) active (Active.Yes {})}
{name "Sam Torres" age 42 salary 158000.0 dept (Department.Marketing {}) active (Active.No {})}
{name "Tina Flores" age 35 salary 132000.0 dept (Department.Sales {}) active (Active.Yes {})}
]
yield {})
seedProjects (do
full *projects = [
{name "Phoenix" lead "Alice Chen" budget 500000.0 priority (Priority.Critical {})}
{name "Atlas" lead "Carol Davis" budget 350000.0 priority (Priority.High {})}
{name "Meridian" lead "Frank Lee" budget 200000.0 priority (Priority.Medium {})}
{name "Horizon" lead "Mia Robinson" budget 750000.0 priority (Priority.Critical {})}
{name "Compass" lead "Eve Johnson" budget 150000.0 priority (Priority.Low {})}
{name "Vanguard" lead "Rita Baker" budget 420000.0 priority (Priority.High {})}
{name "Echo" lead "Bob Martinez" budget 180000.0 priority (Priority.Medium {})}
{name "Nimbus" lead "Kate White" budget 280000.0 priority (Priority.High {})}
]
yield {})
seedTickets (do
full *tickets = [
{
title "Fix auth timeout"
project "Phoenix"
status (Status.InProgress {assignee "Bob Martinez"})
priority (Priority.Critical {})
points 8
}
{title "Add dark mode" project "Phoenix" status (Status.Open {}) priority (Priority.Medium {}) points 5}
{
title "Optimize query planner"
project "Phoenix"
status (Status.InProgress {assignee "Alice Chen"})
priority (Priority.High {})
points 13
}
{title "Write API docs" project "Phoenix" status (Status.Done {}) priority (Priority.Low {}) points 3}
{
title "Database migration tool"
project "Atlas"
status (Status.Blocked {reason "Waiting for schema freeze"})
priority (Priority.High {})
points 8
}
{title "Add CSV export" project "Atlas" status (Status.Open {}) priority (Priority.Medium {}) points 5}
{
title "Fix N+1 queries"
project "Atlas"
status (Status.InProgress {assignee "Dan Wilson"})
priority (Priority.Critical {})
points 8
}
{title "Update CI pipeline" project "Meridian" status (Status.Done {}) priority (Priority.Medium {}) points 3}
{title "Add rate limiting" project "Meridian" status (Status.Open {}) priority (Priority.High {}) points 5}
{
title "Redesign dashboard"
project "Horizon"
status (Status.InProgress {assignee "Eve Johnson"})
priority (Priority.High {})
points 13
}
{
title "Mobile responsive layout"
project "Horizon"
status (Status.Open {})
priority (Priority.Medium {})
points 8
}
{
title "Fix memory leak"
project "Horizon"
status (Status.Blocked {reason "Need profiler access"})
priority (Priority.Critical {})
points 5
}
{title "Logo redesign" project "Compass" status (Status.Done {}) priority (Priority.Low {}) points 2}
{
title "Brand guidelines doc"
project "Compass"
status (Status.InProgress {assignee "Kate White"})
priority (Priority.Low {})
points 3
}
{title "Set up monitoring" project "Vanguard" status (Status.Open {}) priority (Priority.High {}) points 5}
{
title "Implement caching layer"
project "Vanguard"
status (Status.InProgress {assignee "Carol Davis"})
priority (Priority.Critical {})
points 13
}
{title "Add search indexing" project "Vanguard" status (Status.Open {}) priority (Priority.Medium {}) points 8}
{title "Fix date parsing bug" project "Echo" status (Status.Done {}) priority (Priority.High {}) points 3}
{title "Add webhook support" project "Echo" status (Status.Open {}) priority (Priority.Medium {}) points 8}
{
title "Migrate to new SDK"
project "Echo"
status (Status.Blocked {reason "SDK not released yet"})
priority (Priority.Low {})
points 5
}
{
title "Design system components"
project "Nimbus"
status (Status.InProgress {assignee "Quinn Adams"})
priority (Priority.High {})
points 8
}
{title "Accessibility audit" project "Nimbus" status (Status.Open {}) priority (Priority.Medium {}) points 5}
{title "Performance benchmarks" project "Phoenix" status (Status.Open {}) priority (Priority.High {}) points 5}
{title "Implement SSO" project "Phoenix" status (Status.Open {}) priority (Priority.Critical {}) points 13}
{title "Add telemetry" project "Atlas" status (Status.Open {}) priority (Priority.Medium {}) points 5}
]
yield {})
seedCustomers (do
full *customers = [
{name "Acme Corp" email "admin@acme.com" tier (Tier.Enterprise {})}
{name "Widgets Inc" email "hello@widgets.io" tier (Tier.Pro {})}
{name "Startup Labs" email "team@startuplabs.dev" tier (Tier.Free {})}
{name "MegaTech" email "info@megatech.com" tier (Tier.Enterprise {})}
{name "Cloud Nine" email "ops@cloudnine.co" tier (Tier.Pro {})}
{name "DataFlow" email "admin@dataflow.io" tier (Tier.Pro {})}
{name "ByteWorks" email "hello@byteworks.dev" tier (Tier.Free {})}
{name "Quantum Systems" email "sales@quantumsys.com" tier (Tier.Enterprise {})}
{name "NexGen" email "support@nexgen.io" tier (Tier.Pro {})}
{name "TechVista" email "info@techvista.com" tier (Tier.Free {})}
{name "Alpine Digital" email "hello@alpine.digital" tier (Tier.Pro {})}
{name "CoreStack" email "admin@corestack.io" tier (Tier.Enterprise {})}
]
yield {})
seedProducts (do
full *products = [
{name "Laptop Pro 16" price 2499.99 category (Category.Electronics {}) inStock (Active.Yes {})}
{name "Wireless Mouse" price 49.99 category (Category.Electronics {}) inStock (Active.Yes {})}
{name "USB-C Hub" price 79.99 category (Category.Electronics {}) inStock (Active.No {})}
{name "Mechanical KB" price 159.99 category (Category.Electronics {}) inStock (Active.Yes {})}
{name "4K Monitor" price 599.99 category (Category.Electronics {}) inStock (Active.Yes {})}
{name "Clean Code" price 39.99 category (Category.Books {}) inStock (Active.Yes {})}
{name "SICP" price 65.0 category (Category.Books {}) inStock (Active.Yes {})}
{name "The Art of SQL" price 45.5 category (Category.Books {}) inStock (Active.No {})}
{name "Hoodie (Black)" price 59.99 category (Category.Clothing {}) inStock (Active.Yes {})}
{name "T-Shirt (Logo)" price 24.99 category (Category.Clothing {}) inStock (Active.Yes {})}
{name "Coffee Beans 1kg" price 18.99 category (Category.Food {}) inStock (Active.Yes {})}
{name "Green Tea Box" price 12.5 category (Category.Food {}) inStock (Active.Yes {})}
{name "IDE License" price 199.99 category (Category.Software {}) inStock (Active.Yes {})}
{name "CI/CD Platform" price 499.99 category (Category.Software {}) inStock (Active.Yes {})}
{name "Monitoring Suite" price 299.99 category (Category.Software {}) inStock (Active.Yes {})}
]
yield {})
seedOrders (do
full *orders = [
{customer "Acme Corp" product "Laptop Pro 16" quantity 50 total 124999.5}
{customer "Acme Corp" product "4K Monitor" quantity 50 total 29999.5}
{customer "Acme Corp" product "IDE License" quantity 100 total 19999.0}
{customer "Widgets Inc" product "Mechanical KB" quantity 20 total 3199.8}
{customer "Widgets Inc" product "Wireless Mouse" quantity 20 total 999.8}
{customer "MegaTech" product "Laptop Pro 16" quantity 200 total 499998.0}
{customer "MegaTech" product "CI/CD Platform" quantity 1 total 499.99}
{customer "MegaTech" product "Monitoring Suite" quantity 1 total 299.99}
{customer "Cloud Nine" product "IDE License" quantity 15 total 2999.85}
{customer "Cloud Nine" product "Coffee Beans 1kg" quantity 5 total 94.95}
{customer "DataFlow" product "CI/CD Platform" quantity 1 total 499.99}
{customer "DataFlow" product "4K Monitor" quantity 10 total 5999.9}
{customer "Startup Labs" product "Coffee Beans 1kg" quantity 2 total 37.98}
{customer "Startup Labs" product "Clean Code" quantity 5 total 199.95}
{customer "ByteWorks" product "T-Shirt (Logo)" quantity 10 total 249.9}
{customer "Quantum Systems" product "Laptop Pro 16" quantity 100 total 249999.0}
{customer "Quantum Systems" product "Monitoring Suite" quantity 3 total 899.97}
{customer "NexGen" product "Hoodie (Black)" quantity 25 total 1499.75}
{customer "NexGen" product "SICP" quantity 10 total 650.0}
{customer "TechVista" product "Green Tea Box" quantity 20 total 250.0}
{customer "Alpine Digital" product "USB-C Hub" quantity 30 total 2399.7}
{customer "Alpine Digital" product "Mechanical KB" quantity 15 total 2399.85}
{customer "CoreStack" product "Laptop Pro 16" quantity 75 total 187499.25}
{customer "CoreStack" product "IDE License" quantity 75 total 14999.25}
{customer "CoreStack" product "CI/CD Platform" quantity 2 total 999.98}
]
yield {})
seedTeams (do
full *teams = [
{
name "Platform"
members [
{name "Alice Chen" role "Lead"}
{name "Bob Martinez" role "Senior"}
{name "Dan Wilson" role "Junior"}
{name "Leo Garcia" role "Junior"}
]
}
{
name "Frontend"
members [
{name "Eve Johnson" role "Lead"}
{name "Kate White" role "Senior"}
{name "Quinn Adams" role "Junior"}
]
}
{
name "Infrastructure"
members [
{name "Carol Davis" role "Lead"}
{name "Frank Lee" role "Senior"}
{name "Rita Baker" role "Senior"}
]
}
{
name "Growth"
members [
{name "Grace Kim" role "Lead"}
{name "Noah Clark" role "Senior"}
{name "Jack Thompson" role "Senior"}
{name "Olivia Hall" role "Senior"}
{name "Tina Flores" role "Senior"}
]
}
{
name "Customer Success"
members [{name "Iris Patel" role "Lead"} {name "Pat Young" role "Senior"}]
}
]
yield {})
seedLogs (do
full *logs = [
{timestamp 1710900000 level (Level.Info {}) message "Server started on port 8080" source "main"}
{
timestamp 1710900001
level (Level.Info {})
message "Database connection pool initialized (10)"
source "db"
}
{timestamp 1710900005 level (Level.Debug {}) message "Loading configuration from env" source "config"}
{
timestamp 1710900012
level (Level.Info {})
message "Health check endpoint registered"
source "routes"
}
{timestamp 1710900030 level (Level.Warn {}) message "Slow query detected: 2340ms" source "db"}
{
timestamp 1710900045
level (Level.Info {})
message "Request: GET /api/users (200, 45ms)"
source "http"
}
{
timestamp 1710900046
level (Level.Info {})
message "Request: POST /api/orders (201, 120ms)"
source "http"
}
{timestamp 1710900047 level (Level.Debug {}) message "Cache miss for key: user:1234" source "cache"}
{
timestamp 1710900048
level (Level.Info {})
message "Request: GET /api/products (200, 32ms)"
source "http"
}
{
timestamp 1710900060
level (Level.Error {})
message "Connection refused: redis://localhost:6379"
source "cache"
}
{timestamp 1710900061 level (Level.Warn {}) message "Falling back to in-memory cache" source "cache"}
{
timestamp 1710900090
level (Level.Info {})
message "Request: PUT /api/users/42 (200, 88ms)"
source "http"
}
{
timestamp 1710900100
level (Level.Error {})
message "Timeout: external payment API (5000ms)"
source "payments"
}
{
timestamp 1710900101
level (Level.Warn {})
message "Retrying payment request (attempt 2/3)"
source "payments"
}
{
timestamp 1710900105
level (Level.Info {})
message "Payment processed: order #7821"
source "payments"
}
{timestamp 1710900120 level (Level.Debug {}) message "GC pause: 12ms" source "runtime"}
{
timestamp 1710900150
level (Level.Info {})
message "Cron: daily report generation started"
source "scheduler"
}
{
timestamp 1710900180
level (Level.Info {})
message "Report generated: 1,247 rows exported"
source "scheduler"
}
{timestamp 1710900200 level (Level.Warn {}) message "Disk usage at 82%" source "monitor"}
{
timestamp 1710900300
level (Level.Info {})
message "Request: DELETE /api/sessions/old (200)"
source "http"
}
{timestamp 1710900301 level (Level.Info {}) message "Cleaned 847 expired sessions" source "auth"}
{
timestamp 1710900400
level (Level.Error {})
message "TLS certificate expires in 7 days"
source "monitor"
}
{
timestamp 1710900500
level (Level.Info {})
message "Backup completed: 2.4GB compressed"
source "backup"
}
{timestamp 1710900600 level (Level.Debug {}) message "WebSocket connections: 142 active" source "ws"}
{
timestamp 1710900700
level (Level.Info {})
message "Rate limit applied: 10.0.5.23 (429)"
source "http"
}
]
yield {})
seedMetrics (do
full *metrics = [
{name "http_requests_total" value 48291.0 tags "method=GET,status=200"}
{name "http_requests_total" value 12847.0 tags "method=POST,status=201"}
{name "http_requests_total" value 342.0 tags "method=POST,status=400"}
{name "http_requests_total" value 89.0 tags "method=GET,status=404"}
{name "http_requests_total" value 23.0 tags "method=GET,status=500"}
{name "http_request_duration_ms" value 45.2 tags "endpoint=/api/users,p50"}
{name "http_request_duration_ms" value 120.8 tags "endpoint=/api/users,p95"}
{name "http_request_duration_ms" value 340.1 tags "endpoint=/api/users,p99"}
{name "http_request_duration_ms" value 12.4 tags "endpoint=/api/health,p50"}
{name "http_request_duration_ms" value 31.6 tags "endpoint=/api/products,p50"}
{name "http_request_duration_ms" value 88.9 tags "endpoint=/api/products,p95"}
{name "db_connections_active" value 8.0 tags "pool=primary"}
{name "db_connections_active" value 3.0 tags "pool=replica"}
{name "db_query_duration_ms" value 2.1 tags "query=select,table=users"}
{name "db_query_duration_ms" value 15.8 tags "query=select,table=orders"}
{name "db_query_duration_ms" value 0.8 tags "query=select,table=products"}
{name "memory_usage_bytes" value 524288000.0 tags "type=heap"}
{name "memory_usage_bytes" value 134217728.0 tags "type=stack"}
{name "cpu_usage_percent" value 34.5 tags "core=0"}
{name "cpu_usage_percent" value 67.2 tags "core=1"}
{name "cpu_usage_percent" value 22.1 tags "core=2"}
{name "cpu_usage_percent" value 45.8 tags "core=3"}
{name "cache_hit_ratio" value 0.847 tags "cache=redis"}
{name "cache_hit_ratio" value 0.923 tags "cache=local"}
{name "websocket_connections" value 142.0 tags ""}
{name "queue_depth" value 37.0 tags "queue=email"}
{name "queue_depth" value 12.0 tags "queue=webhook"}
{name "queue_depth" value 0.0 tags "queue=analytics"}
{name "disk_usage_percent" value 82.3 tags "mount=/data"}
{name "disk_usage_percent" value 45.1 tags "mount=/logs"}
]
yield {})
-- ── Main ─────────────────────────────────────────────────────────
}
(do
seedEmployees
seedProjects
seedTickets
seedCustomers
seedProducts
seedOrders
seedTeams
seedLogs
seedMetrics
yield (base.show (base.count *employees) ++ " employees, " ++ base.show (base.count *projects) ++ " projects, " ++ base.show (base.count *tickets) ++ " tickets, " ++ base.show (base.count *customers) ++ " customers, " ++ base.show (base.count *products) ++ " products, " ++ base.show (base.count *orders) ++ " orders, " ++ base.show (base.count *teams) ++ " teams, " ++ base.show (base.count *logs) ++ " logs, " ++ base.show (base.count *metrics) ++ " metrics")
)