@getbrevo/cli 2.0.2 → 2.2.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 (220) hide show
  1. package/CHANGELOG.md +237 -0
  2. package/README.md +32 -6
  3. package/agent-context/AGENTS.md +62 -15
  4. package/agent-context/SKILL.md +98 -14
  5. package/dist/bin/files/AGENTS.md.tmpl +119 -0
  6. package/dist/bin/files/CLAUDE.md.tmpl +139 -0
  7. package/dist/bin/files/README.md.tmpl +184 -0
  8. package/dist/bin/files/app-config.json.tmpl +16 -0
  9. package/dist/{templates → bin}/files/src/oauth/.env.example.tmpl +8 -0
  10. package/dist/{templates → bin}/files/src/oauth/.env.local.tmpl +2 -0
  11. package/dist/{templates → bin}/files/src/oauth/handler.js.tmpl +49 -7
  12. package/dist/{templates → bin}/files/src/oauth/server.js.tmpl +20 -14
  13. package/dist/{templates → bin}/files/src/oauth/token-store.js.tmpl +19 -0
  14. package/dist/bin/index.js +680 -235
  15. package/dist/bin/index.js.map +7 -1
  16. package/package.json +6 -4
  17. package/dist/api/client.d.ts +0 -25
  18. package/dist/api/client.d.ts.map +0 -1
  19. package/dist/api/client.js +0 -205
  20. package/dist/api/client.js.map +0 -1
  21. package/dist/bin/index.d.ts +0 -3
  22. package/dist/bin/index.d.ts.map +0 -1
  23. package/dist/commands/app/create.d.ts +0 -8
  24. package/dist/commands/app/create.d.ts.map +0 -1
  25. package/dist/commands/app/create.js +0 -325
  26. package/dist/commands/app/create.js.map +0 -1
  27. package/dist/commands/app/credentials.d.ts +0 -6
  28. package/dist/commands/app/credentials.d.ts.map +0 -1
  29. package/dist/commands/app/credentials.js +0 -114
  30. package/dist/commands/app/credentials.js.map +0 -1
  31. package/dist/commands/app/delete.d.ts +0 -6
  32. package/dist/commands/app/delete.d.ts.map +0 -1
  33. package/dist/commands/app/delete.js +0 -167
  34. package/dist/commands/app/delete.js.map +0 -1
  35. package/dist/commands/app/list.d.ts +0 -4
  36. package/dist/commands/app/list.d.ts.map +0 -1
  37. package/dist/commands/app/list.js +0 -71
  38. package/dist/commands/app/list.js.map +0 -1
  39. package/dist/commands/app/scaffold.d.ts +0 -5
  40. package/dist/commands/app/scaffold.d.ts.map +0 -1
  41. package/dist/commands/app/scaffold.js +0 -213
  42. package/dist/commands/app/scaffold.js.map +0 -1
  43. package/dist/commands/app/scopes.d.ts +0 -2
  44. package/dist/commands/app/scopes.d.ts.map +0 -1
  45. package/dist/commands/app/scopes.js +0 -81
  46. package/dist/commands/app/scopes.js.map +0 -1
  47. package/dist/commands/app/start.d.ts +0 -5
  48. package/dist/commands/app/start.d.ts.map +0 -1
  49. package/dist/commands/app/start.js +0 -220
  50. package/dist/commands/app/start.js.map +0 -1
  51. package/dist/commands/app/update.d.ts +0 -2
  52. package/dist/commands/app/update.d.ts.map +0 -1
  53. package/dist/commands/app/update.js +0 -444
  54. package/dist/commands/app/update.js.map +0 -1
  55. package/dist/commands/definitions.d.ts +0 -5
  56. package/dist/commands/definitions.d.ts.map +0 -1
  57. package/dist/commands/definitions.js +0 -262
  58. package/dist/commands/definitions.js.map +0 -1
  59. package/dist/commands/init.d.ts +0 -2
  60. package/dist/commands/init.d.ts.map +0 -1
  61. package/dist/commands/init.js +0 -138
  62. package/dist/commands/init.js.map +0 -1
  63. package/dist/commands/login.d.ts +0 -6
  64. package/dist/commands/login.d.ts.map +0 -1
  65. package/dist/commands/login.js +0 -251
  66. package/dist/commands/login.js.map +0 -1
  67. package/dist/commands/logout.d.ts +0 -5
  68. package/dist/commands/logout.d.ts.map +0 -1
  69. package/dist/commands/logout.js +0 -54
  70. package/dist/commands/logout.js.map +0 -1
  71. package/dist/commands/skill/install.d.ts +0 -4
  72. package/dist/commands/skill/install.d.ts.map +0 -1
  73. package/dist/commands/skill/install.js +0 -29
  74. package/dist/commands/skill/install.js.map +0 -1
  75. package/dist/commands/skill/uninstall.d.ts +0 -4
  76. package/dist/commands/skill/uninstall.d.ts.map +0 -1
  77. package/dist/commands/skill/uninstall.js +0 -23
  78. package/dist/commands/skill/uninstall.js.map +0 -1
  79. package/dist/commands/whoami.d.ts +0 -4
  80. package/dist/commands/whoami.d.ts.map +0 -1
  81. package/dist/commands/whoami.js +0 -85
  82. package/dist/commands/whoami.js.map +0 -1
  83. package/dist/container.d.ts +0 -7
  84. package/dist/container.d.ts.map +0 -1
  85. package/dist/container.js +0 -28
  86. package/dist/container.js.map +0 -1
  87. package/dist/lang/en.d.ts +0 -162
  88. package/dist/lang/en.d.ts.map +0 -1
  89. package/dist/lang/en.js +0 -189
  90. package/dist/lang/en.js.map +0 -1
  91. package/dist/lib/abort.d.ts +0 -3
  92. package/dist/lib/abort.d.ts.map +0 -1
  93. package/dist/lib/abort.js +0 -30
  94. package/dist/lib/abort.js.map +0 -1
  95. package/dist/lib/auth-guard.d.ts +0 -13
  96. package/dist/lib/auth-guard.d.ts.map +0 -1
  97. package/dist/lib/auth-guard.js +0 -60
  98. package/dist/lib/auth-guard.js.map +0 -1
  99. package/dist/lib/browser.d.ts +0 -2
  100. package/dist/lib/browser.d.ts.map +0 -1
  101. package/dist/lib/browser.js +0 -16
  102. package/dist/lib/browser.js.map +0 -1
  103. package/dist/lib/cli-version.d.ts +0 -2
  104. package/dist/lib/cli-version.d.ts.map +0 -1
  105. package/dist/lib/cli-version.js +0 -59
  106. package/dist/lib/cli-version.js.map +0 -1
  107. package/dist/lib/command-handler.d.ts +0 -10
  108. package/dist/lib/command-handler.d.ts.map +0 -1
  109. package/dist/lib/command-handler.js +0 -16
  110. package/dist/lib/command-handler.js.map +0 -1
  111. package/dist/lib/command-registry.d.ts +0 -28
  112. package/dist/lib/command-registry.d.ts.map +0 -1
  113. package/dist/lib/command-registry.js +0 -54
  114. package/dist/lib/command-registry.js.map +0 -1
  115. package/dist/lib/config.d.ts +0 -83
  116. package/dist/lib/config.d.ts.map +0 -1
  117. package/dist/lib/config.js +0 -430
  118. package/dist/lib/config.js.map +0 -1
  119. package/dist/lib/constants.d.ts +0 -48
  120. package/dist/lib/constants.d.ts.map +0 -1
  121. package/dist/lib/constants.js +0 -121
  122. package/dist/lib/constants.js.map +0 -1
  123. package/dist/lib/errors.d.ts +0 -30
  124. package/dist/lib/errors.d.ts.map +0 -1
  125. package/dist/lib/errors.js +0 -66
  126. package/dist/lib/errors.js.map +0 -1
  127. package/dist/lib/exit-codes.d.ts +0 -9
  128. package/dist/lib/exit-codes.d.ts.map +0 -1
  129. package/dist/lib/exit-codes.js +0 -12
  130. package/dist/lib/exit-codes.js.map +0 -1
  131. package/dist/lib/hidden-input.d.ts +0 -2
  132. package/dist/lib/hidden-input.d.ts.map +0 -1
  133. package/dist/lib/hidden-input.js +0 -78
  134. package/dist/lib/hidden-input.js.map +0 -1
  135. package/dist/lib/json-output.d.ts +0 -6
  136. package/dist/lib/json-output.d.ts.map +0 -1
  137. package/dist/lib/json-output.js +0 -11
  138. package/dist/lib/json-output.js.map +0 -1
  139. package/dist/lib/logger.d.ts +0 -11
  140. package/dist/lib/logger.d.ts.map +0 -1
  141. package/dist/lib/logger.js +0 -110
  142. package/dist/lib/logger.js.map +0 -1
  143. package/dist/lib/oauth-freshness.d.ts +0 -30
  144. package/dist/lib/oauth-freshness.d.ts.map +0 -1
  145. package/dist/lib/oauth-freshness.js +0 -61
  146. package/dist/lib/oauth-freshness.js.map +0 -1
  147. package/dist/lib/port.d.ts +0 -25
  148. package/dist/lib/port.d.ts.map +0 -1
  149. package/dist/lib/port.js +0 -103
  150. package/dist/lib/port.js.map +0 -1
  151. package/dist/lib/telemetry.d.ts +0 -9
  152. package/dist/lib/telemetry.d.ts.map +0 -1
  153. package/dist/lib/telemetry.js +0 -57
  154. package/dist/lib/telemetry.js.map +0 -1
  155. package/dist/lib/ui.d.ts +0 -14
  156. package/dist/lib/ui.d.ts.map +0 -1
  157. package/dist/lib/ui.js +0 -75
  158. package/dist/lib/ui.js.map +0 -1
  159. package/dist/lib/update-notifier.d.ts +0 -37
  160. package/dist/lib/update-notifier.d.ts.map +0 -1
  161. package/dist/lib/update-notifier.js +0 -298
  162. package/dist/lib/update-notifier.js.map +0 -1
  163. package/dist/lib/validators.d.ts +0 -55
  164. package/dist/lib/validators.d.ts.map +0 -1
  165. package/dist/lib/validators.js +0 -166
  166. package/dist/lib/validators.js.map +0 -1
  167. package/dist/services/account.d.ts +0 -8
  168. package/dist/services/account.d.ts.map +0 -1
  169. package/dist/services/account.js +0 -15
  170. package/dist/services/account.js.map +0 -1
  171. package/dist/services/app.d.ts +0 -38
  172. package/dist/services/app.d.ts.map +0 -1
  173. package/dist/services/app.js +0 -145
  174. package/dist/services/app.js.map +0 -1
  175. package/dist/services/browser-auth.d.ts +0 -15
  176. package/dist/services/browser-auth.d.ts.map +0 -1
  177. package/dist/services/browser-auth.js +0 -188
  178. package/dist/services/browser-auth.js.map +0 -1
  179. package/dist/services/normalize-app-id.d.ts +0 -12
  180. package/dist/services/normalize-app-id.d.ts.map +0 -1
  181. package/dist/services/normalize-app-id.js +0 -38
  182. package/dist/services/normalize-app-id.js.map +0 -1
  183. package/dist/services/oauth-metadata.d.ts +0 -7
  184. package/dist/services/oauth-metadata.d.ts.map +0 -1
  185. package/dist/services/oauth-metadata.js +0 -43
  186. package/dist/services/oauth-metadata.js.map +0 -1
  187. package/dist/services/oauth-refresh.d.ts +0 -14
  188. package/dist/services/oauth-refresh.d.ts.map +0 -1
  189. package/dist/services/oauth-refresh.js +0 -70
  190. package/dist/services/oauth-refresh.js.map +0 -1
  191. package/dist/services/scopes-html.d.ts +0 -3
  192. package/dist/services/scopes-html.d.ts.map +0 -1
  193. package/dist/services/scopes-html.js +0 -516
  194. package/dist/services/scopes-html.js.map +0 -1
  195. package/dist/services/scopes-web.d.ts +0 -12
  196. package/dist/services/scopes-web.d.ts.map +0 -1
  197. package/dist/services/scopes-web.js +0 -95
  198. package/dist/services/scopes-web.js.map +0 -1
  199. package/dist/services/skill.d.ts +0 -48
  200. package/dist/services/skill.d.ts.map +0 -1
  201. package/dist/services/skill.js +0 -223
  202. package/dist/services/skill.js.map +0 -1
  203. package/dist/skills/index.d.ts +0 -47
  204. package/dist/skills/index.d.ts.map +0 -1
  205. package/dist/skills/index.js +0 -61
  206. package/dist/skills/index.js.map +0 -1
  207. package/dist/templates/files/AGENTS.md.tmpl +0 -52
  208. package/dist/templates/files/CLAUDE.md.tmpl +0 -59
  209. package/dist/templates/files/README.md.tmpl +0 -85
  210. package/dist/templates/files/app-config.json.tmpl +0 -25
  211. package/dist/templates/index.d.ts +0 -36
  212. package/dist/templates/index.d.ts.map +0 -1
  213. package/dist/templates/index.js +0 -105
  214. package/dist/templates/index.js.map +0 -1
  215. package/dist/types.d.ts +0 -32
  216. package/dist/types.d.ts.map +0 -1
  217. package/dist/types.js +0 -3
  218. package/dist/types.js.map +0 -1
  219. /package/dist/{templates → bin}/files/gitignore.tmpl +0 -0
  220. /package/dist/{templates → bin}/files/src/oauth/package.json.tmpl +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,242 @@
