Skip to content

Commit 11c90b4

Browse files
authored
Merge pull request #41 from objectstack-ai/copilot/update-examples-to-compliance
2 parents a25fbc3 + 3b46de5 commit 11c90b4

File tree

7 files changed

+135
-73
lines changed

7 files changed

+135
-73
lines changed

examples/crm/objectstack.config.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default App.create({
1616
label: 'CRM App',
1717
description: 'Comprehensive CRM example demonstrating all ObjectStack Protocol features',
1818
version: '2.0.0',
19+
icon: 'briefcase',
1920

2021
// All objects in the app
2122
objects: [
@@ -85,17 +86,10 @@ export default App.create({
8586
// Reports
8687
reports: Object.values(CrmReports),
8788

88-
// App-level settings
89-
settings: {
90-
theme: {
91-
primaryColor: '#4169E1',
92-
logo: '/assets/crm-logo.png',
93-
},
94-
features: {
95-
enableGlobalSearch: true,
96-
enableNotifications: true,
97-
enableMobileApp: true,
98-
enableOfflineMode: true,
99-
}
89+
// App-level branding
90+
branding: {
91+
primaryColor: '#4169E1',
92+
logo: '/assets/crm-logo.png',
93+
favicon: '/assets/crm-favicon.ico',
10094
}
10195
});

examples/crm/src/domains/crm/account.object.ts

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const Account = ObjectSchema.create({
66
pluralLabel: 'Accounts',
77
icon: 'building',
88
description: 'Companies and organizations doing business with us',
9+
nameField: 'name',
910

1011
fields: {
1112
// AutoNumber field - Unique account identifier
@@ -23,19 +24,17 @@ export const Account = ObjectSchema.create({
2324
}),
2425

2526
// Select fields with custom options
26-
type: {
27-
type: 'select',
27+
type: Field.select({
2828
label: 'Account Type',
2929
options: [
3030
{ label: 'Prospect', value: 'prospect', color: '#FFA500', default: true },
3131
{ label: 'Customer', value: 'customer', color: '#00AA00' },
3232
{ label: 'Partner', value: 'partner', color: '#0000FF' },
3333
{ label: 'Former Customer', value: 'former', color: '#999999' },
3434
]
35-
},
35+
}),
3636

37-
industry: {
38-
type: 'select',
37+
industry: Field.select({
3938
label: 'Industry',
4039
options: [
4140
{ label: 'Technology', value: 'technology' },
@@ -45,7 +44,7 @@ export const Account = ObjectSchema.create({
4544
{ label: 'Manufacturing', value: 'manufacturing' },
4645
{ label: 'Education', value: 'education' },
4746
]
48-
},
47+
}),
4948

5049
// Number fields
5150
annual_revenue: Field.currency({
@@ -69,12 +68,18 @@ export const Account = ObjectSchema.create({
6968
label: 'Website',
7069
}),
7170

72-
// Address fields
73-
billing_street: Field.textarea({ label: 'Billing Street' }),
74-
billing_city: Field.text({ label: 'Billing City' }),
75-
billing_state: Field.text({ label: 'Billing State/Province' }),
76-
billing_postal_code: Field.text({ label: 'Billing Postal Code' }),
77-
billing_country: Field.text({ label: 'Billing Country' }),
71+
// Structured Address field (new field type)
72+
billing_address: Field.address({
73+
label: 'Billing Address',
74+
addressFormat: 'international',
75+
}),
76+
77+
// Office Location (new field type)
78+
office_location: Field.location({
79+
label: 'Office Location',
80+
displayMap: true,
81+
allowGeocoding: true,
82+
}),
7883

7984
// Relationship fields
8085
owner: Field.lookup('user', {
@@ -104,18 +109,27 @@ export const Account = ObjectSchema.create({
104109
readonly: true,
105110
}),
106111

107-
// Formula field - combines first and last name
108-
full_address: Field.formula({
109-
label: 'Full Billing Address',
110-
expression: 'CONCAT(billing_street, ", ", billing_city, ", ", billing_state, " ", billing_postal_code, ", ", billing_country)',
112+
// Brand color (new field type)
113+
brand_color: Field.color({
114+
label: 'Brand Color',
115+
colorFormat: 'hex',
116+
presetColors: ['#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF'],
111117
}),
112118
},
113119

120+
// Database indexes for performance
121+
indexes: [
122+
{ fields: ['name'], unique: false },
123+
{ fields: ['owner'], unique: false },
124+
{ fields: ['type', 'is_active'], unique: false },
125+
],
126+
114127
// Enable advanced features
115128
enable: {
116129
trackHistory: true, // Track field changes
117130
searchable: true, // Include in global search
118131
apiEnabled: true, // Expose via REST/GraphQL
132+
apiMethods: ['get', 'list', 'create', 'update', 'delete', 'search', 'export'], // Whitelist allowed API operations
119133
files: true, // Allow file attachments
120134
feedEnabled: true, // Enable activity feed/chatter
121135
trash: true, // Recycle bin support
@@ -176,12 +190,12 @@ export const Account = ObjectSchema.create({
176190
{
177191
label: 'Contact Details',
178192
columns: 2,
179-
fields: ['phone', 'website']
193+
fields: ['phone', 'website', 'brand_color']
180194
},
181195
{
182-
label: 'Billing Address',
196+
label: 'Location & Address',
183197
columns: 2,
184-
fields: ['billing_street', 'billing_city', 'billing_state', 'billing_postal_code', 'billing_country', 'full_address']
198+
fields: ['billing_address', 'office_location']
185199
},
186200
{
187201
label: 'Additional Information',

examples/crm/src/domains/crm/case.object.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ export const Case = ObjectSchema.create({
3838
}),
3939

4040
// Case Management
41-
status: {
42-
type: 'select',
41+
status: Field.select({
4342
label: 'Status',
4443
required: true,
4544
options: [
@@ -51,10 +50,9 @@ export const Case = ObjectSchema.create({
5150
{ label: 'Resolved', value: 'resolved', color: '#00AA00' },
5251
{ label: 'Closed', value: 'closed', color: '#006400' },
5352
]
54-
},
53+
}),
5554

56-
priority: {
57-
type: 'select',
55+
priority: Field.select({
5856
label: 'Priority',
5957
required: true,
6058
options: [
@@ -63,7 +61,7 @@ export const Case = ObjectSchema.create({
6361
{ label: 'High', value: 'high', color: '#FF4500' },
6462
{ label: 'Critical', value: 'critical', color: '#FF0000' },
6563
]
66-
},
64+
}),
6765

6866
type: Field.select(['Question', 'Problem', 'Feature Request', 'Bug'], {
6967
label: 'Case Type',
@@ -133,14 +131,21 @@ export const Case = ObjectSchema.create({
133131
}),
134132

135133
// Customer satisfaction
136-
customer_rating: Field.select(['⭐ Very Dissatisfied', '⭐⭐ Dissatisfied', '⭐⭐⭐ Neutral', '⭐⭐⭐⭐ Satisfied', '⭐⭐⭐⭐⭐ Very Satisfied'], {
137-
label: 'Customer Rating',
134+
customer_rating: Field.rating(5, {
135+
label: 'Customer Satisfaction',
136+
description: 'Customer satisfaction rating (1-5 stars)',
138137
}),
139138

140139
customer_feedback: Field.textarea({
141140
label: 'Customer Feedback',
142141
}),
143142

143+
// Customer signature (for case resolution acknowledgment)
144+
customer_signature: Field.signature({
145+
label: 'Customer Signature',
146+
description: 'Digital signature acknowledging case resolution',
147+
}),
148+
144149
// Internal notes
145150
internal_notes: Field.markdown({
146151
label: 'Internal Notes',
@@ -155,6 +160,15 @@ export const Case = ObjectSchema.create({
155160
}),
156161
},
157162

163+
// Database indexes for performance
164+
indexes: [
165+
{ fields: ['case_number'], unique: true },
166+
{ fields: ['account'], unique: false },
167+
{ fields: ['owner'], unique: false },
168+
{ fields: ['status'], unique: false },
169+
{ fields: ['priority'], unique: false },
170+
],
171+
158172
enable: {
159173
trackHistory: true,
160174
searchable: true,
@@ -245,7 +259,7 @@ export const Case = ObjectSchema.create({
245259
{
246260
label: 'Resolution',
247261
columns: 1,
248-
fields: ['resolution', 'customer_rating', 'customer_feedback'],
262+
fields: ['resolution', 'customer_rating', 'customer_feedback', 'customer_signature'],
249263
},
250264
{
251265
label: 'SLA & Metrics',

examples/crm/src/domains/crm/lead.object.ts

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ export const Lead = ObjectSchema.create({
6767
}),
6868

6969
// Lead Qualification
70-
status: {
71-
type: 'select',
70+
status: Field.select({
7271
label: 'Lead Status',
7372
required: true,
7473
options: [
@@ -78,17 +77,13 @@ export const Lead = ObjectSchema.create({
7877
{ label: 'Unqualified', value: 'unqualified', color: '#FF0000' },
7978
{ label: 'Converted', value: 'converted', color: '#00AA00' },
8079
]
81-
},
80+
}),
8281

83-
rating: {
84-
type: 'select',
85-
label: 'Rating',
86-
options: [
87-
{ label: 'Hot', value: 'hot', color: '#FF0000' },
88-
{ label: 'Warm', value: 'warm', color: '#FFA500' },
89-
{ label: 'Cold', value: 'cold', color: '#4169E1' },
90-
]
91-
},
82+
rating: Field.rating(5, {
83+
label: 'Lead Score',
84+
description: 'Lead quality score (1-5 stars)',
85+
allowHalf: true,
86+
}),
9287

9388
lead_source: Field.select(['Web', 'Referral', 'Event', 'Partner', 'Advertisement', 'Cold Call'], {
9489
label: 'Lead Source',
@@ -127,12 +122,11 @@ export const Lead = ObjectSchema.create({
127122
readonly: true,
128123
}),
129124

130-
// Address
131-
street: Field.textarea({ label: 'Street' }),
132-
city: Field.text({ label: 'City' }),
133-
state: Field.text({ label: 'State/Province' }),
134-
postal_code: Field.text({ label: 'Postal Code' }),
135-
country: Field.text({ label: 'Country' }),
125+
// Address (using new address field type)
126+
address: Field.address({
127+
label: 'Address',
128+
addressFormat: 'international',
129+
}),
136130

137131
// Additional Info
138132
annual_revenue: Field.currency({
@@ -148,6 +142,12 @@ export const Lead = ObjectSchema.create({
148142
label: 'Description',
149143
}),
150144

145+
// Custom notes with rich text formatting
146+
notes: Field.richtext({
147+
label: 'Notes',
148+
description: 'Rich text notes with formatting',
149+
}),
150+
151151
// Flags
152152
do_not_call: Field.boolean({
153153
label: 'Do Not Call',
@@ -160,6 +160,14 @@ export const Lead = ObjectSchema.create({
160160
}),
161161
},
162162

163+
// Database indexes for performance
164+
indexes: [
165+
{ fields: ['email'], unique: true },
166+
{ fields: ['owner'], unique: false },
167+
{ fields: ['status'], unique: false },
168+
{ fields: ['company'], unique: false },
169+
],
170+
163171
enable: {
164172
trackHistory: true,
165173
searchable: true,
@@ -193,11 +201,11 @@ export const Lead = ObjectSchema.create({
193201
sort: [{ field: 'created_date', order: 'desc' }],
194202
},
195203
hot_leads: {
196-
label: 'Hot Leads',
204+
label: 'High Score Leads',
197205
type: 'grid',
198-
columns: ['full_name', 'company', 'email', 'phone', 'status', 'owner'],
206+
columns: ['full_name', 'company', 'email', 'phone', 'status', 'rating', 'owner'],
199207
filter: [
200-
['rating', '=', 'hot'],
208+
['rating', '>=', 4],
201209
['is_converted', '=', false],
202210
],
203211
},
@@ -235,13 +243,13 @@ export const Lead = ObjectSchema.create({
235243
{
236244
label: 'Address',
237245
columns: 2,
238-
fields: ['street', 'city', 'state', 'postal_code', 'country'],
246+
fields: ['address'],
239247
},
240248
{
241249
label: 'Additional Information',
242250
columns: 2,
243251
collapsible: true,
244-
fields: ['do_not_call', 'email_opt_out', 'description'],
252+
fields: ['do_not_call', 'email_opt_out', 'description', 'notes'],
245253
},
246254
{
247255
label: 'Conversion Information',
@@ -273,10 +281,10 @@ export const Lead = ObjectSchema.create({
273281

274282
workflows: [
275283
{
276-
name: 'auto_qualify_hot_leads',
284+
name: 'auto_qualify_high_score_leads',
277285
objectName: 'lead',
278286
triggerType: 'on_create_or_update',
279-
criteria: 'rating = "hot" AND status = "new"',
287+
criteria: 'rating >= 4 AND status = "new"',
280288
active: true,
281289
actions: [
282290
{
@@ -288,16 +296,16 @@ export const Lead = ObjectSchema.create({
288296
],
289297
},
290298
{
291-
name: 'notify_owner_on_hot_lead',
299+
name: 'notify_owner_on_high_score_lead',
292300
objectName: 'lead',
293301
triggerType: 'on_create_or_update',
294-
criteria: 'ISCHANGED(rating) AND rating = "hot"',
302+
criteria: 'ISCHANGED(rating) AND rating >= 4.5',
295303
active: true,
296304
actions: [
297305
{
298306
name: 'email_owner',
299307
type: 'email_alert',
300-
template: 'hot_lead_notification',
308+
template: 'high_score_lead_notification',
301309
recipients: ['{owner.email}'],
302310
}
303311
],

0 commit comments

Comments
 (0)