Skip to content

Commit 3e847b5

Browse files
committed
feat: add task object schema with comprehensive fields and workflows
feat: create marketing user profile with specific object permissions feat: implement sales manager profile with full access to sales objects feat: add sales representative profile with limited access to sales objects feat: create service agent profile for customer support access feat: implement system admin profile with all permissions feat: add competitive intelligence RAG pipeline for market insights feat: create product information RAG pipeline for catalog specifications feat: implement sales knowledge RAG pipeline for team best practices feat: add support knowledge RAG pipeline for customer support issues feat: create account report for accounts by industry and type feat: implement case report for cases by status and priority feat: add contact report for contacts grouped by account feat: create lead report for leads by source and status feat: implement opportunity report for opportunities by stage feat: add task report for tasks grouped by owner feat: create account sharing rules for team and territory-based sharing feat: implement case sharing rule for escalated cases feat: add organization-wide defaults for object access levels feat: create opportunity sharing rule for high-value open opportunities feat: implement role hierarchy for CRM roles
1 parent 51f451c commit 3e847b5

66 files changed

Lines changed: 1851 additions & 3213 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 131 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,77 @@
11
import { defineStack } from '@objectstack/spec';
2-
import { App } from '@objectstack/spec/ui';
32

4-
// Sales Domain Objects
5-
import { Account } from './src/domains/sales/account.object';
6-
import { Contact } from './src/domains/sales/contact.object';
7-
import { Opportunity } from './src/domains/sales/opportunity.object';
8-
import { Lead } from './src/domains/sales/lead.object';
9-
import { Quote } from './src/domains/sales/quote.object';
10-
import { Contract } from './src/domains/sales/contract.object';
3+
// ─── Objects ────────────────────────────────────────────────────────
4+
import { Account } from './src/objects/account.object';
5+
import { Contact } from './src/objects/contact.object';
6+
import { Opportunity } from './src/objects/opportunity.object';
7+
import { Lead } from './src/objects/lead.object';
8+
import { Quote } from './src/objects/quote.object';
9+
import { Contract } from './src/objects/contract.object';
10+
import { Case } from './src/objects/case.object';
11+
import { Task } from './src/objects/task.object';
12+
import { Campaign } from './src/objects/campaign.object';
13+
import { Product } from './src/objects/product.object';
1114

12-
// Service Domain Objects
13-
import { Case } from './src/domains/service/case.object';
14-
import { Task } from './src/domains/service/task.object';
15+
// ─── APIs ───────────────────────────────────────────────────────────
16+
import { PipelineStatsApi } from './src/apis/pipeline-stats.api';
17+
import { LeadConvertApi } from './src/apis/lead-convert.api';
1518

16-
// Marketing Domain Objects
17-
import { Campaign } from './src/domains/marketing/campaign.object';
19+
// ─── Actions ────────────────────────────────────────────────────────
20+
import { ConvertLeadAction, CreateCampaignAction } from './src/actions/lead.actions';
21+
import { MarkPrimaryContactAction, SendEmailAction } from './src/actions/contact.actions';
22+
import { CloneOpportunityAction, MassUpdateStageAction } from './src/actions/opportunity.actions';
23+
import { EscalateCaseAction, CloseCaseAction } from './src/actions/case.actions';
24+
import { LogCallAction, ExportToCsvAction } from './src/actions/global.actions';
1825

19-
// Product Domain Objects
20-
import { Product } from './src/domains/products/product.object';
26+
// ─── Dashboards ─────────────────────────────────────────────────────
27+
import { SalesDashboard } from './src/dashboards/sales.dashboard';
28+
import { ServiceDashboard } from './src/dashboards/service.dashboard';
29+
import { ExecutiveDashboard } from './src/dashboards/executive.dashboard';
2130

22-
// APIs
23-
import { PipelineStatsApi, LeadConvertApi } from './src/server';
31+
// ─── Reports ────────────────────────────────────────────────────────
32+
import { OpportunitiesByStageReport, WonOpportunitiesByOwnerReport } from './src/reports/opportunity.report';
33+
import { AccountsByIndustryTypeReport } from './src/reports/account.report';
34+
import { CasesByStatusPriorityReport, SlaPerformanceReport } from './src/reports/case.report';
35+
import { LeadsBySourceReport } from './src/reports/lead.report';
36+
import { ContactsByAccountReport } from './src/reports/contact.report';
37+
import { TasksByOwnerReport } from './src/reports/task.report';
2438

