groundmail-cli 0.23.0 → 0.25.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 +36 -19
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -403,12 +403,18 @@ async function runListCommand(args, deps) {
403
403
  }
404
404
  const test = args.includes("--test") ? true : args.includes("--live") ? false : void 0;
405
405
  const tenant = readFlag7(args, "--tenant");
406
+ const stream = readFlag7(args, "--stream");
407
+ if (stream !== void 0 && stream !== "transactional" && stream !== "product" && stream !== "newsletter") {
408
+ stderr("--stream must be transactional, product or newsletter.");
409
+ return { exitCode: 1, error: "invalid stream" };
410
+ }
406
411
  try {
407
412
  const result = await deps.listEmails({
408
413
  ...limit != null && Number.isFinite(limit) ? { limit } : {},
409
414
  ...cursor ? { cursor } : {},
410
415
  ...test !== void 0 ? { test } : {},
411
- ...tenant ? { tenant } : {}
416
+ ...tenant ? { tenant } : {},
417
+ ...stream ? { stream } : {}
412
418
  });
413
419
  stdout(JSON.stringify(result));
414
420
  return { exitCode: 0 };
@@ -510,6 +516,7 @@ async function createAutomationsClient(apiKey, baseUrl) {
510
516
  return new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0);
511
517
  }
