Skip to content

Commit 97cec06

Browse files
committed
Add CRM and Todo app examples with corresponding schemas and documentation
1 parent bc9d164 commit 97cec06

19 files changed

Lines changed: 365 additions & 13 deletions

File tree

content/docs/references/data/core/Field.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ description: Field Schema Reference
77

88
| Property | Type | Required | Description |
99
| :--- | :--- | :--- | :--- |
10-
| **name** | `string` | | Machine name (snake_case) |
11-
| **label** | `string` | | Human readable label |
10+
| **name** | `string` | optional | Machine name (snake_case) |
11+
| **label** | `string` | optional | Human readable label |
1212
| **type** | `Enum<'text' \| 'textarea' \| 'email' \| 'url' \| 'phone' \| 'password' \| 'markdown' \| 'html' \| 'number' \| 'currency' \| 'percent' \| 'date' \| 'datetime' \| 'time' \| 'boolean' \| 'select' \| 'multiselect' \| 'lookup' \| 'master_detail' \| 'image' \| 'file' \| 'avatar' \| 'formula' \| 'summary' \| 'autonumber'>` || Field Data Type |
1313
| **description** | `string` | optional | Tooltip/Help text |
14+
| **format** | `string` | optional | Format string (e.g. email, phone) |
1415
| **required** | `boolean` | optional | Is required |
16+
| **searchable** | `boolean` | optional | Is searchable |
1517
| **multiple** | `boolean` | optional | Allow multiple values (Stores as Array/JSON). Applicable for select, lookup, file, image. |
1618
| **unique** | `boolean` | optional | Is unique constraint |
1719
| **defaultValue** | `any` | optional | Default value |

examples/crm/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# ObjectStack CRM Example
2+
3+
This is a reference implementation of a simple CRM schema using the ObjectStack Protocol.
4+
5+
## Structure
6+
7+
* `src/domains/crm/` - Contains the Object definitions (`Account`, `Contact`, `Opportunity`).
8+
* `objectstack.config.ts` - The application manifest that bundles the objects into an app.
9+
10+
## Usage
11+
12+
This package is part of the `examples` workspace. To build it and verify types:
13+
14+
```bash
15+
pnpm build
16+
```

examples/crm/objectstack.config.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { App } from '@objectstack/spec';
2+
import { Account } from './src/domains/crm/account.object';
3+
import { Contact } from './src/domains/crm/contact.object';
4+
import { Opportunity } from './src/domains/crm/opportunity.object';
5+
6+
export default App.create({
7+
name: 'crm_example',
8+
label: 'CRM App',
9+
description: 'A simple CRM example demonstrating ObjectStack Protocol',
10+
version: '1.0.0',
11+
objects: [
12+
Account,
13+
Contact,
14+
Opportunity
15+
],
16+
menus: [
17+
{
18+
label: 'Sales',
19+
items: [
20+
{ type: 'object', object: 'account' },
21+
{ type: 'object', object: 'contact' },
22+
{ type: 'object', object: 'opportunity' }
23+
]
24+
}
25+
]
26+
});