1
1
  # @getbrevo/cli
2
2
 
3
+ ## 2.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f3eefcc: **UI apps are GA** (BEX-290). `brevo app create` offers the _UI app_ type in every build (interactive-only — no `--type` flag), and `brevo app install [account-id]` / `brevo app uninstall [account-id]` now ship in the published CLI. Public app distribution (`--distribution public`, `app submit` / `app status` / `app withdraw`) remains pre-GA and excluded from published builds.
8
+
9
+ **Per-entry card `size`** (BEX-416). Each `ui_app.surface_point_list` entry accepts an optional `size` with `width` / `height` as CSS lengths — `"<positive integer>px"` or `"<1-100>%"` — overriding the host page's default card size for that placement. Both axes are optional; an omitted axis keeps the host default.
10
+
11
+ **CTA fields moved into each entry** (BEX-426). `label`, `more_info`, `redirect_link` and `modal_iframe_url` now live on each `surface_point_list` entry instead of the `ui_app` root, so every placement can carry its own label and destination. The root spellings are refused with a migration hint, and the per-type rules run per entry (`actionLink` requires `redirect_link` and refuses `modal_iframe_url`; `iframeExtension` the reverse). `brevo app create` authors exactly one placement — add more by editing `app-config.json` and running `brevo app upload`.
12
+
13
+ **Install/uninstall improvements.** Both commands refuse an app that is not a UI app (previously an OAuth app "installed" with nothing to render), name the resolved target account — `installed into Acme Retail (account 4043630)` — with an additive `accountName` in `--json`, and `uninstall`'s corporate sub-account picker asks "uninstall from" instead of "install into". Their interactive app picker now offers **only UI apps** — an OAuth app in the list was a choice whose only outcome was that refusal one step later — and errors with a pointer at `brevo app create` when there is no UI app to offer.
14
+
15
+ **`brevo app upload` diffs the `ui_app` block, and warns before it changes an installed app.** The summary used to print the block's desired state with a bare `(changed)` marker; it now diffs it against the server placement by placement — every changed value as `before → after`, added placements tagged `(new)`, dropped ones trailing `(removed)`, matched by slot slug so a reordered `surface_point_list` is not a change. For a UI app the command then warns that the app may already be installed in Brevo accounts (the configuration is shared by every install, and an upload is live there immediately, with no re-install) and asks _"Proceed with upload and update every account this app is installed in?"_. `--yes` skips the question but still prints the warning; `--json` prints neither and stays a single parseable document.
16
+
17
+ **`brevo app install` shows what it is about to install.** Before the confirmation it prints the app's configuration **as stored on the server** — app ID, name, `version`, `extension_type` and every placement — because that snapshot, not the local `app-config.json`, is what the account will render. `--json` gains additive `version` and `ui_app` keys carrying the same facts. When the app came from a linked project whose `ui_app` block has drifted from the stored one, the command says so and points at `brevo app upload`, then installs anyway (exit `0`) — installing an already-uploaded configuration is legitimate, so this is a notice rather than a refusal.
18
+
19
+ **`brevo app credentials` refuses a UI app.** A UI app has no OAuth credentials, so the command now exits `1` with a typed message pointing at `brevo app list`, instead of printing an empty credential form (blank client ID, "(none)" scopes and URLs) and caching the emptiness locally.
20
+
21
+ **`brevo app delete` warns before the confirm** that deletion also removes the app from every account where it is installed or published, and that installs and credentials cannot be recovered. `--force` still deletes without prompting, but now prints the same consequence line so a scripted delete leaves a record; it is kept out of `--json` output, which stays parseable JSON only.
22
+
23
+ **A `502 Bad Gateway` is now retried only for idempotent methods.** The automatic retry replays GET, PUT and DELETE; POST and PATCH surface the 502 as an error instead. A 502 comes from a gateway, so the origin may already have processed the request — blindly replaying a create could duplicate the resource (observed: `brevo app create` producing two identical apps). If it happens on `app create`, check `brevo app list` before retrying, since the app may already exist.
24
+
25
+ **The `app install` / `app uninstall` app picker is refused when it cannot be drawn.** Omitting `--app-id` outside a linked project under `--json` (or off a TTY) now exits `1` naming the `--app-id` form, instead of rendering the picker's choice list into what a script is parsing and then aborting on a raw readline error. Matches the guard `app delete`, `app credentials` and `app withdraw` already carry.
26
+
27
+ **A scaffolded UI app's project docs now describe a UI app.** `CLAUDE.md`, `AGENTS.md` and `README.md` branch on the app type, so a UI-app project documents the `ui_app` block, the per-entry placement fields and the `brevo app upload` → `brevo app install` flow. Previously all three were written from the OAuth templates regardless of type, which told the partner to `yarn --cwd src/oauth install` and `brevo app start oauth` against a `src/oauth/` directory a UI app never receives. OAuth projects get byte-identical files to before.
28
+
29
+ Smaller changes: `app create`'s placement prompt is labelled from the registry's own names; the UI integration-type prompt offers Link only until iframe authoring is ready (a hand-authored `iframeExtension` block still uploads); `--help` examples for `--app-id` show a UUID instead of `42`; a `surface_point_list` entry missing its `surface_point_name` key is reported as a missing key — with a rename hint when the pre-rename `surface_point` spelling is present — instead of as a blank slot name.
30
+
31
+ ## 2.1.0
32
+
33
+ ### Minor Changes
34
+
35
+ - e6d72f5: `brevo app update` is replaced by `brevo app upload`, `brevo app scaffold` can set up a
36
+ directory for an app you already have, `app-config.json` moves to a new shape,
37
+ `brevo <command> --help` prints that command's own usage, and `--json` now produces output
38
+ on failure paths.
39
+
40
+ ## `brevo app update` → `brevo app upload` (BEX-250)
41
+
42
+ `upload` takes only `--yes` and `--json`. The edit flags (`--app-id`, `--name`,
43
+ `--redirect-uri`, `--scope`, `--logo-uri`) are gone — edit `app-config.json`, then upload.
44
+
45
+ It always fetches the app's remote state and shows a local-vs-server diff before pushing,
46
+ including under `--yes` (skips the prompt only) and `--json`. No differences means exit `0`,
47
+ "already up to date", and no network push. Otherwise the whole local file is pushed and the
48
+ server-confirmed state written back. `distribution_type` is immutable after `app create`; a
49
+ changed value is refused locally.
50
+
51
+ `app update` stays registered but hidden, and answers with a message naming its replacement
52
+ (reachable with any removed flag, stray args, `--help`, or `brevo app help update`, and with
53
+ no login). Nothing is forwarded or uploaded; it exits `1`.
54
+
55
+ **Migrating:** `brevo app scaffold --app-id <id>`, edit `app-config.json`, `brevo app upload`.
56
+
57
+ ## `brevo app scaffold` gains a bootstrap mode
58
+
59
+ `scaffold` now picks its mode from whether the current directory holds an `app-config.json`.
60
+ With one, it adds a feature to the linked app. Without one it _bootstraps_ — sets the
61
+ directory up for an app that already exists — the successor to `brevo app update --app-id`.
62
+ - `--app-id <id>` fetches the app, writes `app-config.json` plus the base files, then
63
+ continues into the feature flow.
64
+ - Interactively with no config and no flag, it asks _"Set up a project for an app you already
65
+ have?"_ (default yes) and shows an app picker, so recovery no longer needs the app's ID.
66
+ Declining exits `0`. Under `--json` or off a TTY the usual no-config error is raised, so
67
+ scripts are unaffected.
68
+ - A bootstrap also asks for an output directory (defaulting to the app name as a slug),
69
+ creates it, and reports `cd <dir>` as the first next step; answer `.` to stay put. The
70
+ project is written and shown _before_ the feature question, so declining still leaves a
71
+ usable project.
72
+
73
+ Bootstrapping refuses three cases before any network call, each of which previously produced
74
+ a silently wrong project: a directory **inside** an existing app project (which used to nest
75
+ a second config, after which `upload` pushed the wrong app); `--app-id` naming a **different**
76
+ app than the directory is linked to; and an output directory that is **already another app's
77
+ project** (where answering _Merge_ left that app's config in place while writing this app's
78
+ credentials beside it).
79
+
80
+ `scaffold` also asks before reusing existing feature files — **Overwrite / Merge / Cancel**
81
+ (default Merge) — and a new `--overwrite` flag forces a full overwrite without prompting.
82
+
83
+ **Fixed:** bootstrapping into a directory that already holds a project for the _same_ app
84
+ wrote nothing and reported success. It is now treated as the refresh it is: drift is listed,
85
+ you confirm, the file is rewritten.
86
+
87
+ **Fixed:** `brevo app scaffold --json` could block on a prompt and hang CI. It now never
88
+ prompts — each case reports `{ "cancelled": true, "reason": "...", "diffs": [...] }`.
89
+
90
+ ## `brevo app create`
91
+
92
+ Creation is split from feature scaffolding. `create` writes only the base project
93
+ (`app-config.json`, `.gitignore`, `AGENTS.md`, `CLAUDE.md`, `README.md`); the OAuth
94
+ test-server code is now a feature, scaffolded when _"Scaffold the Test OAuth App?"_
95
+ (default yes) is accepted. Non-interactive runs stay base-only — add the code later with
96
+ `brevo app scaffold`.
97
+
98
+ `create` now hard-errors if `app-config.json` already exists, resolves its target directory
99
+ before creating the app, says where files are landing, and adds a `cd <dir>` step to
100
+ _Next steps_ when they land elsewhere. The logo URL is asked right after the app name;
101
+ `--logo-uri` and non-interactive runs are unchanged. Neither command asks _"What feature do
102
+ you want to scaffold?"_ any more — the CLI ships one feature; the picker returns
103
+ automatically if a second is added.
104
+
105
+ Fixed in `create`:
106
+ - `Client ID: undefined` — the create response nests OAuth fields under `auth`, which
107
+ dropped `Redirect URL n:` lines and omitted `clientId` / `redirectUri` from `--json`. The
108
+ response is now flattened in one place, tolerating both shapes.
109
+ - A failed read-back no longer destroys a successful create. A `404` on that one read now
110
+ falls back to the create response and completes with a warning instead of exiting non-zero
111
+ while the app sits on the server.
112
+ - No stray directory is left behind when create fails — the directory _decision_ still comes
113
+ first, but nothing is written until there is provably an app to write it for.
114
+ - The file count no longer reads `(0 files)` above a file tree; it reports `created (5 files)`,
115
+ `already in place (5 files, nothing rewritten)`, or `created (2 of 5 files written)`.
116
+ - Choosing Overwrite/Merge on _"Directory already exists"_ now says `Moving into <dir>...`
117
+ rather than contradicting the answer with `Creating <dir> and moving into it...`.
118
+
119
+ ## `app-config.json` shape
120
+
121
+ Backward compatible on read, migrated on the next write-back (`upload`, `app start`'s URL
122
+ registration, `credentials`, or `scaffold`):
123
+ - `auth.redirectUrls` → **`auth.redirectUris`**, matching the wire key `redirect_uris`. The
124
+ old key is still read; the new one wins if both are present.
125
+ - A legacy top-level `distribution`, and the interim `auth.type`, become **`distribution_type`**.
126
+ - New read-only top-level **`version`**, tracking the app-store API's version field.
127
+ - `cliVersion`, `permittedUrls`, `support` and `auth.type` are dropped — nothing read them.
128
+
129
+ **Downgrade caveat:** older releases read only `redirectUrls`, so a migrated file reads to
130
+ them as having no redirect URLs. That is loud and harmless in `app update`, but **`app start`
131
+ costs you something**: seeing an empty list it offers to register
132
+ `http://localhost:<port>/auth/callback` and, on yes, pushes that single URL as the app's whole
133
+ `redirect_uris` — dropping every real one, silently. Upgrade the lagging CLI, or keep both
134
+ keys as a stopgap; if it already happened, restore the list and `brevo app upload`.
135
+
136
+ `brevo app credentials` backfills a legacy config toward the current shape when its `appId`
137
+ matches the app being inspected, filling a missing `version` / `distribution_type` from the
138
+ server without overwriting existing values — so projects that are never uploaded converge too.
139
+
140
+ ## Help, `--json`, and debugging
141
+ - **`brevo <command> --help` prints that command's own usage, arguments, flags and examples.**
142
+ Subcommands previously rendered the root help screen, which never named the flags being
143
+ looked for. The root screen is unchanged.
144
+ - **`--json` now applies on failure.** Commands other than `whoami` and `logout` exited
145
+ non-zero with nothing on stdout. Failures now write one `{"error": {...}}` document carrying
146
+ `name`, `message`, `exitCode`, plus `statusCode` and (when classified) `code`. The
147
+ human-readable message still goes to stderr, so stdout stays exactly one parseable document.
148
+ - **`brevo app list` shows a `Version:` line** and includes `version` in `--json`. It is also
149
+ hardened against `redirect_uris: null` / `scopes: null` from the list endpoint, which used to
150
+ end the listing part-way with `Cannot read properties of null (reading 'length')`; the same
151
+ dereference is fixed in `app credentials`.
152
+ - **`--debug` logs the request body** before the request goes out, alongside the response —
153
+ same `<METHOD> <path>`, same redaction. Nothing changes without `--debug`.
154
+
155
+ ## Output
156
+ - **Boxed output wraps instead of shredding itself.** `printBox` sized itself to its longest
157
+ line and let the terminal wrap the overflow without the frame. Lines are now wrapped before
158
+ the frame is drawn — on a word where possible, mid-string where not — with continuation rows
159
+ indented under their label and colour carried across. Piped output falls back to 80 columns.
160
+ - **Selection prompts are indented into the CLI's output gutter**; `list` and `checkbox`
161
+ options used to render two columns left of every other line. Numbered app pickers are
162
+ unchanged.
163
+ - **Fixed:** the first row of a printed file tree was indented two columns deeper than the rest.
164
+ - **The logo-URL prompt fits 80 columns** — `App logo URL (optional — leave blank to skip):`,
165
+ with the example URL moved to the validation error.
166
+
167
+ ## Request payloads
168
+
169
+ `POST /v3/app-store/apps` now carries OAuth fields in the same `auth: { scopes, redirect_uris }`
170
+ block the upload endpoint takes, and upload's version field is renamed `app_version` →
171
+ `version`. `cli_version` and `source: 'cli'` are no longer sent in either body — both were
172
+ outside the declared contract, upload rejects unknown keys with a `400`, and the caller is
173
+ identified by a structured `User-Agent` (`brevo-cli/<version> (<os>; auth=<method>)`).
174
+
175
+ ## An expired session is reported before the prompts (BEX-341 follow-up)
176
+
177
+ `brevo app create` could ask every question and only then report ``Your session has expired.
178
+ Run `brevo login` ``, discarding all of it: a refresh token the login service _refuses_ was
179
+ treated like a transient network failure and swallowed.
180
+
181
+ A refused token is now terminal — stored credentials are cleared and the expiry is reported
182
+ from the pre-command hook, before the first prompt. Failures that say nothing about the
183
+ session (timeout, `5xx`, unwritable credentials file) are still swallowed and never block a
184
+ command. The token is also re-checked before each authenticated request rather than once at
185
+ startup, and if a session dies mid-flow `app create` offers to log you back in and re-sends
186
+ the answers you already gave (interactive terminals only). Exit codes and error text are
187
+ unchanged.
188
+
189
+ ## The legacy `all` OAuth scope is refused on upload (BEX-214)
190
+
191
+ `brevo app upload` now stops when `auth.scopes` still contains the deprecated catch-all `all`
192
+ and explains the migration: replace it with the specific scopes your integration uses, list
193
+ them with `brevo app available-scopes`, then upload. `brevo app start oauth` refuses the same
194
+ config with the same guidance, `brevo app list` tags an affected app, and `brevo app scaffold`
195
+ writes granular scopes.
196
+
197
+ The refusal is local — no round trip, nothing pushed. An app already holding `all` on Brevo is
198
+ untouched until you upload a replacement list; the upload diff then labels it as a migration.
199
+
200
+ ## Other fixes
201
+ - **`auth.scopes` written as a single string is read correctly.** A hand-edited
202
+ `"scopes": "contacts:read, contacts:write"` was documented as normalized on read and was
203
+ not — the splitter was only reached for arrays, so the upload validator iterated the string
204
+ one character at a time and rejected the run with `Invalid scope: ":"`. Strings are now split
205
+ on commas and whitespace, exactly as over-long array entries always were.
206
+ - **`app credentials` / `app delete` no longer open an app picker they cannot draw.** Their
207
+ `--app-id` fallback was not gated on the run being interactive, so under `--json` or off a
208
+ TTY it printed its choice list to **stdout** and then aborted with
209
+ `ERR_USE_AFTER_CLOSE: readline was closed`. Both now refuse up front, before any network
210
+ call, naming the exact command to run and exiting `1`; `--json` gets the usual error
211
+ envelope. Interactive runs are unchanged. `app delete` is the consequential one — a scripted
212
+ delete that appeared to rely on the picker was never selecting anything.
213
+
214
+ - 67390da: Take the update banner's message from the Brevo app-store service, and let it block a CLI version that can no longer be supported.
215
+
216
+ Whether an update banner appears is unchanged: the CLI still checks the npm registry, compares against its own version, and applies the same soft-notice and force-update rules. What changed is the first line of that banner, which now comes from `GET /cli/info` and is rendered in red above the box. The box's own contents are untouched.
217
+
218
+ That endpoint is called on the app-store service **directly**, not through the v3 API gateway, and needs no API key — so the notice still renders while logged out, mid-`login`, or with expired credentials, which is exactly when a stale CLI is most likely to be the real problem. `BREVO_APP_STORE_URL` overrides the base URL for non-production testing.
219
+
220
+ The response may also carry `"is_blocked": true`. When it does, every command except `--help` / `--version` prints the banner to stderr and exits `1` without running, letting a broken CLI version be stopped without shipping a new release. This is deliberately **not** silenced by `BREVO_NO_UPDATE_NOTIFIER=1`, `--no-update-notifier`, CI, or a non-TTY — those suppress a _notice_, and a suppressed banner must never mean a suppressed block.
221
+
222
+ Because a block has to prevent a command rather than report on it afterwards, the call now runs once before the command instead of after it. The result is cached at `~/.brevo/cli-info-cache.json` for **15 minutes**, keyed to the running CLI version, so a healthy fleet of invocations doesn't call the app-store service on every single command — revised wording and a new block reach users within minutes rather than after the old 12h npm-style TTL, and an upgrade always gets a live check regardless of the cache's age. A failed call never overwrites a good cache entry.
223
+
224
+ It fails open throughout. A timeout, a non-2xx, HTML from a gateway, or an unparseable body all leave the CLI behaving exactly as before — the banner falls back to local wording and nothing is blocked. Only a literal `true` blocks, so an outage can never lock anyone out. The endpoint is fetched outside the authenticated API client, so a 401 from it cannot reach the re-auth handler or clear stored credentials, and the returned text is control-character stripped, flattened to one line, and clamped before display.
225
+
226
+ Also show the update notice when a command fails. Previously the banner only printed on the success path, so anyone whose command errored — including the auth errors most likely to be fixed by upgrading — never saw that a newer CLI existed. The banner now prints after the error message on stderr, keeping the command's own exit code, and `notifyUpdate` is idempotent so runs that already showed it up front (`--help`, `app init`, `app create`) don't print it twice. A Ctrl-C abort still exits immediately without waiting on the check.
227
+
228
+ The npm registry check backing the soft-notice/force-update gate (`~/.brevo/update-check.json`) moves from a 24h TTL to **12h**, so a newly-published version reaches users about twice as fast.
229
+
230
+ ### Patch Changes
231
+
232
+ - bcfc3c1: Fix two ways the update banner could show local wording when the app-store service had wording of its own.
233
+
234
+ **`--help` and `--version` never asked.** They are exempt from the `is_blocked` gate so a blocked CLI can still say what version it is — but that was implemented by skipping the whole `/cli/info` call, which discarded the message along with the verdict. Both still render an update banner, so the two commands people most often run to check their version were the only ones that could never explain why the version mattered. The exemption now covers the block alone: they fetch the wording, show it, and still exit `0` no matter what `is_blocked` says.
235
+
236
+ **The 15-minute cache ignored which service the answer came from.** The entry was keyed on `cliVersion` and `lastChecked` only, but the base URL is overridable per-invocation via `BREVO_APP_STORE_URL`, so two runs against different environments shared one entry — whichever was hit first answered for both until the TTL expired. The symptom was badly misleading: pointing at staging rendered the message production had returned moments earlier and vice versa, so the CLI and a direct `curl` disagreed, and which environment looked broken depended only on the order the two were run in. `baseUrl` is now part of the key. An entry written before the field existed fails the shape check and is treated as a miss, so an upgrade re-fetches once rather than serving a stale answer.
237
+
238
+ Neither changes what blocks, what fails open, or any exit code.
239
+
3
240
  ## 2.0.2