25-
// UI Configuration
26-
import { CrmActions } from './src/ui/actions';
27-
import { CrmDashboards } from './src/ui/dashboards';
28-
import { CrmReports } from './src/ui/reports';
39+
// ─── Flows ──────────────────────────────────────────────────────────
40+
import { LeadConversionFlow } from './src/flows/lead-conversion.flow';
41+
import { OpportunityApprovalFlow } from './src/flows/opportunity-approval.flow';
42+
import { CaseEscalationFlow } from './src/flows/case-escalation.flow';
43+
import { QuoteGenerationFlow } from './src/flows/quote-generation.flow';
44+
import { CampaignEnrollmentFlow } from './src/flows/campaign-enrollment.flow';
2945

30-
// Security Configuration
31-
import { CrmProfiles } from './src/security/profiles';
32-
import { CrmSharingRules } from './src/security/sharing-rules';
46+
// ─── Agents ─────────────────────────────────────────────────────────
47+
import { SalesAssistantAgent } from './src/agents/sales.agent';
48+
import { ServiceAgent } from './src/agents/service.agent';
49+
import { LeadEnrichmentAgent } from './src/agents/lead-enrichment.agent';
50+
import { RevenueIntelligenceAgent } from './src/agents/revenue-intelligence.agent';
51+
import { EmailCampaignAgent } from './src/agents/email-campaign.agent';
3352

34-
// AI Configuration
35-
import { CrmAgents } from './src/ai/agents';
36-
import { CrmRagPipelines } from './src/ai/rag-pipelines';
53+
// ─── RAG Pipelines ─────────────────────────────────────────────────
54+
import { SalesKnowledgeRAG } from './src/rag/sales-knowledge.rag';
55+
import { SupportKnowledgeRAG } from './src/rag/support-knowledge.rag';
56+
import { ProductInfoRAG } from './src/rag/product-info.rag';
57+
import { CompetitiveIntelRAG } from './src/rag/competitive-intel.rag';
3758

38-
// Automation
39-
import { CrmFlows } from './src/automation/flows';
59+
// ─── Profiles ───────────────────────────────────────────────────────
60+
import { SalesRepProfile } from './src/profiles/sales-rep.profile';
61+
import { SalesManagerProfile } from './src/profiles/sales-manager.profile';
62+
import { ServiceAgentProfile } from './src/profiles/service-agent.profile';
63+
import { MarketingUserProfile } from './src/profiles/marketing-user.profile';
64+
import { SystemAdminProfile } from './src/profiles/system-admin.profile';
65+
66+
// ─── Sharing & Security ────────────────────────────────────────────
67+
import { OrganizationDefaults } from './src/sharing/defaults.sharing';
68+
import { AccountTeamSharingRule, TerritorySharingRules } from './src/sharing/account.sharing';
69+
import { OpportunitySalesSharingRule } from './src/sharing/opportunity.sharing';
70+
import { CaseEscalationSharingRule } from './src/sharing/case.sharing';
71+
import { RoleHierarchy } from './src/sharing/role-hierarchy';
72+
73+
// ─── App ────────────────────────────────────────────────────────────
74+
import { CrmApp } from './src/apps/crm.app';
4075

