-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathobjectstack.config.ts
More file actions
568 lines (564 loc) · 21.9 KB
/
objectstack.config.ts
File metadata and controls
568 lines (564 loc) · 21.9 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
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
import { defineStack } from '@objectstack/spec';
import { App } from '@objectstack/spec/ui';
import { KitchenSinkObject } from './src/objects/kitchen_sink.object';
import { AccountObject } from './src/objects/account.object';
import { ShowcaseObject } from './src/objects/showcase.object';
import { ShowcaseActions } from './src/objects/showcase.actions';
// Helper to create dates relative to today
const daysFromNow = (days: number) => {
const d = new Date();
d.setDate(d.getDate() + days);
return d;
};
export default defineStack({
objects: [
KitchenSinkObject,
AccountObject,
ShowcaseObject
],
views: [
{
listViews: {
all_fields: {
name: 'all_fields',
label: 'All Field Types',
type: 'grid' as const,
data: { provider: 'object' as const, object: 'kitchen_sink' },
columns: ['name', 'category', 'amount', 'price', 'percent', 'rating', 'due_date', 'is_active', 'email'],
sort: [{ field: 'name', order: 'asc' as const }],
},
},
},
{
listViews: {
all_showcase: {
name: 'all_showcase',
label: 'All Showcase Items',
type: 'grid' as const,
data: { provider: 'object' as const, object: 'showcase' },
columns: ['title', 'category', 'status', 'priority', 'price', 'start_date', 'owner_email', 'is_featured'],
sort: [{ field: 'title', order: 'asc' as const }],
},
showcase_board: {
name: 'showcase_board',
label: 'Status Board',
type: 'kanban' as const,
data: { provider: 'object' as const, object: 'showcase' },
columns: ['title', 'priority', 'owner_email', 'start_date'],
kanban: {
groupByField: 'status',
columns: ['title', 'priority', 'owner_email'],
},
},
},
},
],
actions: [
...ShowcaseActions,
],
apps: [
App.create({
name: 'analytics_app',
label: 'Showcase',
icon: 'sparkles',
description: 'All field types, dashboard widgets, and page layouts',
branding: {
primaryColor: '#8B5CF6',
},
navigation: [
{
id: 'nav_dash',
type: 'dashboard',
dashboardName: 'showcase_dashboard',
label: 'Dashboard',
icon: 'layout-dashboard',
},
{
id: 'nav_kitchen_sink',
type: 'object',
objectName: 'kitchen_sink',
label: 'All Field Types',
icon: 'test-tubes',
},
{
id: 'nav_showcase',
type: 'object',
objectName: 'showcase',
label: 'Feature Showcase',
icon: 'sparkles',
},
{
id: 'nav_templates',
type: 'page',
pageName: 'template_showcase',
label: 'Page Templates',
icon: 'layout-template',
},
{
id: 'nav_help',
type: 'page',
pageName: 'showcase_help',
label: 'Help & Resources',
icon: 'help-circle',
},
],
})
],
dashboards: [
{
name: 'showcase_dashboard',
label: 'Platform Showcase',
description: 'Demonstrating all dashboard widget types',
widgets: [
// --- KPI Row ---
{
id: 'total_records',
title: 'Total Records',
type: 'metric',
object: 'kitchen_sink',
layout: { x: 0, y: 0, w: 1, h: 1 },
options: {
label: 'Total Records',
value: '5',
icon: 'Database',
},
},
{
id: 'active_items',
title: 'Active Items',
type: 'metric',
object: 'kitchen_sink',
layout: { x: 1, y: 0, w: 1, h: 1 },
options: {
label: 'Active Items',
value: '4',
trend: { value: 80, direction: 'up', label: 'active rate' },
icon: 'Activity',
},
},
{
id: 'total_value',
title: 'Total Value',
type: 'metric',
object: 'kitchen_sink',
layout: { x: 2, y: 0, w: 1, h: 1 },
options: {
label: 'Total Value',
value: '$22,500',
trend: { value: 15, direction: 'up', label: 'this quarter' },
icon: 'DollarSign',
},
},
{
id: 'avg_rating',
title: 'Avg Rating',
type: 'metric',
object: 'kitchen_sink',
layout: { x: 3, y: 0, w: 1, h: 1 },
options: {
label: 'Avg Rating',
value: '4.2',
trend: { value: 0.3, direction: 'up', label: 'improvement' },
icon: 'Star',
},
},
// --- Charts Row ---
{
id: 'records_by_category',
title: 'Records by Category',
type: 'donut',
object: 'kitchen_sink',
categoryField: 'category',
valueField: 'count',
aggregate: 'count',
layout: { x: 0, y: 1, w: 2, h: 2 },
options: {
xField: 'category',
yField: 'count',
data: {
provider: 'value',
items: [
{ category: 'Option A', count: 2 },
{ category: 'Option B', count: 2 },
{ category: 'Option C', count: 1 },
],
},
},
},
{
id: 'value_distribution',
title: 'Value Distribution',
type: 'bar',
object: 'kitchen_sink',
categoryField: 'name',
valueField: 'amount',
aggregate: 'sum',
layout: { x: 2, y: 1, w: 2, h: 2 },
options: {
xField: 'name',
yField: 'amount',
data: {
provider: 'value',
items: [
{ name: 'Alpha', amount: 1500 },
{ name: 'Beta', amount: 3200 },
{ name: 'Gamma', amount: 800 },
{ name: 'Delta', amount: 5000 },
{ name: 'Epsilon', amount: 12000 },
],
},
},
},
// --- Trend Row ---
{
id: 'monthly_trend',
title: 'Monthly Trend',
type: 'area',
object: 'kitchen_sink',
categoryField: 'month',
valueField: 'value',
aggregate: 'sum',
layout: { x: 0, y: 3, w: 4, h: 2 },
options: {
xField: 'month',
yField: 'value',
data: {
provider: 'value',
items: [
{ month: 'Jan', value: 3200 },
{ month: 'Feb', value: 4500 },
{ month: 'Mar', value: 4100 },
{ month: 'Apr', value: 5800 },
{ month: 'May', value: 6200 },
{ month: 'Jun', value: 7500 },
],
},
},
},
],
},
],
pages: [
// Template Showcase Page — demonstrates page templates
{
name: 'template_showcase',
label: 'Page Templates',
type: 'app',
template: 'header-sidebar-main',
regions: [
{
name: 'header',
components: [
{
type: 'container',
properties: {
className: 'bg-muted/30 rounded-lg p-6 border',
children: [
{ type: 'text', properties: { value: '📐 Page Template Showcase', className: 'text-2xl font-bold mb-2 block' } },
{ type: 'text', properties: { value: 'This page uses the "header-sidebar-main" template — a full-width header with sidebar + main content below.', className: 'text-muted-foreground block' } },
],
},
},
],
},
{
name: 'sidebar',
width: 'medium',
components: [
{
type: 'container',
properties: {
className: 'bg-card rounded-lg p-4 border space-y-3',
children: [
{ type: 'text', properties: { value: '🧭 Available Templates', className: 'font-semibold mb-3 block' } },
{ type: 'text', properties: { value: '• **default** — Full-width single column', className: 'text-sm block' } },
{ type: 'text', properties: { value: '• **header-sidebar-main** — Header + sidebar/main (this page)', className: 'text-sm block' } },
{ type: 'text', properties: { value: '• **three-column** — Sidebar + main + aside', className: 'text-sm block' } },
{ type: 'text', properties: { value: '• **dashboard** — 2-column grid layout', className: 'text-sm block' } },
],
},
},
{
type: 'container',
properties: {
className: 'bg-card rounded-lg p-4 border space-y-3 mt-4',
children: [
{ type: 'text', properties: { value: '🔧 New Features', className: 'font-semibold mb-3 block' } },
{ type: 'text', properties: { value: '✅ **dependsOn** — Fields shown when parent has a value', className: 'text-sm block' } },
{ type: 'text', properties: { value: '✅ **visibleOn** — Fields shown based on expression', className: 'text-sm block' } },
{ type: 'text', properties: { value: '✅ **ActionParams** — Parameter dialog before actions', className: 'text-sm block' } },
{ type: 'text', properties: { value: '✅ **Page Templates** — Predefined page layouts', className: 'text-sm block' } },
],
},
},
],
},
{
name: 'main',
components: [
{
type: 'container',
properties: {
className: 'space-y-6',
children: [
{
type: 'container',
properties: {
className: 'bg-card rounded-lg p-6 border',
children: [
{ type: 'text', properties: { value: '## FormField.dependsOn', className: 'text-xl font-semibold mb-3 block' } },
{ type: 'text', properties: { value: 'Fields with `dependsOn` are only shown when the parent field has a value. For example, "Sub-Category" depends on "Category" — it only appears after a category is selected.', className: 'text-muted-foreground mb-3 block' } },
{ type: 'text', properties: { value: '```typescript\n{ field: "sub_category", dependsOn: "category" }\n```', className: 'font-mono text-sm bg-muted/50 p-3 rounded block' } },
],
},
},
{
type: 'container',
properties: {
className: 'bg-card rounded-lg p-6 border',
children: [
{ type: 'text', properties: { value: '## FormField.visibleOn', className: 'text-xl font-semibold mb-3 block' } },
{ type: 'text', properties: { value: 'Fields with `visibleOn` are shown/hidden based on a dynamic expression. For example, pricing fields only appear when status is "active" or "review".', className: 'text-muted-foreground mb-3 block' } },
{ type: 'text', properties: { value: '```typescript\n{ field: "price", visibleOn: "${data.status === \'active\'}" }\n```', className: 'font-mono text-sm bg-muted/50 p-3 rounded block' } },
],
},
},
{
type: 'container',
properties: {
className: 'bg-card rounded-lg p-6 border',
children: [
{ type: 'text', properties: { value: '## ActionParam Collection', className: 'text-xl font-semibold mb-3 block' } },
{ type: 'text', properties: { value: 'Actions can define `params` to collect from the user before execution. A dialog with form fields is shown automatically. Supports text, number, boolean, select, date, and textarea inputs.', className: 'text-muted-foreground mb-3 block' } },
{ type: 'text', properties: { value: '```typescript\nactions: [{\n name: "assign_owner",\n type: "api",\n params: [\n { name: "owner_email", label: "Email", type: "text", required: true },\n { name: "notify", label: "Notify", type: "boolean", defaultValue: true }\n ]\n}]\n```', className: 'font-mono text-sm bg-muted/50 p-3 rounded block' } },
],
},
},
],
},
},
],
},
],
},
// Help page
{
name: 'showcase_help',
label: 'Help & Resources',
type: 'app',
regions: [
{
name: 'main',
components: [
{
type: 'container',
properties: {
className: 'prose max-w-3xl mx-auto p-8 text-foreground',
children: [
{ type: 'text', properties: { value: '# Platform Showcase', className: 'text-3xl font-bold mb-6 block' } },
{ type: 'text', properties: { value: 'This app demonstrates the full range of ObjectStack capabilities — all field types, dashboard widgets, page layouts, conditional forms, and action parameters.', className: 'text-muted-foreground mb-6 block' } },
{ type: 'text', properties: { value: '## Supported Field Types', className: 'text-xl font-semibold mb-3 block' } },
{ type: 'text', properties: { value: '- **Text** — Text, Textarea, Code, Password, Rich Text\n- **Number** — Integer, Currency, Percentage, Rating\n- **Date** — Date, DateTime\n- **Selection** — Select (single), Multi-Select\n- **Contact** — Email, URL, Phone\n- **Media** — Image, File, Avatar, Signature\n- **Special** — Boolean, Color, Location, Formula, Auto Number\n- **Relations** — Lookup (references other objects)', className: 'whitespace-pre-line mb-6 block' } },
{ type: 'text', properties: { value: '## Dashboard Widgets', className: 'text-xl font-semibold mb-3 block' } },
{ type: 'text', properties: { value: '- **Metric** — KPI cards with trends\n- **Bar Chart** — Categorical comparisons\n- **Donut Chart** — Proportional breakdowns\n- **Area Chart** — Time-series trends\n- **Line Chart** — Multi-series trends\n- **Table** — Tabular data summaries', className: 'whitespace-pre-line mb-6 block' } },
{ type: 'text', properties: { value: '## New Features', className: 'text-xl font-semibold mb-3 block' } },
{ type: 'text', properties: { value: '- **FormField.dependsOn** — Conditional field visibility based on parent field value\n- **FormField.visibleOn** — Expression-based field visibility\n- **ActionParam UI** — Parameter collection dialog before action execution\n- **Page Templates** — Predefined page layout templates (default, header-sidebar-main, three-column, dashboard)', className: 'whitespace-pre-line mb-6 block' } },
{ type: 'text', properties: { value: '## View Types', className: 'text-xl font-semibold mb-3 block' } },
{ type: 'text', properties: { value: '- **Grid** — Default tabular view with sort, filter, search\n- **Kanban** — Card board grouped by any select field\n- **Calendar** — Date-based event visualization\n- **Gantt** — Project timeline with dependencies\n- **Timeline** — Chronological activity stream\n- **Map** — Geographic data on interactive map\n- **Gallery** — Visual card grid layout', className: 'whitespace-pre-line block' } },
],
},
},
],
},
],
},
],
manifest: {
id: 'com.example.kitchen-sink',
version: '1.0.0',
type: 'app',
name: 'Platform Showcase',
description: 'Demonstrates all field types, views, dashboard widgets, conditional forms, actions, and page templates',
data: [
{
object: 'kitchen_sink',
mode: 'upsert',
records: [
{
name: 'Alpha Configuration',
description: 'Primary system settings panel for environment management',
amount: 1500,
price: 29.99,
percent: 75.5,
rating: 4,
due_date: daysFromNow(10),
event_time: daysFromNow(10),
is_active: true,
category: 'opt_a',
tags: ['col_red', 'col_blue'],
email: 'alpha@example.com',
url: 'https://alpha.example.com',
phone: '+1-555-0101',
color: '#3B82F6',
},
{
name: 'Beta Dashboard',
description: 'Real-time monitoring interface with live metrics',
amount: 3200,
price: 149.99,
percent: 42.0,
rating: 5,
due_date: daysFromNow(20),
event_time: daysFromNow(20),
is_active: true,
category: 'opt_b',
tags: ['col_green'],
email: 'beta@example.com',
url: 'https://beta.example.com',
phone: '+1-555-0202',
color: '#10B981',
},
{
name: 'Gamma Report Engine',
description: 'Automated report generation and distribution system',
amount: 800,
price: 49.99,
percent: 90.25,
rating: 3,
due_date: daysFromNow(30),
is_active: false,
category: 'opt_c',
tags: ['col_red', 'col_green', 'col_blue'],
email: 'gamma@example.com',
url: 'https://gamma.example.com',
phone: '+1-555-0303',
color: '#F59E0B',
},
{
name: 'Delta API Gateway',
description: 'Central API routing with rate limiting and auth',
amount: 5000,
price: 299.0,
percent: 15.8,
rating: 5,
due_date: daysFromNow(-5),
event_time: daysFromNow(-5),
is_active: true,
category: 'opt_a',
email: 'delta@example.com',
url: 'https://delta.example.com',
phone: '+1-555-0404',
color: '#EF4444',
},
{
name: 'Epsilon ML Pipeline',
description: 'Machine learning data processing and model training flow',
amount: 12000,
price: 599.99,
percent: 60.0,
rating: 4,
due_date: daysFromNow(45),
is_active: true,
category: 'opt_b',
tags: ['col_blue'],
email: 'epsilon@example.com',
url: 'https://epsilon.example.com',
phone: '+1-555-0505',
color: '#8B5CF6',
},
],
},
{
object: 'showcase',
mode: 'upsert',
records: [
{
title: 'Cloud Infrastructure Setup',
description: 'Setting up cloud infrastructure for production deployment',
category: 'software',
sub_category: 'web_app',
priority: 'high',
status: 'active',
price: 4500,
discount_percent: 10,
start_date: daysFromNow(-10),
end_date: daysFromNow(30),
owner_email: 'alice@example.com',
is_featured: true,
tags: ['new', 'premium'],
},
{
title: 'Server Rack Procurement',
description: 'Purchasing new server racks for data center expansion',
category: 'hardware',
sub_category: 'server',
priority: 'medium',
status: 'review',
price: 12000,
discount_percent: 5,
start_date: daysFromNow(-5),
end_date: daysFromNow(60),
owner_email: 'bob@example.com',
is_featured: false,
tags: ['popular'],
},
{
title: 'Security Consulting',
description: 'Annual security audit and consulting engagement',
category: 'service',
sub_category: 'consulting',
priority: 'critical',
status: 'active',
price: 8000,
start_date: daysFromNow(0),
end_date: daysFromNow(90),
owner_email: 'carol@example.com',
is_featured: true,
tags: ['premium'],
},
{
title: 'Mobile App Redesign',
description: 'Redesigning the mobile application with new UX patterns',
category: 'software',
sub_category: 'mobile_app',
priority: 'high',
status: 'draft',
start_date: daysFromNow(15),
owner_email: 'dave@example.com',
is_featured: false,
tags: ['new'],
},
{
title: 'Laptop Refresh Program',
description: 'Annual laptop replacement for engineering team',
category: 'hardware',
sub_category: 'laptop',
priority: 'low',
status: 'completed',
price: 25000,
discount_percent: 15,
start_date: daysFromNow(-60),
end_date: daysFromNow(-5),
owner_email: 'eve@example.com',
is_featured: false,
tags: ['sale'],
},
{
title: 'Team Training Workshop',
description: 'Advanced TypeScript and React training for the team',
category: 'service',
sub_category: 'training',
priority: 'medium',
status: 'active',
price: 3000,
start_date: daysFromNow(20),
end_date: daysFromNow(22),
owner_email: 'frank@example.com',
is_featured: true,
tags: ['popular', 'new'],
},
],
},
],
},
});