groundmail-cli 0.55.6 → 0.56.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 +26 -6
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -2109,7 +2109,7 @@ async function runListKeysCommandWithClient(args, env = process.env) {
2109
2109
  }
2110
2110
 
2111
2111
  // package.json
2112
- var version = "0.55.6";
2112
+ var version = "0.56.0";
2113
2113
 
2114
2114
  // src/help.ts
2115
2115
  var USAGE_LINES = [
@@ -2248,7 +2248,7 @@ var USAGE_LINES = [
2248
2248
  " groundmail lists add <list> (--emails a@example.com,b@example.com | --ids <contact id>,\u2026) existing contacts; unknown ones come back in not_found",
2249
2249
  " groundmail lists remove <list> <contact id> the contact stays",
2250
2250
  " groundmail broadcasts list [--limit 25] [--cursor \u2026]",
2251
- ' groundmail broadcasts create --name "December" --lists newsletter --from "Acme <news@mail.acme.dev>" (--template <template> | --subject \u2026 (--html \u2026 | --html-file email.html) [--text \u2026|--text-file \u2026]) [--reply-to \u2026] [--preheader \u2026] a draft; nothing is sent',
2251
+ ' groundmail broadcasts create --name "December" --lists newsletter --from "Acme <news@mail.acme.dev>" --subject \u2026 (--design-file layout.json | --html \u2026 | --html-file email.html | --template <template>) [--text \u2026|--text-file \u2026] [--reply-to \u2026] [--preheader \u2026] a draft; nothing is sent. A layout renders with your brand',
2252
2252
  " groundmail broadcasts get <id>",
2253
2253
  " groundmail broadcasts update <id> [the create flags; none clears one] drafts only",
2254
2254
  " groundmail broadcasts delete <id> --yes drafts only",
@@ -2294,7 +2294,7 @@ var FOOTER_LINES = [
2294
2294
  "",
2295
2295
  "Scopes: full, emails:send, emails:read, domains:read, domains:write, webhooks:write, templates:write,",
2296
2296
  " suppressions:write, account:read, mailboxes:read, mailboxes:write, mailboxes:send,",
2297
- " contacts:read, contacts:write, broadcasts:write",
2297
+ " contacts:read, contacts:write, broadcasts:read, broadcasts:write",
2298
2298
  "",
2299
2299
  "<tenant>: the tenant's external id (your id for that customer) or its Groundmail id.",
2300
2300
  "<mailbox>: the mailbox's mbx_ id, its address or your external id.",
@@ -2884,6 +2884,7 @@ var CLI_SCOPES = [
2884
2884
  "mailboxes:send",
2885
2885
  "contacts:read",
2886
2886
  "contacts:write",
2887
+ "broadcasts:read",
2887
2888
  "broadcasts:write"
2888
2889
  ];
2889
2890
  function parseScopeFlag(value) {
@@ -5963,9 +5964,14 @@ async function draftFields(args, read = readText) {
5963
5964
  if (html !== void 0 && htmlFile !== void 0) return { error: "Pass --html or --html-file, not both" };
5964
5965
  if (text !== void 0 && textFile !== void 0) return { error: "Pass --text or --text-file, not both" };
5965
5966
  const template = clearable2(readFlag28(args, "--template"));
5966
- if (template && (html !== void 0 || htmlFile !== void 0 || text !== void 0 || textFile !== void 0)) {
5967
+ const inline = html !== void 0 || htmlFile !== void 0 || text !== void 0 || textFile !== void 0;
5968
+ if (template && inline) {
5967
5969
  return { error: "Use --template or --html/--text, not both" };
5968
5970
  }
5971
+ const designFile = readFlag28(args, "--design-file");
5972
+ const designFlag = readFlag28(args, "--design");
5973
+ if (designFlag !== void 0 && designFlag !== "none") return { error: "Pass the layout with --design-file layout.json (--design none clears it)" };
5974
+ if (designFile !== void 0 && (template || inline)) return { error: "Use one of --design-file, --template or --html/--text" };
5969
5975
  const out = {};
5970
5976
  const name = readFlag28(args, "--name");
5971
5977
  if (name !== void 0) out.name = name;
@@ -5978,6 +5984,20 @@ async function draftFields(args, read = readText) {
5978
5984
  if (value !== void 0) out[key] = value;
5979
5985
  }
5980
5986
  if (template !== void 0) out.template = template;
5987
+ if (designFlag === "none") out.design = null;
5988
+ if (designFile !== void 0) {
5989
+ let raw;
5990
+ try {
5991
+ raw = await read(designFile);
5992
+ } catch (error) {
5993
+ return { error: `Can't read ${designFile}: ${error instanceof Error ? error.message : String(error)}` };
5994
+ }
5995
+ try {
5996
+ out.design = JSON.parse(raw);
5997
+ } catch {
5998
+ return { error: `${designFile} is not JSON. It should hold a layout such as {"blocks":[{"type":"text","content":"Hi {{contact.first_name}}"}]}` };
5999
+ }
6000
+ }
5981
6001
  try {
5982
6002
  if (htmlFile !== void 0) out.html = await read(htmlFile);
5983
6003
  else if (html !== void 0) out.html = clearable2(html);
@@ -5988,7 +6008,7 @@ async function draftFields(args, read = readText) {
5988
6008
  }
5989
6009
  return { value: out };
5990
6010
  }
5991
- var CREATE_USAGE = 'groundmail broadcasts create --name "December" --lists newsletter --from "Acme <news@mail.acme.dev>" (--template <template> | --subject \u2026 (--html \u2026 | --html-file email.html) [--text \u2026])';
6011
+ var CREATE_USAGE = 'groundmail broadcasts create --name "December" --lists newsletter --from "Acme <news@mail.acme.dev>" --subject \u2026 (--design-file layout.json | --html \u2026 | --html-file email.html | --template <template>) [--text \u2026]';
5992
6012
  async function runBroadcastsList(args, env = process.env) {
5993
6013
  const page = pageFlags(args);
5994
6014
  if ("error" in page) return { exitCode: 1, error: page.error };
@@ -6007,7 +6027,7 @@ async function runBroadcastsGet(args, env = process.env) {
6007
6027
  return withClient5(args, env, (client3) => client3.broadcasts.get(id));
6008
6028
  }
6009
6029
  async function runBroadcastsUpdate(args, env = process.env, read = readText) {
6010
- const usage = "groundmail broadcasts update <id> [--name \u2026] [--lists \u2026] [--from \u2026] [--subject \u2026] [--html \u2026|--html-file \u2026] [--template \u2026|none]";
6030
+ const usage = "groundmail broadcasts update <id> [--name \u2026] [--lists \u2026] [--from \u2026] [--subject \u2026] [--design-file \u2026|--design none] [--html \u2026|--html-file \u2026] [--template \u2026|none]";
6011
6031
  const id = positionals4(args)[0];
6012
6032
  if (!id) return usageError("Missing the broadcast id", usage);
6013
6033
  const fields = await draftFields(args, read);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "groundmail-cli",
3
- "version": "0.55.6",
3
+ "version": "0.56.0",
4
4
  "description": "Groundmail CLI: send email and manage mailboxes 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.61.5"
41
+ "groundmail": "0.62.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsup": "^9.0.0",