-
Notifications
You must be signed in to change notification settings - Fork 44
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?
Changes from all commits
4bf8530
0b3f7d0
c155b07
64dee8d
32f9bc3
d5e63cb
a55e9b7
6d3cf2a
e4ae749
2767707
ddb4337
f325b7e
1b36ea2
34c491f
1e0672f
3079d1c
d120d41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 { | ||
|
|
@@ -10,16 +14,19 @@ import { | |
| } from './interfaces/audit-log-export.interface'; | ||
| import { | ||
| AuditLogSchema, | ||
| CreateAuditLogSchemaOptions, | ||
| CreateAuditLogSchemaRequestOptions, | ||
| AuditLogSchemaResponse, | ||
| } from './interfaces/audit-log-schema.interface'; | ||
| import { | ||
| CreateAuditLogSchemaResponse, | ||
| CreateAuditLogSchemaRequestOptions, | ||
| CreateAuditLogSchemaOptions, | ||
| } from './interfaces/create-audit-log-schema-options.interface'; | ||
| import { | ||
| deserializeAuditLogExport, | ||
| deserializeAuditLogSchema, | ||
| serializeAuditLogExportOptions, | ||
| serializeCreateAuditLogEventOptions, | ||
| serializeCreateAuditLogSchemaOptions, | ||
| deserializeAuditLogSchema, | ||
| } from './serializers'; | ||
|
|
||
| export class AuditLogs { | ||
|
|
@@ -77,4 +84,28 @@ export class AuditLogs { | |
|
|
||
| return deserializeAuditLogSchema(data); | ||
| } | ||
|
|
||
| async listSchemas( | ||
| options: ListSchemasOptions, | ||
| ): Promise<AutoPaginatable<AuditLogSchema, ListSchemasOptions>> { | ||
| const { action, ...paginationOptions } = options; | ||
| const endpoint = `/audit_logs/actions/${action}/schemas`; | ||
|
Comment on lines
+88
to
+92
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<AuditLogSchemaResponse, AuditLogSchema>( | ||
| this.workos, | ||
| endpoint, | ||
| deserializeAuditLogSchema, | ||
| paginationOptions, | ||
| ), | ||
| (params: PaginationOptions) => | ||
| fetchAndDeserialize<AuditLogSchemaResponse, AuditLogSchema>( | ||
| this.workos, | ||
| endpoint, | ||
| deserializeAuditLogSchema, | ||
| params, | ||
| ), | ||
| options, | ||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| export type AuditLogSchemaMetadata = | ||
| | Record<string, { type: 'string' | 'boolean' | 'number' }> | ||
| | undefined; | ||
swaroopAkkineniWorkos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export interface AuditLogActorSchema { | ||
| metadata: Record<string, string | boolean | number>; | ||
| } | ||
|
|
||
| export interface AuditLogTargetSchema { | ||
| type: string; | ||
| metadata?: Record<string, string | boolean | number>; | ||
| } | ||
|
|
||
| export interface AuditLogSchema { | ||
| object: 'audit_log_schema'; | ||
| version: number; | ||
| targets: AuditLogTargetSchema[]; | ||
| actor: AuditLogActorSchema | undefined; | ||
| metadata: Record<string, string | boolean | number> | undefined; | ||
| createdAt: string; | ||
swaroopAkkineniWorkos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| interface SerializedAuditLogTargetSchema { | ||
| type: string; | ||
| metadata?: { | ||
| type: 'object'; | ||
| properties: AuditLogSchemaMetadata; | ||
| }; | ||
| } | ||
|
|
||
| export interface AuditLogSchemaResponse { | ||
|
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. If this is exported publicly, this would be a breaking change. Perhaps we can alias
Contributor
Author
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. @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. |
||
| object: 'audit_log_schema'; | ||
| version: number; | ||
| targets: SerializedAuditLogTargetSchema[]; | ||
| actor?: { | ||
| metadata: { | ||
| type: 'object'; | ||
| properties: AuditLogSchemaMetadata; | ||
| }; | ||
| }; | ||
| metadata?: { | ||
| type: 'object'; | ||
| properties: AuditLogSchemaMetadata; | ||
| }; | ||
| created_at: string; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.