examples/crm/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "@objectstack/example-crm",
3+
"version": "1.0.0",
4+
"description": "Example CRM implementation using ObjectStack Protocol",
5+
"private": true,
6+
"scripts": {
7+
"build": "tsc",
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"dependencies": {
11+
"@objectstack/spec": "workspace:*"
12+
},
13+
"devDependencies": {
14+
"typescript": "^5.0.0"
15+
}
16+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { ObjectSchema, Field } from '@objectstack/spec';
2+
3+
export const Account = ObjectSchema.create({
4+
name: 'account',
5+
label: 'Account',
6+
icon: 'building',
7+
fields: {
8+
name: Field.text({
9+
label: 'Account Name',
10+
required: true,
11+
searchable: true
12+
}),
13+
type: Field.select([
14+
'Prospect',
15+
'Customer',
16+
'Partner'
17+
]),
18+
industry: Field.select([
19+
'Technology',
20+
'Finance',
21+
'Healthcare',
22+
'Retail'
23+
]),
24+
annual_revenue: Field.currency({ scale: 2 }),
25+
website: Field.url(),
26+
owner: Field.lookup('user'),
27+
},
28+
list_views: {
29+
all: {
30+
label: 'All Accounts',
31+
columns: ['name', 'type', 'industry', 'annual_revenue', 'owner']
32+
},
33+
my_accounts: {
34+
label: 'My Accounts',
35+
columns: ['name', 'type', 'industry'],
36+
filters: [['owner', '=', '{current_user}']]
37+
}
38+
}
39+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ObjectSchema, Field } from '@objectstack/spec';
2+
3+
export const Contact = ObjectSchema.create({
4+
name: 'contact',
5+
label: 'Contact',
6+
icon: 'user',
7+
fields: {
8+
first_name: Field.text({ required: true }),
9+
last_name: Field.text({ required: true }),
10+
email: Field.text({ format: 'email' }),
11+
phone: Field.text({ format: 'phone' }),
12+
13+
// Relationship: Link to Account
14+
account: Field.master_detail('account', {
15+
label: 'Account',
16+
required: true,
17+
writeRequiresMasterRead: true
18+
}),
19+
20+
title: Field.text(),
21+
}
22+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { ObjectSchema, Field } from '@objectstack/spec';
2+
3+
export const Opportunity = ObjectSchema.create({
4+
name: 'opportunity',
5+
label: 'Opportunity',
6+
icon: 'dollar-sign',
7+
fields: {
8+
name: Field.text({ required: true }),
9+
account: Field.lookup('account', { required: true }),
10+
amount: Field.currency(),
11+
close_date: Field.date(),
12+
13+
stage: Field.select([
14+
'Prospecting',
15+
'Qualification',
16+
'Proposal',
17+
'Negotiation',
18+
'Closed Won',
19+
'Closed Lost'
20+
]),
21+
22+
probability: Field.percent(),
23+
},
24+
enable: {
25+
trackHistory: true, // Track history of Stage changes
26+
// workflow: true
27+
}
28+
});

examples/crm/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "NodeNext",
5+
"moduleResolution": "NodeNext",
6+
"strict": true,
7+
"esModuleInterop": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"skipLibCheck": true,
10+
"outDir": "./dist"
11+
},
12+
"include": ["src/**/*"]
13+
}

examples/todo/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# ObjectStack CRM Example
2+
3+
This is a reference implementation of a simple CRM schema using the ObjectStack Protocol.
4+
5+
## Structure
6+
7+
* `src/domains/crm/` - Contains the Object definitions (`Account`, `Contact`, `Opportunity`).
8+
* `objectstack.config.ts` - The application manifest that bundles the objects into an app.
9+
10+
## Usage
11+
12+
This package is part of the `examples` workspace. To build it and verify types:
13+
14+
```bash
15+
pnpm build
16+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { App } from '@objectstack/spec';
2+
import { Account } from './src/domains/crm/account.object';
3+
import { Contact } from './src/domains/crm/contact.object';
4+
import { Opportunity } from './src/domains/crm/opportunity.object';
5+
6+
export default App.create({
7+
name: 'crm_example',
8+
label: 'CRM App',
9+
description: 'A simple CRM example demonstrating ObjectStack Protocol',
10+
version: '1.0.0',
11+
objects: [
12+
Account,
13+
Contact,
14+
Opportunity
15+
],
16+
menus: [
17+
{
18+
label: 'Sales',
19+
items: [
20+
{ type: 'object', object: 'account' },
21+
{ type: 'object', object: 'contact' },
22+
{ type: 'object', object: 'opportunity' }
23+
]
24+
}
25+
]
26+
});

0 commit comments

Comments
 (0)