Skip to content

feat: CLI - add zitadel invitation create, list, get and cancel - #2929

Merged
vitorbari merged 14 commits into
mainfrom
2858-cli-invitation-commands
Nov 16, 2026
Merged

vitorbari merged 14 commits into
mainfrom
2858-cli-invitation-commands

Conversation

@vitorbari

@vitorbari vitorbari commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #2983 — merge after it.

Summary

Closes #2858. Adds zitadel invitation create, list, get and cancel over the invitations contract (#2849), in a new "Project administration" group in zitadel --help (ADR 086 §8).

  • create asks who the invitation is for and which role it grants, confirms, and prints the link with "Whoever opens it gets the role. It expires in 72 hours." --name, --relation and --replaces skip the matching question; non-interactive runs ask nothing and need --relation.
  • list filters by --status and --type, paged like the other list commands.
  • cancel is destructive (needs --force non-interactively); without an id it offers the pending invitations.
  • The commands are standalone in the API coverage test; lookup, accept and reject stay exempt. The spec names each command with x-zitadel-cli.
  • SKILL.md, the command reference, the telemetry catalog and docs page, and a @zitadel/cli changeset are updated.

Notes

🤖 Generated with Claude Code

Hand-written commands over the invitations contract (#2849), in a new
Project administration help group. The link appears only in create's
output; telemetry records the role and whether it replaced one.

Refs #2858

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cloud Ready Ready Preview Nov 16, 2026 6:29pm UTC

Request Review

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: d27e6fe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@zitadel/cli Minor
@zitadel/testing Minor
@zitadel/server Minor
@zitadel/server-darwin-arm64 Minor
@zitadel/server-darwin-x64 Minor
@zitadel/server-linux-arm64 Minor
@zitadel/server-linux-x64 Minor
@zitadel/server-win32-x64 Minor
@zitadel/api Minor
@zitadel/components Minor
@zitadel/config Minor
@zitadel/sdk-angular Minor
@zitadel/sdk-core Minor
@zitadel/sdk-next Minor
@zitadel/sdk-nuxt Minor
@zitadel/sdk-qwik Minor
@zitadel/sdk-qwik-router Minor
@zitadel/sdk-react Minor
@zitadel/sdk-solid Minor
@zitadel/sdk-solid-start Minor
@zitadel/sdk-svelte Minor
@zitadel/sdk-sveltekit Minor
@zitadel/sdk-tanstack-start Minor
@zitadel/sdk-vue Minor
@zitadel/cloud Patch
@zitadel/client-sdk-contract Patch
@zitadel/server-sdk-contract Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CLI loads commands from an explicit COMMANDS table, so the
invitation commands were unreachable and missing from the reference
and the docs. Adds the topic and its help group row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vitorbari

Copy link
Copy Markdown
Contributor Author

Hi @mridang
I have created this PR, but will keep it as draft until the server implementation lands.

@vitorbari vitorbari changed the title feat: add zitadel invitation create, list, get and cancel feat: CLI - add zitadel invitation create, list, get and cancel Nov 12, 2026
vitorbari and others added 2 commits November 12, 2026 08:09
…ommands

# Conflicts:
#	apps/cli/src/lib/backend/index.ts
#	apps/cli/tests/unit/commands/api-coverage.test.ts
A dry run now answers with the request it would send. --replaces reads
the original first: an accepted one is refused before anything is
asked, and a replacement without --name keeps the original's name, as
the server does. The name prompt asks one question, and list gains a
unit test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vitorbari
vitorbari marked this pull request as ready for review November 12, 2026 07:24
Copilot AI balanced review requested due to automatic review settings November 12, 2026 07:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unescaped links and invitation-name hints allow terminal control-sequence injection, while dry-run paths incorrectly require credentials or live server calls.

6 open issues
What changed in this PR

Adds invitation management to the CLI over the existing invitations API, grouped under “Project administration.”

Changes:

  • Adds create, list, get and cancel commands with prompts, role selection, replacement links, pagination and cancellation confirmation.
  • Adds input-validation tests, help coverage and API command mappings.
  • Updates the command reference, agent guidance, telemetry documentation and CLI release notes.
File Description
docs/​product-analytics-events.yaml Registers invitation-create telemetry dimensions.
apps/​docs/​content/​docs/​reference/​cli/​telemetry.mdx Documents invitation telemetry.
apps/​cli/​tests/​unit/​commands/​invitation/​list.test.ts Tests page-size validation.
apps/​cli/​tests/​unit/​commands/​invitation/​get.test.ts Tests invitation ID validation.
apps/​cli/​tests/​unit/​commands/​invitation/​create.test.ts Tests name and replacement ID validation.
apps/​cli/​tests/​unit/​commands/​invitation/​cancel.test.ts Tests cancellation ID validation.
apps/​cli/​tests/​unit/​commands/​help.test.ts Updates the root-help expectation.
apps/​cli/​tests/​unit/​commands/​api-coverage.test.ts Tracks invitation commands and redemption exemptions.
apps/​cli/​src/​lib/​oclif/​groups.ts Adds the Project administration group.
apps/​cli/​src/​lib/​consent.ts Adds cancellation to consent verbs.
apps/​cli/​src/​lib/​backend/​services/​invitation.ts Wraps invitation API operations and pagination.
apps/​cli/​src/​lib/​backend/​index.ts Exports invitation services and types.
apps/​cli/​src/​index.ts Registers the four commands.
apps/​cli/​src/​commands/​invitation/​list.ts Implements filtered, paginated listing.
apps/​cli/​src/​commands/​invitation/​get.ts Displays invitation details.
apps/​cli/​src/​commands/​invitation/​create.ts Creates and replaces invitations with shareable links.
apps/​cli/​src/​commands/​invitation/​cancel.ts Adds pending-invitation selection and guarded cancellation.
apps/​cli/​skills/​zitadel-cli/​SKILL.md Documents invitation usage and link handling.
apps/​cli/​package.json Adds the invitation topic description.
apps/​cli/​command-reference.json Records the new command reference entries.
apps/​api/​api/​openapi/​endpoints/​invitations/​methods.yaml Maps create and list operations to CLI commands.
apps/​api/​api/​openapi/​endpoints/​invitations/​by_id/​methods.yaml Maps get and cancel operations to CLI commands.
apps/​api/​api/​openapi/​bundled/​openapi.json Includes CLI mappings in the bundled contract.
.changeset/​cli-invitation-commands.md Adds a minor CLI release note.

Review effort: Balanced

- create --dry-run answers before connecting or reading the original.
- cancel --dry-run needs the id instead of reading the pending list.
- The printed link and the picker's hints are escaped for the terminal.
- --name counts characters, as the API's maxLength does.
- The API reference's CLI samples spell invitation create and list
  with their flags, and fall back to the api call for team invitations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Non-interactive invitation cancellation fetches invitations before rejecting a missing ID, allowing network errors or timeouts to obscure the required-input error.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Reject missing IDs before connecting in non-interactive mode

apps/​cli/​src/​commands/​invitation/​cancel.ts:123

A bare invitation cancel --non-interactive (including --json) cannot use the picker, but this first opens a connection and fetches every pending invitation before ask.select refuses the missing ID. An unavailable server therefore produces a network error or timeout instead of reporting the missing input. Reject an omitted invitation ID before connecting when this.nonInteractive is true; only interactive runs need to fetch the choices.

Low severity Regenerate the README command reference

apps/​cli/​src/​index.ts:98

The four commands are registered here and added to command-reference.json, but the generated command section in apps/cli/README.md still contains no invitation commands. That README ships with the CLI, so package consumers receive an incomplete command reference. Please run moon run cli:readme and commit the regenerated README alongside these registrations.

6 resolved since last review

Review effort: Balanced

A non-interactive run, like a dry run, now refuses an omitted id before
reading the pending list, so a down server cannot hide the missing
input. Regenerates the CLI README, which lacked the invitation commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vitorbari and others added 2 commits November 12, 2026 12:24
Follow-ups and retries are { id, flags } suggestions, refusals take no
suggester, list declares --all's exclusion through relatedFlags, and its
page carries only the token. Regenerates the CLI README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mridang mridang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The four commands match the invitations contract, but none of their behaviour is tested beyond flag parsing, there are no integration specs for any of them, and create --replaces refuses an accepted invitation only after it has already asked the questions. The branch is also 29 commits behind main; a trial merge is conflict-free, but seven files this PR touches have changed there.

4 major issues
  • High severity No test runs any command logic · New
  • High severity No integration specs and no mock handlers for the four commands · New
  • High severity The invitation service has no unit test · New
  • High severity --replaces is validated after the prompts, and a dry run skips it · New
3 minor issues
  • Low severity Spec constants are hand-written although the generated schema exports them · New
  • Low severity The invitation id schema is defined in three files · New
  • Low severity Arrow functions return an object literal directly · New

Review effort: Thorough

…ommands

# Conflicts:
#	apps/cli/src/index.ts
vitorbari and others added 3 commits November 13, 2026 17:25
- create --replaces reads the original before any question, and a dry
  run reads it too, so an accepted one is refused the same way in both.
- The invitation id schema has one home (invitation/id.ts); the name
  limit and the list's statuses and types come from the generated
  schema; refusals are declared as const satisfies.
- Unit tests for the invitation service, and for create's and cancel's
  questions, refusals and the requests they do not send.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adapt the invitation commands to main: the task-based help groups put
them under Users and access, the test fixtures moved to tests/fixtures,
and the invitation contract now names the path parameter invitation_id,
reports responded_by/responded_at and takes status as a list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vitorbari
vitorbari added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit 7f682da Nov 16, 2026
18 checks passed
@vitorbari
vitorbari deleted the 2858-cli-invitation-commands branch November 16, 2026 18:41
@github-project-automation github-project-automation Bot moved this from Inbox to Done in Engineering Kanban Nov 16, 2026

This branch was successfully deployed

1 active deployment
Preview — d27e6fee Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

CLI: invitation commands

3 participants