4176
export default defineStack({
4277
manifest: {
@@ -49,127 +84,81 @@ export default defineStack({
4984
repository: 'https://github.com/objectstack-ai/spec',
5085
license: 'MIT',
5186
},
52-
53-
// Data Model - Organized by Domain
87+
5488
objects: [
55-
// Sales Domain (6 objects)
56-
Account,
57-
Contact,
58-
Lead,
59-
Opportunity,
60-
Quote,
61-
Contract,
62-
63-
// Service Domain (2 objects)
64-
Case,
65-
Task,
66-
67-
// Marketing Domain (1 object)
89+
Account, Contact, Lead, Opportunity, Quote, Contract,
90+
Case, Task,
6891
Campaign,
69-
70-
// Product Domain (1 object)
7192
Product,
7293
],
73-
74-
// Custom APIs
94+
7595
apis: [
7696
PipelineStatsApi,
7797
LeadConvertApi,
7898
],
79-
80-
// User Interface
81-
actions: Object.values(CrmActions),
82-
dashboards: Object.values(CrmDashboards),
83-
reports: Object.values(CrmReports),
84-
85-
// Security Configuration
86-
profiles: Object.values(CrmProfiles),
99+
100+
actions: [
101+
ConvertLeadAction, CreateCampaignAction,
102+
MarkPrimaryContactAction, SendEmailAction,
103+
CloneOpportunityAction, MassUpdateStageAction,
104+
EscalateCaseAction, CloseCaseAction,
105+
LogCallAction, ExportToCsvAction,
106+
],
107+
108+
dashboards: [
109+
SalesDashboard,
110+
ServiceDashboard,
111+
ExecutiveDashboard,
112+
],
113+
114+
reports: [
115+
OpportunitiesByStageReport, WonOpportunitiesByOwnerReport,
116+
AccountsByIndustryTypeReport,
117+
CasesByStatusPriorityReport, SlaPerformanceReport,
118+
LeadsBySourceReport,
119+
ContactsByAccountReport,
120+
TasksByOwnerReport,
121+
],
122+
123+
flows: [
124+
LeadConversionFlow,
125+
OpportunityApprovalFlow,
126+
CaseEscalationFlow,
127+
QuoteGenerationFlow,
128+
CampaignEnrollmentFlow,
129+
],
130+
131+
agents: [
132+
SalesAssistantAgent,
133+
ServiceAgent,
134+
LeadEnrichmentAgent,
135+
RevenueIntelligenceAgent,
136+
EmailCampaignAgent,
137+
],
138+
139+
ragPipelines: [
140+
SalesKnowledgeRAG,
141+
SupportKnowledgeRAG,
142+
ProductInfoRAG,
143+
CompetitiveIntelRAG,
144+
],
145+
146+
profiles: [
147+
SalesRepProfile,
148+
SalesManagerProfile,
149+
ServiceAgentProfile,
150+
MarketingUserProfile,
151+
SystemAdminProfile,
152+
],
153+
87154
sharingRules: [
88-
CrmSharingRules.AccountTeamSharingRule,
89-
CrmSharingRules.OpportunitySalesSharingRule,
90-
CrmSharingRules.CaseEscalationSharingRule,
91-
...CrmSharingRules.TerritorySharingRules,
155+
AccountTeamSharingRule,
156+
OpportunitySalesSharingRule,
157+
CaseEscalationSharingRule,
158+
...TerritorySharingRules,
92159
],
93-
roleHierarchy: CrmSharingRules.RoleHierarchy,
94-
organizationDefaults: CrmSharingRules.OrganizationDefaults,
95-
96-
// AI & Automation
97-
agents: Object.values(CrmAgents),
98-
ragPipelines: Object.values(CrmRagPipelines),
99-
flows: Object.values(CrmFlows),
100-
101-
// Application Definition
102-
apps: [
103-
App.create({
104-
name: 'crm_enterprise',
105-
label: 'Enterprise CRM',
106-
icon: 'briefcase',
107-
branding: {
108-
primaryColor: '#4169E1',
109-
secondaryColor: '#00AA00',
110-
logo: '/assets/crm-logo.png',
111-
favicon: '/assets/crm-favicon.ico',
112-
},
113-
114-
// Enhanced Navigation Menu Structure
115-
navigation: [
116-
{
117-
id: 'group_sales',
118-
type: 'group',
119-
label: 'Sales',
120-
icon: 'chart-line',
121-
children: [
122-
{ id: 'nav_lead', type: 'object', objectName: 'lead', label: 'Leads', icon: 'user-plus' },
123-
{ id: 'nav_account', type: 'object', objectName: 'account', label: 'Accounts', icon: 'building' },
124-
{ id: 'nav_contact', type: 'object', objectName: 'contact', label: 'Contacts', icon: 'user' },
125-
{ id: 'nav_opportunity', type: 'object', objectName: 'opportunity', label: 'Opportunities', icon: 'bullseye' },
126-
{ id: 'nav_quote', type: 'object', objectName: 'quote', label: 'Quotes', icon: 'file-invoice' },
127-
{ id: 'nav_contract', type: 'object', objectName: 'contract', label: 'Contracts', icon: 'file-signature' },
128-
{ id: 'nav_sales_dashboard', type: 'dashboard', dashboardName: 'sales_dashboard', label: 'Sales Dashboard', icon: 'chart-bar' },
129-
]
130-
},
131-
{
132-
id: 'group_service',
133-
type: 'group',
134-
label: 'Service',
135-
icon: 'headset',
136-
children: [
137-
{ id: 'nav_case', type: 'object', objectName: 'case', label: 'Cases', icon: 'life-ring' },
138-
{ id: 'nav_task', type: 'object', objectName: 'task', label: 'Tasks', icon: 'tasks' },
139-
{ id: 'nav_service_dashboard', type: 'dashboard', dashboardName: 'service_dashboard', label: 'Service Dashboard', icon: 'chart-pie' },
140-
]
141-
},
142-
{
143-
id: 'group_marketing',
144-
type: 'group',
145-
label: 'Marketing',
146-
icon: 'megaphone',
147-
children: [
148-
{ id: 'nav_campaign', type: 'object', objectName: 'campaign', label: 'Campaigns', icon: 'bullhorn' },
149-
{ id: 'nav_lead_marketing', type: 'object', objectName: 'lead', label: 'Leads', icon: 'user-plus' },
150-
]
151-
},
152-
{
153-
id: 'group_products',
154-
type: 'group',
155-
label: 'Products',
156-
icon: 'box',
157-
children: [
158-
{ id: 'nav_product', type: 'object', objectName: 'product', label: 'Products', icon: 'box-open' },
159-
]
160-
},
161-
{
162-
id: 'group_analytics',
163-
type: 'group',
164-
label: 'Analytics',
165-
icon: 'chart-area',
166-
children: [
167-
{ id: 'nav_exec_dashboard', type: 'dashboard', dashboardName: 'executive_dashboard', label: 'Executive Dashboard', icon: 'tachometer-alt' },
168-
{ id: 'nav_analytics_sales_db', type: 'dashboard', dashboardName: 'sales_dashboard', label: 'Sales Analytics', icon: 'chart-line' },
169-
{ id: 'nav_analytics_service_db', type: 'dashboard', dashboardName: 'service_dashboard', label: 'Service Analytics', icon: 'chart-pie' },
170-
]
171-
}
172-
]
173-
})
174-
]
160+
roleHierarchy: RoleHierarchy,
161+
organizationDefaults: OrganizationDefaults,
162+
163+
apps: [CrmApp],
175164
});
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import type { Action } from '@objectstack/spec/ui';
2+
3+
/** Escalate Case */
4+
export const EscalateCaseAction: Action = {
5+
name: 'escalate_case',
6+
label: 'Escalate Case',
7+
icon: 'alert-triangle',
8+
type: 'modal',
9+
target: 'escalate_case_modal',
10+
locations: ['record_header', 'list_item'],
11+
visible: 'is_escalated = false AND is_closed = false',
12+
params: [
13+
{
14+
name: 'reason',
15+
label: 'Escalation Reason',
16+
type: 'textarea',
17+
required: true,
18+
}
19+
],
20+
confirmText: 'This will escalate the case to the escalation team. Continue?',
21+
successMessage: 'Case escalated successfully!',
22+
refreshAfter: true,
23+
};
24+
25+
/** Close Case */
26+
export const CloseCaseAction: Action = {
27+
name: 'close_case',
28+
label: 'Close Case',
29+
icon: 'check-circle',
30+
type: 'modal',
31+
target: 'close_case_modal',
32+
locations: ['record_header'],
33+
visible: 'is_closed = false',
34+
params: [
35+
{
36+
name: 'resolution',
37+
label: 'Resolution',
38+
type: 'textarea',
39+
required: true,
40+
}
41+
],
42+
confirmText: 'Are you sure you want to close this case?',
43+
successMessage: 'Case closed successfully!',
44+
refreshAfter: true,
45+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type { Action } from '@objectstack/spec/ui';
2+
3+
/** Mark Contact as Primary */
4+
export const MarkPrimaryContactAction: Action = {
5+
name: 'mark_primary',
6+
label: 'Mark as Primary Contact',
7+
icon: 'star',
8+
type: 'script',
9+
execute: 'markAsPrimaryContact',
10+
locations: ['record_header', 'list_item'],
11+
visible: 'is_primary = false',
12+
confirmText: 'Mark this contact as the primary contact for the account?',
13+
successMessage: 'Contact marked as primary!',
14+
refreshAfter: true,
15+
};
16+
17+
/** Send Email to Contact */
18+
export const SendEmailAction: Action = {
19+
name: 'send_email',
20+
label: 'Send Email',
21+
icon: 'mail',
22+
type: 'modal',
23+
target: 'email_composer',
24+
locations: ['record_header', 'list_item'],
25+
visible: 'email_opt_out = false',
26+
refreshAfter: false,
27+
};

0 commit comments

Comments
 (0)