-
Notifications
You must be signed in to change notification settings - Fork 46
Update Node SDK to include auditlogs.listSchemas #1457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@greptile review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
16 files reviewed, 1 comment
|
@greptile re-review plz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, no comments
|
@greptile re-review plz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6 files reviewed, no comments
|
@greptile re-review plz |
There was a problem hiding this 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
|
@greptile re-review plz |
|
@claude can you review and ensure it complies with the listSchema api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, no comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, no comments
| } | ||
|
|
||
| export interface CreateAuditLogSchemaResponse { | ||
| export interface AuditLogSchemaResponse { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is exported publicly, this would be a breaking change. Perhaps we can alias CreateAuditLogSchemaResponse to AuditLogSchemaResponse and mark CreateAuditLogSchemaResponse as deprecated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mattgd updated. Added the alias and also leaving all the exports in CreateAuditLogSchemaResponse as is and just exporting the types from the common, new audit log interface i made.
| export interface AuditLogTargetSchema { | ||
| type: string; | ||
| metadata?: Record<string, string | boolean | number> | undefined; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to src/audit-logs/interfaces/audit-log-schema.interface.ts
|
@greptile re-review plz |
Greptile OverviewGreptile SummaryThis PR adds support for the Audit Logs “List Schemas” endpoint by introducing Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant C as SDK Consumer
participant AL as AuditLogs
participant P as AutoPaginatable
participant W as WorkOS HTTP client
participant API as WorkOS API
C->>AL: listSchemas({action, limit?, after?, order?})
AL->>AL: endpoint = /audit_logs/actions/{action}/schemas
AL->>W: GET endpoint (query = paginationOptions)
W->>API: GET /audit_logs/actions/{action}/schemas
API-->>W: 200 ListResponse<AuditLogSchemaResponse>
W-->>AL: response data
AL->>AL: deserializeAuditLogSchema(schemaResponse)
AL-->>P: new AutoPaginatable(firstPage, getNextPageFn, options)
P-->>C: paginated result (data + listMetadata)
C->>P: nextPage()
P->>W: GET endpoint (query = {after/before/limit/order})
W->>API: GET /audit_logs/actions/{action}/schemas
API-->>W: 200 ListResponse<AuditLogSchemaResponse>
W-->>P: response data
P->>P: deserializeAuditLogSchema(...) for each item
P-->>C: next page
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7 files reviewed, 3 comments
| async listSchemas( | ||
| options: ListSchemasOptions, | ||
| ): Promise<AutoPaginatable<AuditLogSchema, ListSchemasOptions>> { | ||
| const { action, ...paginationOptions } = options; | ||
| const endpoint = `/audit_logs/actions/${action}/schemas`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] listSchemas should accept optional options like other list methods
listSchemas(options: ListSchemasOptions) forces callers to pass an object, even ListSchemasOptions is mostly pagination + required action. Most other list-style SDK methods take options?: ... and allow a simpler call-site / future optional expansion. Consider listSchemas(action: string, options?: PaginationOptions) or listSchemas(options: ListSchemasOptions) but make options optional with a runtime check.
(If this is intentional API design, please ignore—just flagging because it differs from the rest of the SDK pattern.)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/audit-logs/audit-logs.ts
Line: 88:92
Comment:
[P2] `listSchemas` should accept optional options like other list methods
`listSchemas(options: ListSchemasOptions)` forces callers to pass an object, even `ListSchemasOptions` is mostly pagination + required `action`. Most other list-style SDK methods take `options?: ...` and allow a simpler call-site / future optional expansion. Consider `listSchemas(action: string, options?: PaginationOptions)` or `listSchemas(options: ListSchemasOptions)` but make `options` optional with a runtime check.
(If this is intentional API design, please ignore—just flagging because it differs from the rest of the SDK pattern.)
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swaroopAkkineniWorkos This isn't a bad suggestion, since it might be a bit easier for devs to use listSchemas(action) if they're using the auto-pagination.
src/audit-logs/interfaces/create-audit-log-schema-options.interface.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7 files reviewed, 2 comments
| async listSchemas( | ||
| options: ListSchemasOptions, | ||
| ): Promise<AutoPaginatable<AuditLogSchema, ListSchemasOptions>> { | ||
| const { action, ...paginationOptions } = options; | ||
| const endpoint = `/audit_logs/actions/${action}/schemas`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swaroopAkkineniWorkos This isn't a bad suggestion, since it might be a bit easier for devs to use listSchemas(action) if they're using the auto-pagination.
src/audit-logs/interfaces/create-audit-log-schema-options.interface.ts
Outdated
Show resolved
Hide resolved
mattgd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. There's one suggestion Greptile left that may be worthwhile:
#1457 (comment)
https://linear.app/workos/issue/ENT-5028/update-node-sdk-to-include-listschemas
Description
Adding in the following Audit Log endpoints: