feat!: Port DirectorySync to oagen#1626
Conversation
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| export const DirectoryUserWithGroupsState = { | ||
| Active: 'active', | ||
| Suspended: 'suspended', | ||
| Inactive: 'inactive', | ||
| } as const; | ||
|
|
||
| export type DirectoryUserWithGroupsState = | ||
| (typeof DirectoryUserWithGroupsState)[keyof typeof DirectoryUserWithGroupsState]; |
There was a problem hiding this comment.
DirectoryUserWithGroupsState includes 'suspended' but DirectoryUser.state does not
The auto-generated DirectoryUserWithGroupsState constant exports three values — Active, Suspended, and Inactive — implying the wire API can return 'suspended'. However, the hand-maintained DirectoryUser.state type in directory-user.interface.ts is still typed as 'active' | 'inactive'. A directory user whose state is 'suspended' in the provider will carry the value at runtime, but TypeScript consumers trusting the declared union will never expect or handle it. Either the state field in DirectoryUser should include 'suspended', or the generated constant should be reconciled with the hand-owned interface so they don't conflict.
| domains: directory.domains, | ||
| createdAt: directory.created_at, | ||
| updatedAt: directory.updated_at, |
There was a problem hiding this comment.
EventDirectory timestamps remain string while all other timestamp fields are now Date
Directory, DirectoryGroup, and DirectoryUserWithGroups all had their createdAt/updatedAt migrated to Date objects in this PR. EventDirectory still assigns raw strings (directory.created_at, directory.updated_at) with no new Date() conversion, and the EventDirectory interface retains createdAt: string. Consumers who process both event and non-event directory objects will now encounter an inconsistent type for the same conceptual field.
There was a problem hiding this comment.
This does appear to be an oversight rather than intentional. The EventDirectory interface has createdAt: string / updatedAt: string while Directory (the non-event counterpart) uses Date objects — and both represent the same conceptual fields from the same wire format.
If it is intentional (e.g., EventDirectory is deliberately kept as raw strings because it's embedded in webhook payloads and you want to avoid the conversion overhead or a type mismatch with other event types), it's worth calling that out explicitly. Otherwise, the fix would be straightforward:
| domains: directory.domains, | |
| createdAt: directory.created_at, | |
| updatedAt: directory.updated_at, | |
| createdAt: new Date(directory.created_at), | |
| updatedAt: new Date(directory.updated_at), |
And update event-directory.interface.ts to match:
createdAt: Date;
updatedAt: Date;| organization_id?: string; | ||
| domains: EventDirectoryDomain[]; | ||
| domain?: string; | ||
| metadata?: DirectoryMetadataResponse; |
There was a problem hiding this comment.
domain silently changed from required to optional — undocumented breaking change
The PR description calls out timestamp type changes and state value changes as breaking, but domain quietly moved from domain: string (required) to domain?: string. Any consumer code that destructures or assigns directory.domain to a string-typed variable will now produce a TypeScript error (Type 'string | undefined' is not assignable to type 'string'), and code that passes a Directory to a function expecting { domain: string } will break at the call site. Since this is already a major-bump PR, it needs to be listed explicitly in the migration guide alongside the other breaking changes.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/directory-sync/interfaces/directory.interface.ts
Line: 44
Comment:
**`domain` silently changed from required to optional — undocumented breaking change**
The PR description calls out timestamp type changes and `state` value changes as breaking, but `domain` quietly moved from `domain: string` (required) to `domain?: string`. Any consumer code that destructures or assigns `directory.domain` to a `string`-typed variable will now produce a TypeScript error (`Type 'string | undefined' is not assignable to type 'string'`), and code that passes a `Directory` to a function expecting `{ domain: string }` will break at the call site. Since this is already a major-bump PR, it needs to be listed explicitly in the migration guide alongside the other breaking changes.
How can I resolve this? If you propose a fix, please make it concise.The Directory Sync API can return a `suspended` state for directory users (e.g. SCIM-deactivated accounts), but the SDK types only modeled `active` and `inactive`. Consumers had no way to type-check against the suspended case.
Apply the deterministic output of the oagen-emitters fixes (node-bugfixes) directly, so this PR is correct ahead of a full re-generation: - Export `GetUserOptions` from the interfaces barrel. It was emitted and imported by the hand-owned `getUser`, but a cross-service collision with UserManagement's same-named `GetUserOptions` kept it out of the barrel. - Stop coercing `organizationId` to `''` when `organization_id` is absent; the field is optional, so pass the wire value (`undefined`) through. - Remove the orphaned `list-directories-options.serializer.ts`; its logic is inlined in `directory-sync.ts` and the file is referenced nowhere. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The oagen port exposed raw wire states (linked/unlinked/...) on Directory.state, a breaking change for consumers relying on the SDK's historical active/inactive values. The spec only describes the raw enum, so the linked->active / unlinked->inactive translation is restored as hand-owned: - directory-state.interface.ts: DirectoryState back to the mapped union; @oagen-ignore-file + dropped from the manifest. - directory.serializer.ts: restore deserializeDirectoryState and apply it; @oagen-ignore-file + dropped from the manifest. - directory-sync.spec.ts: fixture wire state `linked` now deserializes to `active`. EventDirectory.state already referenced DirectoryState, so it tracks the mapped union as on main (event payloads still pass through unmapped). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the hand-owned `@oagen-ignore-file` carve-out (58c2a08) with generated code now that the emitter supports enum value remaps (oagen-emitters `enumValueRemaps` + the openapi-spec config). `DirectoryState` and `directory.serializer.ts`'s `deserializeDirectoryState` mapper are regenerated (autogen headers restored, back in the manifest); behavior is unchanged (`linked`→`active`, `unlinked`→`inactive`) but a clean regen now reproduces it instead of skipping the files. tsc clean, directory-sync tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
qbalin
left a comment
There was a problem hiding this comment.
@gjtorikian Happy to approve. Are the greptile comments worth addressing in this PR?
… type Regenerate DirectorySync with the enum wire-companion emitter change: DirectoryResponse.state is now typed DirectoryStateResponse (raw wire linked/unlinked) and deserializeDirectoryState maps it to the DirectoryState domain type (active/inactive), restoring the wire/domain distinction flagged in review. Also picks up current-emitter regeneration of the directory-sync tests and serializers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@qbalin Thanks! I think all of this Greptile feedback is already addressed, it's just not clearing (no matter how many times I hit retrigger). This one, for instance, will be documented in the changelog and matches what the spec provides; this one also matches the existing webhook string timestamps and is intentional. |
Description
This PR generates the DirectorySync category in the Node SDK from the OpenAPI spec.
Crucially, the serializer still maps the wire values
linked → activeandunlinked → inactive, preserving a difference between the backend and the SDK.Breaking changes
1. Four methods switched from a positional string argument to an options object:
2. Timestamps are now
Dateobjects, not strings.createdAt/updatedAtonDirectory,DirectoryGroup, andDirectoryUserWithGroupsnow come back asnew Date(...).3.
Directory.domainis now optional. It changed fromdomain: stringtodomain?: string, so it is now typedstring | undefined. Consumers that assigndirectory.domainto astring-typed variable will see a TypeScript error.Because of these changes, this is a major breaking change to the SDK.