feat!: Port DirectorySync to oagen#1626
Conversation
Greptile SummaryThis PR ports the
Confidence Score: 3/5The core logic is correct but three defects in the generated/hand-maintained layer should be resolved before shipping. The src/directory-sync/serializers/directory.serializer.ts (organizationId coercion), src/directory-sync/interfaces/index.ts (missing GetUserOptions export), src/directory-sync/interfaces/directory-user-with-groups-state.interface.ts (suspended state inconsistency) Important Files Changed
|
| export * from './get-directory-options.interface'; | ||
| export * from './list-directories-options.interface'; | ||
| export * from './list-groups-options.interface'; | ||
| export * from './list-directory-users-options.interface'; | ||
| export * from './directory-user.interface'; | ||
| export * from './list-groups-options.interface'; | ||
| export * from './slim-role.interface'; |
There was a problem hiding this comment.
GetUserOptions missing from public barrel export
GetUserOptions (used as the parameter type for getUser) is not re-exported from the barrel. Every other new options interface introduced in this PR — DeleteDirectoryOptions, DirectorySyncGetGroupOptions, GetDirectoryOptions — is exported, but GetUserOptions is absent. TypeScript consumers who want to explicitly annotate variables or write helper functions around getUser will be unable to import the type from the package's public interface index.
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!
| updatedAt: directory.updated_at, | ||
| object: response.object, | ||
| id: response.id, | ||
| organizationId: response.organization_id ?? '', |
There was a problem hiding this comment.
organizationId coerced to empty string when absent
Directory.organizationId is declared organizationId?: string (optional), so the correct mapping when organization_id is absent is to omit the field or assign undefined. Using ?? '' silently sets it to an empty string instead, which violates the declared type contract. Any consumer checking directory.organizationId === undefined (or using the field as an optional discriminator) will get incorrect behaviour — the field will always be present and truthy except for the empty-string edge case, which is harder to reason about.
| organizationId: response.organization_id ?? '', | |
| organizationId: response.organization_id ?? undefined, |
| // 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.
Description
This PR generates the DirecotrySync category in the Node SDK from the OpenAPI spec.
Four methods switched from a positional string argument to an options object:
As well:
createdAt/updatedAtnow come back asnew Date(...).Directory.statevalues changed. The previous serializer mappedlinked → activeandunlinked → inactive. The new serializer passes the raw wire valuestraight through, so
getDirectory/listDirectoriesnow return state:'linked' | 'unlinked' | 'validating' | 'invalid_credentials' | 'deleting'Because of these changes, this is a major breaking change to the SDK.