Skip to content

Commit 7013316

Browse files
Copilothotlong
andcommitted
fix: Fix TypeScript errors in comprehensive CRM example
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent cd698e2 commit 7013316

14 files changed

Lines changed: 106 additions & 198 deletions

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"title": "AI Protocol"
2+
"title": "AI Protocol",
3+
"root": true
34
}

content/docs/references/data/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"title": "Data Protocol",
3+
"root": true,
34
"pages": [
45
"core",
56
"logic",

content/docs/references/meta.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"label": "Protocol Reference",
3-
"root": true,
43
"order": 100,
54
"pages": [
65
"data",

content/docs/references/system/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"title": "System Protocol",
3+
"root": true,
34
"pages": [
45
"identity",
56
"integration",

content/docs/references/ui/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"title": "UI Protocol",
3+
"root": true,
34
"pages": [
45
"app",
56
"views",

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@ export const Account = ObjectSchema.create({
2323
}),
2424

2525
// Select fields with custom options
26-
type: Field.select({
26+
type: {
27+
type: 'select',
2728
label: 'Account Type',
2829
options: [
2930
{ label: 'Prospect', value: 'prospect', color: '#FFA500', default: true },
3031
{ label: 'Customer', value: 'customer', color: '#00AA00' },
3132
{ label: 'Partner', value: 'partner', color: '#0000FF' },
3233
{ label: 'Former Customer', value: 'former', color: '#999999' },
3334
]
34-
}),
35+
},
3536

36-
industry: Field.select({
37+
industry: {
38+
type: 'select',
3739
label: 'Industry',
3840
options: [
3941
{ label: 'Technology', value: 'technology' },
@@ -43,7 +45,7 @@ export const Account = ObjectSchema.create({
4345
{ label: 'Manufacturing', value: 'manufacturing' },
4446
{ label: 'Education', value: 'education' },
4547
]
46-
}),
48+
},
4749

4850
// Number fields
4951
annual_revenue: Field.currency({

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

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

4040
// Case Management
41-
status: Field.select({
41+
status: {
42+
type: 'select',
4243
label: 'Status',
4344
required: true,
4445
options: [
@@ -50,9 +51,10 @@ export const Case = ObjectSchema.create({
5051
{ label: 'Resolved', value: 'resolved', color: '#00AA00' },
5152
{ label: 'Closed', value: 'closed', color: '#006400' },
5253
]
53-
}),
54+
},
5455

55-
priority: Field.select({
56+
priority: {
57+
type: 'select',
5658
label: 'Priority',
5759
required: true,
5860
options: [
@@ -61,27 +63,14 @@ export const Case = ObjectSchema.create({
6163
{ label: 'High', value: 'high', color: '#FF4500' },
6264
{ label: 'Critical', value: 'critical', color: '#FF0000' },
6365
]
64-
}),
66+
},
6567

66-
type: Field.select({
68+
type: Field.select(['Question', 'Problem', 'Feature Request', 'Bug'], {
6769
label: 'Case Type',
68-
options: [
69-
{ label: 'Question', value: 'question' },
70-
{ label: 'Problem', value: 'problem' },
71-
{ label: 'Feature Request', value: 'feature_request' },
72-
{ label: 'Bug', value: 'bug' },
73-
]
7470
}),
7571

76-
origin: Field.select({
72+
origin: Field.select(['Email', 'Phone', 'Web', 'Chat', 'Social Media'], {
7773
label: 'Case Origin',
78-
options: [
79-
{ label: 'Email', value: 'email' },
80-
{ label: 'Phone', value: 'phone' },
81-
{ label: 'Web', value: 'web' },
82-
{ label: 'Chat', value: 'chat' },
83-
{ label: 'Social Media', value: 'social' },
84-
]
8574
}),
8675

8776
// Assignment
@@ -144,15 +133,8 @@ export const Case = ObjectSchema.create({
144133
}),
145134

146135
// Customer satisfaction
147-
customer_rating: Field.select({
136+
customer_rating: Field.select(['⭐ Very Dissatisfied', '⭐⭐ Dissatisfied', '⭐⭐⭐ Neutral', '⭐⭐⭐⭐ Satisfied', '⭐⭐⭐⭐⭐ Very Satisfied'], {
148137
label: 'Customer Rating',
149-
options: [
150-
{ label: '⭐ Very Dissatisfied', value: '1' },
151-
{ label: '⭐⭐ Dissatisfied', value: '2' },
152-
{ label: '⭐⭐⭐ Neutral', value: '3' },
153-
{ label: '⭐⭐⭐⭐ Satisfied', value: '4' },
154-
{ label: '⭐⭐⭐⭐⭐ Very Satisfied', value: '5' },
155-
]
156138
}),
157139

158140
customer_feedback: Field.textarea({

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

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,8 @@ export const Contact = ObjectSchema.create({
99

1010
fields: {
1111
// Name fields
12-
salutation: Field.select({
12+
salutation: Field.select(['Mr.', 'Ms.', 'Mrs.', 'Dr.', 'Prof.'], {
1313
label: 'Salutation',
14-
options: [
15-
{ label: 'Mr.', value: 'mr' },
16-
{ label: 'Ms.', value: 'ms' },
17-
{ label: 'Mrs.', value: 'mrs' },
18-
{ label: 'Dr.', value: 'dr' },
19-
{ label: 'Prof.', value: 'prof' },
20-
]
2114
}),
2215
first_name: Field.text({
2316
label: 'First Name',
@@ -51,31 +44,23 @@ export const Contact = ObjectSchema.create({
5144
unique: true,
5245
}),
5346

54-
phone: Field.phone({
47+
phone: Field.text({
5548
label: 'Phone',
49+
format: 'phone',
5650
}),
5751

58-
mobile: Field.phone({
52+
mobile: Field.text({
5953
label: 'Mobile',
54+
format: 'phone',
6055
}),
6156

6257
// Professional Information
6358
title: Field.text({
6459
label: 'Job Title',
6560
}),
6661

67-
department: Field.select({
62+
department: Field.select(['Executive', 'Sales', 'Marketing', 'Engineering', 'Support', 'Finance', 'HR', 'Operations'], {
6863
label: 'Department',
69-
options: [
70-
{ label: 'Executive', value: 'executive' },
71-
{ label: 'Sales', value: 'sales' },
72-
{ label: 'Marketing', value: 'marketing' },
73-
{ label: 'Engineering', value: 'engineering' },
74-
{ label: 'Support', value: 'support' },
75-
{ label: 'Finance', value: 'finance' },
76-
{ label: 'HR', value: 'hr' },
77-
{ label: 'Operations', value: 'operations' },
78-
]
7964
}),
8065

8166
// Relationship fields
@@ -101,15 +86,8 @@ export const Contact = ObjectSchema.create({
10186
label: 'Birthdate',
10287
}),
10388

104-
lead_source: Field.select({
89+
lead_source: Field.select(['Web', 'Referral', 'Event', 'Partner', 'Advertisement'], {
10590
label: 'Lead Source',
106-
options: [
107-
{ label: 'Web', value: 'web' },
108-
{ label: 'Referral', value: 'referral' },
109-
{ label: 'Event', value: 'event' },
110-
{ label: 'Partner', value: 'partner' },
111-
{ label: 'Advertisement', value: 'advertisement' },
112-
]
11391
}),
11492

11593
description: Field.markdown({

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

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,8 @@ export const Lead = ObjectSchema.create({
99

1010
fields: {
1111
// Personal Information
12-
salutation: Field.select({
12+
salutation: Field.select(['Mr.', 'Ms.', 'Mrs.', 'Dr.'], {
1313
label: 'Salutation',
14-
options: [
15-
{ label: 'Mr.', value: 'mr' },
16-
{ label: 'Ms.', value: 'ms' },
17-
{ label: 'Mrs.', value: 'mrs' },
18-
{ label: 'Dr.', value: 'dr' },
19-
]
2014
}),
2115

2216
first_name: Field.text({
@@ -47,16 +41,8 @@ export const Lead = ObjectSchema.create({
4741
label: 'Job Title',
4842
}),
4943

50-
industry: Field.select({
44+
industry: Field.select(['Technology', 'Finance', 'Healthcare', 'Retail', 'Manufacturing', 'Education'], {
5145
label: 'Industry',
52-
options: [
53-
{ label: 'Technology', value: 'technology' },
54-
{ label: 'Finance', value: 'finance' },
55-
{ label: 'Healthcare', value: 'healthcare' },
56-
{ label: 'Retail', value: 'retail' },
57-
{ label: 'Manufacturing', value: 'manufacturing' },
58-
{ label: 'Education', value: 'education' },
59-
]
6046
}),
6147

6248
// Contact Information
@@ -66,20 +52,23 @@ export const Lead = ObjectSchema.create({
6652
unique: true,
6753
}),
6854

69-
phone: Field.phone({
55+
phone: Field.text({
7056
label: 'Phone',
57+
format: 'phone',
7158
}),
7259

73-
mobile: Field.phone({
60+
mobile: Field.text({
7461
label: 'Mobile',
62+
format: 'phone',
7563
}),
7664

7765
website: Field.url({
7866
label: 'Website',
7967
}),
8068

8169
// Lead Qualification
82-
status: Field.select({
70+
status: {
71+
type: 'select',
8372
label: 'Lead Status',
8473
required: true,
8574
options: [
@@ -89,27 +78,20 @@ export const Lead = ObjectSchema.create({
8978
{ label: 'Unqualified', value: 'unqualified', color: '#FF0000' },
9079
{ label: 'Converted', value: 'converted', color: '#00AA00' },
9180
]
92-
}),
81+
},
9382

94-
rating: Field.select({
83+
rating: {
84+
type: 'select',
9585
label: 'Rating',
9686
options: [
9787
{ label: 'Hot', value: 'hot', color: '#FF0000' },
9888
{ label: 'Warm', value: 'warm', color: '#FFA500' },
9989
{ label: 'Cold', value: 'cold', color: '#4169E1' },
10090
]
101-
}),
91+
},
10292

103-
lead_source: Field.select({
93+
lead_source: Field.select(['Web', 'Referral', 'Event', 'Partner', 'Advertisement', 'Cold Call'], {
10494
label: 'Lead Source',
105-
options: [
106-
{ label: 'Web', value: 'web' },
107-
{ label: 'Referral', value: 'referral' },
108-
{ label: 'Event', value: 'event' },
109-
{ label: 'Partner', value: 'partner' },
110-
{ label: 'Advertisement', value: 'advertisement' },
111-
{ label: 'Cold Call', value: 'cold_call' },
112-
]
11395
}),
11496

11597
// Assignment

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

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export const Opportunity = ObjectSchema.create({
4646
}),
4747

4848
// Sales Process
49-
stage: Field.select({
49+
stage: {
50+
type: 'select',
5051
label: 'Stage',
5152
required: true,
5253
options: [
@@ -58,7 +59,7 @@ export const Opportunity = ObjectSchema.create({
5859
{ label: 'Closed Won', value: 'closed_won', color: '#00AA00' },
5960
{ label: 'Closed Lost', value: 'closed_lost', color: '#FF0000' },
6061
]
61-
}),
62+
},
6263

6364
probability: Field.percent({
6465
label: 'Probability (%)',
@@ -79,36 +80,17 @@ export const Opportunity = ObjectSchema.create({
7980
}),
8081

8182
// Additional Classification
82-
type: Field.select({
83+
type: Field.select(['New Business', 'Existing Customer - Upgrade', 'Existing Customer - Renewal', 'Existing Customer - Expansion'], {
8384
label: 'Opportunity Type',
84-
options: [
85-
{ label: 'New Business', value: 'new_business' },
86-
{ label: 'Existing Customer - Upgrade', value: 'upgrade' },
87-
{ label: 'Existing Customer - Renewal', value: 'renewal' },
88-
{ label: 'Existing Customer - Expansion', value: 'expansion' },
89-
]
9085
}),
9186

92-
lead_source: Field.select({
87+
lead_source: Field.select(['Web', 'Referral', 'Event', 'Partner', 'Advertisement', 'Cold Call'], {
9388
label: 'Lead Source',
94-
options: [
95-
{ label: 'Web', value: 'web' },
96-
{ label: 'Referral', value: 'referral' },
97-
{ label: 'Event', value: 'event' },
98-
{ label: 'Partner', value: 'partner' },
99-
{ label: 'Advertisement', value: 'advertisement' },
100-
{ label: 'Cold Call', value: 'cold_call' },
101-
]
10289
}),
10390

10491
// Competitor Analysis
105-
competitors: Field.multiselect({
92+
competitors: Field.multiselect(['Competitor A', 'Competitor B', 'Competitor C'], {
10693
label: 'Competitors',
107-
options: [
108-
{ label: 'Competitor A', value: 'competitor_a' },
109-
{ label: 'Competitor B', value: 'competitor_b' },
110-
{ label: 'Competitor C', value: 'competitor_c' },
111-
],
11294
multiple: true,
11395
}),
11496

@@ -139,15 +121,8 @@ export const Opportunity = ObjectSchema.create({
139121
defaultValue: false,
140122
}),
141123

142-
forecast_category: Field.select({
124+
forecast_category: Field.select(['Pipeline', 'Best Case', 'Commit', 'Omitted', 'Closed'], {
143125
label: 'Forecast Category',
144-
options: [
145-
{ label: 'Pipeline', value: 'pipeline' },
146-
{ label: 'Best Case', value: 'best_case' },
147-
{ label: 'Commit', value: 'commit' },
148-
{ label: 'Omitted', value: 'omitted' },
149-
{ label: 'Closed', value: 'closed' },
150-
]
151126
}),
152127
},
153128

0 commit comments

Comments
 (0)