Skip to content

Commit 82a9785

Browse files
committed
feat: add Kitchen Sink example with comprehensive object configurations and UI components
1 parent 492a2ae commit 82a9785

File tree

9 files changed

+263
-25
lines changed

9 files changed

+263
-25
lines changed

apps/console/objectstack.config.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineConfig } from './src/config';
22
import crmConfig from '@object-ui/example-crm/objectstack.config';
33
import todoConfig from '@object-ui/example-todo/objectstack.config';
4+
import kitchenSinkConfig from '@object-ui/example-kitchen-sink/objectstack.config';
45

56
export default defineConfig({
67
// ============================================================================
@@ -41,20 +42,23 @@ export default defineConfig({
4142
],
4243

4344
// ============================================================================
44-
// Merged Stack Configuration (CRM + Todo)
45+
// Merged Stack Configuration (CRM + Todo + Kitchen Sink)
4546
// ============================================================================
4647
objects: [
4748
...(crmConfig.objects || []),
48-
...(todoConfig.objects || [])
49+
...(todoConfig.objects || []),
50+
...(kitchenSinkConfig.objects || [])
4951
],
5052
apps: [
5153
...(crmConfig.apps || []),
52-
...(todoConfig.apps || [])
54+
...(todoConfig.apps || []),
55+
...(kitchenSinkConfig.apps || [])
5356
],
5457
manifest: {
5558
data: [
5659
...(crmConfig.manifest?.data || []),
57-
...(todoConfig.manifest?.data || [])
60+
...(todoConfig.manifest?.data || []),
61+
...(kitchenSinkConfig.manifest?.data || [])
5862
]
5963
},
6064

apps/console/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@objectstack/runtime": "^0.7.2",
3030
"@objectstack/spec": "^0.7.2",
3131
"@object-ui/example-crm": "workspace:*",
32+
"@object-ui/example-kitchen-sink": "workspace:*",
3233
"@object-ui/example-todo": "workspace:*",
3334
"lucide-react": "^0.563.0",
3435
"react": "^19.0.0",

examples/crm/objectstack.config.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ export default defineStack({
2727
type: 'object',
2828
objectName: 'opportunity',
2929
label: 'Opportunities'
30+
},
31+
{
32+
id: 'nav_accounts',
33+
type: 'object',
34+
objectName: 'account',
35+
label: 'Accounts'
3036
}
3137
]
3238
})
@@ -38,9 +44,18 @@ export default defineStack({
3844
name: 'CRM Example',
3945
description: 'CRM App Definition',
4046
data: [
47+
{
48+
object: 'account',
49+
mode: 'upsert',
50+
records: [
51+
{ _id: "1", name: "TechCorp" },
52+
{ _id: "2", name: "Software Inc" },
53+
{ _id: "3", name: "Good Grief LLC" }
54+
]
55+
},
4156
{
4257
object: 'contact',
43-
mode: 'upsert', // upsert based on ID (which is usually _id or id)
58+
mode: 'upsert',
4459
records: [
4560
{ _id: "1", name: "Alice Johnson", email: "alice@example.com", phone: "555-0101", title: "VP Sales", company: "TechCorp", status: "Active" },
4661
{ _id: "2", name: "Bob Smith", email: "bob@tech.com", phone: "555-0102", title: "Developer", company: "Software Inc", status: "Lead" },
@@ -57,8 +72,8 @@ export default defineStack({
5772
amount: 50000,
5873
stage: "Proposal",
5974
close_date: new Date("2024-06-30"),
60-
account_id: "1", // This would ideally link to an account record
61-
contact_ids: ["1", "2"], // Corrected IDs
75+
account_id: "1",
76+
contact_ids: ["1", "2"],
6277
description: "Enterprise software license for 500 users. Includes premium support and training."
6378
},
6479
{
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { defineStack } from '@objectstack/spec';
2+
import { App } from '@objectstack/spec/ui';
3+
import { KitchenSinkObject } from './src/objects/kitchen_sink.object';
4+
import { AccountObject } from './src/objects/account.object';
5+
6+
export default defineStack({
7+
objects: [
8+
KitchenSinkObject,
9+
AccountObject
10+
],
11+
apps: [
12+
App.create({
13+
name: 'kitchen_sink_app',
14+
label: 'Kitchen Sink',
15+
icon: 'layout',
16+
navigation: [
17+
{
18+
id: 'nav_kitchen',
19+
type: 'object',
20+
objectName: 'kitchen_sink',
21+
label: 'Components'
22+
},
23+
{
24+
id: 'nav_account',
25+
type: 'object',
26+
objectName: 'account',
27+
label: 'Reference Accounts'
28+
}
29+
]
30+
})
31+
],
32+
manifest: {
33+
id: 'com.example.kitchen-sink',
34+
version: '1.0.0',
35+
type: 'app',
36+
name: 'Kitchen Sink',
37+
description: 'Component Testing App',
38+
data: [
39+
{
40+
object: 'account',
41+
mode: 'upsert',
42+
records: [
43+
{ _id: "1", name: "TechCorp" },
44+
{ _id: "2", name: "Software Inc" }
45+
]
46+
},
47+
{
48+
object: 'kitchen_sink',
49+
mode: 'upsert',
50+
records: [
51+
{
52+
_id: "1001",
53+
name: "Full Feature Test",
54+
description: "This record has every field populated.",
55+
amount: 42,
56+
price: 99.99,
57+
percent: 0.75,
58+
rating: 4,
59+
is_active: true,
60+
category: "opt_a",
61+
tags: ["col_red", "col_blue"],
62+
email: "test@example.com",
63+
url: "https://objectstack.org",
64+
phone: "+15551234567",
65+
code: "{\"foo\": \"bar\"}",
66+
due_date: "2024-12-31",
67+
account: "1"
68+
}
69+
]
70+
}
71+
]
72+
}
73+
});

examples/kitchen-sink/package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "@object-ui/example-kitchen-sink",
3+
"version": "0.1.0",
4+
"description": "Kitchen Sink Example showing all ObjectStack UI capabilities",
5+
"private": true,
6+
"main": "dist/objectstack.json",
7+
"types": "src/index.ts",
8+
"exports": {
9+
".": "./src/index.ts",
10+
"./objectstack.config": "./objectstack.config.ts"
11+
},
12+
"scripts": {
13+
"build": "objectstack compile objectstack.config.ts dist/objectstack.json"
14+
},
15+
"dependencies": {
16+
"@objectstack/spec": "^0.7.2"
17+
},
18+
"devDependencies": {
19+
"typescript": "^5.0.0",
20+
"@objectstack/cli": "^0.7.2"
21+
}
22+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ObjectSchema, Field } from '@objectstack/spec/data';
2+
3+
// Minimal Account Object for Lookup reference
4+
export const AccountObject = ObjectSchema.create({
5+
name: 'account',
6+
label: 'Account',
7+
fields: {
8+
name: Field.text({ label: 'Account Name', required: true })
9+
}
10+
});
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { ObjectSchema, Field } from '@objectstack/spec/data';
2+
3+
export const KitchenSinkObject = ObjectSchema.create({
4+
name: 'kitchen_sink',
5+
label: 'Kitchen Sink',
6+
description: 'Shows all available field types for testing',
7+
fields: {
8+
// Basic Text
9+
name: Field.text({ label: 'Text (Name)', required: true, searchable: true }),
10+
description: Field.textarea({ label: 'Text Area' }),
11+
code: Field.code('json', { label: 'Code' }),
12+
password: Field.password({ label: 'Password' }),
13+
14+
// Numbers
15+
amount: Field.number({ label: 'Number (Int)', scale: 0 }),
16+
price: Field.currency({ label: 'Currency', scale: 2 }),
17+
percent: Field.percent({ label: 'Percentage', scale: 2 }),
18+
rating: Field.rating(5, { label: 'Rating' }),
19+
20+
// Date & Time
21+
due_date: Field.date({ label: 'Date' }),
22+
event_time: Field.datetime({ label: 'Date Time' }),
23+
24+
// Boolean
25+
is_active: Field.boolean({ label: 'Boolean (Switch)', defaultValue: true }),
26+
27+
// Selection
28+
category: Field.select({
29+
options: [
30+
{ label: 'Option A', value: 'opt_a' },
31+
{ label: 'Option B', value: 'opt_b' },
32+
{ label: 'Option C', value: 'opt_c' }
33+
],
34+
label: 'Select (Dropdown)'
35+
}),
36+
tags: Field.select({
37+
options: [
38+
{ label: 'Red', value: 'col_red' },
39+
{ label: 'Green', value: 'col_green' },
40+
{ label: 'Blue', value: 'col_blue' }
41+
],
42+
multiple: true,
43+
label: 'Multi Select'
44+
}),
45+
46+
// Contact & specialized
47+
email: Field.email({ label: 'Email' }),
48+
url: Field.url({ label: 'URL' }),
49+
phone: Field.phone({ label: 'Phone' }),
50+
avatar: Field.avatar({ label: 'Avatar' }),
51+
color: Field.color({ label: 'Color Picker' }),
52+
53+
// Rich Content
54+
rich_text: Field.richtext({ label: 'Rich Text' }),
55+
image: Field.image({ label: 'Image Upload' }),
56+
file: Field.file({ label: 'File Upload' }),
57+
signature: Field.signature({ label: 'Signature' }),
58+
59+
// Relationships
60+
// For these to work, 'account' must exist in the schema.
61+
// Since this is now isolated, we might need a mock 'account' object or rely on dynamic binding.
62+
// For now, we will assume 'account' might be present in the runtime environment or just leave it.
63+
// However, validation might fail if 'account' object isn't in scope of THIS stack.
64+
// Let's keep it but knowing we might need to add a dummy account object to this stack too for compilation.
65+
account: Field.lookup('account', { label: 'Lookup (Account)' }),
66+
67+
// Location
68+
location: Field.location({ label: 'Location' }),
69+
70+
// System/Readonly
71+
formula_field: Field.formula({
72+
expression: '{amount} * {price}',
73+
label: 'Formula (Amount * Price)'
74+
}),
75+
auto_number: Field.autonumber({ label: 'Auto Number' }),
76+
}
77+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"module": "ESNext",
5+
"moduleResolution": "bundler",
6+
"declaration": true,
7+
"strict": true,
8+
"skipLibCheck": true,
9+
"outDir": "./dist"
10+
},
11+
"include": ["src", "objectstack.config.ts"]
12+
}

0 commit comments

Comments
 (0)