Skip to content

feat(groups): add AuthKit Groups support - #60

Merged
gjtorikian merged 3 commits into
mainfrom
feat/groups
Aug 7, 2026
Merged

feat(groups): add AuthKit Groups support#60
gjtorikian merged 3 commits into
mainfrom
feat/groups

Conversation

@gjtorikian

Copy link
Copy Markdown
Collaborator

Summary

  • Implements all nine AuthKit Groups endpoints — CRUD + list for /organizations/{org}/groups, add/list/remove organization memberships to/from a group, and GET /user_management/organization_memberships/{om}/groups — closing the gap from Groups support? #57, where the emulator had no groups routes.
  • Wires the five group.* events (created/updated/deleted, member_added/member_removed) to collection hooks, so seeded and API-created groups emit identically. The events were already declared in the generated catalog but never fired.
  • Makes groups seedable: groups nest under organizations, mirroring memberships; members join by email (the same join key memberships use, since om ids are generated at startup). The config validator cross-references each member against the org's memberships and rejects typos/dangling references at startup.
  • The group-members list returns the spec's slimmer UserlandUserOrganizationMembershipBase shape (no embedded user/roles), via a new formatMembershipBase helper.

Closes #57

Issue #57: the emulator had no `/organizations/{org}/groups`
routes, so SDK consumers testing AuthKit Groups had nothing to
hit, and the five `group.*` events were declared in the generated
catalog but never fired. This implements all nine spec endpoints,
wires the events to collection hooks (so seeded and API-created
groups emit identically), and makes groups seedable nested under
`organizations` — mirroring `memberships` — so a test suite can
pre-populate groups without setup calls.
@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds complete AuthKit Groups support, including API routes, persistence, events, seed configuration, validation, and generated support documentation.

  • Implements group CRUD and organization-membership management endpoints.
  • Adds group and group-membership entities, collections, serialization, and event hooks.
  • Supports groups nested under seeded organizations with members resolved by email.
  • Adds route, event, seeding, and malformed-configuration regression coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/workos/config-validator.ts Adds structured validation for nested groups and safely addresses both previously reported malformed-input crashes.
src/workos/routes/groups.ts Implements the nine AuthKit Groups endpoints with organization scoping and membership operations.
src/workos/index.ts Registers group routes, seeds groups and their memberships, and wires group lifecycle events.
src/workos/store.ts Adds collections for groups and group-to-organization-membership joins.
src/workos/seed-groups.spec.ts Covers group seeding, email-based membership resolution, emitted events, and the two prior malformed-configuration regressions.
src/workos/routes/groups.spec.ts Exercises group CRUD, listing, and organization-membership endpoint behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Seed[Organization seed] --> Validate[Validate groups and member emails]
  Validate --> Memberships[Resolve organization memberships]
  Memberships --> Groups[(Groups collection)]
  Memberships --> GroupMemberships[(Group memberships collection)]
  API[AuthKit Groups routes] --> Groups
  API --> GroupMemberships
  Groups --> GroupEvents[group.created / updated / deleted]
  GroupMemberships --> MemberEvents[group.member_added / member_removed]
Loading

Reviews (3): Last reviewed commit: "fix(groups): guard seed validation again..." | Re-trigger Greptile

Comment thread src/workos/config-validator.ts
When `groups` were configured alongside a truthy non-array
`memberships` value, the groups validation block called `.map()` on
that invalid value and threw a `TypeError`, crashing startup and
`--validate-config` instead of returning the structured memberships
error the validator had already recorded. Guard the cross-reference
with `Array.isArray`, mirroring the memberships block's own check.
Comment thread src/workos/config-validator.ts
A non-object group entry such as `groups: [null]` dereferenced
`group.name` and threw a `TypeError`, crashing startup and
`--validate-config` instead of returning a structured error. Record
an "each group must be an object" error and skip the property checks,
matching the validator's structured-error approach.
@gjtorikian
gjtorikian merged commit 06c1a7f into main Aug 7, 2026
8 checks passed
@gjtorikian
gjtorikian deleted the feat/groups branch August 7, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Groups support?

1 participant