Skip to content

Commit 3e2baa0

Browse files
Copilothuangyiirene
andcommitted
Convert inline field definitions to Field helpers and add API security
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent 991ad32 commit 3e2baa0

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

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

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

2626
// Select fields with custom options
27-
type: {
28-
type: 'select',
27+
type: Field.select({
2928
label: 'Account Type',
3029
options: [
3130
{ label: 'Prospect', value: 'prospect', color: '#FFA500', default: true },
3231
{ label: 'Customer', value: 'customer', color: '#00AA00' },
3332
{ label: 'Partner', value: 'partner', color: '#0000FF' },
3433
{ label: 'Former Customer', value: 'former', color: '#999999' },
3534
]
36-
},
35+
}),
3736

38-
industry: {
39-
type: 'select',
37+
industry: Field.select({
4038
label: 'Industry',
4139
options: [
4240
{ label: 'Technology', value: 'technology' },
@@ -46,7 +44,7 @@ export const Account = ObjectSchema.create({
4644
{ label: 'Manufacturing', value: 'manufacturing' },
4745
{ label: 'Education', value: 'education' },
4846
]
49-
},
47+
}),
5048

5149
// Number fields
5250
annual_revenue: Field.currency({
@@ -131,6 +129,7 @@ export const Account = ObjectSchema.create({
131129
trackHistory: true, // Track field changes
132130
searchable: true, // Include in global search
133131
apiEnabled: true, // Expose via REST/GraphQL
132+
apiMethods: ['get', 'list', 'create', 'update', 'delete', 'search', 'export'], // Whitelist allowed API operations
134133
files: true, // Allow file attachments
135134
feedEnabled: true, // Enable activity feed/chatter
136135
trash: true, // Recycle bin support

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

Lines changed: 4 additions & 6 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',

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

Lines changed: 2 additions & 3 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,7 +77,7 @@ export const Lead = ObjectSchema.create({
7877
{ label: 'Unqualified', value: 'unqualified', color: '#FF0000' },
7978
{ label: 'Converted', value: 'converted', color: '#00AA00' },
8079
]
81-
},
80+
}),
8281

8382
rating: Field.rating(5, {
8483
label: 'Lead Score',

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

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

4949
// Sales Process
50-
stage: {
51-
type: 'select',
50+
stage: Field.select({
5251
label: 'Stage',
5352
required: true,
5453
options: [
@@ -60,7 +59,7 @@ export const Opportunity = ObjectSchema.create({
6059
{ label: 'Closed Won', value: 'closed_won', color: '#00AA00' },
6160
{ label: 'Closed Lost', value: 'closed_lost', color: '#FF0000' },
6261
]
63-
},
62+
}),
6463

6564
probability: Field.percent({
6665
label: 'Probability (%)',
@@ -141,6 +140,7 @@ export const Opportunity = ObjectSchema.create({
141140
trackHistory: true, // Critical for tracking stage changes
142141
searchable: true,
143142
apiEnabled: true,
143+
apiMethods: ['get', 'list', 'create', 'update', 'delete', 'aggregate', 'search'], // Whitelist allowed API operations
144144
files: true, // Attach proposals, contracts
145145
feedEnabled: true, // Team collaboration
146146
trash: true,

0 commit comments

Comments
 (0)