@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.
Files changed (198) hide show
  1. package/.claude/settings.local.json +12 -0
  2. package/.env.example +40 -0
  3. package/.env.test.example +45 -0
  4. package/CHANGELOG.md +1031 -0
  5. package/README.md +41 -37
  6. package/audit-formats.js +128 -0
  7. package/cakemail.rb +20 -0
  8. package/dist/client.js +1 -1
  9. package/dist/client.js.map +1 -1
  10. package/dist/commands/account.js +1 -1
  11. package/dist/commands/account.js.map +1 -1
  12. package/dist/commands/attributes.js +1 -1
  13. package/dist/commands/attributes.js.map +1 -1
  14. package/dist/commands/campaigns.js +1 -1
  15. package/dist/commands/campaigns.js.map +1 -1
  16. package/dist/commands/contacts.js +1 -1
  17. package/dist/commands/contacts.js.map +1 -1
  18. package/dist/commands/emails.js +1 -1
  19. package/dist/commands/emails.js.map +1 -1
  20. package/dist/commands/interests.js +1 -1
  21. package/dist/commands/interests.js.map +1 -1
  22. package/dist/commands/lists.js +1 -1
  23. package/dist/commands/lists.js.map +1 -1
  24. package/dist/commands/logs.js +1 -1
  25. package/dist/commands/logs.js.map +1 -1
  26. package/dist/commands/reports.js +1 -1
  27. package/dist/commands/reports.js.map +1 -1
  28. package/dist/commands/segments.js +1 -1
  29. package/dist/commands/segments.js.map +1 -1
  30. package/dist/commands/senders.js +1 -1
  31. package/dist/commands/senders.js.map +1 -1
  32. package/dist/commands/suppressed.js +1 -1
  33. package/dist/commands/suppressed.js.map +1 -1
  34. package/dist/commands/tags.js +1 -1
  35. package/dist/commands/tags.js.map +1 -1
  36. package/dist/commands/templates.js +1 -1
  37. package/dist/commands/templates.js.map +1 -1
  38. package/dist/commands/transactional-templates.js +1 -1
  39. package/dist/commands/transactional-templates.js.map +1 -1
  40. package/dist/commands/webhooks.js +1 -1
  41. package/dist/commands/webhooks.js.map +1 -1
  42. package/dist/utils/config.js +2 -2
  43. package/dist/utils/config.js.map +1 -1
  44. package/dist/utils/errors.js +1 -1
  45. package/dist/utils/errors.js.map +1 -1
  46. package/dist/utils/progress.d.ts.map +1 -1
  47. package/dist/utils/progress.js +32 -4
  48. package/dist/utils/progress.js.map +1 -1
  49. package/dist/utils/spinner.d.ts +17 -0
  50. package/dist/utils/spinner.d.ts.map +1 -0
  51. package/dist/utils/spinner.js +43 -0
  52. package/dist/utils/spinner.js.map +1 -0
  53. package/docs/DOCUMENTATION-STANDARD.md +1068 -0
  54. package/docs/README.md +161 -0
  55. package/docs/developer/ARCHITECTURE.md +516 -0
  56. package/docs/developer/AUTH.md +204 -0
  57. package/docs/developer/CONTRIBUTING.md +227 -0
  58. package/docs/developer/DOCUMENTATION_SUMMARY.md +346 -0
  59. package/docs/developer/PROJECT_INDEX.md +365 -0
  60. package/docs/planning/API_COVERAGE.md +1045 -0
  61. package/docs/planning/BACKLOG.md +1159 -0
  62. package/docs/planning/PROFILE_SYSTEM_TASKS.md +287 -0
  63. package/docs/planning/UX_IMPLEMENTATION_PLAN.md +691 -0
  64. package/docs/planning/archive/RELEASE_CHECKLIST_v1.3.0.md +332 -0
  65. package/docs/planning/archive/RELEASE_v1.3.0.md +428 -0
  66. package/docs/planning/archive/cakemail-cli-ux-improvements.md +438 -0
  67. package/docs/planning/cakemail-profile-system-plan.md +1121 -0
  68. package/docs/testing/AI_USER_SIMULATION_DESIGN.md +1342 -0
  69. package/docs/testing/KENOGAMI_BIDIRECTIONAL_FLOW.md +1517 -0
  70. package/docs/testing/KENOGAMI_TRUTH_RECONCILIATION_SYSTEM.md +1369 -0
  71. package/docs/user-manual/.obsidian/app.json +1 -0
  72. package/docs/user-manual/.obsidian/appearance.json +1 -0
  73. package/docs/user-manual/.obsidian/core-plugins.json +33 -0
  74. package/docs/user-manual/.obsidian/workspace.json +167 -0
  75. package/docs/user-manual/01-getting-started/01-installation.md +214 -0
  76. package/docs/user-manual/01-getting-started/02-quick-start.md +432 -0
  77. package/docs/user-manual/01-getting-started/03-authentication.md +448 -0
  78. package/docs/user-manual/01-getting-started/04-configuration.md +430 -0
  79. package/docs/user-manual/01-getting-started/05-output-formats.md +447 -0
  80. package/docs/user-manual/02-core-concepts/01-accounts.md +514 -0
  81. package/docs/user-manual/02-core-concepts/02-profile-system.md +771 -0
  82. package/docs/user-manual/02-core-concepts/03-smart-defaults.md +485 -0
  83. package/docs/user-manual/02-core-concepts/04-authentication-methods.md +435 -0
  84. package/docs/user-manual/02-core-concepts/05-pagination-filtering.md +600 -0
  85. package/docs/user-manual/02-core-concepts/06-error-handling.md +718 -0
  86. package/docs/user-manual/02-core-concepts/07-api-coverage.md +483 -0
  87. package/docs/user-manual/03-email-operations/01-senders.md +490 -0
  88. package/docs/user-manual/03-email-operations/02-templates.md +444 -0
  89. package/docs/user-manual/03-email-operations/03-transactional-emails.md +706 -0
  90. package/docs/user-manual/03-email-operations/04-email-tracking.md +407 -0
  91. package/docs/user-manual/04-campaign-management/01-campaigns-basics.md +394 -0
  92. package/docs/user-manual/04-campaign-management/02-campaign-scheduling.md +630 -0
  93. package/docs/user-manual/04-campaign-management/03-campaign-testing.md +997 -0
  94. package/docs/user-manual/04-campaign-management/04-campaign-lifecycle.md +709 -0
  95. package/docs/user-manual/04-campaign-management/05-campaign-links.md +934 -0
  96. package/docs/user-manual/05-contact-management/01-lists.md +836 -0
  97. package/docs/user-manual/05-contact-management/02-contacts.md +1035 -0
  98. package/docs/user-manual/05-contact-management/03-custom-attributes.md +788 -0
  99. package/docs/user-manual/05-contact-management/04-segments.md +1028 -0
  100. package/docs/user-manual/05-contact-management/05-contact-import-export.md +1031 -0
  101. package/docs/user-manual/06-analytics-reporting/01-campaign-analytics.md +867 -0
  102. package/docs/user-manual/06-analytics-reporting/02-account-reports.md +227 -0
  103. package/docs/user-manual/07-integrations/01-webhooks-integration.md +259 -0
  104. package/docs/user-manual/07-integrations/02-automation.md +326 -0
  105. package/docs/user-manual/08-advanced-usage/01-scripting-patterns.md +672 -0
  106. package/docs/user-manual/08-advanced-usage/02-bulk-operations.md +932 -0
  107. package/docs/user-manual/08-advanced-usage/03-ci-cd-integration.md +892 -0
  108. package/docs/user-manual/08-advanced-usage/04-performance-optimization.md +766 -0
  109. package/docs/user-manual/09-command-reference/01-config.md +776 -0
  110. package/docs/user-manual/09-command-reference/02-account.md +652 -0
  111. package/docs/user-manual/09-command-reference/03-lists.md +958 -0
  112. package/docs/user-manual/09-command-reference/04-contacts.md +1408 -0
  113. package/docs/user-manual/09-command-reference/05-attributes.md +617 -0
  114. package/docs/user-manual/09-command-reference/06-segments.md +894 -0
  115. package/docs/user-manual/09-command-reference/07-senders.md +803 -0
  116. package/docs/user-manual/09-command-reference/08-templates.md +818 -0
  117. package/docs/user-manual/09-command-reference/09-campaigns.md +1250 -0
  118. package/docs/user-manual/09-command-reference/10-emails.md +807 -0
  119. package/docs/user-manual/09-command-reference/11-reports.md +1135 -0
  120. package/docs/user-manual/09-command-reference/12-webhooks.md +773 -0
  121. package/docs/user-manual/09-command-reference/13-suppressed.md +797 -0
  122. package/docs/user-manual/09-command-reference/14-interests.md +630 -0
  123. package/docs/user-manual/09-command-reference/15-tags.md +584 -0
  124. package/docs/user-manual/09-command-reference/16-logs.md +656 -0
  125. package/docs/user-manual/09-command-reference/17-transactional-templates.md +850 -0
  126. package/docs/user-manual/10-troubleshooting/01-common-errors.md +457 -0
  127. package/docs/user-manual/10-troubleshooting/02-authentication-issues.md +558 -0
  128. package/docs/user-manual/10-troubleshooting/03-connection-problems.md +634 -0
  129. package/docs/user-manual/10-troubleshooting/04-debugging.md +725 -0
  130. package/docs/user-manual/11-appendix/04-faq.md +484 -0
  131. package/docs/user-manual/11-appendix/05-glossary.md +250 -0
  132. package/docs/user-manual/README.md +0 -0
  133. package/package.json +13 -61
  134. package/src/cli.ts +125 -0
  135. package/src/client.ts +16 -0
  136. package/src/commands/account.ts +267 -0
  137. package/src/commands/accounts.ts +78 -0
  138. package/src/commands/actions.ts +249 -0
  139. package/src/commands/attributes.ts +139 -0
  140. package/src/commands/campaign-blueprints.ts +106 -0
  141. package/src/commands/campaigns.ts +469 -0
  142. package/src/commands/config.ts +77 -0
  143. package/src/commands/contacts.ts +612 -0
  144. package/src/commands/custom-attributes.ts +127 -0
  145. package/src/commands/dkims.ts +117 -0
  146. package/src/commands/domains.ts +82 -0
  147. package/src/commands/email-apis.ts +569 -0
  148. package/src/commands/emails.ts +197 -0
  149. package/src/commands/forms.ts +283 -0
  150. package/src/commands/interests.ts +155 -0
  151. package/src/commands/links.ts +38 -0
  152. package/src/commands/lists.ts +406 -0
  153. package/src/commands/logos.ts +71 -0
  154. package/src/commands/logs.ts +386 -0
  155. package/src/commands/reports.ts +306 -0
  156. package/src/commands/segments.ts +158 -0
  157. package/src/commands/senders.ts +204 -0
  158. package/src/commands/sub-accounts.ts +271 -0
  159. package/src/commands/suppressed-emails.ts +234 -0
  160. package/src/commands/suppressed.ts +198 -0
  161. package/src/commands/system-emails.ts +85 -0
  162. package/src/commands/tags.ts +146 -0
  163. package/src/commands/tasks.ts +116 -0
  164. package/src/commands/templates.ts +189 -0
  165. package/src/commands/tokens.ts +83 -0
  166. package/src/commands/transactional-emails.ts +374 -0
  167. package/src/commands/transactional-templates.ts +385 -0
  168. package/src/commands/users.ts +506 -0
  169. package/src/commands/webhooks.ts +172 -0
  170. package/src/commands/workflow-blueprints.ts +123 -0
  171. package/src/commands/workflows.ts +265 -0
  172. package/src/types/profile.ts +93 -0
  173. package/src/utils/auth.ts +272 -0
  174. package/src/utils/config-file.ts +96 -0
  175. package/src/utils/config.ts +134 -0
  176. package/src/utils/confirm.ts +32 -0
  177. package/src/utils/defaults.ts +99 -0
  178. package/src/utils/errors.ts +116 -0
  179. package/src/utils/interactive.ts +91 -0
  180. package/src/utils/list-defaults.ts +74 -0
  181. package/src/utils/output.ts +190 -0
  182. package/src/utils/progress.ts +320 -0
  183. package/src/utils/spinner.ts +22 -0
  184. package/tests/IMPLEMENTATION_STATUS.md +258 -0
  185. package/tests/PTY_SETUP.md +118 -0
  186. package/tests/PTY_TESTING_GUIDE.md +507 -0
  187. package/tests/README.md +244 -0
  188. package/tests/fixtures/api-responses/campaigns.json +34 -0
  189. package/tests/fixtures/test-config.json +13 -0
  190. package/tests/helpers/cli-runner.ts +128 -0
  191. package/tests/helpers/mock-server.ts +301 -0
  192. package/tests/helpers/pty-runner.ts +181 -0
  193. package/tests/integration/campaigns-real-api.test.ts +196 -0
  194. package/tests/integration/setup-integration.ts +50 -0
  195. package/tests/pty/campaigns.test.ts +241 -0
  196. package/tests/setup.ts +34 -0
  197. package/tsconfig.json +15 -0
  198. package/vitest.config.ts +28 -0