4
241
 
5
242
  ### Patch Changes
package/README.md CHANGED
@@ -5,7 +5,7 @@ Command-line tool to create, manage, and test [Brevo](https://www.brevo.com/) OA
5
5
  > 📖 Full command and option documentation: **[Brevo CLI reference](https://developers.brevo.com/docs/cli-reference)**
6
6
 
7
7
  > [!WARNING]
8
- > **Upgrade to v2.0.0.** All versions from **1.1.1** up to (but not including) **2.0.0** should be migrated to **2.0.0**. The `2.0.0` release introduces **breaking changes**, so some CLI commands may not work as expected on older versions.
8
+ > **Upgrade to the latest released version.** All versions from **1.1.1** up to (but not including) **2.0.0** should be migrated to at least **2.1.0**. The `2.0.0` release introduced **breaking changes**, so some CLI commands may not work as expected on older versions. **`2.1.0` and above** also carry further `app-config.json` migrations (e.g. legacy `auth.redirectUrls` → `auth.redirectUris`) that are applied automatically the next time the CLI writes your config (`brevo app upload`, `brevo app start`, …).
9
9
  >
10
10
  > Upgrade with `npm install -g @getbrevo/cli@latest` (or `yarn global add @getbrevo/cli@latest`, or `brew upgrade brevo`), then confirm with `brevo --version`.
11
11
 
@@ -79,7 +79,7 @@ Or step by step:
79
79
  ```bash
80
80
  brevo app list
81
81
  brevo app create --name "My App" --distribution private
82
- brevo app scaffold --app-id 42
82
+ brevo app scaffold --app-id 3f8c1a2e-5b47-4d9c-8e10-6a2b7d4f0c93
83
83
  brevo app start oauth --port 3000
84
84
  ```
85
85
 
@@ -93,16 +93,42 @@ Run `brevo --help` or `brevo <command> --help` for full command and option lists
93
93
  | `brevo logout` | Clear stored credentials (`--force` to skip confirmation) |
94
94
  | `brevo whoami` | Show the authenticated user |
95
95
  | `brevo app init` | Guided setup — login, create app, and scaffold in one go |
96
- | `brevo app create` | Create an OAuth app (`--name`, `--distribution private\|public`, repeatable `--redirect-uri`, `--logo-uri`) |
97
- | `brevo app list` | List OAuth apps in your account |
96
+ | `brevo app create` | Create an app — an OAuth app (`--name`, `--distribution private`, repeatable `--redirect-uri`, `--logo-uri`), or a UI app via the interactive prompts (there is no `--type` flag; non-interactive runs always create an OAuth app) |
97
+ | `brevo app list` | List apps in your account (each row names its type) |
98
98
  | `brevo app credentials` | Show client ID and secret (`--app-id`, `--reveal-secret`) |
99
- | `brevo app update` | Update app name, redirect URLs, or logo (`--app-id`, `--name`, repeatable `--redirect-uri`, `--logo-uri`, `--yes`) |
99
+ | `brevo app upload` | Push `app-config.json` to Brevo after showing a local-vs-server diff field by field, including every `ui_app` placement (`--yes`) |
100
100
  | `brevo app delete` | Delete an app (`--app-id`, `--force`) |
101
- | `brevo app scaffold` | Generate starter code for an app (`--app-id`) |
101
+ | `brevo app scaffold` | Add a feature to the app in the current directory, or set an empty directory up for an app you already have — picked interactively, or named with `--app-id` (`--overwrite`, `--json`) |
102
102
  | `brevo app start` | Run a scaffolded feature locally (e.g. `brevo app start oauth --port 3000`) |
103
+ | `brevo app install` | Install a UI app into a Brevo account, after showing the configuration and version it will install (`[account-id]` optional — a regular account installs into itself; a corporate account is prompted to pick a sub-account, so pass the ID explicitly in scripts; `--app-id`, `--force`) |
104
+ | `brevo app uninstall` | Uninstall a UI app from a Brevo account (same arguments as `install`) |
105
+ | `brevo app available-scopes` | List the OAuth scopes the IdP supports (`--web` opens the catalog in a browser) |
103
106
 
104
107
  Most commands require a successful `brevo login` first, except authentication/help flows (`brevo login`, `brevo logout`, `brevo app init`, `--help`). Every command accepts `--json` for machine-readable output.
105
108
 
109
+ The table above is the complete command surface of a published release. Features that aren't live on the Brevo platform yet aren't built into the package — `brevo --help` always lists everything the binary can do, so there is nothing hidden behind a flag or an environment variable.
110
+
111
+ ### Uploading a UI app that is already installed
112
+
113
+ A UI app's `ui_app` block is what every account it is installed in renders, and there is no
114
+ separate publish step — an upload is live in those accounts as soon as it succeeds. So the two
115
+ commands show you what you are about to change:
116
+
117
+ - **`brevo app upload`** diffs the block against the server placement by placement, printing
118
+ each changed value as `before → after` and tagging placements as `(new)` / `(removed)`. It
119
+ then warns that the app may already be installed in Brevo accounts and asks for confirmation
120
+ naming that consequence. `--yes` skips the question, not the warning; `--json` prints neither
121
+ and stays a single parseable document.
122
+ - **`brevo app install`** prints the configuration it is about to install — **as stored on the
123
+ server**, since that is what the install makes visible — with the app's version, extension
124
+ type and every placement, before asking to confirm. If the `app-config.json` in the current
125
+ directory has drifted from it, the command says so and points at `brevo app upload`; the
126
+ install still proceeds, because the stored configuration is a legitimate thing to install.
127
+ Under `--json` the same information comes back as `version` and `ui_app`.
128
+
129
+ To change what an installed app renders: edit `app-config.json`, run `brevo app upload`, and the
130
+ accounts it is installed in pick the change up — no re-install needed.
131
+
106
132
  ### Browser login
107
133
 
108
134
  `brevo login` defaults to a browser-based sign-in. The CLI starts a temporary loopback server, opens your browser to the Brevo CLI login service, and stores the returned tokens in `~/.brevo/credentials.json`. Access tokens refresh automatically on expiry.
@@ -3,6 +3,18 @@
3
3
 
4
4
  This project uses the [Brevo Developer CLI](https://www.npmjs.com/package/@getbrevo/cli) (`brevo` binary) to manage Brevo OAuth applications.
5
5
 
6
+ ## `brevo --help` is the source of truth
7
+
8
+ Brevo features that haven't been released are **not built into the published CLI at all** — not as hidden commands, not behind a flag or an env var. `brevo --help` and `brevo app --help` list everything the binary can do. Treat that as the complete surface and build from it.
9
+
10
+ What this means in practice:
11
+
12
+ - **If a command isn't in `--help`, it doesn't exist here.** Invoking it gives Commander's `unknown command` and exit `1`. That is a final answer, not a transient failure and not a permissions problem — there is no flag, config edit, account setting, or environment variable that reveals it. Don't retry, don't hunt for an alternative route, and don't tell the user to request access. Say the feature isn't available in this CLI and offer the nearest thing that works.
13
+ - **Don't act on a command you remember rather than one you can see.** Your training data may include commands from a newer or unreleased build of this CLI. `--help` in the current session is the only reliable source, and the table below documents only what a published build ships.
14
+ - **A flag can be rejected even when its command exists.** `--distribution` is a real flag, but a value tied to an unreleased feature is refused with *"That command is not available yet. It is part of a Brevo feature that has not been released."* Same rule: it's final. Use `--distribution private`.
15
+
16
+ The Brevo API enforces the same boundaries independently, so nothing is gained by routing around the CLI — a hand-rolled `curl` hits the platform's own refusal.
17
+
6
18
  ## AI agents — start here
7
19
 
8
20
  Pick the path that matches your tooling:
@@ -50,10 +62,11 @@ Don't fall back to raw HTTP against `api.brevo.com` — the `brevo` binary is th
50
62
 
51
63
  ## When to use it
52
64
 
53
- - Create, list, update, or delete Brevo OAuth apps
65
+ - Create, list, upload changes to, or delete Brevo apps — OAuth apps, or UI apps (action links rendering inside Brevo CRM records)
54
66
  - Scaffold a starter OAuth integration
55
67
  - Run a local OAuth test server (`brevo app start oauth`)
56
68
  - Inspect or rotate app credentials
69
+ - Install or uninstall a UI app in a Brevo account (`brevo app install` / `brevo app uninstall`)
57
70
 
58
71
  ## Common commands
59
72
 
@@ -63,13 +76,15 @@ Don't fall back to raw HTTP against `api.brevo.com` — the `brevo` binary is th
63
76
  | `brevo logout` | Clear stored credentials (`--force`, `--json`) |
64
77
  | `brevo whoami` | Show the authenticated account (`--json`) |
65
78
  | `brevo app init` | Guided setup (login, create, scaffold) |
66
- | `brevo app list` | List OAuth apps (`--json`) |
67
- | `brevo app create` | Create an app (`--name`, `--distribution`, `--redirect-uri`, `--logo-uri`, `--json`). Only `--distribution private` is available today `public` is rejected with a "coming soon" error. Defaults to scopes `contacts:read`, `contacts:write`, `crm:read`, `crm:write`. |
68
- | `brevo app update` | Update name / redirect URLs / scopes / logo (`--app-id`, `--name`, `--redirect-uri`, `--scope` repeatable appends, `--logo-uri`, `--yes`, `--json`) |
69
- | `brevo app credentials` | Show client ID / secret (`--app-id`, `--reveal-secret`, `--json`) |
70
- | `brevo app delete` | Delete an app (`--app-id`, `--force`, `--json`) |
71
- | `brevo app scaffold` | Generate starter OAuth code (`--app-id`, `--json`) |
79
+ | `brevo app list` | List apps (`--json`). Each row names its type. |
80
+ | `brevo app create` | Create an app (`--name`, `--distribution private`, `--redirect-uri`, `--logo-uri`, `--json`). **Pass `--distribution private`** run `brevo app create --help` for the values this build accepts and don't pass one it doesn't list. Defaults to scopes `contacts:read`, `contacts:write`, `crm:read`, `crm:write`. Interactively it asks for the name before the OAuth prompts, and asks the **app type** (OAuth vs UI app) as the last question before the flow splits — there is no `--type` flag, so a UI app is only reachable interactively and every non-interactive run creates an OAuth app. **Errors immediately if `app-config.json` already exists in the working directory** — move elsewhere or use `brevo app scaffold` there instead. Otherwise resolves (creates/`cd`s into) a target directory, creates the app, and writes the basic project structure (`app-config.json` + `.gitignore`/`AGENTS.md`/`CLAUDE.md`/`README.md`). It scaffolds a feature (OAuth test server) only when the interactive confirm (*"Scaffold the Test OAuth App?"*, default yes) is answered yes; non-interactive runs (`--json` or piped) stay base-only — add the feature afterward with `brevo app scaffold`. |
81
+ | `brevo app upload` | Push `app-config.json` to Brevo (`--yes`, `--json`). No edit flags — change name/redirect URLs/scopes/logo/version by editing `app-config.json` directly, then run `upload`. **`distribution_type` is immutable** — set at `app create` time; if the local value differs from the server, `upload` errors before pushing (restore the local value, or create a new app). Always fetches the remote app first and shows a local-vs-server diff (even under `--yes`/`--json`); exits 0 with no network push if nothing differs. **For a UI app the diff covers the `ui_app` block placement by placement** — every changed value as `before → after`, added placements tagged `(new)`, dropped ones trailing `(removed)`, matched by slot slug so a reordered `surface_point_list` is not a change — and the command then warns that the app may already be installed in Brevo accounts and asks *"Proceed with upload and update every account this app is installed in?"*. There is no separate publish step: a successful upload changes what every account the app is installed in renders, immediately and with no re-install. `--yes` skips the question but still prints the warning; `--json` prints neither and stays a single parseable document. |
82
+ | `brevo app credentials` | Show client ID / secret (`--app-id`, `--reveal-secret`, `--json`). **`--app-id` is required when scripting** — see the picker note below. **OAuth apps only** — a UI app has no OAuth credentials, so the command refuses it with exit `1` and points at `brevo app list` for the app's type. Also backfills a missing top-level `version` / `distribution_type` into cwd's `app-config.json` when its `appId` matches (fill-only-when-missing, silent). |
83
+ | `brevo app delete` | Delete an app (`--app-id`, `--force`, `--json`). **`--app-id` is required when scripting** — see the picker note below. |
84
+ | `brevo app scaffold` | Add a feature to the app in the current directory (`--app-id`, `--overwrite`, `--json`). Requires an `app-config.json` in cwd **unless `--app-id <id>` is passed or you accept its bootstrap offer**; reads the linked app from it. `--app-id` in a directory with no config fetches that app and writes `app-config.json` + the base files first — the only way to get a config for an app that already exists, and the migration path off the removed `brevo app update --app-id`. Interactively, omitting `--app-id` in a config-less directory prints *"No app-config.json in this directory…"*, asks **"Set up a project for an app you already have?"** (default yes) and on yes shows an app picker; answering no exits `0` with the remaining routes on screen. Every interactive bootstrap (picker or `--app-id`) then asks `Output directory:` defaulted to `./<slugified app name>`, creates it and `cd`s into it — answer `.` to stay in the current directory — and the *Next steps* box opens with `cd <dir>`. Under `--json` or off a TTY there is no offer — it errors, listing the three ways out. It refuses, before any network call: if the directory is already linked to a different app — either the one the command ran in or the one it was pointed at (naming the app it is already linked to is a no-op), if the directory is **inside** an existing app project (a nested second config would make a later `brevo app upload` from there push the wrong app). Diffs the local config against the server and, on drift, updates `app-config.json` to match (on consent) before writing the feature files — including when a bootstrap is pointed at a directory that already holds a project, where answering **Merge** to the directory question does *not* skip that refresh. When feature files already exist, prompts Overwrite / Merge / Cancel (default Merge — existing files kept); `--overwrite` forces overwrite and skips the prompt. The scaffolded OAuth flow is the confidential-client flow: the token exchange is authenticated with the `CLIENT_SECRET` written into the generated `.env.local`. |
72
85
  | `brevo app start oauth` | Run the scaffolded OAuth test server (`--port`) |
86
+ | `brevo app install` | Install a **UI app** into a Brevo account (`[account-id]` positional, `--app-id`, `--force`, `--json`). UI apps only — an OAuth app has nothing to install and the CLI refuses with exit `1`. `[account-id]` is optional: omitted, a plain account installs into itself (no prompt, `--json`/CI safe) and a corporate account picks a sub-account interactively — non-interactive corporate runs must pass it. Refused locally until the app has been validated by a `brevo app upload` (the `version` field is the signal). Interactively, omitting `--app-id` outside a linked project opens an app picker that lists **only UI apps**; with no UI app to offer it errors (exit `1`) naming `brevo app create`. That picker needs a terminal: under `--json` or off a TTY, omitting `--app-id` outside a linked project is refused with exit `1`. **Prints the configuration it will install before acting** — app ID, name, `version`, extension type and every placement, read from the server, because the account renders the stored snapshot and not the local `app-config.json`; under `--json` the same facts come back as additive `version` / `ui_app` keys on the result. When the linked project's block has drifted from the stored one it says so and names `brevo app upload`, then installs anyway (a notice, not a refusal — the stored configuration is a legitimate thing to install). |
87
+ | `brevo app uninstall` | Uninstall a UI app from a Brevo account (same arguments and target resolution as `install`). Uninstalling an app that isn't installed is informational, exit `0` — not an error. |
73
88
  | `brevo app available-scopes` | List OAuth scopes supported by the IdP (`--json`, `--web`) |
74
89
  | `brevo skill:cli install` | Install the brevo-cli Claude Code skill (Claude-only; auto-refreshes on every `brevo` run) |
75
90
  | `brevo skill:cli uninstall` | Remove the brevo-cli skill from `~/.claude/skills/` (Claude-only) |
@@ -78,30 +93,61 @@ Run `brevo --help` or `brevo <command> --help` for the full set.
78
93
 
79
94
  ## Conventions
80
95
 
81
- - **Every command supports `--json`** — prefer this when parsing output programmatically.
82
- - **`app-config.json`** in the working directory pins the linked app — `brevo app update` and `brevo app start` read from it. The optional top-level `logoUri` string is pushed as `logo_uri` by a flagless `brevo app update`; leave it empty to keep the API value untouched.
96
+ - **Every command supports `--json`** — prefer this when parsing output programmatically. It applies to failures too: a failing `--json` run writes a single `{"error": {...}}` document to stdout (see *JSON errors* below) while the human message goes to stderr.
97
+ - **Two app types, one command surface.** `app-config.json` describes either an **OAuth app** — a populated `auth` block (`auth.scopes` / `auth.redirectUris`) and no `ui_app` — or a **UI app** — a `ui_app` block and an **empty** `auth: {}` (no callbacks, scopes, or credentials). The presence of `ui_app` is the discriminator; never mix the two in one file. Both types share the top-level `appId` / `appName` / `logoUri` / `version` / `distribution_type` and the same `create`/`upload`/`list`/`delete` commands; only UI apps take `install`/`uninstall`. **A UI app has one stored configuration, shared by every account it is installed in** — `brevo app upload` is therefore how you change what an installed app renders (edit `app-config.json`, upload, done), never uninstall-then-reinstall; both commands show what is about to change for that reason. The `ui_app` block holds `extension_type` at its root (`actionLink`, `iframeExtension`, `legacyComponent` — camelCase only) and a `surface_point_list` of placement entries, each carrying `surface_point_name` (the dot-notation slug from the platform's registry, e.g. `contactDetails.header.menu` not the `<location>.<place>.<kind>` extension-point name like `contactDetails.headerMenu.action`, which is dotted too but a different string), `label`, optional `more_info`, `redirect_link` (record context arrives as query parameters), optional `context`, optional `size` (e.g. `{ "width": "280px", "height": "160px" }` — each axis a positive-integer `px` length or `1%`–`100%` of the host slot, shrink-only, both axes optional), and — `iframeExtension` only — `modal_iframe_url`. Do **not** write `link_target` or `extension_point_name` into the file: both are wire/server-stamped (`app upload` injects `link_target` itself). Write only the keys documented here — `brevo app upload` validates the whole file and rejects anything it doesn't recognise, including the pre-GA `heading`/`subheading` names (now `label`/`more_info`, per entry). A UI-app project is **configuration only** — no feature to scaffold and no `src/oauth/`, since an action link has no local server (`brevo app scaffold` inside one says so and exits `0`; `brevo app start` does not apply) — and the base docs the scaffold writes (`AGENTS.md` / `CLAUDE.md` / `README.md`) describe whichever type the app is, so a UI app's copies cover the `ui_app` block and the `upload` → `install` flow instead of an OAuth server.
98
+ - **`brevo app create` refuses to run inside an already-linked directory.** If `app-config.json` exists in cwd, it throws immediately (no confirm, no override) — the error points at moving elsewhere or running `brevo app scaffold` there.
99
+ - **`brevo app create` resolves its target directory before creating the app**, then writes the **basic project structure only** (`app-config.json` + `.gitignore`/`AGENTS.md`/`CLAUDE.md`/`README.md`) — the OAuth server code is a *feature*, not part of the base. Interactive mode prompts for the target directory (default `./<slugified-app-name>`, `cd`s into it) before the API call, how to handle an existing one (overwrite / merge / choose a different path), and — after the app is created — whether to scaffold a feature (*"Scaffold the Test OAuth App?"*, default **yes**). There is no follow-up "which feature?" question while the CLI ships one: a list of one is not asked, and the confirm names it instead. A second feature would bring the picker back. Non-interactive runs stay base-only: `--json` (and piped, non-TTY) create the app and write the base files but never scaffold a feature — run `brevo app scaffold` afterward for the OAuth code. Under `--json` the same default directory is used and `cd`d into if it doesn't already exist; if it already exists, both directory setup and scaffolding are skipped (the app is still created). The JSON response always includes `directory` (absolute path) alongside the app fields, plus either `scaffolded` (base file count, on success) or `scaffoldSkipped` (a message, when the directory already existed).
100
+ - **`brevo app scaffold` adds a feature to an already-created project, or sets an empty directory up for an app that already exists.** It **requires** an `app-config.json` in cwd unless `--app-id` is passed or its bootstrap offer is accepted, and only the bootstrap mode ever creates a directory (the feature-add mode always writes into the project it was run in). **`--app-id <id>` bootstraps a project for an app that already exists**: it fetches the app, writes `app-config.json` + the base files, and then continues into the feature flow. That is the only command that produces a config for an existing app (`app create` creates a new one, `app upload` only reads the linked project), which makes it the migration path off the removed `brevo app update --app-id`. **Interactively, `--app-id` is optional**: in a config-less directory the command explains there is no app here, asks *"Set up a project for an app you already have?"* (default **yes**), and on yes runs the same app picker `app delete` uses — because a user who has lost their project folder has the app but not necessarily its ID. Declining is a normal outcome that exits `0` after printing the remaining routes; the offer is skipped entirely under `--json` or off a TTY, where the no-config error (naming all three ways out: `cd` into a project, `--app-id`, `brevo app create`) is raised instead, so scripts behave exactly as before. **An interactive bootstrap also asks where to put the project** — `Output directory:`, defaulted to `./<slugified app name>`, the same prompt (and the same overwrite / merge / choose-a-different-path follow-up on an existing directory) `app create` uses; it creates the directory, `cd`s the CLI process into it, writes and reports the project, then asks *"Scaffold the Test OAuth App?"* (default yes; declining leaves the project and exits `0`), and opens *Next steps* with `cd <dir>` since the user's shell stayed behind. Answering `.` keeps the current directory and drops that step. This too is interactive-only: under `--json` or off a TTY the files go into the current directory as they always have, which is what makes `scaffold --app-id` safe to script. In bootstrap mode the config is written from the server's copy of the app, since there is nothing local to read it from. Bootstrapping is refused, before any network call or write, in two cases: a directory already linked to a **different** app (passing the app it is already linked to changes nothing), and a directory **inside** an existing app project — `readProjectConfig` reads cwd only and never walks up, so without that check a stray `cd` would nest a second `app-config.json` inside the first and a later `app upload` from there would push the wrong app silently. The different-app check applies to the answer to `Output directory:` as well as to cwd, and there it is the only thing standing between you and a project whose `app-config.json` and `src/oauth/.env.local` name two different apps. **A target directory that already holds a project for the same app makes the bootstrap a refresh**: its config is diffed against the server and rewritten only on consent, and the directory question's **Merge** answer does not suppress that. The two answers address different things — Merge means "don't clobber my own files" and is implemented by skipping any path that already exists, which `app-config.json` always does here, so letting it govern the base write meant the command fetched the app, discarded every field, wrote nothing, and still printed its success box. No drift leaves `app-config.json` as it is with a one-line notice; the feature is still offered either way. It otherwise reads the linked app id from that config (no picker — the picker is only for the config-less bootstrap), diffs the local config against the server, and if fields drifted it shows them and asks consent to update `app-config.json` (and the other base files) to match before writing the feature files. When any feature file already exists it prompts **Overwrite / Merge / Cancel** (default **Merge** — existing, e.g. hand-edited, files are kept and only missing files added; Cancel aborts without writing). The `--overwrite` flag forces a full overwrite of feature files and skips that prompt (works interactively and under `--json`). **Under `--json` it never prompts**: a config diff comes back as `{ "cancelled": true, "reason": "...", "diffs": [...] }`; otherwise it writes the feature (merging existing files unless `--overwrite` is passed) and returns `{ "scaffolded": <n>, "directory": "..." }`.
101
+ - **`app-config.json`** in the working directory pins the linked app — `brevo app upload` and `brevo app start` read from it. `upload` is the *only* command that pushes config changes, and it has no `--app-id` override (it always resolves the app from cwd's `app-config.json`, hard-erroring if that file is missing/invalid/lacks `appId`); `brevo app start` accepts `--app-id` to target a different app. The top-level `logoUri` string is pushed as `logo_uri`; leave it empty to keep the API value untouched. The top-level `version` string is round-tripped as `version` on the wire — `upload` sends the local value (falling back to the server's current value if locally absent) and writes back whatever the server confirms. `brevo app credentials` additionally backfills a missing top-level `version` / `distribution_type` into cwd's `app-config.json` when its `appId` matches the inspected app — fill-only-when-missing (never overwrites an existing local value), silent in all modes — so legacy projects that are never `upload`ed still converge to the current shape.
102
+ - **Commands that pick an app interactively refuse to do so when scripted.** `brevo app credentials` and `brevo app delete` fall back to an interactive app picker when `--app-id` is absent. Under `--json` **or** off a TTY that picker is refused up front — before any network call — with a `CliError` naming the exact command to run (`brevo app credentials --app-id <id>`) and exiting `1`. **Always pass `--app-id` when scripting these.** The refusal exists because the picker renders its choice list to stdout, which would otherwise corrupt the single-JSON-document contract below and leak app ids into whatever is parsing it. `brevo app delete` is the one that matters most: it is destructive, so a script that relied on the picker was never doing what its author thought.
103
+ - **There is no `brevo app update`.** It was removed and replaced by `brevo app upload`, with no shim and no flag-for-flag equivalent — change an app's name, redirect URLs, scopes or logo by editing `app-config.json`, then run `brevo app upload`. That is what to replace it with wherever you find it: a user's script, a CI job, a README, or your own recollection. Invoking it — with any of the old flags (`--name`, `--redirect-uri`, `--scope`, `--logo-uri`, `--app-id`), with `--help`, or as `brevo app help update` — prints a message naming `upload` and exits `1` **without uploading anything**, so a `1` from `brevo app update` means the command is gone, not that an upload failed. It is absent from every help screen, and needs no login to reach.
83
104
  - **Credentials** live at `~/.brevo/credentials.json`. Never commit this file or any `.env.local`.
84
105
  - **Non-interactive auth:** `BREVO_API_KEY=xkeysib-... brevo login`. The legacy `--api-key` flag was removed because it leaks into shell history.
85
- - **Skip prompts:** `--force` for delete/logout; `--yes` for `app update`.
106
+ - **Skip prompts:** `--force` for `app delete`, `app install`, `app uninstall` and `logout`; `--yes` for `app upload`. `app delete --force` still prints the install-loss warning line (kept out of `--json` output, which stays parseable JSON only). `app upload --yes` behaves the same way for a UI app: it skips the confirmation but still prints the line warning that the app may already be installed.
86
107
  - **Forced update:** when the installed CLI is a full **major** version behind the latest npm release, every command except `--help`/`--version` prints a blocking update banner to stderr and exits `1` without running. Update with `npm install -g @getbrevo/cli` (or `yarn global add`). The gate honors the same opt-outs as the soft update notice (`BREVO_NO_UPDATE_NOTIFIER=1`, `--no-update-notifier`, CI, non-TTY), so it never fires in those contexts.
108
+ - **Update notice wording:** the update/force-update banners take their first line from the app-store service (`GET /cli/info`). It is called directly, not through the v3 API gateway, and needs no API key — so it works while logged out or with expired credentials. It runs once per invocation, **before** the command, and the response is cached at `~/.brevo/cli-info-cache.json` for **15 minutes**, keyed to the installed `cliVersion` — so reworded text or a new block reaches the CLI within minutes rather than after the old 12h npm-style TTL. Whether an update banner appears is still decided from the npm registry, and if the call fails the banner still appears with local wording (a failed call never overwrites a good cache entry).
109
+ - **Soft update notice on failures:** the non-blocking update banner also prints after a command *fails*, not just after it succeeds — so stderr may hold the error message followed by the update box. Exit codes are unchanged (still the command's own), the box never appears twice in one run, and a Ctrl-C abort skips it. Parse stderr accordingly, or set `BREVO_NO_UPDATE_NOTIFIER=1` / pass `--no-update-notifier`.
110
+ - **Server-side block:** `GET /cli/info` may answer `"is_blocked": true`, in which case every command except `--help` / `--version` prints a banner to stderr and exits `1` **without running** — independently of the npm major-version gate. Unlike the update notice, this is **not** suppressed by `BREVO_NO_UPDATE_NOTIFIER=1`, `--no-update-notifier`, CI, or a non-TTY: a hidden banner must never mean a hidden block. It fails open — a timeout, a non-2xx, or an unparseable body lets the command run, and only a literal `true` blocks. So a `brevo` call that suddenly exits `1` with an update banner may mean either a major-version gap or a server-side block; both are cleared by upgrading. Because the verdict is cached for 15 minutes, a lifted block can take up to 15 minutes to clear on a machine that already cached the blocked answer — delete `~/.brevo/cli-info-cache.json` for an immediate re-check. Note `--help` / `--version` are exempt from the block only, not from the lookup: they still fetch `/cli/info` and still show the server's wording on their update banner, they just never exit non-zero because of it.
87
111
  - **Exit codes:** `0` success · `1` general error · `2` aborted · `3` auth · `4` network · `5` not found.
88
112
 
113
+ ## JSON errors
114
+
115
+ Under `--json`, a failing command writes **one** JSON document to stdout describing the failure; the human-readable message still goes to stderr. The `error` key is the discriminator — no success payload has one:
116
+
117
+ ```json
118
+ { "error": { "name": "CliError", "message": "Not authenticated. Run: brevo login", "exitCode": 1 } }
119
+ ```
120
+
121
+ | Field | Always present | Meaning |
122
+ | --- | --- | --- |
123
+ | `name` | yes | Error class — `CliError`, `ApiError`, `AuthExpiredError`, `AbortError` |
124
+ | `message` | yes | Same text written to stderr |
125
+ | `exitCode` | yes | Matches the process exit code |
126
+ | `statusCode` | `ApiError` only | HTTP status behind the failure |
127
+ | `code` | `ApiError`, when classified | `AUTH_INVALID`, `AUTH_EXPIRED`, `ACCESS_DENIED`, `APP_NOT_FOUND`, `REDIRECT_INVALID`, `PORT_IN_USE`, `NETWORK_ERROR`, `RATE_LIMITED`, `APP_LIMIT_REACHED`, `REGISTRY_ERROR`, `AUTH_GATEWAY` |
128
+
129
+ Stdout is always **exactly one** parseable document. Commands that already describe their own failure keep their shape rather than emitting this envelope — `brevo whoami --json` returns `{"authenticated": false, "reason": "no_key"}` (exit `1`). Check for `error` first, then fall back to the command's own shape.
130
+
131
+ ## Command help
132
+
133
+ `brevo --help` prints the grouped overview of every command. `brevo <command> --help` prints that command's own usage line, arguments, flags, and examples — e.g. `brevo app scaffold --help` documents `--app-id` / `--overwrite` / `--json`. Use it to confirm a flag exists on the installed version rather than assuming from this file.
134
+
89
135
  ## Scopes
90
136
 
91
137
  - New apps created via `brevo app create` default to `contacts:read`, `contacts:write`, `crm:read`, `crm:write`. The CLI prints these on success.
92
- - `brevo app update --scope <scope>` is repeatable and appends, mirroring `--redirect-uri`. De-duped, order-preserving. Writes back to `app-config.json` when that file describes the target app. A single flag value may contain multiple comma- or whitespace-separated tokens (`--scope "crm:read, crm:write"` is equivalent to `--scope crm:read --scope crm:write`). Same normalization is applied to `auth.scopes` when read from `app-config.json`.
138
+ - To change scopes, redirect URLs, name, logo, or version, edit the corresponding field in `app-config.json` directly and run `brevo app upload` there is no `--scope`/`--redirect-uri`/`--name`/`--logo-uri` flag on `upload`. Same normalization (comma/whitespace-split, de-duped) is applied to `auth.scopes` when read from `app-config.json`. `distribution_type` cannot be changed this way — it is immutable after `app create`, and `upload` errors if the local value drifts from the server.
93
139
  - `brevo app available-scopes [--json] [--web]` lists the OAuth scopes the IdP currently supports. It reads a **public** catalog and works **without `brevo login`** (no API key needed). Text output groups names by category (e.g. `account`, `data_crm`, `messaging`); `--json` returns a flat `{ scopes: string[] }` of names. OIDC-reserved scopes (`openid`, `profile`, `email`, `offline_access`) and magic wildcards are excluded. The CLI validates scope **format** locally (must match `[A-Za-z0-9][A-Za-z0-9:_.-]*`) but does **not** validate that a scope is recognized by the IdP — server returns 400 on unknown scopes.
94
140
  - Passing `--web` to `brevo app available-scopes` additionally starts a short-lived loopback HTTP server on `127.0.0.1:<ephemeral>` rendering the same catalog as a styled HTML page and opens the user's browser. It stays in the foreground until Ctrl+C. Without `--web` the command exits after printing the list — TTY detection no longer triggers the browser. `--json` always suppresses the browser (`--json` returns before `--web` is evaluated).
95
141
 
96
142
  ### Legacy `'all'` scope deprecation
97
143
 
98
- The legacy catch-all `'all'` OAuth scope is deprecated. The CLI **blocks** `brevo app update` and `brevo app start oauth` when scopes still contain `'all'` (no escape hatch, no silent rewrite); the only mutating path that proceeds is an explicit `--scope` migration. To handle a legacy app:
144
+ The legacy catch-all `'all'` OAuth scope is deprecated. The CLI **blocks** `brevo app upload` and `brevo app start oauth` when scopes still contain `'all'` (no escape hatch, no silent rewrite); the only mutating path that proceeds is editing `auth.scopes` in `app-config.json` and running `upload`. To handle a legacy app:
99
145
 
100
146
  1. **Detect** `'all'` in `auth.scopes` of a local `app-config.json`, or on a remote app via `brevo app list --json` — affected apps carry `"legacy_all_scope": true` (text output appends `(legacy 'all' — deprecated)` to the scopes line).
101
147
  2. **Prompt the user to pick granular scopes** — use `brevo app available-scopes --json` for the catalog, or fall back to the four defaults (`contacts:read`, `contacts:write`, `crm:read`, `crm:write`).
102
- 3. **Migrate** with `brevo app update --scope <scope> --scope <scope> ...` — passing `--scope` drops `'all'` from the outgoing scope set and applies the new granular scopes (the summary shows a "Migrating from legacy 'all' scope" line and `all (removed)`).
148
+ 3. **Migrate** by editing `auth.scopes` in `app-config.json` to replace `'all'` with the granular scopes your integration uses, then run `brevo app upload` (the summary shows a "Migrating from legacy 'all' scope" line and `all (removed)`).
103
149
 
104
- `brevo app scaffold` against an app whose remote scopes contain `'all'` never propagates it: the new `app-config.json` keeps the app's remaining granular scopes (or the four default scopes when `'all'` was the only scope), with a one-line substitution notice (suppressed under `--json`). Note the substitution is local-only — the remote app still needs the `--scope` migration above.
150
+ Writing `app-config.json` for an app whose remote scopes contain `'all'` never propagates it: the file keeps the app's remaining granular scopes (or the four default scopes when `'all'` was the only scope), with a one-line substitution notice (suppressed under `--json`). This happens when `brevo app create` writes the base config and when `brevo app scaffold` rewrites it after a detected server drift. Note the substitution is local-only — the remote app still needs the `app-config.json` edit + `brevo app upload` migration above.
105
151
 
106
152
  ## Environment variables
107
153
 
@@ -110,10 +156,11 @@ The legacy catch-all `'all'` OAuth scope is deprecated. The CLI **blocks** `brev
110
156
  | `BREVO_API_KEY` | Non-interactive login |
111
157
  | `BREVO_API_URL` | Override API base (HTTPS required, except `localhost`) |
112
158
  | `BREVO_OAUTH_PROXY_URL` | Override OAuth proxy used by browser login |
159
+ | `BREVO_APP_STORE_URL` | Override the app-store service base used for the update notice and the server-side block check (HTTPS required, except `localhost`) |
113
160
  | `BREVO_CONFIG_HOME` | Override credentials directory (default `~/.brevo/`) |
114
161
  | `BREVO_CLAUDE_HOME` | Override Claude Code home used by `skill:cli` (default `~/.claude/`) |
115
162
  | `BREVO_NO_SKILL_AUTOREFRESH` | Set to `1` to suppress automatic skill refresh on `brevo` runs |
116
- | `BREVO_NO_UPDATE_NOTIFIER` | Set to `1` to suppress the npm update-available notice **and** the blocking major-version force-update gate |
163
+ | `BREVO_NO_UPDATE_NOTIFIER` | Set to `1` to suppress the npm update-available notice **and** the blocking major-version force-update gate. Does **not** suppress a server-side `is_blocked` block. |
117
164
  | `BREVO_DEBUG=1` or `--debug` | Verbose HTTP and error logging |
118
165
 
119
166
  ## Safety