Repository navigation
SDK 12.2.0: triggers.ensureBrewEvent for Brew-event triggers (brew-v2#2071) - #66
Merged
Merged
Conversation
…#2071) GetBrew/brew-v2#2071 adds triggers Brew starts itself, the first being a contact unsubscribing. This mirrors that API: - `brew.automations.triggers.ensureBrewEvent({ event, scope, domainId? })` wraps `POST /v1/automations/triggers/brew-events`, the get-or-create for one scope, and returns the row plus `created`. - Exports `EnsureBrewEventTriggerInput`, `EnsureBrewEventTriggerResponse` and `BrewEventTriggerConfig`. - The bundled spec takes exactly brew-v2#2071's spec change; the consent-source sync stays with #62. Generated types are regenerated. Trigger `provider` and instance `source` gain `brew_event`, and the error codes gain `TRIGGER_NOT_FIREABLE`. - `docs/automations.md` gets an "Unsubscribe triggers" section, and the `fire` JSDoc names the 409. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- 12.2.0, the next free version: this lands before the open 12.2.0 and 12.3.0 branches, which renumber when they merge. - Vendored spec delta from brew-v2#2071: the test operation says a Brew-event automation's test runs on Brew's sample with passed fields laid over it, and unsubscribe.reasons is required. Types regenerated. - Docs and changelog: the sample overlay, and that mail from another marketing domain reaches the contact only while they are still on it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comments Outside DiffThese findings could not be posted inline.
|
thedogwiththedataonit
added a commit
to GetBrew/brew-cli
that referenced
this pull request
Oct 15, 2026
* CLI 0.16.0: automations triggers ensure-brew-event (brew-v2#2071) GetBrew/brew-v2#2071 adds triggers Brew starts itself, the first being a contact unsubscribing. GetBrew/typescript-sdk#66 exposes them as `triggers.ensureBrewEvent`. This adds the command: - `brew-cli automations triggers ensure-brew-event --scope domain --domain-id <id>` or `--scope all` gets or creates the brand's trigger for that scope and prints the row with `created`. `--event` defaults to `contact.unsubscribed`. Scope/domain mistakes exit 2 before any request, and `--idempotency-key` replays a retry. - The bundled spec takes exactly brew-v2#2071's spec change; the consent-source sync stays with #51. Generated types and the command reference are regenerated. Needs @brew.new/sdk ^12.4.0. Until that is on npm, typecheck and parity fail in CI. Once it publishes: `bun add @brew.new/sdk@^12.4.0`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Needs SDK 12.2.0; spec delta for Brew-event test runs - The SDK PR now releases as 12.2.0 (the next free version). - Vendored spec delta from brew-v2#2071 (Brew-event test runs lay passed fields over Brew's sample; unsubscribe.reasons is required). Types regenerated. - SKILL.md counts 145 commands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Depend on @brew.new/sdk ^12.2.0 (triggers.ensureBrewEvent) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
GetBrew/brew-v2#2071 adds Brew events: triggers Brew starts itself. The first is
contact.unsubscribed, a contact unsubscribing with an email's link or their mail app's one-click button. This mirrors it in the SDK.triggers.ensureBrewEvent(input, options?)wrapsPOST /v1/automations/triggers/brew-events. It returns the brand's trigger for one scope, creating it the first time, pluscreated. Like every POST it carries an auto idempotency key, so a retry replays.EnsureBrewEventTriggerInput,EnsureBrewEventTriggerResponseandBrewEventTriggerConfig.providerand trigger-instancesourcegainbrew_event.brewEvent.ApiErrorCodegainsTRIGGER_NOT_FIREABLE.docs/automations.mdgets an "Unsubscribe triggers" section, and thefireJSDoc names the409 TRIGGER_NOT_FIREABLErefusal.Spec vendoring
The bundled
openapi/public-api-v1.yamlis this repo'smaincopy plus exactly brew-v2#2071's spec diff, applied withpatch. Brew-v2mainalso carries the consent-sourceintegrationchange, which stays with #62 so the two PRs don't overlap. The result is byte-identical to the vendored copies in the CLI and docs PRs.Merge order and version
^12.2.0from npm.Validation
tests/resources/automations/triggers/brew-events.test.tsfailed first (4/4), then passed. It covers the 201 create, the 200 existing row, a typedDOMAIN_PURPOSE_NOT_ALLOWEDandraw: true.bun tsc,bun lint,bun run format:check,bun run test(108 files, 649 tests) andbun run buildpass.node scripts/generate-types.mjsis a no-op on the committed types, which is CI's freshness guard.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.

Confidence Score: 5/5
The PR appears safe to merge; removing the unused spec backup is a non-blocking cleanup.Summary
Adds
triggers.ensureBrewEventfor unsubscribe triggers, with exported types, generated API types, and tests.Diagram
sequenceDiagram participant Caller participant SDK participant Brew API Caller->>SDK: triggers.ensureBrewEvent(input, options?) SDK->>Brew API: POST /v1/automations/triggers/brew-events alt Trigger created Brew API-->>SDK: 201, row with created=true else Trigger already exists Brew API-->>SDK: 200, row with created=false end SDK-->>Caller: Trigger row or raw responseReviews (2) · Last reviewed commit: "Release as 12.2.0; spec delta for Brew-e..." · Reviewed by Greptile