Update Node SDK to include auditlogs.listSchemas#1457
Update Node SDK to include auditlogs.listSchemas#1457swaroopAkkineniWorkos wants to merge 17 commits intomainfrom
Conversation
|
@greptile review |
|
@greptile re-review plz |
|
@greptile re-review plz |
|
@greptile re-review plz |
|
@greptile re-review plz |
|
@claude can you review and ensure it complies with the listSchema api |
| } | ||
|
|
||
| export interface CreateAuditLogSchemaResponse { | ||
| export interface AuditLogSchemaResponse { |
There was a problem hiding this comment.
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.
@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.
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
|
| 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.
[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.
@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.
| 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.
@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.
| export type { | ||
| AuditLogSchema, | ||
| AuditLogSchemaResponse, | ||
| AuditLogSchemaMetadata, | ||
| AuditLogActorSchema, | ||
| AuditLogTargetSchema, | ||
| } from './audit-log-schema.interface'; | ||
|
|
||
| import type { | ||
| AuditLogSchemaMetadata, | ||
| AuditLogSchemaResponse, | ||
| AuditLogActorSchema, | ||
| AuditLogTargetSchema, | ||
| } from './audit-log-schema.interface'; |
There was a problem hiding this comment.
I believe this actually isn't required because the barrel file exports these all at the same location whether they're in this file or the audit-log-schema.interface.ts file.
https://linear.app/workos/issue/ENT-5028/update-node-sdk-to-include-listschemas
Description
Adding in the following Audit Log endpoints: