@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.
- package/LICENSE +21 -0
- package/config/app.config.ts +4 -5
- package/config/dashboard.config.ts +13 -0
- package/config/permissions.config.ts +11 -0
- package/entities/activities/api/docs.md +146 -0
- package/entities/activities/api/presets.ts +132 -0
- package/entities/campaigns/api/docs.md +140 -0
- package/entities/campaigns/api/presets.ts +147 -0
- package/entities/companies/api/docs.md +139 -0
- package/entities/companies/api/presets.ts +107 -0
- package/entities/contacts/api/docs.md +139 -0
- package/entities/contacts/api/presets.ts +98 -0
- package/entities/leads/api/docs.md +132 -0
- package/entities/leads/api/presets.ts +109 -0
- package/entities/notes/api/docs.md +135 -0
- package/entities/notes/api/presets.ts +115 -0
- package/entities/opportunities/api/docs.md +151 -0
- package/entities/opportunities/api/presets.ts +151 -0
- package/entities/pipelines/api/docs.md +145 -0
- package/entities/pipelines/api/presets.ts +118 -0
- package/entities/products/api/docs.md +137 -0
- package/entities/products/api/presets.ts +132 -0
- package/lib/selectors.ts +2 -3
- package/package.json +8 -3
- package/styles/globals.css +37 -1
- package/tests/cypress/e2e/api/activities/activities-crud.cy.ts +686 -0
- package/tests/cypress/e2e/api/campaigns/campaigns-crud.cy.ts +592 -0
- package/tests/cypress/e2e/api/companies/companies-crud.cy.ts +682 -0
- package/tests/cypress/e2e/api/contacts/contacts-crud.cy.ts +668 -0
- package/tests/cypress/e2e/api/leads/leads-crud.cy.ts +648 -0
- package/tests/cypress/e2e/api/notes/notes-crud.cy.ts +424 -0
- package/tests/cypress/e2e/api/opportunities/opportunities-crud.cy.ts +865 -0
- package/tests/cypress/e2e/api/pipelines/pipelines-crud.cy.ts +545 -0
- package/tests/cypress/e2e/api/products/products-crud.cy.ts +447 -0
- package/tests/cypress/e2e/ui/activities/activities-admin.cy.ts +268 -0
- package/tests/cypress/e2e/ui/activities/activities-member.cy.ts +257 -0
- package/tests/cypress/e2e/ui/activities/activities-owner.cy.ts +268 -0
- package/tests/cypress/e2e/ui/companies/companies-admin.cy.ts +188 -0
- package/tests/cypress/e2e/ui/companies/companies-member.cy.ts +166 -0
- package/tests/cypress/e2e/ui/companies/companies-owner.cy.ts +189 -0
- package/tests/cypress/e2e/ui/contacts/contacts-admin.cy.ts +252 -0
- package/tests/cypress/e2e/ui/contacts/contacts-member.cy.ts +224 -0
- package/tests/cypress/e2e/ui/contacts/contacts-owner.cy.ts +236 -0
- package/tests/cypress/e2e/ui/leads/leads-admin.cy.ts +286 -0
- package/tests/cypress/e2e/ui/leads/leads-member.cy.ts +193 -0
- package/tests/cypress/e2e/ui/leads/leads-owner.cy.ts +210 -0
- package/tests/cypress/e2e/ui/opportunities/opportunities-admin.cy.ts +197 -0
- package/tests/cypress/e2e/ui/opportunities/opportunities-member.cy.ts +229 -0
- package/tests/cypress/e2e/ui/opportunities/opportunities-owner.cy.ts +196 -0
- package/tests/cypress/e2e/ui/pipelines/pipelines-admin.cy.ts +320 -0
- package/tests/cypress/e2e/ui/pipelines/pipelines-member.cy.ts +262 -0
- package/tests/cypress/e2e/ui/pipelines/pipelines-owner.cy.ts +282 -0
- package/tests/cypress/fixtures/blocks.json +9 -0
- package/tests/cypress/fixtures/entities.json +240 -0
- package/tests/cypress/src/components/CRMDataTable.js +223 -0
- package/tests/cypress/src/components/CRMMobileNav.js +138 -0
- package/tests/cypress/src/components/CRMSidebar.js +145 -0
- package/tests/cypress/src/components/CRMTopBar.js +194 -0
- package/tests/cypress/src/components/DealCard.js +197 -0
- package/tests/cypress/src/components/EntityDetail.ts +290 -0
- package/tests/cypress/src/components/EntityForm.ts +357 -0
- package/tests/cypress/src/components/EntityList.ts +360 -0
- package/tests/cypress/src/components/PipelineKanban.js +204 -0
- package/tests/cypress/src/components/StageColumn.js +196 -0
- package/tests/cypress/src/components/index.js +13 -0
- package/tests/cypress/src/components/index.ts +22 -0
- package/tests/cypress/src/controllers/ActivityAPIController.ts +113 -0
- package/tests/cypress/src/controllers/BaseAPIController.ts +307 -0
- package/tests/cypress/src/controllers/CampaignAPIController.ts +114 -0
- package/tests/cypress/src/controllers/CompanyAPIController.ts +112 -0
- package/tests/cypress/src/controllers/ContactAPIController.ts +104 -0
- package/tests/cypress/src/controllers/LeadAPIController.ts +96 -0
- package/tests/cypress/src/controllers/NoteAPIController.ts +130 -0
- package/tests/cypress/src/controllers/OpportunityAPIController.ts +134 -0
- package/tests/cypress/src/controllers/PipelineAPIController.ts +116 -0
- package/tests/cypress/src/controllers/ProductAPIController.ts +113 -0
- package/tests/cypress/src/controllers/index.ts +35 -0
- package/tests/cypress/src/entities/ActivitiesPOM.ts +130 -0
- package/tests/cypress/src/entities/CompaniesPOM.ts +117 -0
- package/tests/cypress/src/entities/ContactsPOM.ts +117 -0
- package/tests/cypress/src/entities/LeadsPOM.ts +129 -0
- package/tests/cypress/src/entities/OpportunitiesPOM.ts +178 -0
- package/tests/cypress/src/entities/PipelinesPOM.ts +341 -0
- package/tests/cypress/src/entities/index.ts +31 -0
- package/tests/cypress/src/forms/OpportunityForm.js +316 -0
- package/tests/cypress/src/forms/PipelineForm.js +243 -0
- package/tests/cypress/src/forms/index.js +8 -0
- package/tests/cypress/src/index.js +22 -0
- package/tests/cypress/src/index.ts +68 -0
- package/tests/cypress/src/selectors.ts +50 -0
- package/tests/cypress/src/session-helpers.ts +176 -0
- package/tests/cypress/support/e2e.ts +90 -0
- package/tests/cypress.config.ts +154 -0
- package/tests/jest/__mocks__/jose.js +22 -0
- package/tests/jest/__mocks__/next-server.js +56 -0
- package/tests/jest/jest.config.cjs +131 -0
- package/tests/jest/setup.ts +170 -0
- package/tests/tsconfig.json +15 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Companies API
|
|
2
|
+
|
|
3
|
+
Manage customer and prospect companies. Companies serve as the central entity linking contacts, opportunities, and activities.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Companies API allows you to create, read, update, and delete company records. Companies represent organizations that your team works with and can be categorized by type (prospect, customer, partner, etc.).
|
|
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 Companies
|
|
18
|
+
`GET /api/v1/companies`
|
|
19
|
+
|
|
20
|
+
Returns a paginated list of companies.
|
|
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 (prospect, customer, partner, competitor, vendor, other)
|
|
26
|
+
- `rating` (string, optional): Filter by rating (hot, warm, cold)
|
|
27
|
+
- `search` (string, optional): Search by name, email, industry
|
|
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": "company_abc123",
|
|
37
|
+
"name": "Acme Corporation",
|
|
38
|
+
"legalName": "Acme Corp Inc.",
|
|
39
|
+
"website": "https://acme.com",
|
|
40
|
+
"email": "info@acme.com",
|
|
41
|
+
"phone": "+1-555-0100",
|
|
42
|
+
"industry": "Technology",
|
|
43
|
+
"type": "customer",
|
|
44
|
+
"size": "201-500",
|
|
45
|
+
"rating": "hot",
|
|
46
|
+
"country": "US",
|
|
47
|
+
"assignedTo": "user_456",
|
|
48
|
+
"createdAt": "2024-01-15T10:30:00Z"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"pagination": {
|
|
52
|
+
"total": 89,
|
|
53
|
+
"limit": 20,
|
|
54
|
+
"offset": 0
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Get Single Company
|
|
60
|
+
`GET /api/v1/companies/[id]`
|
|
61
|
+
|
|
62
|
+
Returns a single company by ID.
|
|
63
|
+
|
|
64
|
+
### Create Company
|
|
65
|
+
`POST /api/v1/companies`
|
|
66
|
+
|
|
67
|
+
Create a new company record.
|
|
68
|
+
|
|
69
|
+
**Request Body:**
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"name": "New Tech Inc",
|
|
73
|
+
"email": "info@newtech.com",
|
|
74
|
+
"website": "https://newtech.com",
|
|
75
|
+
"industry": "Software",
|
|
76
|
+
"type": "prospect",
|
|
77
|
+
"size": "51-200"
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Update Company
|
|
82
|
+
`PATCH /api/v1/companies/[id]`
|
|
83
|
+
|
|
84
|
+
Update an existing company. Supports partial updates.
|
|
85
|
+
|
|
86
|
+
### Delete Company
|
|
87
|
+
`DELETE /api/v1/companies/[id]`
|
|
88
|
+
|
|
89
|
+
Delete a company record.
|
|
90
|
+
|
|
91
|
+
## Fields
|
|
92
|
+
|
|
93
|
+
| Field | Type | Required | Description |
|
|
94
|
+
|-------|------|----------|-------------|
|
|
95
|
+
| name | text | Yes | Company display name |
|
|
96
|
+
| legalName | text | No | Legal registered name |
|
|
97
|
+
| taxId | text | No | Tax identification number |
|
|
98
|
+
| website | url | No | Company website URL |
|
|
99
|
+
| email | email | No | General company email |
|
|
100
|
+
| phone | text | No | Main phone number |
|
|
101
|
+
| industry | text | No | Industry sector |
|
|
102
|
+
| type | select | No | Type: prospect, customer, partner, competitor, vendor, other |
|
|
103
|
+
| size | select | No | Size: 1-10, 11-50, 51-200, 201-500, 500+ |
|
|
104
|
+
| annualRevenue | number | No | Annual revenue |
|
|
105
|
+
| address | textarea | No | Street address |
|
|
106
|
+
| city | text | No | City |
|
|
107
|
+
| state | text | No | State or province |
|
|
108
|
+
| country | text | No | Country |
|
|
109
|
+
| postalCode | text | No | Postal or ZIP code |
|
|
110
|
+
| logo | url | No | Company logo URL |
|
|
111
|
+
| rating | select | No | Sales rating: hot, warm, cold |
|
|
112
|
+
| assignedTo | user | No | Account manager assigned |
|
|
113
|
+
| createdAt | datetime | Auto | Creation timestamp |
|
|
114
|
+
| updatedAt | datetime | Auto | Last update timestamp |
|
|
115
|
+
|
|
116
|
+
## Features
|
|
117
|
+
|
|
118
|
+
- **Searchable**: name, legal name, tax ID, email, phone, industry, address, city, state, country, postal code
|
|
119
|
+
- **Sortable**: Most fields
|
|
120
|
+
- **Bulk Operations**: Supported
|
|
121
|
+
- **Import/Export**: Supported
|
|
122
|
+
- **Metadata**: Supported
|
|
123
|
+
|
|
124
|
+
## Error Responses
|
|
125
|
+
|
|
126
|
+
| Status | Description |
|
|
127
|
+
|--------|-------------|
|
|
128
|
+
| 400 | Bad Request - Invalid parameters |
|
|
129
|
+
| 401 | Unauthorized - Missing or invalid auth |
|
|
130
|
+
| 403 | Forbidden - Insufficient permissions |
|
|
131
|
+
| 404 | Not Found - Company doesn't exist |
|
|
132
|
+
| 422 | Validation Error - Invalid data |
|
|
133
|
+
|
|
134
|
+
## Related APIs
|
|
135
|
+
|
|
136
|
+
- **[Contacts](/api/v1/contacts)** - People at this company
|
|
137
|
+
- **[Opportunities](/api/v1/opportunities)** - Sales opportunities
|
|
138
|
+
- **[Activities](/api/v1/activities)** - Activities with this company
|
|
139
|
+
- **[Notes](/api/v1/notes)** - Notes about this company
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Presets for Companies Entity
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { defineApiEndpoint } from '@nextsparkjs/core/types/api-presets'
|
|
6
|
+
|
|
7
|
+
export default defineApiEndpoint({
|
|
8
|
+
summary: 'Manage company/organization records',
|
|
9
|
+
presets: [
|
|
10
|
+
{
|
|
11
|
+
id: 'list-all',
|
|
12
|
+
title: 'List All Companies',
|
|
13
|
+
description: 'Get all companies with pagination',
|
|
14
|
+
method: 'GET',
|
|
15
|
+
params: {
|
|
16
|
+
limit: 20
|
|
17
|
+
},
|
|
18
|
+
tags: ['read', 'list']
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 'list-customers',
|
|
22
|
+
title: 'List Customers',
|
|
23
|
+
description: 'Get customer companies',
|
|
24
|
+
method: 'GET',
|
|
25
|
+
params: {
|
|
26
|
+
type: 'customer'
|
|
27
|
+
},
|
|
28
|
+
tags: ['read', 'filter']
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'list-prospects',
|
|
32
|
+
title: 'List Prospects',
|
|
33
|
+
description: 'Get prospect companies',
|
|
34
|
+
method: 'GET',
|
|
35
|
+
params: {
|
|
36
|
+
type: 'prospect'
|
|
37
|
+
},
|
|
38
|
+
tags: ['read', 'filter']
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'list-hot',
|
|
42
|
+
title: 'List Hot Companies',
|
|
43
|
+
description: 'Get companies with hot rating',
|
|
44
|
+
method: 'GET',
|
|
45
|
+
params: {
|
|
46
|
+
rating: 'hot'
|
|
47
|
+
},
|
|
48
|
+
tags: ['read', 'filter', 'priority']
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'filter-by-industry',
|
|
52
|
+
title: 'Filter by Industry',
|
|
53
|
+
description: 'Get companies in a specific industry',
|
|
54
|
+
method: 'GET',
|
|
55
|
+
params: {
|
|
56
|
+
industry: '{{industry}}'
|
|
57
|
+
},
|
|
58
|
+
tags: ['read', 'filter']
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 'search-by-name',
|
|
62
|
+
title: 'Search by Name',
|
|
63
|
+
description: 'Search companies by name',
|
|
64
|
+
method: 'GET',
|
|
65
|
+
params: {
|
|
66
|
+
search: '{{name}}'
|
|
67
|
+
},
|
|
68
|
+
tags: ['read', 'search']
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'create-company',
|
|
72
|
+
title: 'Create New Company',
|
|
73
|
+
description: 'Create a company with sample data',
|
|
74
|
+
method: 'POST',
|
|
75
|
+
payload: {
|
|
76
|
+
name: 'Sample Corp',
|
|
77
|
+
email: 'info@samplecorp.com',
|
|
78
|
+
industry: 'Technology',
|
|
79
|
+
type: 'prospect'
|
|
80
|
+
},
|
|
81
|
+
tags: ['write', 'create']
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: 'update-rating',
|
|
85
|
+
title: 'Update Rating',
|
|
86
|
+
description: 'Update the sales rating of a company',
|
|
87
|
+
method: 'PATCH',
|
|
88
|
+
pathParams: {
|
|
89
|
+
id: '{{id}}'
|
|
90
|
+
},
|
|
91
|
+
payload: {
|
|
92
|
+
rating: '{{rating}}'
|
|
93
|
+
},
|
|
94
|
+
tags: ['write', 'update']
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: 'delete-company',
|
|
98
|
+
title: 'Delete Company',
|
|
99
|
+
description: 'Delete a company record',
|
|
100
|
+
method: 'DELETE',
|
|
101
|
+
pathParams: {
|
|
102
|
+
id: '{{id}}'
|
|
103
|
+
},
|
|
104
|
+
tags: ['write', 'delete']
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
})
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Contacts API
|
|
2
|
+
|
|
3
|
+
Manage people contacts at companies. Contacts can be linked to companies and support social profiles, communication preferences, and contact history.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Contacts API allows you to create, read, update, and delete contact records. Contacts represent people at companies and can be associated with companies, opportunities, and activities.
|
|
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 Contacts
|
|
18
|
+
`GET /api/v1/contacts`
|
|
19
|
+
|
|
20
|
+
Returns a paginated list of contacts.
|
|
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
|
+
- `companyId` (string, optional): Filter by associated company
|
|
26
|
+
- `search` (string, optional): Search by name, email, phone
|
|
27
|
+
- `sortBy` (string, optional): Field to sort by
|
|
28
|
+
- `sortOrder` (string, optional): Sort direction (asc, desc)
|
|
29
|
+
|
|
30
|
+
**Example Response:**
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"data": [
|
|
34
|
+
{
|
|
35
|
+
"id": "contact_abc123",
|
|
36
|
+
"firstName": "Jane",
|
|
37
|
+
"lastName": "Smith",
|
|
38
|
+
"email": "jane.smith@acme.com",
|
|
39
|
+
"phone": "+1-555-0100",
|
|
40
|
+
"mobile": "+1-555-0101",
|
|
41
|
+
"companyId": "company_xyz",
|
|
42
|
+
"position": "VP of Sales",
|
|
43
|
+
"isPrimary": true,
|
|
44
|
+
"lastContactedAt": "2024-01-15T14:30:00Z",
|
|
45
|
+
"createdAt": "2024-01-10T10:30:00Z"
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"pagination": {
|
|
49
|
+
"total": 156,
|
|
50
|
+
"limit": 20,
|
|
51
|
+
"offset": 0
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Get Single Contact
|
|
57
|
+
`GET /api/v1/contacts/[id]`
|
|
58
|
+
|
|
59
|
+
Returns a single contact by ID.
|
|
60
|
+
|
|
61
|
+
### Create Contact
|
|
62
|
+
`POST /api/v1/contacts`
|
|
63
|
+
|
|
64
|
+
Create a new contact record.
|
|
65
|
+
|
|
66
|
+
**Request Body:**
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"firstName": "John",
|
|
70
|
+
"lastName": "Doe",
|
|
71
|
+
"email": "john.doe@company.com",
|
|
72
|
+
"phone": "+1-555-0200",
|
|
73
|
+
"companyId": "company_xyz",
|
|
74
|
+
"position": "CTO",
|
|
75
|
+
"preferredChannel": "email"
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Update Contact
|
|
80
|
+
`PATCH /api/v1/contacts/[id]`
|
|
81
|
+
|
|
82
|
+
Update an existing contact. Supports partial updates.
|
|
83
|
+
|
|
84
|
+
### Delete Contact
|
|
85
|
+
`DELETE /api/v1/contacts/[id]`
|
|
86
|
+
|
|
87
|
+
Delete a contact record.
|
|
88
|
+
|
|
89
|
+
## Fields
|
|
90
|
+
|
|
91
|
+
| Field | Type | Required | Description |
|
|
92
|
+
|-------|------|----------|-------------|
|
|
93
|
+
| firstName | text | Yes | Contact first name |
|
|
94
|
+
| lastName | text | Yes | Contact last name |
|
|
95
|
+
| email | email | Yes | Email address |
|
|
96
|
+
| phone | text | No | Office phone number |
|
|
97
|
+
| mobile | text | No | Mobile phone number |
|
|
98
|
+
| companyId | relation | No | Associated company (→ companies) |
|
|
99
|
+
| position | text | No | Job position or title |
|
|
100
|
+
| department | text | No | Department in company |
|
|
101
|
+
| isPrimary | boolean | No | Is primary contact for company |
|
|
102
|
+
| birthDate | date | No | Contact birth date |
|
|
103
|
+
| linkedin | url | No | LinkedIn profile URL |
|
|
104
|
+
| twitter | text | No | Twitter/X handle |
|
|
105
|
+
| preferredChannel | select | No | Preferred channel: email, phone, whatsapp, linkedin, slack, other |
|
|
106
|
+
| timezone | text | No | Contact timezone |
|
|
107
|
+
| lastContactedAt | datetime | Auto | Last time contacted |
|
|
108
|
+
| createdAt | datetime | Auto | Creation timestamp |
|
|
109
|
+
| updatedAt | datetime | Auto | Last update timestamp |
|
|
110
|
+
|
|
111
|
+
## Relationships
|
|
112
|
+
|
|
113
|
+
| Relation | Entity | Description |
|
|
114
|
+
|----------|--------|-------------|
|
|
115
|
+
| companyId | companies | Company this contact works at |
|
|
116
|
+
|
|
117
|
+
## Features
|
|
118
|
+
|
|
119
|
+
- **Searchable**: first name, last name, email, phone, mobile, position, department
|
|
120
|
+
- **Sortable**: All fields except social profiles
|
|
121
|
+
- **Bulk Operations**: Supported
|
|
122
|
+
- **Import/Export**: Supported
|
|
123
|
+
|
|
124
|
+
## Error Responses
|
|
125
|
+
|
|
126
|
+
| Status | Description |
|
|
127
|
+
|--------|-------------|
|
|
128
|
+
| 400 | Bad Request - Invalid parameters |
|
|
129
|
+
| 401 | Unauthorized - Missing or invalid auth |
|
|
130
|
+
| 403 | Forbidden - Insufficient permissions |
|
|
131
|
+
| 404 | Not Found - Contact doesn't exist |
|
|
132
|
+
| 422 | Validation Error - Invalid data |
|
|
133
|
+
|
|
134
|
+
## Related APIs
|
|
135
|
+
|
|
136
|
+
- **[Companies](/api/v1/companies)** - Associated companies
|
|
137
|
+
- **[Activities](/api/v1/activities)** - Activities with this contact
|
|
138
|
+
- **[Notes](/api/v1/notes)** - Notes about this contact
|
|
139
|
+
- **[Opportunities](/api/v1/opportunities)** - Related opportunities
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Presets for Contacts Entity
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { defineApiEndpoint } from '@nextsparkjs/core/types/api-presets'
|
|
6
|
+
|
|
7
|
+
export default defineApiEndpoint({
|
|
8
|
+
summary: 'Manage customer contacts with company associations',
|
|
9
|
+
presets: [
|
|
10
|
+
{
|
|
11
|
+
id: 'list-all',
|
|
12
|
+
title: 'List All Contacts',
|
|
13
|
+
description: 'Get all contacts with pagination',
|
|
14
|
+
method: 'GET',
|
|
15
|
+
params: {
|
|
16
|
+
limit: 20
|
|
17
|
+
},
|
|
18
|
+
tags: ['read', 'list']
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 'list-by-company',
|
|
22
|
+
title: 'List by Company',
|
|
23
|
+
description: 'Get contacts for a specific company',
|
|
24
|
+
method: 'GET',
|
|
25
|
+
params: {
|
|
26
|
+
companyId: '{{companyId}}'
|
|
27
|
+
},
|
|
28
|
+
tags: ['read', 'filter']
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'list-primary',
|
|
32
|
+
title: 'List Primary Contacts',
|
|
33
|
+
description: 'Get all primary contacts',
|
|
34
|
+
method: 'GET',
|
|
35
|
+
params: {
|
|
36
|
+
isPrimary: 'true'
|
|
37
|
+
},
|
|
38
|
+
tags: ['read', 'filter']
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'search-by-name',
|
|
42
|
+
title: 'Search by Name',
|
|
43
|
+
description: 'Search contacts by name',
|
|
44
|
+
method: 'GET',
|
|
45
|
+
params: {
|
|
46
|
+
search: '{{name}}'
|
|
47
|
+
},
|
|
48
|
+
tags: ['read', 'search']
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'search-by-email',
|
|
52
|
+
title: 'Search by Email',
|
|
53
|
+
description: 'Search contacts by email',
|
|
54
|
+
method: 'GET',
|
|
55
|
+
params: {
|
|
56
|
+
search: '{{email}}'
|
|
57
|
+
},
|
|
58
|
+
tags: ['read', 'search']
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 'create-contact',
|
|
62
|
+
title: 'Create New Contact',
|
|
63
|
+
description: 'Create a contact with sample data',
|
|
64
|
+
method: 'POST',
|
|
65
|
+
payload: {
|
|
66
|
+
firstName: 'Jane',
|
|
67
|
+
lastName: 'Doe',
|
|
68
|
+
email: 'jane.doe@sample.com',
|
|
69
|
+
position: 'Manager',
|
|
70
|
+
preferredChannel: 'email'
|
|
71
|
+
},
|
|
72
|
+
tags: ['write', 'create']
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: 'update-contact',
|
|
76
|
+
title: 'Update Contact',
|
|
77
|
+
description: 'Update contact information',
|
|
78
|
+
method: 'PATCH',
|
|
79
|
+
pathParams: {
|
|
80
|
+
id: '{{id}}'
|
|
81
|
+
},
|
|
82
|
+
payload: {
|
|
83
|
+
phone: '{{phone}}'
|
|
84
|
+
},
|
|
85
|
+
tags: ['write', 'update']
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: 'delete-contact',
|
|
89
|
+
title: 'Delete Contact',
|
|
90
|
+
description: 'Delete a contact record',
|
|
91
|
+
method: 'DELETE',
|
|
92
|
+
pathParams: {
|
|
93
|
+
id: '{{id}}'
|
|
94
|
+
},
|
|
95
|
+
tags: ['write', 'delete']
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
})
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Leads API
|
|
2
|
+
|
|
3
|
+
Manage prospective customers before conversion. Leads are team-shared and support full CRUD operations with import/export.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Leads API allows you to create, read, update, and delete lead records. Leads represent potential customers in the early stages of the sales funnel before they become contacts or opportunities.
|
|
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 Leads
|
|
18
|
+
`GET /api/v1/leads`
|
|
19
|
+
|
|
20
|
+
Returns a paginated list of leads.
|
|
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
|
+
- `status` (string, optional): Filter by status (new, contacted, qualified, proposal, negotiation, converted, lost)
|
|
26
|
+
- `source` (string, optional): Filter by lead source
|
|
27
|
+
- `search` (string, optional): Search term for company name, contact name, email
|
|
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": "lead_abc123",
|
|
37
|
+
"companyName": "Acme Corp",
|
|
38
|
+
"contactName": "John Smith",
|
|
39
|
+
"email": "john@acme.com",
|
|
40
|
+
"phone": "+1-555-0100",
|
|
41
|
+
"source": "web",
|
|
42
|
+
"status": "qualified",
|
|
43
|
+
"score": 75,
|
|
44
|
+
"industry": "Technology",
|
|
45
|
+
"assignedTo": "user_456",
|
|
46
|
+
"createdAt": "2024-01-15T10:30:00Z"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"pagination": {
|
|
50
|
+
"total": 42,
|
|
51
|
+
"limit": 20,
|
|
52
|
+
"offset": 0
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Get Single Lead
|
|
58
|
+
`GET /api/v1/leads/[id]`
|
|
59
|
+
|
|
60
|
+
Returns a single lead by ID.
|
|
61
|
+
|
|
62
|
+
### Create Lead
|
|
63
|
+
`POST /api/v1/leads`
|
|
64
|
+
|
|
65
|
+
Create a new lead record.
|
|
66
|
+
|
|
67
|
+
**Request Body:**
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"companyName": "New Prospect Inc",
|
|
71
|
+
"contactName": "Jane Doe",
|
|
72
|
+
"email": "jane@newprospect.com",
|
|
73
|
+
"phone": "+1-555-0200",
|
|
74
|
+
"source": "referral",
|
|
75
|
+
"status": "new",
|
|
76
|
+
"industry": "Healthcare",
|
|
77
|
+
"companySize": "51-200"
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Update Lead
|
|
82
|
+
`PATCH /api/v1/leads/[id]`
|
|
83
|
+
|
|
84
|
+
Update an existing lead. Supports partial updates.
|
|
85
|
+
|
|
86
|
+
### Delete Lead
|
|
87
|
+
`DELETE /api/v1/leads/[id]`
|
|
88
|
+
|
|
89
|
+
Delete a lead record.
|
|
90
|
+
|
|
91
|
+
## Fields
|
|
92
|
+
|
|
93
|
+
| Field | Type | Required | Description |
|
|
94
|
+
|-------|------|----------|-------------|
|
|
95
|
+
| companyName | text | Yes | Name of the prospect company |
|
|
96
|
+
| contactName | text | Yes | Name of the contact person |
|
|
97
|
+
| email | email | Yes | Email address |
|
|
98
|
+
| phone | text | No | Phone number |
|
|
99
|
+
| website | url | No | Company website |
|
|
100
|
+
| source | select | No | Lead source: web, referral, cold_call, trade_show, social_media, email, advertising, partner, other |
|
|
101
|
+
| status | select | No | Status: new, contacted, qualified, proposal, negotiation, converted, lost |
|
|
102
|
+
| score | number | No | Lead score (0-100) |
|
|
103
|
+
| industry | text | No | Industry sector |
|
|
104
|
+
| companySize | select | No | Company size: 1-10, 11-50, 51-200, 201-500, 500+ |
|
|
105
|
+
| budget | number | No | Estimated budget amount |
|
|
106
|
+
| assignedTo | user | No | Sales rep assigned |
|
|
107
|
+
| notes | textarea | No | Internal notes |
|
|
108
|
+
| createdAt | datetime | Auto | Creation timestamp |
|
|
109
|
+
| updatedAt | datetime | Auto | Last update timestamp |
|
|
110
|
+
|
|
111
|
+
## Features
|
|
112
|
+
|
|
113
|
+
- **Searchable**: company name, contact name, email, industry, notes
|
|
114
|
+
- **Sortable**: All fields except notes
|
|
115
|
+
- **Bulk Operations**: Supported
|
|
116
|
+
- **Import/Export**: Supported
|
|
117
|
+
|
|
118
|
+
## Error Responses
|
|
119
|
+
|
|
120
|
+
| Status | Description |
|
|
121
|
+
|--------|-------------|
|
|
122
|
+
| 400 | Bad Request - Invalid parameters |
|
|
123
|
+
| 401 | Unauthorized - Missing or invalid auth |
|
|
124
|
+
| 403 | Forbidden - Insufficient permissions |
|
|
125
|
+
| 404 | Not Found - Lead doesn't exist |
|
|
126
|
+
| 422 | Validation Error - Invalid data |
|
|
127
|
+
|
|
128
|
+
## Related APIs
|
|
129
|
+
|
|
130
|
+
- **[Contacts](/api/v1/contacts)** - Convert leads to contacts
|
|
131
|
+
- **[Companies](/api/v1/companies)** - Company records
|
|
132
|
+
- **[Opportunities](/api/v1/opportunities)** - Sales opportunities
|