feat!: Port AuditLogs to oagen#1627
Conversation
Greptile SummaryThis PR ports the
Confidence Score: 3/5The generated code is mostly correct, but createEvent no longer attaches any idempotency key, meaning the HTTP client's built-in retry logic can produce duplicate audit log events without any recourse for the caller. The bulk of the change — new interfaces, serializers, and method routing — is mechanically consistent and the Date deserialization is handled correctly throughout. The concerning part is createEvent: the old implementation always guaranteed an idempotency key (auto-generated if not supplied), and the new CreateEventOptions interface removes even the ability to pass one. Because the WorkOS HTTP client retries on 5xx responses, a network hiccup can now silently duplicate an audit log event with no way for callers to prevent it. This regression on a write path that carries compliance implications warrants careful review before merging. src/audit-logs/audit-logs.ts (createEvent idempotency regression) and src/audit-logs/interfaces/audit-log-export-options.interface.ts (orphaned SerializedAuditLogExportOptions export) Important Files Changed
|
| * @param options.actorNames - List of actor names to filter against. | ||
| * @example ["Jon Smith"] | ||
| * @param options.actorIds - List of actor IDs to filter against. | ||
| * @example ["user_01GBZK5MP7TD1YCFQHFR22180V"] | ||
| * @param options.targets - List of target types to filter against. | ||
| * @example ["team"] | ||
| * @returns {Promise<AuditLogExport>} | ||
| * @throws {BadRequestException} 400 | ||
| */ | ||
| async createExport(options: AuditLogExportOptions): Promise<AuditLogExport> { |
There was a problem hiding this comment.
Idempotency key dropped from
createEvent
The old implementation always attached an idempotency key to every createEvent call — either the caller-supplied one or an auto-generated workos-node-{uuid}. The new implementation sends no idempotency header at all, and CreateEventOptions exposes no field to supply one. The WorkOS HTTP client retries on 5xx responses, so a transient server error will now silently produce duplicate audit log events. The JSDoc comment retained in this method still explicitly documents idempotency-key semantics, making the omission especially surprising for callers.
|
|
||
| /** | ||
| * Create Export | ||
| * | ||
| * Create an Audit Log Export. Exports are scoped to a single organization within a specified date range. | ||
| * @param payload - Object containing organizationId, rangeStart, rangeEnd. | ||
| * @param options - Object containing organizationId, rangeStart, rangeEnd. | ||
| * @param options.organizationId - The unique ID of the Organization. | ||
| * @example "org_01EHZNVPK3SFK441A1RGBFSHRT" | ||
| * @param options.rangeStart - ISO-8601 value for start of the export range. | ||
| * @example "2022-07-02T18:09:06.996Z" | ||
| * @param options.rangeEnd - ISO-8601 value for end of the export range. | ||
| * @example "2022-09-02T18:09:06.996Z" | ||
| * @param options.actions - List of actions to filter against. | ||
| * @example ["user.signed_in"] |
There was a problem hiding this comment.
JSDoc documents
@param options.actors for createExport but the field is absent from AuditLogExportOptions
The JSDoc for createExport includes @param options.actors - (deprecated) Deprecated. Use actor_names instead., yet AuditLogExportOptions has no actors field. A caller reading the docs and attempting to pass actors would get a TypeScript error. AuditLogExportCreation (the internal serialization type) has this field; the mismatch between the public option type and the documented param should either be resolved by adding actors to AuditLogExportOptions or by removing the @param entry.
Description
This PR generates the AuditLogs category in the Node SDK from the OpenAPI spec.
Almost every existing method changed its input signature, its output, or both. Callers cannot expect the same input/output format.
As well:
AuditLogExport.createdAt/updatedAtchange:string → DateAuditLogSchema.createdAtalso changedstring → DateThe following new methods were added:
getOrganizationAuditLogsRetention(options)updateOrganizationAuditLogsRetention(options)listActions(options?)Because of these changes, this is a major breaking change to the SDK.