512
518
  async function readAutomationDefinition(args) {
519
+ const folderFlag = readFlag9(args, "--folder");
513
520
  const file = readFlag9(args, "--file");
514
521
  if (file) {
515
522
  try {
@@ -518,7 +525,8 @@ async function readAutomationDefinition(args) {
518
525
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
519
526
  return { ok: false, error: "--file must contain a JSON object" };
520
527
  }
521
- return { ok: true, value: parsed };
528
+ const value = parsed;
529
+ return { ok: true, value: folderFlag !== void 0 ? { ...value, folder: folderFlag } : value };
522
530
  } catch (error) {
523
531
  return {
524
532
  ok: false,
@@ -545,7 +553,8 @@ async function readAutomationDefinition(args) {
545
553
  value: {
546
554
  ...name ? { name } : {},
547
555
  ...triggerEvent ? { trigger: { type: "event", event: triggerEvent } } : {},
548
- ...steps !== void 0 ? { steps } : {}
556
+ ...steps !== void 0 ? { steps } : {},
557
+ ...folderFlag !== void 0 ? { folder: folderFlag } : {}
549
558
  }
550
559
  };
551
560
  }
@@ -595,7 +604,7 @@ async function runCreateCommand(args, env = process.env) {
595
604
  }
596
605
  const definition = await readAutomationDefinition(args);
597
606
  if (!definition.ok) return { exitCode: 1, error: definition.error };
598
- const { name, trigger, steps } = definition.value;
607
+ const { name, trigger, steps, folder } = definition.value;
599
608
  if (!name || typeof name !== "string") {
600
609
  return { exitCode: 1, error: "Required: --name or name in --file" };
601
610
  }
@@ -610,7 +619,8 @@ async function runCreateCommand(args, env = process.env) {
610
619
  const result = await client2.automations.create({
611
620
  name,
612
621
  trigger,
613
- steps
622
+ steps,
623
+ ...typeof folder === "string" && folder.trim() ? { folder } : {}
614
624
  });
615
625
  console.log(JSON.stringify(result));
616
626
  return { exitCode: 0 };
@@ -630,11 +640,11 @@ async function runUpdateCommand(args, env = process.env) {
630
640
  if (!id) return { exitCode: 1, error: "Required flag: --id" };
631
641
  const definition = await readAutomationDefinition(args);
632
642
  if (!definition.ok) return { exitCode: 1, error: definition.error };
633
- const { name, trigger, steps } = definition.value;
634
- if (!name && !trigger && !steps) {
643
+ const { name, trigger, steps, folder } = definition.value;
644
+ if (!name && !trigger && !steps && folder === void 0) {
635
645
  return {
636
646
  exitCode: 1,
637
- error: "Nothing to update. Pass --file and/or --name/--trigger/--steps."
647
+ error: "Nothing to update. Pass --file and/or --name/--trigger/--steps/--folder."
638
648
  };
639
649
  }
640
650
  try {
@@ -642,7 +652,8 @@ async function runUpdateCommand(args, env = process.env) {
642
652
  const result = await client2.automations.update(id, {
643
653
  ...name ? { name } : {},
644
654
  ...trigger ? { trigger } : {},
645
- ...steps ? { steps } : {}
655
+ ...steps ? { steps } : {},
656
+ ...folder !== void 0 ? { folder } : {}
646
657
  });
647
658
  console.log(JSON.stringify(result));
648
659
  return { exitCode: 0 };
@@ -1441,7 +1452,7 @@ function trimUrl(value) {
1441
1452
  }
1442
1453
 
1443
1454
  // package.json
1444
- var version = "0.23.0";
1455
+ var version = "0.25.0";
1445
1456
 
1446
1457
  // src/user-agent.ts
1447
1458
  function buildUserAgent(own) {
@@ -2823,6 +2834,7 @@ async function runCreateCommand3(args, env = process.env) {
2823
2834
  const text = readFlag20(args, "--text");
2824
2835
  const alias = readFlag20(args, "--alias");
2825
2836
  const category = readFlag20(args, "--category");
2837
+ const folder = readFlag20(args, "--folder");
2826
2838
  const unsubscribeEnabled = args.includes("--unsubscribe-enabled");
2827
2839
  if (!name) {
2828
2840
  return { exitCode: 1, error: 'Missing name. Pass --name "Welcome"' };
@@ -2842,7 +2854,8 @@ async function runCreateCommand3(args, env = process.env) {
2842
2854
  ...text ? { text } : {},
2843
2855
  ...alias ? { alias } : {},
2844
2856
  ...category ? { category } : {},
2845
- ...unsubscribeEnabled ? { unsubscribe_enabled: true } : {}
2857
+ ...unsubscribeEnabled ? { unsubscribe_enabled: true } : {},
2858
+ ...folder?.trim() ? { folder } : {}
2846
2859
  });
2847
2860
  console.log(JSON.stringify(result));
2848
2861
  return { exitCode: 0 };
@@ -2862,7 +2875,8 @@ var POSITIONAL_FLAGS11 = [
2862
2875
  "--subject",
2863
2876
  "--html",
2864
2877
  "--text",
2865
- "--variable"
2878
+ "--variable",
2879
+ "--folder"
2866
2880
  ];
2867
2881
  async function runUpdateCommand4(args, env = process.env) {
2868
2882
  const options = parseTemplatesCommonArgs(args);
@@ -2881,12 +2895,13 @@ async function runUpdateCommand4(args, env = process.env) {
2881
2895
  const alias = readFlag20(args, "--set-alias");
2882
2896
  const variables = readFlags3(args, "--variable");
2883
2897
  const category = readFlag20(args, "--category");
2898
+ const folder = readFlag20(args, "--folder");
2884
2899
  const unsubscribeEnabled = args.includes("--unsubscribe-enabled");
2885
2900
  const unsubscribeDisabled = args.includes("--no-unsubscribe-enabled");
2886
- if (!name && !subject && !html && !text && !alias && variables.length === 0 && !category && !unsubscribeEnabled && !unsubscribeDisabled) {
2901
+ if (!name && !subject && !html && !text && !alias && variables.length === 0 && !category && folder === void 0 && !unsubscribeEnabled && !unsubscribeDisabled) {
2887
2902
  return {
2888
2903
  exitCode: 1,
2889
- error: "Nothing to update. Pass --name, --subject, --html, --text, --set-alias, --category, --variable, or unsubscribe flags."
2904
+ error: "Nothing to update. Pass --name, --subject, --html, --text, --set-alias, --category, --variable, --folder, or unsubscribe flags."
2890
2905
  };
2891
2906
  }
2892
2907
  try {
@@ -2900,7 +2915,8 @@ async function runUpdateCommand4(args, env = process.env) {
2900
2915
  ...variables.length > 0 ? { variables } : {},
2901
2916
  ...category ? { category } : {},
2902
2917
  ...unsubscribeEnabled ? { unsubscribe_enabled: true } : {},
2903
- ...unsubscribeDisabled ? { unsubscribe_enabled: false } : {}
2918
+ ...unsubscribeDisabled ? { unsubscribe_enabled: false } : {},
2919
+ ...folder !== void 0 ? { folder } : {}
2904
2920
  });
2905
2921
  console.log(JSON.stringify(result));
2906
2922
  return { exitCode: 0 };
@@ -3716,9 +3732,9 @@ var USAGE_LINES = [
3716
3732
  " groundmail dmarc disable example.com",
3717
3733
  " groundmail received-emails list [--domain inbound.example.com]",
3718
3734
  " groundmail received-emails get inb_...",
3719
- ' groundmail emails send --from you@domain.com --to user@example.com --subject "Hello" --html "<p>Hi</p>" [--category transactional|product] [--unsubscribe] [--tenant <tenant>]',
3735
+ ' groundmail emails send --from you@domain.com --to user@example.com --subject "Hello" --html "<p>Hi</p>" [--category transactional|product|newsletter] [--unsubscribe] [--tenant <tenant>]',
3720
3736
  " groundmail emails batch --file ./emails.json [--tenant <tenant>]",
3721
- " groundmail emails list [--limit 25] [--cursor \u2026] [--test | --live] [--tenant <tenant>]",
3737
+ " groundmail emails list [--limit 25] [--cursor \u2026] [--test | --live] [--tenant <tenant>] [--stream transactional|product|newsletter]",
3722
3738
  " groundmail emails insights [--window 7d|30d]",
3723
3739
  " groundmail emails get --id msg_\u2026",
3724
3740
  " groundmail emails cancel --id msg_\u2026",
@@ -3730,6 +3746,7 @@ var USAGE_LINES = [
3730
3746
  " groundmail automations create --file ./otp-sms.json",
3731
3747
  " groundmail automations get --id <automation-id>",
3732
3748
  " groundmail automations update --id <automation-id> --file ./welcome.json",
3749
+ ' groundmail automations update --id <automation-id> --folder Onboarding (--folder "" takes it out of any folder)',
3733
3750
  " groundmail automations activate --id <automation-id>",
3734
3751
  " groundmail automations pause --id <automation-id>",
3735
3752
  " groundmail automations delete --id <automation-id>",
@@ -3745,9 +3762,9 @@ var USAGE_LINES = [
3745
3762
  " groundmail templates list [--status draft|published]",
3746
3763
  " groundmail templates starters",
3747
3764
  " groundmail templates from-starter password-reset",
3748
- ' groundmail templates create --name Welcome --subject "Hi" --html "<p>Hi</p>" [--category transactional|product] [--unsubscribe-enabled]',
3765
+ ' groundmail templates create --name Welcome --subject "Hi" --html "<p>Hi</p>" [--category transactional|product] [--unsubscribe-enabled] [--folder Onboarding]',
3749
3766
  " groundmail templates get --id tpl_\u2026",
3750
- " groundmail templates update --id tpl_\u2026 [--name \u2026] [--subject \u2026] [--html \u2026] [--text \u2026] [--set-alias \u2026] [--category transactional|product] [--unsubscribe-enabled|--no-unsubscribe-enabled]",
3767
+ " groundmail templates update --id tpl_\u2026 [--name \u2026] [--subject \u2026] [--html \u2026] [--text \u2026] [--set-alias \u2026] [--category transactional|product] [--unsubscribe-enabled|--no-unsubscribe-enabled] [--folder \u2026]",
3751
3768
  " groundmail templates publish --id tpl_\u2026",
3752
3769
  ` groundmail templates push ./emails/welcome.tsx --alias welcome [--subject "Welcome"] [--props '{"name":"Ada"}'] [--publish]`,
3753
3770
  " groundmail templates versions --id tpl_\u2026",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "groundmail-cli",
3
- "version": "0.23.0",
3
+ "version": "0.25.0",
4
4
  "description": "Groundmail CLI — send transactional email from the terminal",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -38,7 +38,7 @@
38
38
  "prepublishOnly": "npm run build"
39
39
  },
40
40
  "dependencies": {
41
- "groundmail": "0.20.0"
41
+ "groundmail": "0.22.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsup": "^8.5.0",