Skip to content

Add flows update + flows publish commands and flow placement audiences - #20

Draft
mlnchk wants to merge 5 commits into
mainfrom
cli-flow-cruds
Draft

Add flows update + flows publish commands and flow placement audiences#20
mlnchk wants to merge 5 commits into
mainfrom
cli-flow-cruds

Conversation

@mlnchk

@mlnchk mlnchk commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Adds the CLI surface for renaming a flow, publishing a flow, and attaching a flow to a placement audience.

What's here

  • adapty flows update --app <uuid> <flow_id> --name <name>PUT /apps/<app>/flows/<id>/ with {name}.
  • adapty flows publish --app <uuid> <flow_id>POST /apps/<app>/flows/<id>/publish/ (no body). Publish is async: the response reports status: publishing, not published. The command says so and does not claim the flow is live.
  • PlacementAudienceEntryDTO is now a paywall | flow discriminated union. Paywall entry keeps content_type optional, so existing paywall-audience calls stay valid (additive). Flow entry requires content_type: 'flow' and flow_id. placements create / placements update document the flow form in help; the parse logic is unchanged.
  • Tests for flows update, flows publish, and flow audiences on placements create / placements update.

Behavior note

Attaching a draft flow returns 400 (FlowNotPublishedError — "Flow must be published before placing in a placement"). Even after flows publish, the flow is only attachable once it reaches published, which happens asynchronously.

Verification

pnpm build, pnpm test (178 passing), pnpm lint (clean; one pre-existing warning in auth/login.ts), and pnpm run check:agent-docs all pass.

Land order — do not merge yet

This depends on the adapty-dashboard-api change (branch cli-flow-cruds) landing first. Per the feature's land order (api → qa → cli), this PR must not merge before the API publish endpoint is released. Kept as a draft for that reason.

mlnchk and others added 2 commits September 2, 2026 15:15
New `adapty flows update` renames a flow (PUT .../flows/<id>/, body {name}).
New `adapty flows publish` publishes a flow (POST .../flows/<id>/publish/, no
body); publish is async, so it reports status: publishing, not published.

`PlacementAudienceEntryDTO` becomes a paywall | flow discriminated union.
Paywall entry keeps content_type optional (additive — existing calls stay
valid); flow entry requires content_type: 'flow' and flow_id. placements
create/update surface the flow form in help; a draft flow returns 400 until
published.
…publish

Rename src/lib/asa-confirm.ts to src/lib/confirm.ts (git mv, history
preserved); the exports were already generic. Repoint all 15 importers to
the new path and reorder the affected asa imports alphabetically.

flows publish now gates on a confirmation: it fetches the flow to name it,
then confirmMutation() previews the POST and requires --yes (refuses when
piped or --json). Publishing goes live to end users, so it is high-stakes.
Async messaging is unchanged (status stays 'publishing').

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mlnchk and others added 3 commits September 2, 2026 16:41
Make content_type required on the paywall audience variant too, so
PlacementAudienceEntryDTO now demands an explicit 'paywall' | 'flow' on
every entry — no implicit paywall.

The type alone cannot guard --audiences (JSON.parse yields unknown), so add
a runtime check shared by placements create/update: each entry must be an
object with content_type exactly 'paywall' or 'flow', a paywall entry must
carry paywall_id and a flow entry flow_id, else exit 2 with a message that
names the offending index and tells the caller to add content_type. Same for
humans and agents; no prompting. Flag help and examples now always show
content_type.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Publishing a flow with no valid config returns a 400 validation_error whose
bare message ("Flow has no current version.") does not tell the caller what
to do. Wrap the publish POST in flows publish: on a 400 / validation_error,
re-raise with the server reason plus the two ways to fix it — the builder UI
for this flow and the Adapty flows agent skill — then exit 1. Other statuses
(403/404/…) rethrow unchanged. Scoped to this command; errors.ts is untouched
because validation_error is generic.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Developer API now returns is_active on placements. Add it to
PlacementSummaryDTO and PlacementDetailDTO (true = Live, false = Inactive).
printResponse/printList render every field, so list and get surface it with
no per-command change; tests assert "Is Active" appears in both.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant