@cakemail-org/cakemail-cli 1.7.0 → 2.0.0
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/.claude/settings.local.json +12 -0
- package/.env.example +40 -0
- package/.env.test.example +45 -0
- package/CHANGELOG.md +1031 -0
- package/README.md +41 -37
- package/audit-formats.js +128 -0
- package/cakemail.rb +20 -0
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/commands/account.js +1 -1
- package/dist/commands/account.js.map +1 -1
- package/dist/commands/attributes.js +1 -1
- package/dist/commands/attributes.js.map +1 -1
- package/dist/commands/campaigns.js +1 -1
- package/dist/commands/campaigns.js.map +1 -1
- package/dist/commands/contacts.js +1 -1
- package/dist/commands/contacts.js.map +1 -1
- package/dist/commands/emails.js +1 -1
- package/dist/commands/emails.js.map +1 -1
- package/dist/commands/interests.js +1 -1
- package/dist/commands/interests.js.map +1 -1
- package/dist/commands/lists.js +1 -1
- package/dist/commands/lists.js.map +1 -1
- package/dist/commands/logs.js +1 -1
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/reports.js +1 -1
- package/dist/commands/reports.js.map +1 -1
- package/dist/commands/segments.js +1 -1
- package/dist/commands/segments.js.map +1 -1
- package/dist/commands/senders.js +1 -1
- package/dist/commands/senders.js.map +1 -1
- package/dist/commands/suppressed.js +1 -1
- package/dist/commands/suppressed.js.map +1 -1
- package/dist/commands/tags.js +1 -1
- package/dist/commands/tags.js.map +1 -1
- package/dist/commands/templates.js +1 -1
- package/dist/commands/templates.js.map +1 -1
- package/dist/commands/transactional-templates.js +1 -1
- package/dist/commands/transactional-templates.js.map +1 -1
- package/dist/commands/webhooks.js +1 -1
- package/dist/commands/webhooks.js.map +1 -1
- package/dist/utils/config.js +2 -2
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/errors.js +1 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/progress.d.ts.map +1 -1
- package/dist/utils/progress.js +32 -4
- package/dist/utils/progress.js.map +1 -1
- package/dist/utils/spinner.d.ts +17 -0
- package/dist/utils/spinner.d.ts.map +1 -0
- package/dist/utils/spinner.js +43 -0
- package/dist/utils/spinner.js.map +1 -0
- package/docs/DOCUMENTATION-STANDARD.md +1068 -0
- package/docs/README.md +161 -0
- package/docs/developer/ARCHITECTURE.md +516 -0
- package/docs/developer/AUTH.md +204 -0
- package/docs/developer/CONTRIBUTING.md +227 -0
- package/docs/developer/DOCUMENTATION_SUMMARY.md +346 -0
- package/docs/developer/PROJECT_INDEX.md +365 -0
- package/docs/planning/API_COVERAGE.md +1045 -0
- package/docs/planning/BACKLOG.md +1159 -0
- package/docs/planning/PROFILE_SYSTEM_TASKS.md +287 -0
- package/docs/planning/UX_IMPLEMENTATION_PLAN.md +691 -0
- package/docs/planning/archive/RELEASE_CHECKLIST_v1.3.0.md +332 -0
- package/docs/planning/archive/RELEASE_v1.3.0.md +428 -0
- package/docs/planning/archive/cakemail-cli-ux-improvements.md +438 -0
- package/docs/planning/cakemail-profile-system-plan.md +1121 -0
- package/docs/testing/AI_USER_SIMULATION_DESIGN.md +1342 -0
- package/docs/testing/KENOGAMI_BIDIRECTIONAL_FLOW.md +1517 -0
- package/docs/testing/KENOGAMI_TRUTH_RECONCILIATION_SYSTEM.md +1369 -0
- package/docs/user-manual/.obsidian/app.json +1 -0
- package/docs/user-manual/.obsidian/appearance.json +1 -0
- package/docs/user-manual/.obsidian/core-plugins.json +33 -0
- package/docs/user-manual/.obsidian/workspace.json +167 -0
- package/docs/user-manual/01-getting-started/01-installation.md +214 -0
- package/docs/user-manual/01-getting-started/02-quick-start.md +432 -0
- package/docs/user-manual/01-getting-started/03-authentication.md +448 -0
- package/docs/user-manual/01-getting-started/04-configuration.md +430 -0
- package/docs/user-manual/01-getting-started/05-output-formats.md +447 -0
- package/docs/user-manual/02-core-concepts/01-accounts.md +514 -0
- package/docs/user-manual/02-core-concepts/02-profile-system.md +771 -0
- package/docs/user-manual/02-core-concepts/03-smart-defaults.md +485 -0
- package/docs/user-manual/02-core-concepts/04-authentication-methods.md +435 -0
- package/docs/user-manual/02-core-concepts/05-pagination-filtering.md +600 -0
- package/docs/user-manual/02-core-concepts/06-error-handling.md +718 -0
- package/docs/user-manual/02-core-concepts/07-api-coverage.md +483 -0
- package/docs/user-manual/03-email-operations/01-senders.md +490 -0
- package/docs/user-manual/03-email-operations/02-templates.md +444 -0
- package/docs/user-manual/03-email-operations/03-transactional-emails.md +706 -0
- package/docs/user-manual/03-email-operations/04-email-tracking.md +407 -0
- package/docs/user-manual/04-campaign-management/01-campaigns-basics.md +394 -0
- package/docs/user-manual/04-campaign-management/02-campaign-scheduling.md +630 -0
- package/docs/user-manual/04-campaign-management/03-campaign-testing.md +997 -0
- package/docs/user-manual/04-campaign-management/04-campaign-lifecycle.md +709 -0
- package/docs/user-manual/04-campaign-management/05-campaign-links.md +934 -0
- package/docs/user-manual/05-contact-management/01-lists.md +836 -0
- package/docs/user-manual/05-contact-management/02-contacts.md +1035 -0
- package/docs/user-manual/05-contact-management/03-custom-attributes.md +788 -0
- package/docs/user-manual/05-contact-management/04-segments.md +1028 -0
- package/docs/user-manual/05-contact-management/05-contact-import-export.md +1031 -0
- package/docs/user-manual/06-analytics-reporting/01-campaign-analytics.md +867 -0
- package/docs/user-manual/06-analytics-reporting/02-account-reports.md +227 -0
- package/docs/user-manual/07-integrations/01-webhooks-integration.md +259 -0
- package/docs/user-manual/07-integrations/02-automation.md +326 -0
- package/docs/user-manual/08-advanced-usage/01-scripting-patterns.md +672 -0
- package/docs/user-manual/08-advanced-usage/02-bulk-operations.md +932 -0
- package/docs/user-manual/08-advanced-usage/03-ci-cd-integration.md +892 -0
- package/docs/user-manual/08-advanced-usage/04-performance-optimization.md +766 -0
- package/docs/user-manual/09-command-reference/01-config.md +776 -0
- package/docs/user-manual/09-command-reference/02-account.md +652 -0
- package/docs/user-manual/09-command-reference/03-lists.md +958 -0
- package/docs/user-manual/09-command-reference/04-contacts.md +1408 -0
- package/docs/user-manual/09-command-reference/05-attributes.md +617 -0
- package/docs/user-manual/09-command-reference/06-segments.md +894 -0
- package/docs/user-manual/09-command-reference/07-senders.md +803 -0
- package/docs/user-manual/09-command-reference/08-templates.md +818 -0
- package/docs/user-manual/09-command-reference/09-campaigns.md +1250 -0
- package/docs/user-manual/09-command-reference/10-emails.md +807 -0
- package/docs/user-manual/09-command-reference/11-reports.md +1135 -0
- package/docs/user-manual/09-command-reference/12-webhooks.md +773 -0
- package/docs/user-manual/09-command-reference/13-suppressed.md +797 -0
- package/docs/user-manual/09-command-reference/14-interests.md +630 -0
- package/docs/user-manual/09-command-reference/15-tags.md +584 -0
- package/docs/user-manual/09-command-reference/16-logs.md +656 -0
- package/docs/user-manual/09-command-reference/17-transactional-templates.md +850 -0
- package/docs/user-manual/10-troubleshooting/01-common-errors.md +457 -0
- package/docs/user-manual/10-troubleshooting/02-authentication-issues.md +558 -0
- package/docs/user-manual/10-troubleshooting/03-connection-problems.md +634 -0
- package/docs/user-manual/10-troubleshooting/04-debugging.md +725 -0
- package/docs/user-manual/11-appendix/04-faq.md +484 -0
- package/docs/user-manual/11-appendix/05-glossary.md +250 -0
- package/docs/user-manual/README.md +0 -0
- package/package.json +13 -61
- package/src/cli.ts +125 -0
- package/src/client.ts +16 -0
- package/src/commands/account.ts +267 -0
- package/src/commands/accounts.ts +78 -0
- package/src/commands/actions.ts +249 -0
- package/src/commands/attributes.ts +139 -0
- package/src/commands/campaign-blueprints.ts +106 -0
- package/src/commands/campaigns.ts +469 -0
- package/src/commands/config.ts +77 -0
- package/src/commands/contacts.ts +612 -0
- package/src/commands/custom-attributes.ts +127 -0
- package/src/commands/dkims.ts +117 -0
- package/src/commands/domains.ts +82 -0
- package/src/commands/email-apis.ts +569 -0
- package/src/commands/emails.ts +197 -0
- package/src/commands/forms.ts +283 -0
- package/src/commands/interests.ts +155 -0
- package/src/commands/links.ts +38 -0
- package/src/commands/lists.ts +406 -0
- package/src/commands/logos.ts +71 -0
- package/src/commands/logs.ts +386 -0
- package/src/commands/reports.ts +306 -0
- package/src/commands/segments.ts +158 -0
- package/src/commands/senders.ts +204 -0
- package/src/commands/sub-accounts.ts +271 -0
- package/src/commands/suppressed-emails.ts +234 -0
- package/src/commands/suppressed.ts +198 -0
- package/src/commands/system-emails.ts +85 -0
- package/src/commands/tags.ts +146 -0
- package/src/commands/tasks.ts +116 -0
- package/src/commands/templates.ts +189 -0
- package/src/commands/tokens.ts +83 -0
- package/src/commands/transactional-emails.ts +374 -0
- package/src/commands/transactional-templates.ts +385 -0
- package/src/commands/users.ts +506 -0
- package/src/commands/webhooks.ts +172 -0
- package/src/commands/workflow-blueprints.ts +123 -0
- package/src/commands/workflows.ts +265 -0
- package/src/types/profile.ts +93 -0
- package/src/utils/auth.ts +272 -0
- package/src/utils/config-file.ts +96 -0
- package/src/utils/config.ts +134 -0
- package/src/utils/confirm.ts +32 -0
- package/src/utils/defaults.ts +99 -0
- package/src/utils/errors.ts +116 -0
- package/src/utils/interactive.ts +91 -0
- package/src/utils/list-defaults.ts +74 -0
- package/src/utils/output.ts +190 -0
- package/src/utils/progress.ts +320 -0
- package/src/utils/spinner.ts +22 -0
- package/tests/IMPLEMENTATION_STATUS.md +258 -0
- package/tests/PTY_SETUP.md +118 -0
- package/tests/PTY_TESTING_GUIDE.md +507 -0
- package/tests/README.md +244 -0
- package/tests/fixtures/api-responses/campaigns.json +34 -0
- package/tests/fixtures/test-config.json +13 -0
- package/tests/helpers/cli-runner.ts +128 -0
- package/tests/helpers/mock-server.ts +301 -0
- package/tests/helpers/pty-runner.ts +181 -0
- package/tests/integration/campaigns-real-api.test.ts +196 -0
- package/tests/integration/setup-integration.ts +50 -0
- package/tests/pty/campaigns.test.ts +241 -0
- package/tests/setup.ts +34 -0
- package/tsconfig.json +15 -0
- package/vitest.config.ts +28 -0
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
# Pagination & Filtering
|
|
2
|
+
|
|
3
|
+
Master list operations with pagination, filtering, sorting, and search to efficiently work with large datasets.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Most Cakemail CLI list commands support:
|
|
8
|
+
|
|
9
|
+
- **Pagination** - Retrieve results in manageable chunks
|
|
10
|
+
- **Filtering** - Narrow results based on criteria
|
|
11
|
+
- **Sorting** - Order results by specific fields
|
|
12
|
+
- **Search** - Find specific items by keyword
|
|
13
|
+
|
|
14
|
+
These features help you work efficiently with large lists of campaigns, contacts, templates, and other resources.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Pagination
|
|
19
|
+
|
|
20
|
+
### What is Pagination?
|
|
21
|
+
|
|
22
|
+
Pagination splits large result sets into smaller "pages" of results. Instead of retrieving 10,000 campaigns at once, you retrieve 50 at a time.
|
|
23
|
+
|
|
24
|
+
### Why Use Pagination?
|
|
25
|
+
|
|
26
|
+
- **Performance**: Faster response times
|
|
27
|
+
- **Memory**: Lower memory usage
|
|
28
|
+
- **Usability**: Easier to read and process results
|
|
29
|
+
- **API limits**: Respects rate limits
|
|
30
|
+
|
|
31
|
+
### Pagination Options
|
|
32
|
+
|
|
33
|
+
#### `--limit` (or `-l`)
|
|
34
|
+
|
|
35
|
+
Specify how many results per page (default varies by resource, typically 50-100).
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Get 10 campaigns
|
|
39
|
+
cakemail campaigns list --limit 10
|
|
40
|
+
|
|
41
|
+
# Get 100 contacts
|
|
42
|
+
cakemail contacts list 123 --limit 100
|
|
43
|
+
|
|
44
|
+
# Get 25 templates
|
|
45
|
+
cakemail templates list --limit 25
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### `--page` (or `-p`)
|
|
49
|
+
|
|
50
|
+
Specify which page of results to retrieve (1-indexed).
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Get first page (default)
|
|
54
|
+
cakemail campaigns list --page 1
|
|
55
|
+
|
|
56
|
+
# Get second page
|
|
57
|
+
cakemail campaigns list --page 2
|
|
58
|
+
|
|
59
|
+
# Get third page with custom limit
|
|
60
|
+
cakemail campaigns list --limit 25 --page 3
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Pagination Metadata
|
|
64
|
+
|
|
65
|
+
List responses include pagination information:
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"data": [...],
|
|
70
|
+
"count": 25, // Number of items in this response
|
|
71
|
+
"total": 247, // Total items available
|
|
72
|
+
"page": 1, // Current page
|
|
73
|
+
"per_page": 25 // Items per page
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Calculate total pages:**
|
|
78
|
+
```bash
|
|
79
|
+
# total_pages = ceiling(total / per_page)
|
|
80
|
+
# 247 total / 25 per_page = 10 pages
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Pagination Examples
|
|
84
|
+
|
|
85
|
+
**Example 1: Browse Pages Interactively**
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Page 1
|
|
89
|
+
cakemail -f table campaigns list --limit 20 --page 1
|
|
90
|
+
|
|
91
|
+
# Page 2
|
|
92
|
+
cakemail -f table campaigns list --limit 20 --page 2
|
|
93
|
+
|
|
94
|
+
# Page 3
|
|
95
|
+
cakemail -f table campaigns list --limit 20 --page 3
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Example 2: Retrieve All Results (Scripting)**
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
#!/bin/bash
|
|
102
|
+
# Get all campaigns across all pages
|
|
103
|
+
|
|
104
|
+
PAGE=1
|
|
105
|
+
LIMIT=100
|
|
106
|
+
|
|
107
|
+
while true; do
|
|
108
|
+
RESPONSE=$(cakemail -f json campaigns list --limit $LIMIT --page $PAGE)
|
|
109
|
+
|
|
110
|
+
# Extract data
|
|
111
|
+
DATA=$(echo "$RESPONSE" | jq '.data')
|
|
112
|
+
|
|
113
|
+
# Break if no more data
|
|
114
|
+
if [ "$(echo "$DATA" | jq 'length')" -eq 0 ]; then
|
|
115
|
+
break
|
|
116
|
+
fi
|
|
117
|
+
|
|
118
|
+
# Process data
|
|
119
|
+
echo "$DATA" | jq -r '.[] | "\(.id) - \(.name)"'
|
|
120
|
+
|
|
121
|
+
# Next page
|
|
122
|
+
PAGE=$((PAGE + 1))
|
|
123
|
+
done
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Example 3: Get Total Count**
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Just get the count without retrieving all data
|
|
130
|
+
cakemail -f json campaigns list --limit 1 | jq '.total'
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Filtering
|
|
136
|
+
|
|
137
|
+
### What is Filtering?
|
|
138
|
+
|
|
139
|
+
Filtering allows you to retrieve only items that match specific criteria, like campaigns with status "delivered" or contacts subscribed after a certain date.
|
|
140
|
+
|
|
141
|
+
### Filter Syntax
|
|
142
|
+
|
|
143
|
+
Filters use a simple query language:
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
field==value # Equals
|
|
147
|
+
field!=value # Not equals
|
|
148
|
+
field>value # Greater than
|
|
149
|
+
field<value # Less than
|
|
150
|
+
field>=value # Greater than or equal
|
|
151
|
+
field<=value # Less than or equal
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Multiple filters** are separated by `;` (AND logic):
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
field1==value1;field2==value2
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Filter Examples
|
|
161
|
+
|
|
162
|
+
**Example 1: Filter Campaigns by Status**
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Only delivered campaigns
|
|
166
|
+
cakemail campaigns list --filter "status==delivered"
|
|
167
|
+
|
|
168
|
+
# Only scheduled campaigns
|
|
169
|
+
cakemail campaigns list --filter "status==scheduled"
|
|
170
|
+
|
|
171
|
+
# Only draft campaigns
|
|
172
|
+
cakemail campaigns list --filter "status==draft"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Example 2: Filter Contacts by Status**
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Only active contacts
|
|
179
|
+
cakemail contacts list 123 --filter "status==active"
|
|
180
|
+
|
|
181
|
+
# Only unsubscribed contacts
|
|
182
|
+
cakemail contacts list 123 --filter "status==unsubscribed"
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Example 3: Filter by Name**
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# Campaigns with "Newsletter" in name
|
|
189
|
+
cakemail campaigns list --filter "name==Newsletter"
|
|
190
|
+
|
|
191
|
+
# Lists with specific name
|
|
192
|
+
cakemail lists list --filter "name==Subscribers"
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Example 4: Multiple Filters (AND)**
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Delivered campaigns named "Newsletter"
|
|
199
|
+
cakemail campaigns list --filter "status==delivered;name==Newsletter"
|
|
200
|
+
|
|
201
|
+
# Active confirmed senders
|
|
202
|
+
cakemail senders list --filter "confirmed==true"
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**Example 5: Filter by Date**
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# Campaigns created after a date
|
|
209
|
+
cakemail campaigns list --filter "created_on>=2024-01-01"
|
|
210
|
+
|
|
211
|
+
# Contacts subscribed before a date
|
|
212
|
+
cakemail contacts list 123 --filter "subscribed_on<2024-06-01"
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Filterable Fields by Resource
|
|
216
|
+
|
|
217
|
+
**Campaigns:**
|
|
218
|
+
- `status` - draft, scheduled, sending, delivered, suspended, cancelled
|
|
219
|
+
- `name` - Campaign name
|
|
220
|
+
- `created_on` - Creation date
|
|
221
|
+
- `scheduled_for` - Scheduled date
|
|
222
|
+
|
|
223
|
+
**Contacts:**
|
|
224
|
+
- `status` - active, unsubscribed, bounced
|
|
225
|
+
- `email` - Email address
|
|
226
|
+
- `subscribed_on` - Subscription date
|
|
227
|
+
|
|
228
|
+
**Lists:**
|
|
229
|
+
- `status` - active, archived
|
|
230
|
+
- `name` - List name
|
|
231
|
+
- `created_on` - Creation date
|
|
232
|
+
|
|
233
|
+
**Templates:**
|
|
234
|
+
- `name` - Template name
|
|
235
|
+
- `created_on` - Creation date
|
|
236
|
+
|
|
237
|
+
**Senders:**
|
|
238
|
+
- `confirmed` - true/false
|
|
239
|
+
- `email` - Email address
|
|
240
|
+
- `name` - Sender name
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Sorting
|
|
245
|
+
|
|
246
|
+
### What is Sorting?
|
|
247
|
+
|
|
248
|
+
Sorting allows you to order results by a specific field in ascending or descending order.
|
|
249
|
+
|
|
250
|
+
### Sort Syntax
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
+field # Ascending order
|
|
254
|
+
-field # Descending order
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Sort Examples
|
|
258
|
+
|
|
259
|
+
**Example 1: Sort Campaigns**
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# Sort by name (A-Z)
|
|
263
|
+
cakemail campaigns list --sort "+name"
|
|
264
|
+
|
|
265
|
+
# Sort by name (Z-A)
|
|
266
|
+
cakemail campaigns list --sort "-name"
|
|
267
|
+
|
|
268
|
+
# Sort by creation date (oldest first)
|
|
269
|
+
cakemail campaigns list --sort "+created_on"
|
|
270
|
+
|
|
271
|
+
# Sort by creation date (newest first)
|
|
272
|
+
cakemail campaigns list --sort "-created_on"
|
|
273
|
+
|
|
274
|
+
# Sort by scheduled date (soonest first)
|
|
275
|
+
cakemail campaigns list --sort "+scheduled_for"
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
**Example 2: Sort Contacts**
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
# Sort by email (A-Z)
|
|
282
|
+
cakemail contacts list 123 --sort "+email"
|
|
283
|
+
|
|
284
|
+
# Sort by subscription date (newest first)
|
|
285
|
+
cakemail contacts list 123 --sort "-subscribed_on"
|
|
286
|
+
|
|
287
|
+
# Sort by status
|
|
288
|
+
cakemail contacts list 123 --sort "+status"
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
**Example 3: Sort Lists**
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
# Sort by name (A-Z)
|
|
295
|
+
cakemail lists list --sort "+name"
|
|
296
|
+
|
|
297
|
+
# Sort by creation date (newest first)
|
|
298
|
+
cakemail lists list --sort "-created_on"
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**Example 4: Sort Senders**
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
# Sort by email (A-Z)
|
|
305
|
+
cakemail senders list --sort "+email"
|
|
306
|
+
|
|
307
|
+
# Sort by name
|
|
308
|
+
cakemail senders list --sort "+name"
|
|
309
|
+
|
|
310
|
+
# Sort by confirmation status
|
|
311
|
+
cakemail senders list --sort "-confirmed"
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Sortable Fields by Resource
|
|
315
|
+
|
|
316
|
+
**Campaigns:**
|
|
317
|
+
- `name` - Campaign name
|
|
318
|
+
- `created_on` - Creation date
|
|
319
|
+
- `scheduled_for` - Scheduled date
|
|
320
|
+
- `status` - Status
|
|
321
|
+
|
|
322
|
+
**Contacts:**
|
|
323
|
+
- `email` - Email address
|
|
324
|
+
- `subscribed_on` - Subscription date
|
|
325
|
+
- `status` - Status
|
|
326
|
+
|
|
327
|
+
**Lists:**
|
|
328
|
+
- `name` - List name
|
|
329
|
+
- `created_on` - Creation date
|
|
330
|
+
|
|
331
|
+
**Templates:**
|
|
332
|
+
- `name` - Template name
|
|
333
|
+
- `created_on` - Creation date
|
|
334
|
+
|
|
335
|
+
**Senders:**
|
|
336
|
+
- `name` - Sender name
|
|
337
|
+
- `email` - Email address
|
|
338
|
+
- `confirmed` - Confirmation status
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## Search
|
|
343
|
+
|
|
344
|
+
### What is Search?
|
|
345
|
+
|
|
346
|
+
Some list commands support keyword search using the `--query` (or `-q`) option. This searches across multiple fields.
|
|
347
|
+
|
|
348
|
+
### Search Examples
|
|
349
|
+
|
|
350
|
+
**Example 1: Search Contacts**
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
# Search contacts by email or name
|
|
354
|
+
cakemail contacts list 123 --query "john"
|
|
355
|
+
|
|
356
|
+
# Will match:
|
|
357
|
+
# - john@example.com
|
|
358
|
+
# - John Doe
|
|
359
|
+
# - johnny@example.com
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
**Example 2: Paginated Search**
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
# Search with pagination
|
|
366
|
+
cakemail contacts list 123 --query "example.com" --limit 50 --page 1
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Searchable Resources
|
|
370
|
+
|
|
371
|
+
Currently, these resources support `--query`:
|
|
372
|
+
|
|
373
|
+
- **Contacts** - Searches email, first name, last name
|
|
374
|
+
|
|
375
|
+
**Note**: Most other resources use `--filter` for specific field matching instead of full-text search.
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
## Combining Options
|
|
380
|
+
|
|
381
|
+
### Pagination + Filtering
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
# First 20 delivered campaigns
|
|
385
|
+
cakemail campaigns list --filter "status==delivered" --limit 20 --page 1
|
|
386
|
+
|
|
387
|
+
# Next 20 delivered campaigns
|
|
388
|
+
cakemail campaigns list --filter "status==delivered" --limit 20 --page 2
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### Pagination + Sorting
|
|
392
|
+
|
|
393
|
+
```bash
|
|
394
|
+
# 50 newest campaigns
|
|
395
|
+
cakemail campaigns list --sort "-created_on" --limit 50
|
|
396
|
+
|
|
397
|
+
# Next 50
|
|
398
|
+
cakemail campaigns list --sort "-created_on" --limit 50 --page 2
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### Filtering + Sorting
|
|
402
|
+
|
|
403
|
+
```bash
|
|
404
|
+
# Delivered campaigns, newest first
|
|
405
|
+
cakemail campaigns list --filter "status==delivered" --sort "-created_on"
|
|
406
|
+
|
|
407
|
+
# Active contacts, sorted by email
|
|
408
|
+
cakemail contacts list 123 --filter "status==active" --sort "+email"
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### All Together
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
# 25 delivered campaigns named "Newsletter", newest first
|
|
415
|
+
cakemail campaigns list \
|
|
416
|
+
--filter "status==delivered;name==Newsletter" \
|
|
417
|
+
--sort "-created_on" \
|
|
418
|
+
--limit 25 \
|
|
419
|
+
--page 1
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
## Practical Examples
|
|
425
|
+
|
|
426
|
+
### Example 1: Find Recent Campaigns
|
|
427
|
+
|
|
428
|
+
```bash
|
|
429
|
+
# Last 10 campaigns
|
|
430
|
+
cakemail -f table campaigns list --sort "-created_on" --limit 10
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Example 2: Count Active Contacts
|
|
434
|
+
|
|
435
|
+
```bash
|
|
436
|
+
# Get total active contacts
|
|
437
|
+
cakemail -f json contacts list 123 --filter "status==active" --limit 1 | jq '.total'
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### Example 3: Export Delivered Campaigns
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
#!/bin/bash
|
|
444
|
+
# Export all delivered campaign IDs
|
|
445
|
+
|
|
446
|
+
OUTPUT_FILE="delivered_campaigns.txt"
|
|
447
|
+
|
|
448
|
+
cakemail -f json campaigns list --filter "status==delivered" --limit 1000 \
|
|
449
|
+
| jq -r '.data[].id' > "$OUTPUT_FILE"
|
|
450
|
+
|
|
451
|
+
echo "Exported to $OUTPUT_FILE"
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### Example 4: List Unconfirmed Senders
|
|
455
|
+
|
|
456
|
+
```bash
|
|
457
|
+
# Show senders needing confirmation
|
|
458
|
+
cakemail -f table senders list --filter "confirmed==false"
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### Example 5: Find Contacts by Domain
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
# All contacts from example.com
|
|
465
|
+
cakemail contacts list 123 --query "@example.com"
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Example 6: Monthly Campaign Review
|
|
469
|
+
|
|
470
|
+
```bash
|
|
471
|
+
# Campaigns created this month, sorted by date
|
|
472
|
+
cakemail campaigns list \
|
|
473
|
+
--filter "created_on>=2024-06-01;created_on<2024-07-01" \
|
|
474
|
+
--sort "+created_on"
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
---
|
|
478
|
+
|
|
479
|
+
## Output Format Recommendations
|
|
480
|
+
|
|
481
|
+
### For Browsing
|
|
482
|
+
|
|
483
|
+
Use **table** or **compact** format:
|
|
484
|
+
|
|
485
|
+
```bash
|
|
486
|
+
cakemail -f table campaigns list --limit 20
|
|
487
|
+
cakemail -f compact campaigns list --limit 50
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### For Scripting
|
|
491
|
+
|
|
492
|
+
Use **JSON** format:
|
|
493
|
+
|
|
494
|
+
```bash
|
|
495
|
+
cakemail -f json campaigns list --filter "status==delivered" | jq '.data'
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
### For Quick Counts
|
|
499
|
+
|
|
500
|
+
Use **JSON** with limit 1:
|
|
501
|
+
|
|
502
|
+
```bash
|
|
503
|
+
cakemail -f json campaigns list --limit 1 | jq '.total'
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
## Performance Tips
|
|
509
|
+
|
|
510
|
+
### 1. Use Appropriate Limits
|
|
511
|
+
|
|
512
|
+
```bash
|
|
513
|
+
# ✅ Good: Reasonable page size
|
|
514
|
+
cakemail campaigns list --limit 50
|
|
515
|
+
|
|
516
|
+
# ❌ Avoid: Very large limits
|
|
517
|
+
cakemail campaigns list --limit 10000
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
### 2. Filter Before Sorting
|
|
521
|
+
|
|
522
|
+
```bash
|
|
523
|
+
# ✅ Efficient: Filter narrows results first
|
|
524
|
+
cakemail campaigns list --filter "status==delivered" --sort "-created_on"
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
### 3. Use Pagination for Large Sets
|
|
528
|
+
|
|
529
|
+
```bash
|
|
530
|
+
# ✅ Process in chunks
|
|
531
|
+
for PAGE in {1..10}; do
|
|
532
|
+
cakemail campaigns list --limit 100 --page $PAGE
|
|
533
|
+
done
|
|
534
|
+
|
|
535
|
+
# ❌ Avoid: Retrieving everything at once
|
|
536
|
+
cakemail campaigns list --limit 100000
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
### 4. Minimize Data Transfer
|
|
540
|
+
|
|
541
|
+
```bash
|
|
542
|
+
# ✅ Get only what you need with filtering
|
|
543
|
+
cakemail campaigns list --filter "status==delivered"
|
|
544
|
+
|
|
545
|
+
# ❌ Retrieve all and filter locally
|
|
546
|
+
cakemail campaigns list | grep delivered
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
---
|
|
550
|
+
|
|
551
|
+
## Troubleshooting
|
|
552
|
+
|
|
553
|
+
### No Results Returned
|
|
554
|
+
|
|
555
|
+
**Check:**
|
|
556
|
+
1. Filter criteria might be too restrictive
|
|
557
|
+
2. Try removing filters one by one
|
|
558
|
+
3. Verify field names are correct
|
|
559
|
+
|
|
560
|
+
```bash
|
|
561
|
+
# Debug: Remove filters to see all results
|
|
562
|
+
cakemail campaigns list
|
|
563
|
+
|
|
564
|
+
# Then add filters back one at a time
|
|
565
|
+
cakemail campaigns list --filter "status==delivered"
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
### "Invalid filter" Error
|
|
569
|
+
|
|
570
|
+
**Cause:** Filter syntax is incorrect
|
|
571
|
+
|
|
572
|
+
**Solutions:**
|
|
573
|
+
1. Check for typos in field names
|
|
574
|
+
2. Ensure proper operators (`==`, `!=`, `>`, etc.)
|
|
575
|
+
3. Use semicolons for multiple filters: `field1==value1;field2==value2`
|
|
576
|
+
|
|
577
|
+
```bash
|
|
578
|
+
# ❌ Wrong
|
|
579
|
+
cakemail campaigns list --filter "status=delivered"
|
|
580
|
+
|
|
581
|
+
# ✅ Correct
|
|
582
|
+
cakemail campaigns list --filter "status==delivered"
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
### Pagination Shows Wrong Total
|
|
586
|
+
|
|
587
|
+
**Cause:** Filters affect the total count
|
|
588
|
+
|
|
589
|
+
**Explanation:** `total` reflects the filtered result count, not the overall total.
|
|
590
|
+
|
|
591
|
+
```bash
|
|
592
|
+
# Total of all campaigns
|
|
593
|
+
cakemail -f json campaigns list | jq '.total'
|
|
594
|
+
|
|
595
|
+
# Total of delivered campaigns only
|
|
596
|
+
cakemail -f json campaigns list --filter "status==delivered" | jq '.total'
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
---
|
|
600
|
+
|