Skip to content

Conversation

@csrbarber
Copy link
Contributor

Description

  • Adds Permission support

Documentation

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

[X] Yes

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

@linear
Copy link

linear bot commented Jan 30, 2026

ENT-4798 workos-node

@csrbarber csrbarber marked this pull request as ready for review January 30, 2026 14:07
@csrbarber csrbarber requested a review from a team as a code owner January 30, 2026 14:07
@csrbarber csrbarber requested review from marji-workos and removed request for a team January 30, 2026 14:07
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 30, 2026

Greptile Overview

Greptile Summary

This PR adds comprehensive CRUD (Create, Read, Update, Delete, List) operations for permissions to the Authorization module, mirroring the existing patterns for environment roles and organization roles.

Key changes:

  • Added five new methods to Authorization class: createPermission, listPermissions, getPermission, updatePermission, and deletePermission
  • Created complete TypeScript interfaces for Permission entities with proper API response/client format separation
  • Implemented serializers/deserializers to handle snake_case to camelCase conversion
  • Added comprehensive test coverage including edge cases (null descriptions, pagination parameters)
  • Consistent with existing codebase patterns for roles management

The implementation follows established conventions in the codebase and includes proper type safety throughout.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation perfectly mirrors existing patterns for roles management, includes comprehensive test coverage, and follows all TypeScript type safety practices. No security issues were found based on custom rules (no SQL concatenation, CORS wildcards, sensitive logging, or TLS issues).
  • No files require special attention

Important Files Changed

Filename Overview
src/authorization/authorization.ts Added five CRUD methods for permissions management following existing patterns for roles
src/authorization/authorization.spec.ts Added comprehensive test coverage for all five permission methods
src/authorization/interfaces/permission.interface.ts Defined Permission interfaces with camelCase client format and snake_case API format
src/authorization/serializers/permission.serializer.ts Implemented deserializer to convert API response from snake_case to camelCase

Sequence Diagram

sequenceDiagram
    participant Client
    participant Authorization
    participant WorkOS API
    
    Note over Client,WorkOS API: Create Permission
    Client->>Authorization: createPermission(options)
    Authorization->>Authorization: serializeCreatePermissionOptions(options)
    Authorization->>WorkOS API: POST /authorization/permissions
    WorkOS API-->>Authorization: PermissionResponse
    Authorization->>Authorization: deserializePermission(data)
    Authorization-->>Client: Permission
    
    Note over Client,WorkOS API: List Permissions
    Client->>Authorization: listPermissions(options?)
    Authorization->>WorkOS API: GET /authorization/permissions?query
    WorkOS API-->>Authorization: PermissionListResponse
    Authorization->>Authorization: map(deserializePermission)
    Authorization-->>Client: PermissionList
    
    Note over Client,WorkOS API: Get Permission
    Client->>Authorization: getPermission(slug)
    Authorization->>WorkOS API: GET /authorization/permissions/{slug}
    WorkOS API-->>Authorization: PermissionResponse
    Authorization->>Authorization: deserializePermission(data)
    Authorization-->>Client: Permission
    
    Note over Client,WorkOS API: Update Permission
    Client->>Authorization: updatePermission(slug, options)
    Authorization->>Authorization: serializeUpdatePermissionOptions(options)
    Authorization->>WorkOS API: PATCH /authorization/permissions/{slug}
    WorkOS API-->>Authorization: PermissionResponse
    Authorization->>Authorization: deserializePermission(data)
    Authorization-->>Client: Permission
    
    Note over Client,WorkOS API: Delete Permission
    Client->>Authorization: deletePermission(slug)
    Authorization->>WorkOS API: DELETE /authorization/permissions/{slug}
    WorkOS API-->>Authorization: 204 No Content
    Authorization-->>Client: void
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Comment on lines +1 to +6
export interface ListPermissionsOptions {
before?: string;
after?: string;
limit?: number;
order?: 'asc' | 'desc';
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can extend PaginationOptions here.

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.

3 participants