@@ -0,0 +1,634 @@
1
+ # Connection Problems
2
+
3
+ Diagnose and resolve network connectivity and API communication issues.
4
+
5
+ ## Overview
6
+
7
+ Common connection problems:
8
+ - Network timeouts
9
+ - DNS resolution failures
10
+ - SSL/TLS certificate errors
11
+ - Proxy configuration issues
12
+ - Firewall blocking
13
+ - API service disruptions
14
+
15
+ ## Network Timeouts
16
+
17
+ ### Error: "Connection timeout" or "Request timeout"
18
+
19
+ **Cause:** Request takes too long to complete.
20
+
21
+ **Solutions:**
22
+
23
+ ```bash
24
+ # Check internet connectivity
25
+ $ ping -c 3 google.com
26
+ PING google.com: 64 bytes from...
27
+
28
+ # Test Cakemail API specifically
29
+ $ ping -c 3 api.cakemail.com
30
+
31
+ # Test with curl
32
+ $ curl -I https://api.cakemail.com
33
+ HTTP/2 200
34
+
35
+ # Increase timeout (if supported)
36
+ $ export CAKEMAIL_TIMEOUT=60000 # 60 seconds
37
+
38
+ # Check if slow network
39
+ $ time curl https://api.cakemail.com
40
+ real 0m5.234s # If > 10s, network is slow
41
+
42
+ # Try from different network
43
+ # - Switch from WiFi to ethernet
44
+ # - Try mobile hotspot
45
+ # - Use VPN if corporate network
46
+ ```
47
+
48
+ ### Slow API Responses
49
+
50
+ **Problem:** Commands take very long to complete.
51
+
52
+ **Solutions:**
53
+
54
+ ```bash
55
+ # Measure response time
56
+ $ time cakemail lists list
57
+
58
+ # Compare to direct API call
59
+ $ time curl -s https://api.cakemail.com/v1/lists
60
+
61
+ # If API is slow:
62
+ # - Check API status: status.cakemail.com
63
+ # - Use filters to reduce data transfer
64
+ $ cakemail lists list --limit 10
65
+
66
+ # If network is slow:
67
+ # - Use caching (see Performance guide)
68
+ # - Reduce API calls
69
+ # - Use compact output format
70
+ $ cakemail lists list -f compact
71
+ ```
72
+
73
+ ## DNS Resolution Issues
74
+
75
+ ### Error: "Could not resolve host" or "Name resolution failed"
76
+
77
+ **Cause:** Cannot resolve domain name to IP address.
78
+
79
+ **Solutions:**
80
+
81
+ ```bash
82
+ # Test DNS resolution
83
+ $ nslookup api.cakemail.com
84
+ Server: 8.8.8.8
85
+ Address: 8.8.8.8#53
86
+
87
+ Name: api.cakemail.com
88
+ Address: 104.18.x.x
89
+
90
+ # If fails, try different DNS server
91
+ $ nslookup api.cakemail.com 8.8.8.8 # Google DNS
92
+ $ nslookup api.cakemail.com 1.1.1.1 # Cloudflare DNS
93
+
94
+ # Change system DNS (macOS)
95
+ $ networksetup -setdnsservers Wi-Fi 8.8.8.8 1.1.1.1
96
+
97
+ # Change system DNS (Linux)
98
+ $ echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
99
+
100
+ # Flush DNS cache (macOS)
101
+ $ sudo dscacheutil -flushcache
102
+
103
+ # Flush DNS cache (Linux)
104
+ $ sudo systemd-resolve --flush-caches
105
+
106
+ # Test again
107
+ $ cakemail lists list
108
+ ```
109
+
110
+ ### DNS Cache Issues
111
+
112
+ **Problem:** Cached DNS pointing to old IP.
113
+
114
+ **Solutions:**
115
+
116
+ ```bash
117
+ # Clear DNS cache
118
+
119
+ # macOS
120
+ $ sudo dscacheutil -flushcache
121
+ $ sudo killall -HUP mDNSResponder
122
+
123
+ # Linux (systemd)
124
+ $ sudo systemd-resolve --flush-caches
125
+
126
+ # Windows
127
+ $ ipconfig /flushdns
128
+
129
+ # Verify new resolution
130
+ $ nslookup api.cakemail.com
131
+
132
+ # Force CLI to use specific IP (temporary)
133
+ $ echo "104.18.x.x api.cakemail.com" | sudo tee -a /etc/hosts
134
+ ```
135
+
136
+ ## SSL/TLS Certificate Errors
137
+
138
+ ### Error: "SSL certificate problem" or "Certificate verification failed"
139
+
140
+ **Cause:** SSL certificate validation issues.
141
+
142
+ **Solutions:**
143
+
144
+ ```bash
145
+ # Check certificate
146
+ $ openssl s_client -connect api.cakemail.com:443 -showcerts
147
+
148
+ # Verify certificate validity
149
+ $ curl -vI https://api.cakemail.com 2>&1 | grep -i certificate
150
+
151
+ # Update CA certificates (Linux)
152
+ $ sudo apt-get update
153
+ $ sudo apt-get install ca-certificates
154
+
155
+ # Update CA certificates (macOS)
156
+ $ brew install ca-certificates
157
+
158
+ # Temporarily skip verification (NOT RECOMMENDED FOR PRODUCTION)
159
+ $ export NODE_TLS_REJECT_UNAUTHORIZED=0
160
+ $ cakemail lists list
161
+ $ unset NODE_TLS_REJECT_UNAUTHORIZED
162
+
163
+ # Check system time (cert validation requires accurate time)
164
+ $ date
165
+ ```
166
+
167
+ ### Certificate Expiration
168
+
169
+ **Problem:** Cakemail's certificate expired (rare).
170
+
171
+ **Solutions:**
172
+
173
+ ```bash
174
+ # Check certificate expiration
175
+ $ echo | openssl s_client -connect api.cakemail.com:443 2>/dev/null | \
176
+ openssl x509 -noout -dates
177
+
178
+ notBefore=Jan 1 00:00:00 2024 GMT
179
+ notAfter=Jan 1 23:59:59 2025 GMT
180
+
181
+ # If expired:
182
+ # - Check status.cakemail.com
183
+ # - Wait for Cakemail to renew
184
+ # - Contact support
185
+
186
+ # Check your system time is correct
187
+ $ date
188
+ # Incorrect time causes cert validation to fail
189
+
190
+ # Sync system time (Linux)
191
+ $ sudo ntpdate -s time.nist.gov
192
+
193
+ # Sync system time (macOS)
194
+ $ sudo sntp -sS time.apple.com
195
+ ```
196
+
197
+ ## Proxy Configuration
198
+
199
+ ### Behind Corporate Proxy
200
+
201
+ **Problem:** CLI cannot reach API through corporate proxy.
202
+
203
+ **Solutions:**
204
+
205
+ ```bash
206
+ # Configure HTTP proxy
207
+ $ export HTTP_PROXY=http://proxy.company.com:8080
208
+ $ export HTTPS_PROXY=http://proxy.company.com:8080
209
+
210
+ # With authentication
211
+ $ export HTTP_PROXY=http://user:password@proxy.company.com:8080
212
+ $ export HTTPS_PROXY=http://user:password@proxy.company.com:8080
213
+
214
+ # Exclude localhost (if needed)
215
+ $ export NO_PROXY=localhost,127.0.0.1
216
+
217
+ # Test with curl
218
+ $ curl -I https://api.cakemail.com
219
+
220
+ # Test CLI
221
+ $ cakemail lists list
222
+
223
+ # Make permanent (add to ~/.bashrc or ~/.zshrc)
224
+ $ cat >> ~/.bashrc << 'EOF'
225
+ export HTTP_PROXY=http://proxy.company.com:8080
226
+ export HTTPS_PROXY=http://proxy.company.com:8080
227
+ EOF
228
+ ```
229
+
230
+ ### Proxy Authentication Issues
231
+
232
+ **Problem:** Proxy requires authentication.
233
+
234
+ **Solutions:**
235
+
236
+ ```bash
237
+ # URL-encode special characters in password
238
+ # If password is: p@ssw0rd!
239
+ # Encoded: p%40ssw0rd%21
240
+
241
+ # Use encoded password
242
+ $ export HTTP_PROXY=http://user:p%40ssw0rd%21@proxy.company.com:8080
243
+
244
+ # Or use .netrc file (more secure)
245
+ $ cat > ~/.netrc << EOF
246
+ machine proxy.company.com
247
+ login user
248
+ password p@ssw0rd!
249
+ EOF
250
+ $ chmod 600 ~/.netrc
251
+
252
+ # Configure proxy in npm (for CLI installation)
253
+ $ npm config set proxy http://proxy.company.com:8080
254
+ $ npm config set https-proxy http://proxy.company.com:8080
255
+ ```
256
+
257
+ ## Firewall Issues
258
+
259
+ ### Error: "Connection refused" or "Network unreachable"
260
+
261
+ **Cause:** Firewall blocking outbound HTTPS.
262
+
263
+ **Solutions:**
264
+
265
+ ```bash
266
+ # Check if port 443 is reachable
267
+ $ nc -zv api.cakemail.com 443
268
+ Connection to api.cakemail.com 443 port [tcp/https] succeeded!
269
+
270
+ # If fails:
271
+ # - Firewall blocking outbound HTTPS
272
+ # - Network restrictions
273
+
274
+ # Test with telnet
275
+ $ telnet api.cakemail.com 443
276
+ Trying 104.18.x.x...
277
+ Connected to api.cakemail.com.
278
+
279
+ # Check firewall rules (Linux)
280
+ $ sudo iptables -L | grep -i drop
281
+
282
+ # Allow HTTPS outbound (Linux - requires admin)
283
+ $ sudo iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
284
+
285
+ # macOS firewall
286
+ # System Preferences → Security & Privacy → Firewall
287
+ # Allow Node.js or terminal application
288
+
289
+ # Corporate firewall
290
+ # Contact IT to whitelist:
291
+ # - api.cakemail.com
292
+ # - *.cakemail.com
293
+ # Port: 443 (HTTPS)
294
+ ```
295
+
296
+ ### VPN Interference
297
+
298
+ **Problem:** VPN blocking or routing issues.
299
+
300
+ **Solutions:**
301
+
302
+ ```bash
303
+ # Test without VPN
304
+ $ # Disconnect VPN
305
+ $ cakemail lists list
306
+
307
+ # If works without VPN:
308
+ # - VPN routing all traffic through restrictive gateway
309
+ # - VPN blocking certain domains
310
+
311
+ # Split tunnel configuration
312
+ # Route only corporate traffic through VPN
313
+ # Contact IT for split tunnel setup
314
+
315
+ # Or add exception for Cakemail
316
+ # VPN settings → Exceptions
317
+ # Add: api.cakemail.com
318
+
319
+ # Test with VPN server's DNS
320
+ $ nslookup api.cakemail.com <VPN_DNS_SERVER>
321
+ ```
322
+
323
+ ## API Service Issues
324
+
325
+ ### Check API Status
326
+
327
+ ```bash
328
+ # Check if API is down
329
+ $ curl -I https://api.cakemail.com
330
+ HTTP/2 503 # Service unavailable
331
+
332
+ # Check status page
333
+ $ curl -s https://status.cakemail.com | grep -i status
334
+
335
+ # Check from external service
336
+ $ curl -I https://api.cakemail.com \
337
+ --resolve api.cakemail.com:443:8.8.8.8
338
+
339
+ # If API is down:
340
+ # - Check status.cakemail.com
341
+ # - Check @cakemail on Twitter
342
+ # - Wait for service restoration
343
+ # - Contact support for estimated resolution time
344
+ ```
345
+
346
+ ### Rate Limiting
347
+
348
+ **Error:** "Too many requests" or "Rate limit exceeded"
349
+
350
+ **Solutions:**
351
+
352
+ ```bash
353
+ # You're making too many requests
354
+ # API limits: ~100 requests/minute (example)
355
+
356
+ # Check rate limit headers
357
+ $ curl -I https://api.cakemail.com/v1/lists
358
+ X-RateLimit-Limit: 100
359
+ X-RateLimit-Remaining: 0
360
+ X-RateLimit-Reset: 1710345600
361
+
362
+ # Wait until reset time
363
+ $ date -d @1710345600
364
+ Wed Mar 13 14:00:00 EDT 2024
365
+
366
+ # Add delays between requests
367
+ $ for id in {1..10}; do
368
+ cakemail campaigns get $id
369
+ sleep 1 # Wait 1 second
370
+ done
371
+
372
+ # Use bulk operations instead
373
+ $ cakemail campaigns list # Single request
374
+
375
+ # Implement exponential backoff (see Scripting Patterns)
376
+ ```
377
+
378
+ ## Connection Debugging
379
+
380
+ ### Verbose Network Diagnostics
381
+
382
+ ```bash
383
+ # Enable verbose curl output
384
+ $ curl -v https://api.cakemail.com 2>&1 | less
385
+
386
+ # Check headers
387
+ * Trying 104.18.x.x:443...
388
+ * Connected to api.cakemail.com (104.18.x.x) port 443
389
+ * ALPN, offering h2
390
+ * ALPN, offering http/1.1
391
+ * successfully set certificate verify locations
392
+ * TLSv1.3 (OUT), TLS handshake, Client hello (1):
393
+ * TLSv1.3 (IN), TLS handshake, Server hello (2):
394
+ ...
395
+
396
+ # Trace network path
397
+ $ traceroute api.cakemail.com
398
+ traceroute to api.cakemail.com (104.18.x.x), 30 hops max
399
+ 1 router.local (192.168.1.1) 2.123 ms
400
+ 2 10.x.x.x 5.456 ms
401
+ ...
402
+
403
+ # Check packet loss
404
+ $ ping -c 100 api.cakemail.com | grep loss
405
+ 100 packets transmitted, 98 received, 2% packet loss
406
+ ```
407
+
408
+ ### Test with Different Tools
409
+
410
+ ```bash
411
+ # wget
412
+ $ wget -q -O- https://api.cakemail.com
413
+ $ echo $? # 0 = success
414
+
415
+ # curl
416
+ $ curl -f https://api.cakemail.com
417
+ $ echo $? # 0 = success
418
+
419
+ # nc (netcat)
420
+ $ nc -zv api.cakemail.com 443
421
+ Connection to api.cakemail.com 443 succeeded!
422
+
423
+ # openssl
424
+ $ openssl s_client -connect api.cakemail.com:443
425
+ CONNECTED(00000005)
426
+ ...
427
+
428
+ # If one works but CLI doesn't:
429
+ # - Node.js network issues
430
+ # - CLI bug
431
+ # - Reinstall CLI
432
+ ```
433
+
434
+ ## Environment-Specific Issues
435
+
436
+ ### Docker Containers
437
+
438
+ **Problem:** CLI fails inside Docker container.
439
+
440
+ **Solutions:**
441
+
442
+ ```bash
443
+ # Check container DNS
444
+ $ docker run --rm alpine nslookup api.cakemail.com
445
+
446
+ # Use host network (Linux only)
447
+ $ docker run --network host cakemail-cli
448
+
449
+ # Configure DNS in container
450
+ $ docker run --dns 8.8.8.8 --dns 1.1.1.1 cakemail-cli
451
+
452
+ # Check if behind corporate proxy
453
+ $ docker run -e HTTP_PROXY=http://proxy:8080 cakemail-cli
454
+
455
+ # Dockerfile with proxy
456
+ FROM node:18
457
+ ENV HTTP_PROXY=http://proxy:8080
458
+ ENV HTTPS_PROXY=http://proxy:8080
459
+ ```
460
+
461
+ ### CI/CD Environments
462
+
463
+ **Problem:** Works locally but fails in CI.
464
+
465
+ **Solutions:**
466
+
467
+ ```bash
468
+ # GitHub Actions - check network
469
+ - name: Test connectivity
470
+ run: |
471
+ curl -I https://api.cakemail.com
472
+ nslookup api.cakemail.com
473
+
474
+ # GitLab CI - use different runner
475
+ # Some runners have restricted network access
476
+
477
+ # Check if CI server IP is blocked
478
+ # Contact Cakemail support to whitelist
479
+
480
+ # Use retry logic in CI
481
+ - name: Deploy campaign
482
+ run: |
483
+ for i in {1..3}; do
484
+ cakemail campaigns schedule $ID && break
485
+ sleep 5
486
+ done
487
+ ```
488
+
489
+ ### Mobile Hotspot / Tethering
490
+
491
+ **Problem:** Different behavior on mobile network.
492
+
493
+ **Solutions:**
494
+
495
+ ```bash
496
+ # Mobile carriers may block/throttle HTTPS
497
+ # - Try different carrier
498
+ # - Use VPN to bypass throttling
499
+ # - Disable mobile optimization in carrier settings
500
+
501
+ # Check if carrier DNS causing issues
502
+ $ nslookup api.cakemail.com
503
+
504
+ # Use public DNS
505
+ # iOS: Settings → Wi-Fi → Configure DNS → Manual
506
+ # Android: Settings → Network → Private DNS → dns.google
507
+ ```
508
+
509
+ ## Network Testing Scripts
510
+
511
+ ### Comprehensive Connectivity Test
512
+
513
+ ```bash
514
+ #!/bin/bash
515
+
516
+ echo "=== Cakemail Connectivity Test ==="
517
+ echo ""
518
+
519
+ # 1. Internet connectivity
520
+ echo "1. Testing internet connectivity..."
521
+ if ping -c 3 google.com &>/dev/null; then
522
+ echo "✓ Internet: OK"
523
+ else
524
+ echo "✗ Internet: FAIL"
525
+ exit 1
526
+ fi
527
+
528
+ # 2. DNS resolution
529
+ echo ""
530
+ echo "2. Testing DNS resolution..."
531
+ if nslookup api.cakemail.com &>/dev/null; then
532
+ echo "✓ DNS resolution: OK"
533
+ IP=$(nslookup api.cakemail.com | grep -A1 "Name:" | grep "Address:" | awk '{print $2}' | head -1)
534
+ echo " Resolved to: $IP"
535
+ else
536
+ echo "✗ DNS resolution: FAIL"
537
+ exit 1
538
+ fi
539
+
540
+ # 3. Port connectivity
541
+ echo ""
542
+ echo "3. Testing port 443 connectivity..."
543
+ if nc -zv api.cakemail.com 443 2>&1 | grep -q "succeeded"; then
544
+ echo "✓ Port 443: OK"
545
+ else
546
+ echo "✗ Port 443: FAIL"
547
+ exit 1
548
+ fi
549
+
550
+ # 4. SSL certificate
551
+ echo ""
552
+ echo "4. Testing SSL certificate..."
553
+ if openssl s_client -connect api.cakemail.com:443 </dev/null 2>/dev/null | \
554
+ grep -q "Verify return code: 0"; then
555
+ echo "✓ SSL certificate: OK"
556
+ else
557
+ echo "⚠ SSL certificate: WARNING"
558
+ fi
559
+
560
+ # 5. API availability
561
+ echo ""
562
+ echo "5. Testing API availability..."
563
+ if curl -f -s -I https://api.cakemail.com | grep -q "HTTP/2 200"; then
564
+ echo "✓ API: OK"
565
+ else
566
+ echo "✗ API: FAIL"
567
+ exit 1
568
+ fi
569
+
570
+ # 6. API latency
571
+ echo ""
572
+ echo "6. Measuring API latency..."
573
+ LATENCY=$(curl -o /dev/null -s -w '%{time_total}' https://api.cakemail.com)
574
+ echo " Latency: ${LATENCY}s"
575
+
576
+ if (( $(echo "$LATENCY > 5.0" | bc -l) )); then
577
+ echo "⚠ High latency (slow network)"
578
+ fi
579
+
580
+ echo ""
581
+ echo "=== All tests passed ==="
582
+ ```
583
+
584
+ ## Quick Fixes
585
+
586
+ ### Reset Network Stack
587
+
588
+ ```bash
589
+ # macOS
590
+ $ sudo ifconfig en0 down
591
+ $ sudo ifconfig en0 up
592
+
593
+ # Linux
594
+ $ sudo systemctl restart NetworkManager
595
+
596
+ # Flush DNS
597
+ $ sudo dscacheutil -flushcache # macOS
598
+ $ sudo systemd-resolve --flush-caches # Linux
599
+
600
+ # Reset routing table
601
+ $ sudo route flush # macOS
602
+ $ sudo ip route flush cache # Linux
603
+ ```
604
+
605
+ ### Check System Configuration
606
+
607
+ ```bash
608
+ # View network settings
609
+ $ ifconfig # or ip addr
610
+
611
+ # Check gateway
612
+ $ netstat -rn | grep default
613
+
614
+ # View DNS servers
615
+ $ cat /etc/resolv.conf
616
+
617
+ # Check proxy settings
618
+ $ env | grep -i proxy
619
+
620
+ # Verify time sync (important for SSL)
621
+ $ date
622
+ ```
623
+
624
+ ## Getting Help
625
+
626
+ If connection issues persist:
627
+
628
+ 1. Run connectivity test script
629
+ 2. Test with `curl` to isolate issue
630
+ 3. Check firewall/proxy settings
631
+ 4. Verify API status: status.cakemail.com
632
+ 5. Contact IT (if corporate network)
633
+ 6. Create GitHub issue with diagnostics
634
+