@nextsparkjs/theme-crm 0.1.0-beta.42 → 0.1.0-beta.45

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.
@@ -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
@@ -0,0 +1,109 @@
1
+ /**
2
+ * API Presets for Leads Entity
3
+ */
4
+
5
+ import { defineApiEndpoint } from '@nextsparkjs/core/types/api-presets'
6
+
7
+ export default defineApiEndpoint({
8
+ summary: 'Manage prospective customers before conversion',
9
+ presets: [
10
+ {
11
+ id: 'list-all',
12
+ title: 'List All Leads',
13
+ description: 'Get all leads with pagination',
14
+ method: 'GET',
15
+ params: {
16
+ limit: 20
17
+ },
18
+ tags: ['read', 'list']
19
+ },
20
+ {
21
+ id: 'list-new',
22
+ title: 'List New Leads',
23
+ description: 'Get leads with status "new"',
24
+ method: 'GET',
25
+ params: {
26
+ status: 'new'
27
+ },
28
+ tags: ['read', 'filter']
29
+ },
30
+ {
31
+ id: 'list-qualified',
32
+ title: 'List Qualified Leads',
33
+ description: 'Get leads with status "qualified"',
34
+ method: 'GET',
35
+ params: {
36
+ status: 'qualified'
37
+ },
38
+ tags: ['read', 'filter']
39
+ },
40
+ {
41
+ id: 'list-hot',
42
+ title: 'List Hot Leads',
43
+ description: 'Get leads sorted by score (highest first)',
44
+ method: 'GET',
45
+ params: {
46
+ sortBy: 'score',
47
+ sortOrder: 'desc'
48
+ },
49
+ tags: ['read', 'filter', 'priority']
50
+ },
51
+ {
52
+ id: 'search-by-company',
53
+ title: 'Search by Company',
54
+ description: 'Search leads by company name',
55
+ method: 'GET',
56
+ params: {
57
+ search: '{{companyName}}'
58
+ },
59
+ tags: ['read', 'search']
60
+ },
61
+ {
62
+ id: 'filter-by-source',
63
+ title: 'Filter by Source',
64
+ description: 'Get leads from a specific source',
65
+ method: 'GET',
66
+ params: {
67
+ source: '{{source}}'
68
+ },
69
+ tags: ['read', 'filter']
70
+ },
71
+ {
72
+ id: 'create-lead',
73
+ title: 'Create New Lead',
74
+ description: 'Create a lead with sample data',
75
+ method: 'POST',
76
+ payload: {
77
+ companyName: 'Sample Company',
78
+ contactName: 'John Doe',
79
+ email: 'john@sample.com',
80
+ status: 'new',
81
+ source: 'web'
82
+ },
83
+ tags: ['write', 'create']
84
+ },
85
+ {
86
+ id: 'update-status',
87
+ title: 'Update Lead Status',
88
+ description: 'Update the status of a lead',
89
+ method: 'PATCH',
90
+ pathParams: {
91
+ id: '{{id}}'
92
+ },
93
+ payload: {
94
+ status: '{{newStatus}}'
95
+ },
96
+ tags: ['write', 'update']
97
+ },
98
+ {
99
+ id: 'delete-lead',
100
+ title: 'Delete Lead',
101
+ description: 'Delete a lead record',
102
+ method: 'DELETE',
103
+ pathParams: {
104
+ id: '{{id}}'
105
+ },
106
+ tags: ['write', 'delete']
107
+ }
108
+ ]
109
+ })