groundmail-cli 0.22.0 → 0.24.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 +50 -18
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -510,6 +510,7 @@ async function createAutomationsClient(apiKey, baseUrl) {
510
510
  return new Groundmail(apiKey, baseUrl ? { baseUrl } : void 0);
511
511
  }
512
512
  async function readAutomationDefinition(args) {
513
+ const folderFlag = readFlag9(args, "--folder");
513
514
  const file = readFlag9(args, "--file");
514
515
  if (file) {
515
516
  try {
@@ -518,7 +519,8 @@ async function readAutomationDefinition(args) {
518
519
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
519
520
  return { ok: false, error: "--file must contain a JSON object" };
520
521
  }
521
- return { ok: true, value: parsed };
522
+ const value = parsed;
523
+ return { ok: true, value: folderFlag !== void 0 ? { ...value, folder: folderFlag } : value };
522
524
  } catch (error) {
523
525
  return {
524
526
  ok: false,
@@ -545,7 +547,8 @@ async function readAutomationDefinition(args) {
545
547
  value: {
546
548
  ...name ? { name } : {},
547
549
  ...triggerEvent ? { trigger: { type: "event", event: triggerEvent } } : {},
548
- ...steps !== void 0 ? { steps } : {}
550
+ ...steps !== void 0 ? { steps } : {},
551
+ ...folderFlag !== void 0 ? { folder: folderFlag } : {}
549
552
  }
550
553
  };
551
554
  }
@@ -595,7 +598,7 @@ async function runCreateCommand(args, env = process.env) {
595
598
  }
596
599
  const definition = await readAutomationDefinition(args);
597
600
  if (!definition.ok) return { exitCode: 1, error: definition.error };
598
- const { name, trigger, steps } = definition.value;
601
+ const { name, trigger, steps, folder } = definition.value;
599
602
  if (!name || typeof name !== "string") {
600
603
  return { exitCode: 1, error: "Required: --name or name in --file" };
601
604
  }
@@ -610,7 +613,8 @@ async function runCreateCommand(args, env = process.env) {
610
613
  const result = await client2.automations.create({
611
614
  name,
612
615
  trigger,
613
- steps
616
+ steps,
617
+ ...typeof folder === "string" && folder.trim() ? { folder } : {}
614
618
  });
615
619
  console.log(JSON.stringify(result));
616
620
  return { exitCode: 0 };
@@ -630,11 +634,11 @@ async function runUpdateCommand(args, env = process.env) {
630
634
  if (!id) return { exitCode: 1, error: "Required flag: --id" };
631
635
  const definition = await readAutomationDefinition(args);
632
636
  if (!definition.ok) return { exitCode: 1, error: definition.error };
633
- const { name, trigger, steps } = definition.value;
634
- if (!name && !trigger && !steps) {
637
+ const { name, trigger, steps, folder } = definition.value;
638
+ if (!name && !trigger && !steps && folder === void 0) {
635
639
  return {
636
640
  exitCode: 1,
637
- error: "Nothing to update. Pass --file and/or --name/--trigger/--steps."
641
+ error: "Nothing to update. Pass --file and/or --name/--trigger/--steps/--folder."
638
642
  };
639
643
  }
640
644
  try {
@@ -642,7 +646,8 @@ async function runUpdateCommand(args, env = process.env) {
642
646
  const result = await client2.automations.update(id, {
643
647
  ...name ? { name } : {},
644
648
  ...trigger ? { trigger } : {},
645
- ...steps ? { steps } : {}
649
+ ...steps ? { steps } : {},
650
+ ...folder !== void 0 ? { folder } : {}
646
651
  });
647
652
  console.log(JSON.stringify(result));
648
653
  return { exitCode: 0 };
@@ -927,7 +932,9 @@ var POSITIONAL_FLAGS3 = [
927
932
  "--tls-mode",
928
933
  "--open-tracking",
929
934
  "--click-tracking",
930
- "--inbound"
935
+ "--inbound",
936
+ "--inbound-spam-threshold",
937
+ "--inbound-spam-action"
931
938
  ];
932
939
  function readFirstPositional4(args) {
933
940
  for (let i = 0; i < args.length; i += 1) {
@@ -968,10 +975,29 @@ async function runUpdateCommand2(args, env = process.env) {
968
975
  if (clickTracking !== void 0) payload.click_tracking = clickTracking;
969
976
  const inbound = parseBooleanFlag(readFlag10(args, "--inbound"), "--inbound");
970
977
  if (inbound !== void 0) payload.inbound_enabled = inbound;
978
+ const spamThreshold = readFlag10(args, "--inbound-spam-threshold");
979
+ if (spamThreshold != null) {
980
+ if (spamThreshold === "default" || spamThreshold === "null") {
981
+ payload.inbound_spam_threshold = null;
982
+ } else {
983
+ const value = Number(spamThreshold);
984
+ if (!Number.isFinite(value) || value < 1 || value > 100) {
985
+ return { exitCode: 1, error: "--inbound-spam-threshold must be a number from 1 to 100, or default" };
986
+ }
987
+ payload.inbound_spam_threshold = value;
988
+ }
989
+ }
990
+ const spamAction = readFlag10(args, "--inbound-spam-action");
991
+ if (spamAction != null) {
992
+ if (spamAction !== "flag" && spamAction !== "drop") {
993
+ return { exitCode: 1, error: "--inbound-spam-action must be flag or drop" };
994
+ }
995
+ payload.inbound_spam_action = spamAction;
996
+ }
971
997
  if (!Object.keys(payload).length) {
972
998
  return {
973
999
  exitCode: 1,
974
- error: "No updates provided. Pass --inbound true|false, --tls-mode opportunistic|enforced, --open-tracking true|false, or --click-tracking true|false."
1000
+ error: "No updates provided. Pass --inbound true|false, --tls-mode opportunistic|enforced, --open-tracking true|false, --click-tracking true|false, --inbound-spam-threshold <1-100|default>, or --inbound-spam-action flag|drop."
975
1001
  };
976
1002
  }
977
1003
  const client2 = await createDomainsClient(apiKey, options.baseUrl);
@@ -1420,7 +1446,7 @@ function trimUrl(value) {
1420
1446
  }
1421
1447
 
1422
1448
  // package.json
1423
- var version = "0.22.0";
1449
+ var version = "0.24.0";
1424
1450
 
1425
1451
  // src/user-agent.ts
1426
1452
  function buildUserAgent(own) {
@@ -2802,6 +2828,7 @@ async function runCreateCommand3(args, env = process.env) {
2802
2828
  const text = readFlag20(args, "--text");
2803
2829
  const alias = readFlag20(args, "--alias");
2804
2830
  const category = readFlag20(args, "--category");
2831
+ const folder = readFlag20(args, "--folder");
2805
2832
  const unsubscribeEnabled = args.includes("--unsubscribe-enabled");
2806
2833
  if (!name) {
2807
2834
  return { exitCode: 1, error: 'Missing name. Pass --name "Welcome"' };
@@ -2821,7 +2848,8 @@ async function runCreateCommand3(args, env = process.env) {
2821
2848
  ...text ? { text } : {},
2822
2849
  ...alias ? { alias } : {},
2823
2850
  ...category ? { category } : {},
2824
- ...unsubscribeEnabled ? { unsubscribe_enabled: true } : {}
2851
+ ...unsubscribeEnabled ? { unsubscribe_enabled: true } : {},
2852
+ ...folder?.trim() ? { folder } : {}
2825
2853
  });
2826
2854
  console.log(JSON.stringify(result));
2827
2855
  return { exitCode: 0 };
@@ -2841,7 +2869,8 @@ var POSITIONAL_FLAGS11 = [
2841
2869
  "--subject",
2842
2870
  "--html",
2843
2871
  "--text",
2844
- "--variable"
2872
+ "--variable",
2873
+ "--folder"
2845
2874
  ];
2846
2875
  async function runUpdateCommand4(args, env = process.env) {
2847
2876
  const options = parseTemplatesCommonArgs(args);
@@ -2860,12 +2889,13 @@ async function runUpdateCommand4(args, env = process.env) {
2860
2889
  const alias = readFlag20(args, "--set-alias");
2861
2890
  const variables = readFlags3(args, "--variable");
2862
2891
  const category = readFlag20(args, "--category");
2892
+ const folder = readFlag20(args, "--folder");
2863
2893
  const unsubscribeEnabled = args.includes("--unsubscribe-enabled");
2864
2894
  const unsubscribeDisabled = args.includes("--no-unsubscribe-enabled");
2865
- if (!name && !subject && !html && !text && !alias && variables.length === 0 && !category && !unsubscribeEnabled && !unsubscribeDisabled) {
2895
+ if (!name && !subject && !html && !text && !alias && variables.length === 0 && !category && folder === void 0 && !unsubscribeEnabled && !unsubscribeDisabled) {
2866
2896
  return {
2867
2897
  exitCode: 1,
2868
- error: "Nothing to update. Pass --name, --subject, --html, --text, --set-alias, --category, --variable, or unsubscribe flags."
2898
+ error: "Nothing to update. Pass --name, --subject, --html, --text, --set-alias, --category, --variable, --folder, or unsubscribe flags."
2869
2899
  };
2870
2900
  }
2871
2901
  try {
@@ -2879,7 +2909,8 @@ async function runUpdateCommand4(args, env = process.env) {
2879
2909
  ...variables.length > 0 ? { variables } : {},
2880
2910
  ...category ? { category } : {},
2881
2911
  ...unsubscribeEnabled ? { unsubscribe_enabled: true } : {},
2882
- ...unsubscribeDisabled ? { unsubscribe_enabled: false } : {}
2912
+ ...unsubscribeDisabled ? { unsubscribe_enabled: false } : {},
2913
+ ...folder !== void 0 ? { folder } : {}
2883
2914
  });
2884
2915
  console.log(JSON.stringify(result));
2885
2916
  return { exitCode: 0 };
@@ -3709,6 +3740,7 @@ var USAGE_LINES = [
3709
3740
  " groundmail automations create --file ./otp-sms.json",
3710
3741
  " groundmail automations get --id <automation-id>",
3711
3742
  " groundmail automations update --id <automation-id> --file ./welcome.json",
3743
+ ' groundmail automations update --id <automation-id> --folder Onboarding (--folder "" takes it out of any folder)',
3712
3744
  " groundmail automations activate --id <automation-id>",
3713
3745
  " groundmail automations pause --id <automation-id>",
3714
3746
  " groundmail automations delete --id <automation-id>",
@@ -3724,9 +3756,9 @@ var USAGE_LINES = [
3724
3756
  " groundmail templates list [--status draft|published]",
3725
3757
  " groundmail templates starters",
3726
3758
  " groundmail templates from-starter password-reset",
3727
- ' groundmail templates create --name Welcome --subject "Hi" --html "<p>Hi</p>" [--category transactional|product] [--unsubscribe-enabled]',
3759
+ ' groundmail templates create --name Welcome --subject "Hi" --html "<p>Hi</p>" [--category transactional|product] [--unsubscribe-enabled] [--folder Onboarding]',
3728
3760
  " groundmail templates get --id tpl_\u2026",
3729
- " 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]",
3761
+ " 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]",
3730
3762
  " groundmail templates publish --id tpl_\u2026",
3731
3763
  ` groundmail templates push ./emails/welcome.tsx --alias welcome [--subject "Welcome"] [--props '{"name":"Ada"}'] [--publish]`,
3732
3764
  " groundmail templates versions --id tpl_\u2026",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "groundmail-cli",
3
- "version": "0.22.0",
3
+ "version": "0.24.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.19.0"
41
+ "groundmail": "0.21.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsup": "^8.5.0",