@nextsparkjs/theme-crm 0.1.0-beta.1 → 0.1.0-beta.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/LICENSE +21 -0
  2. package/config/app.config.ts +4 -5
  3. package/config/dashboard.config.ts +13 -0
  4. package/config/permissions.config.ts +11 -0
  5. package/entities/activities/api/docs.md +146 -0
  6. package/entities/activities/api/presets.ts +132 -0
  7. package/entities/campaigns/api/docs.md +140 -0
  8. package/entities/campaigns/api/presets.ts +147 -0
  9. package/entities/companies/api/docs.md +139 -0
  10. package/entities/companies/api/presets.ts +107 -0
  11. package/entities/contacts/api/docs.md +139 -0
  12. package/entities/contacts/api/presets.ts +98 -0
  13. package/entities/leads/api/docs.md +132 -0
  14. package/entities/leads/api/presets.ts +109 -0
  15. package/entities/notes/api/docs.md +135 -0
  16. package/entities/notes/api/presets.ts +115 -0
  17. package/entities/opportunities/api/docs.md +151 -0
  18. package/entities/opportunities/api/presets.ts +151 -0
  19. package/entities/pipelines/api/docs.md +145 -0
  20. package/entities/pipelines/api/presets.ts +118 -0
  21. package/entities/products/api/docs.md +137 -0
  22. package/entities/products/api/presets.ts +132 -0
  23. package/lib/selectors.ts +2 -3
  24. package/package.json +8 -3
  25. package/styles/globals.css +37 -1
  26. package/tests/cypress/e2e/api/activities/activities-crud.cy.ts +686 -0
  27. package/tests/cypress/e2e/api/campaigns/campaigns-crud.cy.ts +592 -0
  28. package/tests/cypress/e2e/api/companies/companies-crud.cy.ts +682 -0
  29. package/tests/cypress/e2e/api/contacts/contacts-crud.cy.ts +668 -0
  30. package/tests/cypress/e2e/api/leads/leads-crud.cy.ts +648 -0
  31. package/tests/cypress/e2e/api/notes/notes-crud.cy.ts +424 -0
  32. package/tests/cypress/e2e/api/opportunities/opportunities-crud.cy.ts +865 -0
  33. package/tests/cypress/e2e/api/pipelines/pipelines-crud.cy.ts +545 -0
  34. package/tests/cypress/e2e/api/products/products-crud.cy.ts +447 -0
  35. package/tests/cypress/e2e/ui/activities/activities-admin.cy.ts +268 -0
  36. package/tests/cypress/e2e/ui/activities/activities-member.cy.ts +257 -0
  37. package/tests/cypress/e2e/ui/activities/activities-owner.cy.ts +268 -0
  38. package/tests/cypress/e2e/ui/companies/companies-admin.cy.ts +188 -0
  39. package/tests/cypress/e2e/ui/companies/companies-member.cy.ts +166 -0
  40. package/tests/cypress/e2e/ui/companies/companies-owner.cy.ts +189 -0
  41. package/tests/cypress/e2e/ui/contacts/contacts-admin.cy.ts +252 -0
  42. package/tests/cypress/e2e/ui/contacts/contacts-member.cy.ts +224 -0
  43. package/tests/cypress/e2e/ui/contacts/contacts-owner.cy.ts +236 -0
  44. package/tests/cypress/e2e/ui/leads/leads-admin.cy.ts +286 -0
  45. package/tests/cypress/e2e/ui/leads/leads-member.cy.ts +193 -0
  46. package/tests/cypress/e2e/ui/leads/leads-owner.cy.ts +210 -0
  47. package/tests/cypress/e2e/ui/opportunities/opportunities-admin.cy.ts +197 -0
  48. package/tests/cypress/e2e/ui/opportunities/opportunities-member.cy.ts +229 -0
  49. package/tests/cypress/e2e/ui/opportunities/opportunities-owner.cy.ts +196 -0
  50. package/tests/cypress/e2e/ui/pipelines/pipelines-admin.cy.ts +320 -0
  51. package/tests/cypress/e2e/ui/pipelines/pipelines-member.cy.ts +262 -0
  52. package/tests/cypress/e2e/ui/pipelines/pipelines-owner.cy.ts +282 -0
  53. package/tests/cypress/fixtures/blocks.json +9 -0
  54. package/tests/cypress/fixtures/entities.json +240 -0
  55. package/tests/cypress/src/components/CRMDataTable.js +223 -0
  56. package/tests/cypress/src/components/CRMMobileNav.js +138 -0
  57. package/tests/cypress/src/components/CRMSidebar.js +145 -0
  58. package/tests/cypress/src/components/CRMTopBar.js +194 -0
  59. package/tests/cypress/src/components/DealCard.js +197 -0
  60. package/tests/cypress/src/components/EntityDetail.ts +290 -0
  61. package/tests/cypress/src/components/EntityForm.ts +357 -0
  62. package/tests/cypress/src/components/EntityList.ts +360 -0
  63. package/tests/cypress/src/components/PipelineKanban.js +204 -0
  64. package/tests/cypress/src/components/StageColumn.js +196 -0
  65. package/tests/cypress/src/components/index.js +13 -0
  66. package/tests/cypress/src/components/index.ts +22 -0
  67. package/tests/cypress/src/controllers/ActivityAPIController.ts +113 -0
  68. package/tests/cypress/src/controllers/BaseAPIController.ts +307 -0
  69. package/tests/cypress/src/controllers/CampaignAPIController.ts +114 -0
  70. package/tests/cypress/src/controllers/CompanyAPIController.ts +112 -0
  71. package/tests/cypress/src/controllers/ContactAPIController.ts +104 -0
  72. package/tests/cypress/src/controllers/LeadAPIController.ts +96 -0
  73. package/tests/cypress/src/controllers/NoteAPIController.ts +130 -0
  74. package/tests/cypress/src/controllers/OpportunityAPIController.ts +134 -0
  75. package/tests/cypress/src/controllers/PipelineAPIController.ts +116 -0
  76. package/tests/cypress/src/controllers/ProductAPIController.ts +113 -0
  77. package/tests/cypress/src/controllers/index.ts +35 -0
  78. package/tests/cypress/src/entities/ActivitiesPOM.ts +130 -0
  79. package/tests/cypress/src/entities/CompaniesPOM.ts +117 -0
  80. package/tests/cypress/src/entities/ContactsPOM.ts +117 -0
  81. package/tests/cypress/src/entities/LeadsPOM.ts +129 -0
  82. package/tests/cypress/src/entities/OpportunitiesPOM.ts +178 -0
  83. package/tests/cypress/src/entities/PipelinesPOM.ts +341 -0
  84. package/tests/cypress/src/entities/index.ts +31 -0
  85. package/tests/cypress/src/forms/OpportunityForm.js +316 -0
  86. package/tests/cypress/src/forms/PipelineForm.js +243 -0
  87. package/tests/cypress/src/forms/index.js +8 -0
  88. package/tests/cypress/src/index.js +22 -0
  89. package/tests/cypress/src/index.ts +68 -0
  90. package/tests/cypress/src/selectors.ts +50 -0
  91. package/tests/cypress/src/session-helpers.ts +176 -0
  92. package/tests/cypress/support/e2e.ts +90 -0
  93. package/tests/cypress.config.ts +154 -0
  94. package/tests/jest/__mocks__/jose.js +22 -0
  95. package/tests/jest/__mocks__/next-server.js +56 -0
  96. package/tests/jest/jest.config.cjs +131 -0
  97. package/tests/jest/setup.ts +170 -0
  98. package/tests/tsconfig.json +15 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 NextSpark
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -64,11 +64,10 @@ export const APP_CONFIG_OVERRIDES = {
64
64
  // =============================================================================
65
65
  api: {
66
66
  cors: {
67
- allowedOrigins: {
68
- development: [
69
- 'http://localhost:3000',
70
- 'http://localhost:5173',
71
- ],
67
+ // Theme-specific CORS origins (extends core defaults, does not replace)
68
+ // No additional origins needed for CRM theme - uses core defaults
69
+ additionalOrigins: {
70
+ development: [],
72
71
  production: [],
73
72
  },
74
73
  },
@@ -53,6 +53,19 @@ export const DASHBOARD_CONFIG = {
53
53
  devtoolsAccess: {
54
54
  enabled: true,
55
55
  },
56
+ /**
57
+ * Settings menu dropdown (gear icon)
58
+ */
59
+ settingsMenu: {
60
+ enabled: true,
61
+ links: [
62
+ {
63
+ label: 'navigation.patterns',
64
+ href: '/dashboard/patterns',
65
+ icon: 'layers',
66
+ },
67
+ ],
68
+ },
56
69
  userMenu: {
57
70
  enabled: true,
58
71
  showAvatar: true,
@@ -151,6 +151,17 @@ export const PERMISSIONS_CONFIG_OVERRIDES: ThemePermissionsConfig = {
151
151
  { action: 'update', label: 'Edit pipelines', description: 'Can modify pipeline stages', roles: ['owner'] },
152
152
  { action: 'delete', label: 'Delete pipelines', description: 'Can delete pipelines', roles: ['owner'], dangerous: true },
153
153
  ],
154
+
155
+ // ------------------------------------------
156
+ // PATTERNS
157
+ // ------------------------------------------
158
+ patterns: [
159
+ { action: 'create', label: 'Create Patterns', description: 'Can create reusable patterns', roles: ['owner', 'admin'] },
160
+ { action: 'read', label: 'View Patterns', description: 'Can view pattern details', roles: ['owner', 'admin', 'member', 'viewer'] },
161
+ { action: 'list', label: 'List Patterns', description: 'Can see the patterns list', roles: ['owner', 'admin', 'member', 'viewer'] },
162
+ { action: 'update', label: 'Edit Patterns', description: 'Can modify patterns', roles: ['owner', 'admin'] },
163
+ { action: 'delete', label: 'Delete Patterns', description: 'Can delete patterns', roles: ['owner', 'admin'], dangerous: true },
164
+ ],
154
165
  },
155
166
 
156
167
  // ==========================================
@@ -0,0 +1,146 @@
1
+ # Activities API
2
+
3
+ Manage tasks and activities related to CRM records. Activities track calls, emails, meetings, and other interactions with contacts, companies, and opportunities.
4
+
5
+ ## Overview
6
+
7
+ The Activities API allows you to create, read, update, and delete activity records. Activities help teams track their interactions and tasks across all CRM entities.
8
+
9
+ ## Authentication
10
+
11
+ All endpoints require authentication via:
12
+ - **Session cookie** (for browser-based requests)
13
+ - **API Key** header (for server-to-server requests)
14
+
15
+ ## Endpoints
16
+
17
+ ### List Activities
18
+ `GET /api/v1/activities`
19
+
20
+ Returns a paginated list of activities.
21
+
22
+ **Query Parameters:**
23
+ - `limit` (number, optional): Maximum records to return. Default: 20
24
+ - `offset` (number, optional): Number of records to skip. Default: 0
25
+ - `type` (string, optional): Filter by type (call, email, meeting, task, note, demo, presentation)
26
+ - `status` (string, optional): Filter by status (scheduled, in_progress, completed, cancelled, overdue)
27
+ - `contactId` (string, optional): Filter by contact
28
+ - `companyId` (string, optional): Filter by company
29
+ - `opportunityId` (string, optional): Filter by opportunity
30
+ - `search` (string, optional): Search by subject
31
+ - `sortBy` (string, optional): Field to sort by
32
+ - `sortOrder` (string, optional): Sort direction (asc, desc)
33
+
34
+ **Example Response:**
35
+ ```json
36
+ {
37
+ "data": [
38
+ {
39
+ "id": "activity_abc123",
40
+ "type": "meeting",
41
+ "subject": "Product Demo",
42
+ "description": "Demo of new features",
43
+ "status": "scheduled",
44
+ "priority": "high",
45
+ "dueDate": "2024-01-20T14:00:00Z",
46
+ "duration": 60,
47
+ "location": "Zoom",
48
+ "contactId": "contact_456",
49
+ "companyId": "company_xyz",
50
+ "assignedTo": "user_789",
51
+ "createdAt": "2024-01-15T10:30:00Z"
52
+ }
53
+ ],
54
+ "pagination": {
55
+ "total": 156,
56
+ "limit": 20,
57
+ "offset": 0
58
+ }
59
+ }
60
+ ```
61
+
62
+ ### Get Single Activity
63
+ `GET /api/v1/activities/[id]`
64
+
65
+ Returns a single activity by ID.
66
+
67
+ ### Create Activity
68
+ `POST /api/v1/activities`
69
+
70
+ Create a new activity record.
71
+
72
+ **Request Body:**
73
+ ```json
74
+ {
75
+ "type": "call",
76
+ "subject": "Follow-up call",
77
+ "description": "Discuss proposal",
78
+ "status": "scheduled",
79
+ "priority": "medium",
80
+ "dueDate": "2024-01-22T10:00:00Z",
81
+ "duration": 30,
82
+ "contactId": "contact_456"
83
+ }
84
+ ```
85
+
86
+ ### Update Activity
87
+ `PATCH /api/v1/activities/[id]`
88
+
89
+ Update an existing activity. Supports partial updates.
90
+
91
+ ### Delete Activity
92
+ `DELETE /api/v1/activities/[id]`
93
+
94
+ Delete an activity record.
95
+
96
+ ## Fields
97
+
98
+ | Field | Type | Required | Description |
99
+ |-------|------|----------|-------------|
100
+ | type | select | Yes | Type: call, email, meeting, task, note, demo, presentation |
101
+ | subject | text | Yes | Activity subject or title |
102
+ | description | textarea | No | Detailed description |
103
+ | status | select | No | Status: scheduled, in_progress, completed, cancelled, overdue |
104
+ | priority | select | No | Priority: low, medium, high, urgent |
105
+ | dueDate | datetime | No | When activity is due |
106
+ | completedAt | datetime | Auto | When activity was completed |
107
+ | duration | number | No | Duration in minutes |
108
+ | outcome | textarea | No | Activity outcome or result |
109
+ | location | text | No | Location for meetings |
110
+ | contactId | relation | No | Related contact (→ contacts) |
111
+ | companyId | relation | No | Related company (→ companies) |
112
+ | opportunityId | relation | No | Related opportunity (→ opportunities) |
113
+ | assignedTo | user | No | User assigned |
114
+ | createdAt | datetime | Auto | Creation timestamp |
115
+ | updatedAt | datetime | Auto | Last update timestamp |
116
+
117
+ ## Relationships
118
+
119
+ | Relation | Entity | Description |
120
+ |----------|--------|-------------|
121
+ | contactId | contacts | Related contact |
122
+ | companyId | companies | Related company |
123
+ | opportunityId | opportunities | Related opportunity |
124
+
125
+ ## Features
126
+
127
+ - **Searchable**: subject, description, outcome, location
128
+ - **Sortable**: Most fields
129
+ - **Bulk Operations**: Supported
130
+ - **Metadata**: Supported
131
+
132
+ ## Error Responses
133
+
134
+ | Status | Description |
135
+ |--------|-------------|
136
+ | 400 | Bad Request - Invalid parameters |
137
+ | 401 | Unauthorized - Missing or invalid auth |
138
+ | 403 | Forbidden - Insufficient permissions |
139
+ | 404 | Not Found - Activity doesn't exist |
140
+ | 422 | Validation Error - Invalid data |
141
+
142
+ ## Related APIs
143
+
144
+ - **[Contacts](/api/v1/contacts)** - Related contact
145
+ - **[Companies](/api/v1/companies)** - Related company
146
+ - **[Opportunities](/api/v1/opportunities)** - Related opportunity
@@ -0,0 +1,132 @@
1
+ /**
2
+ * API Presets for Activities Entity
3
+ */
4
+
5
+ import { defineApiEndpoint } from '@nextsparkjs/core/types/api-presets'
6
+
7
+ export default defineApiEndpoint({
8
+ summary: 'Track calls, meetings, tasks, and emails',
9
+ presets: [
10
+ {
11
+ id: 'list-all',
12
+ title: 'List All Activities',
13
+ description: 'Get all activities with pagination',
14
+ method: 'GET',
15
+ params: {
16
+ limit: 20
17
+ },
18
+ tags: ['read', 'list']
19
+ },
20
+ {
21
+ id: 'list-upcoming',
22
+ title: 'List Upcoming',
23
+ description: 'Get scheduled activities sorted by due date',
24
+ method: 'GET',
25
+ params: {
26
+ status: 'scheduled',
27
+ sortBy: 'dueDate',
28
+ sortOrder: 'asc'
29
+ },
30
+ tags: ['read', 'filter', 'priority']
31
+ },
32
+ {
33
+ id: 'list-overdue',
34
+ title: 'List Overdue',
35
+ description: 'Get overdue activities',
36
+ method: 'GET',
37
+ params: {
38
+ status: 'overdue'
39
+ },
40
+ tags: ['read', 'filter', 'priority']
41
+ },
42
+ {
43
+ id: 'list-by-type',
44
+ title: 'List by Type',
45
+ description: 'Get activities of a specific type',
46
+ method: 'GET',
47
+ params: {
48
+ type: '{{type}}'
49
+ },
50
+ tags: ['read', 'filter']
51
+ },
52
+ {
53
+ id: 'list-by-contact',
54
+ title: 'List by Contact',
55
+ description: 'Get activities for a specific contact',
56
+ method: 'GET',
57
+ params: {
58
+ contactId: '{{contactId}}'
59
+ },
60
+ tags: ['read', 'filter']
61
+ },
62
+ {
63
+ id: 'list-by-company',
64
+ title: 'List by Company',
65
+ description: 'Get activities for a specific company',
66
+ method: 'GET',
67
+ params: {
68
+ companyId: '{{companyId}}'
69
+ },
70
+ tags: ['read', 'filter']
71
+ },
72
+ {
73
+ id: 'list-by-opportunity',
74
+ title: 'List by Opportunity',
75
+ description: 'Get activities for a specific opportunity',
76
+ method: 'GET',
77
+ params: {
78
+ opportunityId: '{{opportunityId}}'
79
+ },
80
+ tags: ['read', 'filter']
81
+ },
82
+ {
83
+ id: 'create-call',
84
+ title: 'Create Call',
85
+ description: 'Create a new call activity',
86
+ method: 'POST',
87
+ payload: {
88
+ type: 'call',
89
+ subject: 'Follow-up call',
90
+ status: 'scheduled',
91
+ priority: 'medium'
92
+ },
93
+ tags: ['write', 'create']
94
+ },
95
+ {
96
+ id: 'create-meeting',
97
+ title: 'Create Meeting',
98
+ description: 'Create a new meeting activity',
99
+ method: 'POST',
100
+ payload: {
101
+ type: 'meeting',
102
+ subject: 'Meeting',
103
+ status: 'scheduled',
104
+ duration: 60
105
+ },
106
+ tags: ['write', 'create']
107
+ },
108
+ {
109
+ id: 'mark-completed',
110
+ title: 'Mark Completed',
111
+ description: 'Mark an activity as completed',
112
+ method: 'PATCH',
113
+ pathParams: {
114
+ id: '{{id}}'
115
+ },
116
+ payload: {
117
+ status: 'completed'
118
+ },
119
+ tags: ['write', 'update']
120
+ },
121
+ {
122
+ id: 'delete-activity',
123
+ title: 'Delete Activity',
124
+ description: 'Delete an activity record',
125
+ method: 'DELETE',
126
+ pathParams: {
127
+ id: '{{id}}'
128
+ },
129
+ tags: ['write', 'delete']
130
+ }
131
+ ]
132
+ })
@@ -0,0 +1,140 @@
1
+ # Campaigns API
2
+
3
+ Manage marketing campaigns with budget tracking, lead generation metrics, and ROI analysis.
4
+
5
+ ## Overview
6
+
7
+ The Campaigns API allows you to create, read, update, and delete campaign records. Campaigns track marketing efforts and their effectiveness in generating leads and revenue.
8
+
9
+ ## Authentication
10
+
11
+ All endpoints require authentication via:
12
+ - **Session cookie** (for browser-based requests)
13
+ - **API Key** header (for server-to-server requests)
14
+
15
+ ## Endpoints
16
+
17
+ ### List Campaigns
18
+ `GET /api/v1/campaigns`
19
+
20
+ Returns a paginated list of campaigns.
21
+
22
+ **Query Parameters:**
23
+ - `limit` (number, optional): Maximum records to return. Default: 20
24
+ - `offset` (number, optional): Number of records to skip. Default: 0
25
+ - `type` (string, optional): Filter by type (email, social, event, webinar, advertising, content, other)
26
+ - `status` (string, optional): Filter by status (planned, active, paused, completed, cancelled)
27
+ - `search` (string, optional): Search by name, objective
28
+ - `sortBy` (string, optional): Field to sort by
29
+ - `sortOrder` (string, optional): Sort direction (asc, desc)
30
+
31
+ **Example Response:**
32
+ ```json
33
+ {
34
+ "data": [
35
+ {
36
+ "id": "campaign_abc123",
37
+ "name": "Q1 Email Campaign",
38
+ "type": "email",
39
+ "status": "active",
40
+ "objective": "Generate leads for new product launch",
41
+ "startDate": "2024-01-01",
42
+ "endDate": "2024-03-31",
43
+ "budget": 10000,
44
+ "actualCost": 7500,
45
+ "targetLeads": 500,
46
+ "actualLeads": 350,
47
+ "targetRevenue": 100000,
48
+ "actualRevenue": 75000,
49
+ "roi": 900,
50
+ "channel": "email",
51
+ "assignedTo": "user_456",
52
+ "createdAt": "2024-01-15T10:30:00Z"
53
+ }
54
+ ],
55
+ "pagination": {
56
+ "total": 15,
57
+ "limit": 20,
58
+ "offset": 0
59
+ }
60
+ }
61
+ ```
62
+
63
+ ### Get Single Campaign
64
+ `GET /api/v1/campaigns/[id]`
65
+
66
+ Returns a single campaign by ID.
67
+
68
+ ### Create Campaign
69
+ `POST /api/v1/campaigns`
70
+
71
+ Create a new campaign record.
72
+
73
+ **Request Body:**
74
+ ```json
75
+ {
76
+ "name": "New Product Launch",
77
+ "type": "social",
78
+ "status": "planned",
79
+ "objective": "Create awareness for new product",
80
+ "startDate": "2024-04-01",
81
+ "endDate": "2024-05-31",
82
+ "budget": 15000,
83
+ "targetLeads": 300,
84
+ "channel": "social_media"
85
+ }
86
+ ```
87
+
88
+ ### Update Campaign
89
+ `PATCH /api/v1/campaigns/[id]`
90
+
91
+ Update an existing campaign. Supports partial updates.
92
+
93
+ ### Delete Campaign
94
+ `DELETE /api/v1/campaigns/[id]`
95
+
96
+ Delete a campaign record.
97
+
98
+ ## Fields
99
+
100
+ | Field | Type | Required | Description |
101
+ |-------|------|----------|-------------|
102
+ | name | text | Yes | Campaign name |
103
+ | type | select | No | Type: email, social, event, webinar, advertising, content, other |
104
+ | status | select | No | Status: planned, active, paused, completed, cancelled |
105
+ | objective | text | No | Campaign objective |
106
+ | description | textarea | No | Detailed campaign description |
107
+ | startDate | date | Yes | Campaign start date |
108
+ | endDate | date | Yes | Campaign end date |
109
+ | budget | number | No | Campaign budget |
110
+ | actualCost | number | No | Actual cost spent |
111
+ | targetAudience | text | No | Target audience description |
112
+ | targetLeads | number | No | Target number of leads |
113
+ | actualLeads | number | No | Actual leads generated |
114
+ | targetRevenue | number | No | Target revenue to generate |
115
+ | actualRevenue | number | No | Actual revenue generated |
116
+ | roi | number | Auto | Return on investment percentage |
117
+ | channel | select | No | Main channel: email, social_media, web, print, tv, radio, other |
118
+ | assignedTo | user | No | Campaign manager assigned |
119
+ | createdAt | datetime | Auto | Creation timestamp |
120
+ | updatedAt | datetime | Auto | Last update timestamp |
121
+
122
+ ## Features
123
+
124
+ - **Searchable**: name, objective, description, target audience
125
+ - **Sortable**: Most fields
126
+ - **Metadata**: Supported
127
+
128
+ ## Error Responses
129
+
130
+ | Status | Description |
131
+ |--------|-------------|
132
+ | 400 | Bad Request - Invalid parameters |
133
+ | 401 | Unauthorized - Missing or invalid auth |
134
+ | 403 | Forbidden - Insufficient permissions |
135
+ | 404 | Not Found - Campaign doesn't exist |
136
+ | 422 | Validation Error - Invalid data |
137
+
138
+ ## Related APIs
139
+
140
+ - **[Leads](/api/v1/leads)** - Leads generated by campaigns
@@ -0,0 +1,147 @@
1
+ /**
2
+ * API Presets for Campaigns Entity
3
+ */
4
+
5
+ import { defineApiEndpoint } from '@nextsparkjs/core/types/api-presets'
6
+
7
+ export default defineApiEndpoint({
8
+ summary: 'Manage marketing campaigns with budget and ROI tracking',
9
+ presets: [
10
+ {
11
+ id: 'list-all',
12
+ title: 'List All Campaigns',
13
+ description: 'Get all campaigns with pagination',
14
+ method: 'GET',
15
+ params: {
16
+ limit: 20
17
+ },
18
+ tags: ['read', 'list']
19
+ },
20
+ {
21
+ id: 'list-active',
22
+ title: 'List Active Campaigns',
23
+ description: 'Get all active campaigns',
24
+ method: 'GET',
25
+ params: {
26
+ status: 'active'
27
+ },
28
+ tags: ['read', 'filter']
29
+ },
30
+ {
31
+ id: 'list-planned',
32
+ title: 'List Planned Campaigns',
33
+ description: 'Get all planned campaigns',
34
+ method: 'GET',
35
+ params: {
36
+ status: 'planned'
37
+ },
38
+ tags: ['read', 'filter']
39
+ },
40
+ {
41
+ id: 'list-completed',
42
+ title: 'List Completed Campaigns',
43
+ description: 'Get all completed campaigns',
44
+ method: 'GET',
45
+ params: {
46
+ status: 'completed'
47
+ },
48
+ tags: ['read', 'filter']
49
+ },
50
+ {
51
+ id: 'list-by-type',
52
+ title: 'List by Type',
53
+ description: 'Get campaigns of a specific type',
54
+ method: 'GET',
55
+ params: {
56
+ type: '{{type}}'
57
+ },
58
+ tags: ['read', 'filter']
59
+ },
60
+ {
61
+ id: 'list-email',
62
+ title: 'List Email Campaigns',
63
+ description: 'Get all email campaigns',
64
+ method: 'GET',
65
+ params: {
66
+ type: 'email'
67
+ },
68
+ tags: ['read', 'filter']
69
+ },
70
+ {
71
+ id: 'search-by-name',
72
+ title: 'Search by Name',
73
+ description: 'Search campaigns by name',
74
+ method: 'GET',
75
+ params: {
76
+ search: '{{name}}'
77
+ },
78
+ tags: ['read', 'search']
79
+ },
80
+ {
81
+ id: 'create-campaign',
82
+ title: 'Create Campaign',
83
+ description: 'Create a new campaign',
84
+ method: 'POST',
85
+ payload: {
86
+ name: 'New Campaign',
87
+ type: 'email',
88
+ status: 'planned',
89
+ startDate: '2024-01-01',
90
+ endDate: '2024-03-31',
91
+ budget: 5000
92
+ },
93
+ tags: ['write', 'create']
94
+ },
95
+ {
96
+ id: 'update-metrics',
97
+ title: 'Update Metrics',
98
+ description: 'Update campaign performance metrics',
99
+ method: 'PATCH',
100
+ pathParams: {
101
+ id: '{{id}}'
102
+ },
103
+ payload: {
104
+ actualLeads: '{{leads}}',
105
+ actualRevenue: '{{revenue}}',
106
+ actualCost: '{{cost}}'
107
+ },
108
+ tags: ['write', 'update']
109
+ },
110
+ {
111
+ id: 'activate',
112
+ title: 'Activate Campaign',
113
+ description: 'Set campaign status to active',
114
+ method: 'PATCH',
115
+ pathParams: {
116
+ id: '{{id}}'
117
+ },
118
+ payload: {
119
+ status: 'active'
120
+ },
121
+ tags: ['write', 'update']
122
+ },
123
+ {
124
+ id: 'complete',
125
+ title: 'Complete Campaign',
126
+ description: 'Mark campaign as completed',
127
+ method: 'PATCH',
128
+ pathParams: {
129
+ id: '{{id}}'
130
+ },
131
+ payload: {
132
+ status: 'completed'
133
+ },
134
+ tags: ['write', 'update']
135
+ },
136
+ {
137
+ id: 'delete-campaign',
138
+ title: 'Delete Campaign',
139
+ description: 'Delete a campaign record',
140
+ method: 'DELETE',
141
+ pathParams: {
142
+ id: '{{id}}'
143
+ },
144
+ tags: ['write', 'delete']
145
+ }
146
+ ]
147
+ })