Skip to content

feat: add vault events#1531

Merged
awolfden merged 4 commits intomainfrom
add-vault-events
Mar 25, 2026
Merged

feat: add vault events#1531
awolfden merged 4 commits intomainfrom
add-vault-events

Conversation

@awolfden
Copy link
Contributor

Description

Add new Vault events and tests to the SDK

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@awolfden awolfden requested review from a team as code owners March 24, 2026 19:25
@awolfden awolfden requested a review from amygdalama March 24, 2026 19:25
@awolfden awolfden changed the title Add Vault events feat: add vault events Mar 24, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 24, 2026

Greptile Summary

This PR adds support for 9 new Vault-related webhook events to the workos-node SDK, following the established pattern of paired *Event / *EventResponse interfaces, per-event deserializer functions, and a switch-case dispatch in the central deserializeEvent function.

  • Adds src/vault/interfaces/vault-event.interface.ts with typed interfaces for all vault event payloads (vault.data.{created,updated,read,deleted}, vault.names.listed, vault.metadata.read, vault.kek.{created}, vault.dek.{read,decrypted})
  • Adds src/vault/serializers/vault-event.serializer.ts with a deserializeVaultActor helper and one export per event type
  • Wires the new types into event.interface.ts (discriminated union) and event.serializer.ts (switch dispatch)
  • Exports new types via the vault interfaces barrel (src/vault/interfaces/index.ts)
  • Adds comprehensive tests in events.spec.ts — one test per event type covering full round-trip deserialization

Confidence Score: 5/5

  • Safe to merge — changes are purely additive, follow existing patterns exactly, and are fully covered by tests.
  • All 9 new event types are wired through interfaces, serializers, the central dispatcher, and tests consistently. No breaking changes, no missing cases in the switch statement, and no violations of the project's custom rules. The only open questions are minor style points (duplicate interface structures and optional keyContext) that don't affect correctness.
  • No files require special attention. Optional follow-up: confirm with the API team whether key_context can be absent on vault.data.created, vault.data.updated, and vault.dek.read events, and mark the field optional if so.

Important Files Changed

Filename Overview
src/vault/interfaces/vault-event.interface.ts New file defining typed interfaces for all 9 vault event payloads. Follows the snake_case (API response) / camelCase (SDK) dual-interface pattern used throughout the codebase. Minor concerns: VaultDataCreatedEventData and VaultDataUpdatedEventData are structurally identical, and keyContext fields may need to be optional.
src/vault/serializers/vault-event.serializer.ts New serializer file with a per-event deserialize function for each vault event type. Logic is correct and consistent; the only minor issue is an unnecessary object spread in deserializeVaultNamesListedEvent.
src/common/interfaces/event.interface.ts Adds 9 vault event interface pairs (Event + EventResponse) and appends them to both the Event and EventResponse discriminated union types. Changes are additive and correctly follow existing conventions.
src/common/serializers/event.serializer.ts Adds 9 new switch cases to deserializeEvent, each delegating to the corresponding vault deserializer. Coverage matches the new union members exactly.
src/events/events.spec.ts Adds one unit test per vault event type (9 total), covering both the response shape and the deserialized SDK shape. Tests include a case with context and cases without. Coverage is thorough.
src/vault/interfaces/index.ts One-line change re-exporting the new vault-event.interface module so all vault event types are accessible from the vault interfaces barrel.

Sequence Diagram

sequenceDiagram
    participant API as WorkOS API
    participant SDK as workos-node SDK
    participant App as Application

    API->>SDK: EventResponse (snake_case JSON)
    note over SDK: deserializeEvent() switch on event name
    SDK->>SDK: vault.data.created → deserializeVaultDataCreatedEvent(data)
    SDK->>SDK: vault.data.updated → deserializeVaultDataUpdatedEvent(data)
    SDK->>SDK: vault.data.read    → deserializeVaultDataReadEvent(data)
    SDK->>SDK: vault.data.deleted → deserializeVaultDataDeletedEvent(data)
    SDK->>SDK: vault.names.listed → deserializeVaultNamesListedEvent(data)
    SDK->>SDK: vault.metadata.read → deserializeVaultMetadataReadEvent(data)
    SDK->>SDK: vault.kek.created  → deserializeVaultKekCreatedEvent(data)
    SDK->>SDK: vault.dek.read     → deserializeVaultDekReadEvent(data)
    SDK->>SDK: vault.dek.decrypted → deserializeVaultDekDecryptedEvent(data)
    note over SDK: deserializeVaultActor() maps<br/>actor_id→actorId, etc.
    SDK->>App: Event (camelCase, typed)
Loading

Reviews (1): Last reviewed commit: "Add Vault events" | Re-trigger Greptile

Copy link
Member

@nicknisi nicknisi left a comment

Choose a reason for hiding this comment

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

LGTM overall, just some minor nits to fix

@awolfden awolfden merged commit a5e619f into main Mar 25, 2026
8 checks passed
@awolfden awolfden deleted the add-vault-events branch March 25, 2026 18:43
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.

2 participants