supersendtx-cli 0.6.0 → 0.8.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 (2) hide show
  1. package/dist/cli.js +620 -54
  2. package/package.json +3 -3
package/dist/cli.js CHANGED
@@ -116,18 +116,93 @@ async function runSendCommandWithClient(args, env = process.env) {
116
116
  return { exitCode };
117
117
  }
118
118
 
119
- // src/commands/emails/cancel.ts
119
+ // src/commands/emails/batch.ts
120
+ import { readFile } from "fs/promises";
120
121
  function readFlag2(args, flag) {
121
122
  const index = args.indexOf(flag);
122
123
  if (index === -1) return void 0;
123
124
  return args[index + 1];
124
125
  }
125
- async function runCancelCommand(args, deps) {
126
+ function readFirstPositional(args) {
127
+ for (let index = 0; index < args.length; index += 1) {
128
+ const arg = args[index];
129
+ if (arg.startsWith("--")) {
130
+ if (arg === "--api-key" || arg === "--base-url" || arg === "--file") index += 1;
131
+ continue;
132
+ }
133
+ return arg;
134
+ }
135
+ return void 0;
136
+ }
137
+ async function runBatchCommand(args, deps) {
126
138
  const env = deps.env ?? process.env;
127
139
  const stdout = deps.stdout ?? ((line) => console.log(line));
128
140
  const stderr = deps.stderr ?? ((line) => console.error(line));
129
141
  const apiKey = readFlag2(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
130
- const id = readFlag2(args, "--id") || args.find((arg) => !arg.startsWith("--"));
142
+ if (!apiKey) {
143
+ stderr("Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key.");
144
+ return { exitCode: 1, error: "missing key" };
145
+ }
146
+ const filePath = readFlag2(args, "--file") || readFirstPositional(args);
147
+ if (!filePath) {
148
+ stderr("Required: --file <emails.json>");
149
+ return { exitCode: 1, error: "missing file" };
150
+ }
151
+ try {
152
+ const readTextFile = deps.readTextFile ?? ((path) => readFile(path, "utf8"));
153
+ const source = await readTextFile(filePath);
154
+ const payload = parseBatchPayload(source);
155
+ if ("error" in payload) {
156
+ stderr(payload.error);
157
+ return { exitCode: 1, error: payload.error };
158
+ }
159
+ const result = await deps.sendBatch(payload.emails);
160
+ stdout(JSON.stringify(result));
161
+ return { exitCode: 0 };
162
+ } catch (error) {
163
+ stderr(error instanceof Error ? error.message : String(error));
164
+ return { exitCode: 1, error: String(error) };
165
+ }
166
+ }
167
+ async function runBatchCommandWithClient(args, env = process.env) {
168
+ const apiKey = readFlag2(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
169
+ const baseUrl = readFlag2(args, "--base-url");
170
+ if (!apiKey) {
171
+ return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
172
+ }
173
+ const { SuperSendTX } = await import("supersendtx");
174
+ const client = new SuperSendTX(apiKey, baseUrl ? { baseUrl } : void 0);
175
+ return runBatchCommand(args, {
176
+ env,
177
+ sendBatch: (emails) => client.emails.batch(emails)
178
+ });
179
+ }
180
+ function parseBatchPayload(source) {
181
+ let parsed;
182
+ try {
183
+ parsed = JSON.parse(source);
184
+ } catch {
185
+ return { error: "Batch file must be valid JSON." };
186
+ }
187
+ const emails = Array.isArray(parsed) ? parsed : parsed && typeof parsed === "object" && "emails" in parsed && Array.isArray(parsed.emails) ? parsed.emails : null;
188
+ if (!emails || emails.length === 0) {
189
+ return { error: "Batch file must contain a non-empty array of emails." };
190
+ }
191
+ return { emails };
192
+ }
193
+
194
+ // src/commands/emails/cancel.ts
195
+ function readFlag3(args, flag) {
196
+ const index = args.indexOf(flag);
197
+ if (index === -1) return void 0;
198
+ return args[index + 1];
199
+ }
200
+ async function runCancelCommand(args, deps) {
201
+ const env = deps.env ?? process.env;
202
+ const stdout = deps.stdout ?? ((line) => console.log(line));
203
+ const stderr = deps.stderr ?? ((line) => console.error(line));
204
+ const apiKey = readFlag3(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
205
+ const id = readFlag3(args, "--id") || args.find((arg) => !arg.startsWith("--"));
131
206
  if (!apiKey) {
132
207
  stderr("Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key.");
133
208
  return { exitCode: 1, error: "missing key" };
@@ -146,8 +221,8 @@ async function runCancelCommand(args, deps) {
146
221
  }
147
222
  }
148
223
  async function runCancelCommandWithClient(args, env = process.env) {
149
- const apiKey = readFlag2(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
150
- const baseUrl = readFlag2(args, "--base-url");
224
+ const apiKey = readFlag3(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
225
+ const baseUrl = readFlag3(args, "--base-url");
151
226
  if (!apiKey) {
152
227
  return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
153
228
  }
@@ -160,7 +235,7 @@ async function runCancelCommandWithClient(args, env = process.env) {
160
235
  }
161
236
 
162
237
  // src/commands/emails/get.ts
163
- function readFlag3(args, flag) {
238
+ function readFlag4(args, flag) {
164
239
  const index = args.indexOf(flag);
165
240
  if (index === -1) return void 0;
166
241
  return args[index + 1];
@@ -169,8 +244,8 @@ async function runGetCommand(args, deps) {
169
244
  const env = deps.env ?? process.env;
170
245
  const stdout = deps.stdout ?? ((line) => console.log(line));
171
246
  const stderr = deps.stderr ?? ((line) => console.error(line));
172
- const id = readFlag3(args, "--id") || args.find((a) => !a.startsWith("--"));
173
- const apiKey = readFlag3(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
247
+ const id = readFlag4(args, "--id") || args.find((a) => !a.startsWith("--"));
248
+ const apiKey = readFlag4(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
174
249
  if (!apiKey) {
175
250
  stderr("Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key.");
176
251
  return { exitCode: 1, error: "missing key" };
@@ -189,8 +264,8 @@ async function runGetCommand(args, deps) {
189
264
  }
190
265
  }
191
266
  async function runGetCommandWithClient(args, env = process.env) {
192
- const apiKey = readFlag3(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
193
- const baseUrl = readFlag3(args, "--base-url");
267
+ const apiKey = readFlag4(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
268
+ const baseUrl = readFlag4(args, "--base-url");
194
269
  if (!apiKey) {
195
270
  return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
196
271
  }
@@ -202,8 +277,51 @@ async function runGetCommandWithClient(args, env = process.env) {
202
277
  });
203
278
  }
204
279
 
280
+ // src/commands/emails/insights.ts
281
+ function readFlag5(args, flag) {
282
+ const index = args.indexOf(flag);
283
+ if (index === -1) return void 0;
284
+ return args[index + 1];
285
+ }
286
+ async function runInsightsCommand(args, deps) {
287
+ const env = deps.env ?? process.env;
288
+ const stdout = deps.stdout ?? ((line) => console.log(line));
289
+ const stderr = deps.stderr ?? ((line) => console.error(line));
290
+ const apiKey = readFlag5(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
291
+ if (!apiKey) {
292
+ stderr("Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key.");
293
+ return { exitCode: 1, error: "missing key" };
294
+ }
295
+ const windowFlag = readFlag5(args, "--window");
296
+ if (windowFlag && windowFlag !== "7d" && windowFlag !== "30d") {
297
+ stderr("Invalid --window. Use 7d or 30d.");
298
+ return { exitCode: 1, error: "invalid window" };
299
+ }
300
+ try {
301
+ const result = await deps.getInsights(windowFlag);
302
+ stdout(JSON.stringify(result));
303
+ return { exitCode: 0 };
304
+ } catch (error) {
305
+ stderr(error instanceof Error ? error.message : String(error));
306
+ return { exitCode: 1, error: String(error) };
307
+ }
308
+ }
309
+ async function runInsightsCommandWithClient(args, env = process.env) {
310
+ const apiKey = readFlag5(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
311
+ const baseUrl = readFlag5(args, "--base-url");
312
+ if (!apiKey) {
313
+ return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
314
+ }
315
+ const { SuperSendTX } = await import("supersendtx");
316
+ const client = new SuperSendTX(apiKey, baseUrl ? { baseUrl } : void 0);
317
+ return runInsightsCommand(args, {
318
+ env,
319
+ getInsights: (window) => client.emails.insights(window)
320
+ });
321
+ }
322
+
205
323
  // src/commands/emails/list.ts
206
- function readFlag4(args, flag) {
324
+ function readFlag6(args, flag) {
207
325
  const index = args.indexOf(flag);
208
326
  if (index === -1) return void 0;
209
327
  return args[index + 1];
@@ -212,13 +330,13 @@ async function runListCommand(args, deps) {
212
330
  const env = deps.env ?? process.env;
213
331
  const stdout = deps.stdout ?? ((line) => console.log(line));
214
332
  const stderr = deps.stderr ?? ((line) => console.error(line));
215
- const apiKey = readFlag4(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
333
+ const apiKey = readFlag6(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
216
334
  if (!apiKey) {
217
335
  stderr("Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key.");
218
336
  return { exitCode: 1, error: "missing key" };
219
337
  }
220
- const limitRaw = readFlag4(args, "--limit");
221
- const cursor = readFlag4(args, "--cursor");
338
+ const limitRaw = readFlag6(args, "--limit");
339
+ const cursor = readFlag6(args, "--cursor");
222
340
  const limit = limitRaw ? Number(limitRaw) : void 0;
223
341
  try {
224
342
  const result = await deps.listEmails({
@@ -233,8 +351,8 @@ async function runListCommand(args, deps) {
233
351
  }
234
352
  }
235
353
  async function runListCommandWithClient(args, env = process.env) {
236
- const apiKey = readFlag4(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
237
- const baseUrl = readFlag4(args, "--base-url");
354
+ const apiKey = readFlag6(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
355
+ const baseUrl = readFlag6(args, "--base-url");
238
356
  if (!apiKey) {
239
357
  return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
240
358
  }
@@ -247,17 +365,17 @@ async function runListCommandWithClient(args, env = process.env) {
247
365
  }
248
366
 
249
367
  // src/commands/domains/shared.ts
250
- function readFlag5(args, flag) {
368
+ function readFlag7(args, flag) {
251
369
  const index = args.indexOf(flag);
252
370
  if (index === -1) return void 0;
253
371
  return args[index + 1];
254
372
  }
255
373
  function parseDomainsCommonArgs(args) {
256
374
  return {
257
- apiKey: readFlag5(args, "--api-key"),
258
- baseUrl: readFlag5(args, "--base-url"),
259
- name: readFlag5(args, "--name") || readFlag5(args, "--domain"),
260
- id: readFlag5(args, "--id")
375
+ apiKey: readFlag7(args, "--api-key"),
376
+ baseUrl: readFlag7(args, "--base-url"),
377
+ name: readFlag7(args, "--name") || readFlag7(args, "--domain"),
378
+ id: readFlag7(args, "--id")
261
379
  };
262
380
  }
263
381
  function resolveApiKey(options, env) {
@@ -363,6 +481,62 @@ async function runApplyCommand(args, env = process.env) {
363
481
  }
364
482
  }
365
483
 
484
+ // src/commands/domains/delete.ts
485
+ var POSITIONAL_FLAGS = ["--api-key", "--base-url", "--name", "--domain", "--id"];
486
+ async function runDeleteCommand(args, env = process.env) {
487
+ const options = parseDomainsCommonArgs(args);
488
+ const apiKey = resolveApiKey(options, env);
489
+ if (!apiKey) return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
490
+ const idOrName = options.id || options.name || readFirstPositional2(args);
491
+ if (!idOrName) return { exitCode: 1, error: "Missing domain. Usage: supersendtx domains delete example.com" };
492
+ try {
493
+ const client = await createDomainsClient(apiKey, options.baseUrl);
494
+ console.log(JSON.stringify(await client.domains.delete(idOrName)));
495
+ return { exitCode: 0 };
496
+ } catch (error) {
497
+ return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
498
+ }
499
+ }
500
+ function readFirstPositional2(args) {
501
+ for (let i = 0; i < args.length; i += 1) {
502
+ const arg = args[i];
503
+ if (arg.startsWith("--")) {
504
+ if (POSITIONAL_FLAGS.includes(arg)) i += 1;
505
+ continue;
506
+ }
507
+ return arg;
508
+ }
509
+ return void 0;
510
+ }
511
+
512
+ // src/commands/domains/get.ts
513
+ var POSITIONAL_FLAGS2 = ["--api-key", "--base-url", "--name", "--domain", "--id"];
514
+ async function runGetCommand2(args, env = process.env) {
515
+ const options = parseDomainsCommonArgs(args);
516
+ const apiKey = resolveApiKey(options, env);
517
+ if (!apiKey) return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
518
+ const idOrName = options.id || options.name || readFirstPositional3(args);
519
+ if (!idOrName) return { exitCode: 1, error: "Missing domain. Usage: supersendtx domains get example.com" };
520
+ try {
521
+ const client = await createDomainsClient(apiKey, options.baseUrl);
522
+ console.log(JSON.stringify(await client.domains.get(idOrName)));
523
+ return { exitCode: 0 };
524
+ } catch (error) {
525
+ return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
526
+ }
527
+ }
528
+ function readFirstPositional3(args) {
529
+ for (let i = 0; i < args.length; i += 1) {
530
+ const arg = args[i];
531
+ if (arg.startsWith("--")) {
532
+ if (POSITIONAL_FLAGS2.includes(arg)) i += 1;
533
+ continue;
534
+ }
535
+ return arg;
536
+ }
537
+ return void 0;
538
+ }
539
+
366
540
  // src/commands/domains/list.ts
367
541
  async function runListCommand2(args, env = process.env) {
368
542
  const options = parseDomainsCommonArgs(args);
@@ -408,15 +582,15 @@ async function runVerifyCommand(args, env = process.env) {
408
582
  }
409
583
 
410
584
  // src/commands/webhooks/shared.ts
411
- function readFlag6(args, flag) {
585
+ function readFlag8(args, flag) {
412
586
  const index = args.indexOf(flag);
413
587
  if (index === -1) return void 0;
414
588
  return args[index + 1];
415
589
  }
416
590
  function parseWebhooksCommonArgs(args) {
417
591
  return {
418
- apiKey: readFlag6(args, "--api-key"),
419
- baseUrl: readFlag6(args, "--base-url")
592
+ apiKey: readFlag8(args, "--api-key"),
593
+ baseUrl: readFlag8(args, "--base-url")
420
594
  };
421
595
  }
422
596
  function resolveApiKey2(options, env) {
@@ -434,7 +608,7 @@ async function runCreateCommand(args, env = process.env) {
434
608
  if (!apiKey) {
435
609
  return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
436
610
  }
437
- const url = readFlag6(args, "--url");
611
+ const url = readFlag8(args, "--url");
438
612
  if (!url) {
439
613
  return { exitCode: 1, error: "Required flag: --url" };
440
614
  }
@@ -448,14 +622,46 @@ async function runCreateCommand(args, env = process.env) {
448
622
  }
449
623
  }
450
624
 
625
+ // src/commands/webhooks/get.ts
626
+ var POSITIONAL_FLAGS3 = ["--api-key", "--base-url", "--id"];
627
+ async function runGetCommand3(args, env = process.env) {
628
+ const options = parseWebhooksCommonArgs(args);
629
+ const apiKey = resolveApiKey2(options, env);
630
+ if (!apiKey) return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
631
+ const id = readFlag9(args, "--id") || readFirstPositional4(args);
632
+ if (!id) return { exitCode: 1, error: "Missing webhook id. Pass --id wh_\u2026" };
633
+ try {
634
+ const client = await createWebhooksClient(apiKey, options.baseUrl);
635
+ console.log(JSON.stringify(await client.webhooks.get(id)));
636
+ return { exitCode: 0 };
637
+ } catch (error) {
638
+ return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
639
+ }
640
+ }
641
+ function readFlag9(args, flag) {
642
+ const index = args.indexOf(flag);
643
+ return index === -1 ? void 0 : args[index + 1];
644
+ }
645
+ function readFirstPositional4(args) {
646
+ for (let i = 0; i < args.length; i += 1) {
647
+ const arg = args[i];
648
+ if (arg.startsWith("--")) {
649
+ if (POSITIONAL_FLAGS3.includes(arg)) i += 1;
650
+ continue;
651
+ }
652
+ return arg;
653
+ }
654
+ return void 0;
655
+ }
656
+
451
657
  // src/commands/webhooks/delete.ts
452
- async function runDeleteCommand(args, env = process.env) {
658
+ async function runDeleteCommand2(args, env = process.env) {
453
659
  const options = parseWebhooksCommonArgs(args);
454
660
  const apiKey = resolveApiKey2(options, env);
455
661
  if (!apiKey) {
456
662
  return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
457
663
  }
458
- const id = readFlag6(args, "--id");
664
+ const id = readFlag8(args, "--id");
459
665
  if (!id) {
460
666
  return { exitCode: 1, error: "Required flag: --id" };
461
667
  }
@@ -486,23 +692,71 @@ async function runListCommand3(args, env = process.env) {
486
692
  }
487
693
  }
488
694
 
695
+ // src/commands/webhooks/update.ts
696
+ var POSITIONAL_FLAGS4 = ["--api-key", "--base-url", "--id", "--url", "--event", "--enabled"];
697
+ async function runUpdateCommand(args, env = process.env) {
698
+ const options = parseWebhooksCommonArgs(args);
699
+ const apiKey = resolveApiKey2(options, env);
700
+ if (!apiKey) return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
701
+ const id = readFlag10(args, "--id") || readFirstPositional5(args);
702
+ if (!id) return { exitCode: 1, error: "Missing webhook id. Pass --id wh_\u2026" };
703
+ const url = readFlag10(args, "--url");
704
+ const events = readFlags2(args, "--event");
705
+ const enabled = parseEnabledFlag(readFlag10(args, "--enabled"));
706
+ if ("error" in enabled) return { exitCode: 1, error: enabled.error };
707
+ if (!url && events.length === 0 && enabled.value === void 0) return { exitCode: 1, error: "Nothing to update. Pass --url, --event, or --enabled true|false." };
708
+ try {
709
+ const client = await createWebhooksClient(apiKey, options.baseUrl);
710
+ console.log(JSON.stringify(await client.webhooks.update(id, { ...url ? { url } : {}, ...events.length > 0 ? { events } : {}, ...enabled.value !== void 0 ? { enabled: enabled.value } : {} })));
711
+ return { exitCode: 0 };
712
+ } catch (error) {
713
+ return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
714
+ }
715
+ }
716
+ function readFlag10(args, flag) {
717
+ const index = args.indexOf(flag);
718
+ return index === -1 ? void 0 : args[index + 1];
719
+ }
720
+ function readFlags2(args, flag) {
721
+ const values = [];
722
+ for (let i = 0; i < args.length; i += 1) if (args[i] === flag && args[i + 1]) values.push(args[i + 1]);
723
+ return values;
724
+ }
725
+ function readFirstPositional5(args) {
726
+ for (let i = 0; i < args.length; i += 1) {
727
+ const arg = args[i];
728
+ if (arg.startsWith("--")) {
729
+ if (POSITIONAL_FLAGS4.includes(arg)) i += 1;
730
+ continue;
731
+ }
732
+ return arg;
733
+ }
734
+ return void 0;
735
+ }
736
+ function parseEnabledFlag(value) {
737
+ if (value === void 0) return { value: void 0 };
738
+ if (value === "true") return { value: true };
739
+ if (value === "false") return { value: false };
740
+ return { error: "--enabled must be true or false" };
741
+ }
742
+
489
743
  // src/commands/keys/list.ts
490
- function readFlag7(args, flag) {
744
+ function readFlag11(args, flag) {
491
745
  const index = args.indexOf(flag);
492
746
  if (index === -1) return void 0;
493
747
  return args[index + 1];
494
748
  }
495
749
  async function runListKeysCommandWithClient(args, env = process.env) {
496
- const apiKey = readFlag7(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
497
- const baseUrl = readFlag7(args, "--base-url");
750
+ const apiKey = readFlag11(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
751
+ const baseUrl = readFlag11(args, "--base-url");
498
752
  if (!apiKey) {
499
753
  return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
500
754
  }
501
755
  const { SuperSendTX } = await import("supersendtx");
502
756
  const client = new SuperSendTX(apiKey, baseUrl ? { baseUrl } : void 0);
503
757
  try {
504
- const limitRaw = readFlag7(args, "--limit");
505
- const cursor = readFlag7(args, "--cursor");
758
+ const limitRaw = readFlag11(args, "--limit");
759
+ const cursor = readFlag11(args, "--cursor");
506
760
  const result = await client.apiKeys.list({
507
761
  ...limitRaw ? { limit: Number(limitRaw) } : {},
508
762
  ...cursor ? { cursor } : {}
@@ -517,19 +771,19 @@ async function runListKeysCommandWithClient(args, env = process.env) {
517
771
  }
518
772
 
519
773
  // src/commands/keys/create.ts
520
- function readFlag8(args, flag) {
774
+ function readFlag12(args, flag) {
521
775
  const index = args.indexOf(flag);
522
776
  if (index === -1) return void 0;
523
777
  return args[index + 1];
524
778
  }
525
779
  async function runCreateKeyCommandWithClient(args, env = process.env) {
526
- const apiKey = readFlag8(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
527
- const baseUrl = readFlag8(args, "--base-url");
780
+ const apiKey = readFlag12(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
781
+ const baseUrl = readFlag12(args, "--base-url");
528
782
  if (!apiKey) {
529
783
  return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
530
784
  }
531
- const name = readFlag8(args, "--name");
532
- const scope = readFlag8(args, "--scope");
785
+ const name = readFlag12(args, "--name");
786
+ const scope = readFlag12(args, "--scope");
533
787
  if (scope && scope !== "full" && scope !== "sending") {
534
788
  return { exitCode: 1, error: "--scope must be full or sending" };
535
789
  }
@@ -550,15 +804,15 @@ async function runCreateKeyCommandWithClient(args, env = process.env) {
550
804
  }
551
805
 
552
806
  // src/commands/keys/delete.ts
553
- function readFlag9(args, flag) {
807
+ function readFlag13(args, flag) {
554
808
  const index = args.indexOf(flag);
555
809
  if (index === -1) return void 0;
556
810
  return args[index + 1];
557
811
  }
558
812
  async function runDeleteKeyCommandWithClient(args, env = process.env) {
559
- const apiKey = readFlag9(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
560
- const baseUrl = readFlag9(args, "--base-url");
561
- const id = readFlag9(args, "--id");
813
+ const apiKey = readFlag13(args, "--api-key") || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY;
814
+ const baseUrl = readFlag13(args, "--base-url");
815
+ const id = readFlag13(args, "--id");
562
816
  if (!apiKey) {
563
817
  return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
564
818
  }
@@ -579,15 +833,15 @@ async function runDeleteKeyCommandWithClient(args, env = process.env) {
579
833
  }
580
834
 
581
835
  // src/commands/suppressions/shared.ts
582
- function readFlag10(args, flag) {
836
+ function readFlag14(args, flag) {
583
837
  const index = args.indexOf(flag);
584
838
  if (index === -1) return void 0;
585
839
  return args[index + 1];
586
840
  }
587
841
  function parseSuppressionsCommonArgs(args) {
588
842
  return {
589
- apiKey: readFlag10(args, "--api-key"),
590
- baseUrl: readFlag10(args, "--base-url")
843
+ apiKey: readFlag14(args, "--api-key"),
844
+ baseUrl: readFlag14(args, "--base-url")
591
845
  };
592
846
  }
593
847
  function resolveApiKey3(options, env) {
@@ -607,9 +861,9 @@ async function runListCommand4(args, env = process.env) {
607
861
  }
608
862
  try {
609
863
  const client = await createSuppressionsClient(apiKey, options.baseUrl);
610
- const limitRaw = readFlag10(args, "--limit");
611
- const cursor = readFlag10(args, "--cursor");
612
- const email = readFlag10(args, "--email");
864
+ const limitRaw = readFlag14(args, "--limit");
865
+ const cursor = readFlag14(args, "--cursor");
866
+ const email = readFlag14(args, "--email");
613
867
  const result = await client.suppressions.list({
614
868
  ...limitRaw ? { limit: Number(limitRaw) } : {},
615
869
  ...cursor ? { cursor } : {},
@@ -629,13 +883,13 @@ async function runAddCommand2(args, env = process.env) {
629
883
  if (!apiKey) {
630
884
  return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
631
885
  }
632
- const email = readFlag10(args, "--email") || args.find((a) => a.includes("@") && !a.startsWith("-"));
886
+ const email = readFlag14(args, "--email") || args.find((a) => a.includes("@") && !a.startsWith("-"));
633
887
  if (!email) {
634
888
  return { exitCode: 1, error: "Missing email. Pass --email user@example.com" };
635
889
  }
636
890
  try {
637
891
  const client = await createSuppressionsClient(apiKey, options.baseUrl);
638
- const reason = readFlag10(args, "--reason");
892
+ const reason = readFlag14(args, "--reason");
639
893
  const result = await client.suppressions.create({
640
894
  email,
641
895
  ...reason ? { reason } : {}
@@ -654,7 +908,7 @@ async function runRemoveCommand(args, env = process.env) {
654
908
  if (!apiKey) {
655
909
  return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
656
910
  }
657
- const idOrEmail = readFlag10(args, "--id") || readFlag10(args, "--email") || args.find((a) => !a.startsWith("-") && a !== "remove" && a !== "delete");
911
+ const idOrEmail = readFlag14(args, "--id") || readFlag14(args, "--email") || args.find((a) => !a.startsWith("-") && a !== "remove" && a !== "delete");
658
912
  if (!idOrEmail) {
659
913
  return { exitCode: 1, error: "Missing id or email. Pass --id <uuid> or --email user@example.com" };
660
914
  }
@@ -668,6 +922,240 @@ async function runRemoveCommand(args, env = process.env) {
668
922
  }
669
923
  }
670
924
 
925
+ // src/commands/templates/shared.ts
926
+ function readFlag15(args, flag) {
927
+ const index = args.indexOf(flag);
928
+ if (index === -1) return void 0;
929
+ return args[index + 1];
930
+ }
931
+ function parseTemplatesCommonArgs(args) {
932
+ return {
933
+ apiKey: readFlag15(args, "--api-key"),
934
+ baseUrl: readFlag15(args, "--base-url")
935
+ };
936
+ }
937
+ function resolveApiKey4(options, env) {
938
+ return options.apiKey || env.SUPERSENDTX_API_KEY || env.SUPERTX_API_KEY || null;
939
+ }
940
+ async function createTemplatesClient(apiKey, baseUrl) {
941
+ const { SuperSendTX } = await import("supersendtx");
942
+ return new SuperSendTX(apiKey, baseUrl ? { baseUrl } : void 0);
943
+ }
944
+
945
+ // src/commands/templates/delete.ts
946
+ var POSITIONAL_FLAGS5 = ["--api-key", "--base-url", "--id", "--alias"];
947
+ async function runDeleteCommand3(args, env = process.env) {
948
+ const options = parseTemplatesCommonArgs(args);
949
+ const apiKey = resolveApiKey4(options, env);
950
+ if (!apiKey) return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
951
+ const idOrAlias = readFlag15(args, "--id") || readFlag15(args, "--alias") || readFirstPositional6(args);
952
+ if (!idOrAlias) return { exitCode: 1, error: "Missing template id or alias. Pass --id tpl_\u2026 or --alias welcome" };
953
+ try {
954
+ const client = await createTemplatesClient(apiKey, options.baseUrl);
955
+ console.log(JSON.stringify(await client.templates.remove(idOrAlias)));
956
+ return { exitCode: 0 };
957
+ } catch (error) {
958
+ return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
959
+ }
960
+ }
961
+ function readFirstPositional6(args) {
962
+ for (let i = 0; i < args.length; i += 1) {
963
+ const arg = args[i];
964
+ if (arg.startsWith("--")) {
965
+ if (POSITIONAL_FLAGS5.includes(arg)) i += 1;
966
+ continue;
967
+ }
968
+ return arg;
969
+ }
970
+ return void 0;
971
+ }
972
+
973
+ // src/commands/templates/duplicate.ts
974
+ var POSITIONAL_FLAGS6 = ["--api-key", "--base-url", "--id", "--alias", "--name"];
975
+ async function runDuplicateCommand(args, env = process.env) {
976
+ const options = parseTemplatesCommonArgs(args);
977
+ const apiKey = resolveApiKey4(options, env);
978
+ if (!apiKey) return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
979
+ const idOrAlias = readFlag15(args, "--id") || readFlag15(args, "--alias") || readFirstPositional7(args);
980
+ if (!idOrAlias) return { exitCode: 1, error: "Missing template id or alias. Pass --id tpl_\u2026 or --alias welcome" };
981
+ const name = readFlag15(args, "--name");
982
+ try {
983
+ const client = await createTemplatesClient(apiKey, options.baseUrl);
984
+ console.log(JSON.stringify(await client.templates.duplicate(idOrAlias, name ? { name } : {})));
985
+ return { exitCode: 0 };
986
+ } catch (error) {
987
+ return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
988
+ }
989
+ }
990
+ function readFirstPositional7(args) {
991
+ for (let i = 0; i < args.length; i += 1) {
992
+ const arg = args[i];
993
+ if (arg.startsWith("--")) {
994
+ if (POSITIONAL_FLAGS6.includes(arg)) i += 1;
995
+ continue;
996
+ }
997
+ return arg;
998
+ }
999
+ return void 0;
1000
+ }
1001
+
1002
+ // src/commands/templates/get.ts
1003
+ var POSITIONAL_FLAGS7 = ["--api-key", "--base-url", "--id", "--alias"];
1004
+ async function runGetCommand4(args, env = process.env) {
1005
+ const options = parseTemplatesCommonArgs(args);
1006
+ const apiKey = resolveApiKey4(options, env);
1007
+ if (!apiKey) return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
1008
+ const idOrAlias = readFlag15(args, "--id") || readFlag15(args, "--alias") || readFirstPositional8(args);
1009
+ if (!idOrAlias) return { exitCode: 1, error: "Missing template id or alias. Pass --id tpl_\u2026 or --alias welcome" };
1010
+ try {
1011
+ const client = await createTemplatesClient(apiKey, options.baseUrl);
1012
+ console.log(JSON.stringify(await client.templates.get(idOrAlias)));
1013
+ return { exitCode: 0 };
1014
+ } catch (error) {
1015
+ return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
1016
+ }
1017
+ }
1018
+ function readFirstPositional8(args) {
1019
+ for (let i = 0; i < args.length; i += 1) {
1020
+ const arg = args[i];
1021
+ if (arg.startsWith("--")) {
1022
+ if (POSITIONAL_FLAGS7.includes(arg)) i += 1;
1023
+ continue;
1024
+ }
1025
+ return arg;
1026
+ }
1027
+ return void 0;
1028
+ }
1029
+
1030
+ // src/commands/templates/list.ts
1031
+ async function runListCommand5(args, env = process.env) {
1032
+ const options = parseTemplatesCommonArgs(args);
1033
+ const apiKey = resolveApiKey4(options, env);
1034
+ if (!apiKey) {
1035
+ return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
1036
+ }
1037
+ try {
1038
+ const client = await createTemplatesClient(apiKey, options.baseUrl);
1039
+ const limitRaw = readFlag15(args, "--limit");
1040
+ const cursor = readFlag15(args, "--cursor");
1041
+ const status = readFlag15(args, "--status");
1042
+ const result = await client.templates.list({
1043
+ ...limitRaw ? { limit: Number(limitRaw) } : {},
1044
+ ...cursor ? { cursor } : {},
1045
+ ...status ? { status } : {}
1046
+ });
1047
+ console.log(JSON.stringify(result));
1048
+ return { exitCode: 0 };
1049
+ } catch (error) {
1050
+ return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
1051
+ }
1052
+ }
1053
+
1054
+ // src/commands/templates/publish.ts
1055
+ var POSITIONAL_FLAGS8 = ["--api-key", "--base-url", "--id", "--alias"];
1056
+ async function runPublishCommand(args, env = process.env) {
1057
+ const options = parseTemplatesCommonArgs(args);
1058
+ const apiKey = resolveApiKey4(options, env);
1059
+ if (!apiKey) return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
1060
+ const idOrAlias = readFlag15(args, "--id") || readFlag15(args, "--alias") || readFirstPositional9(args);
1061
+ if (!idOrAlias) return { exitCode: 1, error: "Missing template id or alias. Pass --id tpl_\u2026 or --alias welcome" };
1062
+ try {
1063
+ const client = await createTemplatesClient(apiKey, options.baseUrl);
1064
+ console.log(JSON.stringify(await client.templates.publish(idOrAlias)));
1065
+ return { exitCode: 0 };
1066
+ } catch (error) {
1067
+ return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
1068
+ }
1069
+ }
1070
+ function readFirstPositional9(args) {
1071
+ for (let i = 0; i < args.length; i += 1) {
1072
+ const arg = args[i];
1073
+ if (arg.startsWith("--")) {
1074
+ if (POSITIONAL_FLAGS8.includes(arg)) i += 1;
1075
+ continue;
1076
+ }
1077
+ return arg;
1078
+ }
1079
+ return void 0;
1080
+ }
1081
+
1082
+ // src/commands/templates/create.ts
1083
+ async function runCreateCommand2(args, env = process.env) {
1084
+ const options = parseTemplatesCommonArgs(args);
1085
+ const apiKey = resolveApiKey4(options, env);
1086
+ if (!apiKey) {
1087
+ return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
1088
+ }
1089
+ const name = readFlag15(args, "--name");
1090
+ const subject = readFlag15(args, "--subject");
1091
+ const html = readFlag15(args, "--html");
1092
+ const text = readFlag15(args, "--text");
1093
+ const alias = readFlag15(args, "--alias");
1094
+ if (!name) {
1095
+ return { exitCode: 1, error: 'Missing name. Pass --name "Welcome"' };
1096
+ }
1097
+ if (!subject) {
1098
+ return { exitCode: 1, error: 'Missing subject. Pass --subject "Hello {{name}}"' };
1099
+ }
1100
+ if (!html && !text) {
1101
+ return { exitCode: 1, error: 'Missing body. Pass --html "<p>Hi</p>" or --text "Hi"' };
1102
+ }
1103
+ try {
1104
+ const client = await createTemplatesClient(apiKey, options.baseUrl);
1105
+ const result = await client.templates.create({
1106
+ name,
1107
+ subject,
1108
+ ...html ? { html } : {},
1109
+ ...text ? { text } : {},
1110
+ ...alias ? { alias } : {}
1111
+ });
1112
+ console.log(JSON.stringify(result));
1113
+ return { exitCode: 0 };
1114
+ } catch (error) {
1115
+ return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
1116
+ }
1117
+ }
1118
+
1119
+ // src/commands/templates/update.ts
1120
+ var POSITIONAL_FLAGS9 = ["--api-key", "--base-url", "--id", "--alias", "--set-alias", "--name", "--subject", "--html", "--text", "--variable"];
1121
+ async function runUpdateCommand2(args, env = process.env) {
1122
+ const options = parseTemplatesCommonArgs(args);
1123
+ const apiKey = resolveApiKey4(options, env);
1124
+ if (!apiKey) return { exitCode: 1, error: "Missing API key. Set SUPERSENDTX_API_KEY or pass --api-key." };
1125
+ const idOrAlias = readFlag15(args, "--id") || readFlag15(args, "--alias") || readFirstPositional10(args);
1126
+ if (!idOrAlias) return { exitCode: 1, error: "Missing template id or alias. Pass --id tpl_\u2026 or --alias welcome" };
1127
+ const name = readFlag15(args, "--name");
1128
+ const subject = readFlag15(args, "--subject");
1129
+ const html = readFlag15(args, "--html");
1130
+ const text = readFlag15(args, "--text");
1131
+ const alias = readFlag15(args, "--set-alias");
1132
+ const variables = readFlags3(args, "--variable");
1133
+ if (!name && !subject && !html && !text && !alias && variables.length === 0) return { exitCode: 1, error: "Nothing to update. Pass --name, --subject, --html, --text, --set-alias, or --variable." };
1134
+ try {
1135
+ const client = await createTemplatesClient(apiKey, options.baseUrl);
1136
+ console.log(JSON.stringify(await client.templates.update(idOrAlias, { ...name ? { name } : {}, ...subject ? { subject } : {}, ...html ? { html } : {}, ...text ? { text } : {}, ...alias ? { alias } : {}, ...variables.length > 0 ? { variables } : {} })));
1137
+ return { exitCode: 0 };
1138
+ } catch (error) {
1139
+ return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
1140
+ }
1141
+ }
1142
+ function readFlags3(args, flag) {
1143
+ const values = [];
1144
+ for (let i = 0; i < args.length; i += 1) if (args[i] === flag && args[i + 1]) values.push(args[i + 1]);
1145
+ return values;
1146
+ }
1147
+ function readFirstPositional10(args) {
1148
+ for (let i = 0; i < args.length; i += 1) {
1149
+ const arg = args[i];
1150
+ if (arg.startsWith("--")) {
1151
+ if (POSITIONAL_FLAGS9.includes(arg)) i += 1;
1152
+ continue;
1153
+ }
1154
+ return arg;
1155
+ }
1156
+ return void 0;
1157
+ }
1158
+
671
1159
  // src/cli.ts
672
1160
  function printUsage() {
673
1161
  console.error("Usage:");
@@ -675,19 +1163,30 @@ function printUsage() {
675
1163
  console.error(" supersendtx domains apply example.com --provider cloudflare");
676
1164
  console.error(" supersendtx domains apply example.com --provider godaddy");
677
1165
  console.error(" supersendtx domains list");
1166
+ console.error(" supersendtx domains get example.com");
678
1167
  console.error(" supersendtx domains verify example.com");
679
- console.error(
680
- ' supersendtx emails send --from you@domain.com --to user@example.com --subject "Hello" --html "<p>Hi</p>"'
681
- );
1168
+ console.error(" supersendtx domains delete example.com");
1169
+ console.error(' supersendtx emails send --from you@domain.com --to user@example.com --subject "Hello" --html "<p>Hi</p>"');
1170
+ console.error(" supersendtx emails batch --file ./emails.json");
682
1171
  console.error(" supersendtx emails list [--limit 25] [--cursor \u2026]");
1172
+ console.error(" supersendtx emails insights [--window 7d|30d]");
683
1173
  console.error(" supersendtx emails get --id msg_\u2026");
684
1174
  console.error(" supersendtx emails cancel --id msg_\u2026");
685
1175
  console.error(" supersendtx webhooks list");
686
1176
  console.error(" supersendtx webhooks create --url https://yourapp.com/hooks");
1177
+ console.error(" supersendtx webhooks get --id wh_\u2026");
1178
+ console.error(" supersendtx webhooks update --id wh_\u2026 [--url \u2026] [--event email.sent] [--enabled true|false]");
687
1179
  console.error(" supersendtx webhooks delete --id <webhook-id>");
688
1180
  console.error(" supersendtx suppressions list");
689
1181
  console.error(" supersendtx suppressions add --email user@example.com [--reason \u2026]");
690
1182
  console.error(" supersendtx suppressions remove --id <id> | --email user@example.com");
1183
+ console.error(" supersendtx templates list [--status draft|published]");
1184
+ console.error(' supersendtx templates create --name Welcome --subject "Hi" --html "<p>Hi</p>"');
1185
+ console.error(" supersendtx templates get --id tpl_\u2026");
1186
+ console.error(" supersendtx templates update --id tpl_\u2026 [--name \u2026] [--subject \u2026] [--html \u2026] [--text \u2026] [--set-alias \u2026]");
1187
+ console.error(" supersendtx templates publish --id tpl_\u2026");
1188
+ console.error(' supersendtx templates duplicate --id tpl_\u2026 [--name "Copy"]');
1189
+ console.error(" supersendtx templates delete --id tpl_\u2026");
691
1190
  console.error(" supersendtx keys list");
692
1191
  console.error(" supersendtx keys create [--name Default] [--scope full|sending]");
693
1192
  console.error(" supersendtx keys delete --id <api-key-id>");
@@ -710,11 +1209,21 @@ async function main() {
710
1209
  if (result.error) console.error(result.error);
711
1210
  process.exit(result.exitCode);
712
1211
  }
1212
+ if (subcommand === "get") {
1213
+ const result = await runGetCommand2(rest);
1214
+ if (result.error) console.error(result.error);
1215
+ process.exit(result.exitCode);
1216
+ }
713
1217
  if (subcommand === "list") {
714
1218
  const result = await runListCommand2(rest);
715
1219
  if (result.error) console.error(result.error);
716
1220
  process.exit(result.exitCode);
717
1221
  }
1222
+ if (subcommand === "delete" || subcommand === "remove") {
1223
+ const result = await runDeleteCommand(rest);
1224
+ if (result.error) console.error(result.error);
1225
+ process.exit(result.exitCode);
1226
+ }
718
1227
  if (subcommand === "verify") {
719
1228
  const result = await runVerifyCommand(rest);
720
1229
  if (result.error) console.error(result.error);
@@ -726,6 +1235,11 @@ async function main() {
726
1235
  const result = await runSendCommandWithClient(rest);
727
1236
  process.exit(result.exitCode);
728
1237
  }
1238
+ if (subcommand === "batch") {
1239
+ const result = await runBatchCommandWithClient(rest);
1240
+ if (result.error) console.error(result.error);
1241
+ process.exit(result.exitCode);
1242
+ }
729
1243
  if (subcommand === "cancel") {
730
1244
  const result = await runCancelCommandWithClient(rest);
731
1245
  if (result.error) console.error(result.error);
@@ -736,6 +1250,11 @@ async function main() {
736
1250
  if (result.error) console.error(result.error);
737
1251
  process.exit(result.exitCode);
738
1252
  }
1253
+ if (subcommand === "insights") {
1254
+ const result = await runInsightsCommandWithClient(rest);
1255
+ if (result.error) console.error(result.error);
1256
+ process.exit(result.exitCode);
1257
+ }
739
1258
  if (subcommand === "get") {
740
1259
  const result = await runGetCommandWithClient(rest);
741
1260
  if (result.error) console.error(result.error);
@@ -748,13 +1267,23 @@ async function main() {
748
1267
  if (result.error) console.error(result.error);
749
1268
  process.exit(result.exitCode);
750
1269
  }
1270
+ if (subcommand === "get") {
1271
+ const result = await runGetCommand3(rest);
1272
+ if (result.error) console.error(result.error);
1273
+ process.exit(result.exitCode);
1274
+ }
751
1275
  if (subcommand === "create") {
752
1276
  const result = await runCreateCommand(rest);
753
1277
  if (result.error) console.error(result.error);
754
1278
  process.exit(result.exitCode);
755
1279
  }
1280
+ if (subcommand === "update") {
1281
+ const result = await runUpdateCommand(rest);
1282
+ if (result.error) console.error(result.error);
1283
+ process.exit(result.exitCode);
1284
+ }
756
1285
  if (subcommand === "delete") {
757
- const result = await runDeleteCommand(rest);
1286
+ const result = await runDeleteCommand2(rest);
758
1287
  if (result.error) console.error(result.error);
759
1288
  process.exit(result.exitCode);
760
1289
  }
@@ -776,6 +1305,43 @@ async function main() {
776
1305
  process.exit(result.exitCode);
777
1306
  }
778
1307
  }
1308
+ if (command === "templates") {
1309
+ if (subcommand === "list") {
1310
+ const result = await runListCommand5(rest);
1311
+ if (result.error) console.error(result.error);
1312
+ process.exit(result.exitCode);
1313
+ }
1314
+ if (subcommand === "create" || subcommand === "add") {
1315
+ const result = await runCreateCommand2(rest);
1316
+ if (result.error) console.error(result.error);
1317
+ process.exit(result.exitCode);
1318
+ }
1319
+ if (subcommand === "get") {
1320
+ const result = await runGetCommand4(rest);
1321
+ if (result.error) console.error(result.error);
1322
+ process.exit(result.exitCode);
1323
+ }
1324
+ if (subcommand === "update") {
1325
+ const result = await runUpdateCommand2(rest);
1326
+ if (result.error) console.error(result.error);
1327
+ process.exit(result.exitCode);
1328
+ }
1329
+ if (subcommand === "publish") {
1330
+ const result = await runPublishCommand(rest);
1331
+ if (result.error) console.error(result.error);
1332
+ process.exit(result.exitCode);
1333
+ }
1334
+ if (subcommand === "duplicate") {
1335
+ const result = await runDuplicateCommand(rest);
1336
+ if (result.error) console.error(result.error);
1337
+ process.exit(result.exitCode);
1338
+ }
1339
+ if (subcommand === "delete" || subcommand === "remove") {
1340
+ const result = await runDeleteCommand3(rest);
1341
+ if (result.error) console.error(result.error);
1342
+ process.exit(result.exitCode);
1343
+ }
1344
+ }
779
1345
  if (command === "keys") {
780
1346
  if (subcommand === "list") {
781
1347
  const result = await runListKeysCommandWithClient(rest);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "supersendtx-cli",
3
- "version": "0.6.0",
4
- "description": "SuperSend TX CLI send transactional email from the terminal",
3
+ "version": "0.8.0",
4
+ "description": "SuperSend TX CLI \u2014 send transactional email from the terminal",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "bin": {
@@ -39,7 +39,7 @@
39
39
  "prepublishOnly": "npm run build"
40
40
  },
41
41
  "dependencies": {
42
- "supersendtx": "0.6.0"
42
+ "supersendtx": "0.7.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "tsup": "^8.5.0",