@sesender/cli 1.0.5 → 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
@@ -13,8 +13,9 @@ import { templatesList, templatesGet } from "../src/commands/templates.mjs";
13
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.5";
18
+ const VERSION = "1.0.6";
18
19
 
19
20
  function parseArgs(argv) {
20
21
  const args = { _positional: [] };
@@ -111,7 +112,8 @@ ACCOUNT
111
112
  account info View account information
112
113
  account rate View API rate limit status
113
114
  account balance View all credit balances
114
-
115
+ SETTINGS
116
+ settings daily-limit Get or set max messages per recipient per day
115
117
  GLOBAL OPTIONS
116
118
  --json Output in JSON format (machine-readable)
117
119
  --help Show this help message
@@ -308,7 +310,7 @@ async function main() {
308
310
  await seedBalance(args, jsonMode);
309
311
  break;
310
312
 
311
- case "account":
313
+ case "account":
312
314
  switch (subcommand) {
313
315
  case "info": await accountInfo(args, jsonMode); break;
314
316
  case "rate": await accountRateLimit(args, jsonMode); break;
@@ -318,7 +320,16 @@ async function main() {
318
320
  process.exit(1);
319
321
  }
320
322
  break;
321
-
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)");
330
+ process.exit(1);
331
+ }
332
+ break;
322
333
  default:
323
334
  console.error(`Unknown command: ${command}`);
324
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.5",
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": {
@@ -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
+ }