@sesender/cli 1.0.4 → 1.0.6

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/bin/ses-cli.mjs CHANGED
@@ -10,11 +10,12 @@ import { providersList } from "../src/commands/providers.mjs";
10
10
  import { webhooksList, webhooksCreate, webhooksDelete, webhooksTest } from "../src/commands/webhooks.mjs";
11
11
  import { seedCheck, seedBalance } from "../src/commands/seedcheck.mjs";
12
12
  import { templatesList, templatesGet } from "../src/commands/templates.mjs";
13
- import { accountInfo, accountRateLimit } from "../src/commands/account.mjs";
13
+ import { accountInfo, accountRateLimit, accountBalance } from "../src/commands/account.mjs";
14
14
  import { trackingDomainsList, trackingStats } from "../src/commands/tracking.mjs";
15
15
  import { scheduleList, scheduleCancel } from "../src/commands/schedule.mjs";
16
+ import { settingsDailyLimit } from "../src/commands/settings.mjs";
16
17
 
17
- const VERSION = "1.0.1";
18
+ const VERSION = "1.0.6";
18
19
 
19
20
  function parseArgs(argv) {
20
21
  const args = { _positional: [] };
@@ -98,6 +99,7 @@ VALIDATION
98
99
  validate phone Validate a phone number
99
100
  validate email Validate an email address
100
101
  validate bulk Bulk validate from file
102
+ validate balance Check validation credit balance
101
103
 
102
104
  SEED CHECK
103
105
  seed-check Check emails against seed database
@@ -109,7 +111,9 @@ ANALYTICS
109
111
  ACCOUNT
110
112
  account info View account information
111
113
  account rate View API rate limit status
112
-
114
+ account balance View all credit balances
115
+ SETTINGS
116
+ settings daily-limit Get or set max messages per recipient per day
113
117
  GLOBAL OPTIONS
114
118
  --json Output in JSON format (machine-readable)
115
119
  --help Show this help message
@@ -291,8 +295,9 @@ async function main() {
291
295
  case "phone": await validatePhone(args, jsonMode); break;
292
296
  case "email": await validateEmail(args, jsonMode); break;
293
297
  case "bulk": await validateBulk(args, jsonMode); break;
298
+ case "balance": await accountBalance(args, jsonMode); break;
294
299
  default:
295
- console.error("Usage: ses-cli validate <phone|email|bulk>");
300
+ console.error("Usage: ses-cli validate <phone|email|bulk|balance>");
296
301
  process.exit(1);
297
302
  }
298
303
  break;
@@ -305,16 +310,26 @@ async function main() {
305
310
  await seedBalance(args, jsonMode);
306
311
  break;
307
312
 
308
- case "account":
313
+ case "account":
309
314
  switch (subcommand) {
310
315
  case "info": await accountInfo(args, jsonMode); break;
311
316
  case "rate": await accountRateLimit(args, jsonMode); break;
317
+ case "balance": await accountBalance(args, jsonMode); break;
312
318
  default:
313
- console.error("Usage: ses-cli account <info|rate>");
319
+ console.error("Usage: ses-cli account <info|rate|balance>");
320
+ process.exit(1);
321
+ }
322
+ break;
323
+ case "settings":
324
+ switch (subcommand) {
325
+ case "daily-limit": await settingsDailyLimit(args, jsonMode); break;
326
+ default:
327
+ console.error("Usage: ses-cli settings <daily-limit>");
328
+ console.error("\n daily-limit Get or set max messages per recipient per day");
329
+ console.error(" --set <N> Set limit (use 0 to remove)");
314
330
  process.exit(1);
315
331
  }
316
332
  break;
317
-
318
333
  default:
319
334
  console.error(`Unknown command: ${command}`);
320
335
  console.error("Run 'ses-cli --help' for usage information.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sesender/cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "SESender CLI - Send SMS/emails, manage contacts, and view analytics from your terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,15 +11,7 @@
11
11
  "src/",
12
12
  "README.md"
13
13
  ],
14
- "keywords": [
15
- "sesender",
16
- "sms",
17
- "email",
18
- "marketing",
19
- "cli",
20
- "bulk-sms",
21
- "bulk-email"
22
- ],
14
+ "keywords": ["sesender", "sms", "email", "marketing", "cli", "bulk-sms", "bulk-email"],
23
15
  "author": "SESender Team",
24
16
  "license": "MIT",
25
17
  "repository": {
@@ -13,6 +13,28 @@ export async function accountInfo(args, jsonMode) {
13
13
  console.log(` Name: ${data.name || "N/A"}`);
14
14
  console.log(` Email: ${data.email || "N/A"}`);
15
15
  console.log(` User ID: ${data.id || "N/A"}`);
16
+
17
+ if (data.balances) {
18
+ console.log(`\n Balances`);
19
+ console.log(` ─────────────────────────`);
20
+ if (data.balances.validation) {
21
+ const v = data.balances.validation;
22
+ console.log(` Validation: ${v.balanceFormatted} (${v.rateFormatted})`);
23
+ if (v.balance > 0 && v.rate > 0) {
24
+ const remaining = Math.floor(v.balance / v.rate);
25
+ console.log(` ~${remaining} checks remaining`);
26
+ }
27
+ }
28
+ if (data.balances.seedCheck) {
29
+ const s = data.balances.seedCheck;
30
+ console.log(` Seed Check: ${s.balanceFormatted} (${s.rateFormatted})`);
31
+ if (s.balance > 0 && s.rate > 0) {
32
+ const remaining = Math.floor(s.balance / s.rate);
33
+ console.log(` ~${remaining} checks remaining`);
34
+ }
35
+ }
36
+ }
37
+
16
38
  if (data.apiKey) {
17
39
  console.log(`\n API Key Details`);
18
40
  console.log(` ─────────────────────────`);
@@ -46,3 +68,33 @@ export async function accountRateLimit(args, jsonMode) {
46
68
  console.log("");
47
69
  }
48
70
  }
71
+
72
+ export async function accountBalance(args, jsonMode) {
73
+ const result = await apiRequest("GET", "/validate/balance");
74
+ const seedResult = await apiRequest("GET", "/seed-check/balance");
75
+
76
+ if (jsonMode) {
77
+ outputResult({
78
+ validation: result.data || result,
79
+ seedCheck: seedResult.data || seedResult,
80
+ }, true);
81
+ } else {
82
+ const vData = result.data || result;
83
+ const sData = seedResult.data || seedResult;
84
+ console.log(`\n Account Balances`);
85
+ console.log(` ═══════════════════════════`);
86
+ console.log(`\n Phone & Email Validation`);
87
+ console.log(` ─────────────────────────`);
88
+ console.log(` Balance: ${vData.balanceFormatted || `€${((vData.balance || 0) / 100).toFixed(2)}`}`);
89
+ console.log(` Rate: ${vData.rateFormatted || `${vData.rate || 0.7} cents/check`}`);
90
+ console.log(` Remaining: ~${vData.checksRemaining || 0} checks`);
91
+ console.log(`\n Seed Check`);
92
+ console.log(` ─────────────────────────`);
93
+ console.log(` Balance: €${(sData.balance || 0).toFixed(2)}`);
94
+ console.log(` Rate: €${(sData.rate || 0.01).toFixed(4)}/email`);
95
+ if (sData.balance > 0 && sData.rate > 0) {
96
+ console.log(` Remaining: ~${Math.floor(sData.balance / sData.rate)} checks`);
97
+ }
98
+ console.log("");
99
+ }
100
+ }
@@ -0,0 +1,54 @@
1
+ import { apiRequest } from "../api.mjs";
2
+ import { success, info, warn } from "../output.mjs";
3
+
4
+ export async function settingsDailyLimit(args, jsonMode) {
5
+ const newLimit = args["--limit"] || args["--set"];
6
+
7
+ if (newLimit !== undefined) {
8
+ // Set the daily limit
9
+ const limitValue = newLimit === "0" || newLimit === "none" || newLimit === "null"
10
+ ? null
11
+ : parseInt(newLimit);
12
+
13
+ if (limitValue !== null && (isNaN(limitValue) || limitValue < 1)) {
14
+ if (jsonMode) {
15
+ console.log(JSON.stringify({ error: "Invalid limit value. Must be a positive integer or 0/none for no limit." }));
16
+ } else {
17
+ console.error("Error: Limit must be a positive integer, or use 0/none to remove the limit.");
18
+ }
19
+ process.exit(1);
20
+ }
21
+
22
+ const result = await apiRequest("PUT", "/settings/daily-limit", { limit: limitValue });
23
+
24
+ if (jsonMode) {
25
+ console.log(JSON.stringify(result, null, 2));
26
+ } else {
27
+ if (limitValue) {
28
+ success(`Daily limit set to ${limitValue} messages per recipient per day`);
29
+ } else {
30
+ success("Daily limit removed (no limit)");
31
+ }
32
+ }
33
+ } else {
34
+ // Get the current daily limit
35
+ const result = await apiRequest("GET", "/settings/daily-limit");
36
+
37
+ if (jsonMode) {
38
+ console.log(JSON.stringify(result, null, 2));
39
+ } else {
40
+ const limit = result.data?.maxMessagesPerRecipientPerDay;
41
+ console.log("\n Daily Recipient Limit");
42
+ console.log(" " + "─".repeat(40));
43
+ if (limit) {
44
+ console.log(` Max messages per recipient/day: ${limit}`);
45
+ info(" Each email/phone can receive at most " + limit + " message(s) per day across all campaigns.");
46
+ } else {
47
+ console.log(" Max messages per recipient/day: No limit");
48
+ info(" Recipients can receive unlimited messages per day.");
49
+ }
50
+ console.log("\n To set a limit: ses-cli settings daily-limit --set 3");
51
+ console.log(" To remove limit: ses-cli settings daily-limit --set 0\n");
52
+ }
53
+ }
54
+ }