-
Notifications
You must be signed in to change notification settings - Fork 53
feat: 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
Changes from 5 commits
4bf8530
0b3f7d0
c155b07
64dee8d
32f9bc3
d5e63cb
a55e9b7
6d3cf2a
e4ae749
2767707
ddb4337
f325b7e
1b36ea2
34c491f
1e0672f
3079d1c
d120d41
c2552ed
27b5110
e1d508a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,11 @@ | ||
| import { PaginationOptions } from '../common/interfaces'; | ||
| import { fetchAndDeserialize } from '../common/utils/fetch-and-deserialize'; | ||
| import { AutoPaginatable } from '../common/utils/pagination'; | ||
| import { WorkOS } from '../workos'; | ||
| import { | ||
| CreateAuditLogEventOptions, | ||
| CreateAuditLogEventRequestOptions, | ||
| ListSchemasOptions, | ||
| } from './interfaces'; | ||
| import { AuditLogExportOptions } from './interfaces/audit-log-export-options.interface'; | ||
| import { | ||
|
|
@@ -14,12 +18,17 @@ import { | |
| CreateAuditLogSchemaRequestOptions, | ||
| CreateAuditLogSchemaResponse, | ||
| } from './interfaces/create-audit-log-schema-options.interface'; | ||
| import { | ||
| ListAuditLogSchemaItemResponse, | ||
| ListedAuditLogSchema, | ||
| } from './interfaces/list-audit-log-schemas.interface'; | ||
| import { | ||
| deserializeAuditLogExport, | ||
| deserializeAuditLogSchema, | ||
| deserializeListedAuditLogSchema, | ||
| serializeAuditLogExportOptions, | ||
| serializeCreateAuditLogEventOptions, | ||
| serializeCreateAuditLogSchemaOptions, | ||
| deserializeAuditLogSchema, | ||
| } from './serializers'; | ||
|
|
||
| export class AuditLogs { | ||
|
|
@@ -77,4 +86,35 @@ export class AuditLogs { | |
|
|
||
| return deserializeAuditLogSchema(data); | ||
| } | ||
|
|
||
| /** | ||
| * Lists all schemas for a specific audit log action. | ||
| * | ||
| * @param options - Options including the action identifier and pagination parameters | ||
| * @returns A paginated list of audit log schemas | ||
| */ | ||
| async listSchemas( | ||
| options: ListSchemasOptions, | ||
| ): Promise<AutoPaginatable<ListedAuditLogSchema, ListSchemasOptions>> { | ||
| const { action, ...paginationOptions } = options; | ||
| const endpoint = `/audit_logs/actions/${action}/schemas`; | ||
|
Comment on lines
+87
to
+91
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2]
(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 AIThis 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.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
| return new AutoPaginatable( | ||
| await fetchAndDeserialize< | ||
| ListAuditLogSchemaItemResponse, | ||
| ListedAuditLogSchema | ||
| >( | ||
| this.workos, | ||
| endpoint, | ||
| deserializeListedAuditLogSchema, | ||
| paginationOptions, | ||
| ), | ||
| (params: PaginationOptions) => | ||
| fetchAndDeserialize< | ||
| ListAuditLogSchemaItemResponse, | ||
| ListedAuditLogSchema | ||
| >(this.workos, endpoint, deserializeListedAuditLogSchema, params), | ||
| options, | ||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { AuditLogSchemaMetadata } from './create-audit-log-schema-options.interface'; | ||
|
|
||
| /** | ||
| * Target schema in the raw API response format. | ||
| */ | ||
| interface ListAuditLogSchemaTargetResponse { | ||
| type: string; | ||
| metadata?: { | ||
| type: 'object'; | ||
| properties: AuditLogSchemaMetadata; | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Actor schema in the raw API response format. | ||
| */ | ||
| interface ListAuditLogSchemaActorResponse { | ||
| metadata: { | ||
| type: 'object'; | ||
| properties: AuditLogSchemaMetadata; | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * API response for a single schema item in the list schemas endpoint. | ||
| */ | ||
| export interface ListAuditLogSchemaItemResponse { | ||
| object: 'audit_log_schema'; | ||
| version: number; | ||
| targets: ListAuditLogSchemaTargetResponse[]; | ||
| actor?: ListAuditLogSchemaActorResponse; | ||
| metadata?: { | ||
| type: 'object'; | ||
| properties: AuditLogSchemaMetadata; | ||
| }; | ||
| created_at: string; | ||
| } | ||
|
|
||
| /** | ||
| * Deserialized audit log schema from the list schemas endpoint. | ||
| * Uses the same deserialized format as AuditLogSchema for consistency. | ||
| */ | ||
| export interface ListedAuditLogSchema { | ||
| object: 'audit_log_schema'; | ||
| version: number; | ||
| targets: Array<{ | ||
| type: string; | ||
| metadata?: Record<string, string | boolean | number>; | ||
| }>; | ||
| actor?: { | ||
| metadata: Record<string, string | boolean | number>; | ||
| }; | ||
| metadata?: Record<string, string | boolean | number>; | ||
| createdAt: string; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { PaginationOptions } from '../../common/interfaces'; | ||
|
|
||
| /** | ||
| * Options for listing audit log schemas for a specific action. | ||
| */ | ||
| export interface ListSchemasOptions extends PaginationOptions { | ||
| /** The action identifier (e.g., 'user.logged_in') */ | ||
| action: string; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.