feat: Generate Pipes off the OpenAPI spec#1625
Conversation
| // This file is auto-generated by oagen. Do not edit. | ||
|
|
||
| export * from './connected-account.serializer'; | ||
| export * from './data-integration-access-token-response-access-token.serializer'; | ||
| export * from './data-integration-authorize-url-response.serializer'; | ||
| export * from './data-integrations-get-data-integration-authorize-url-request.serializer'; | ||
| export * from './data-integrations-get-user-token-request.serializer'; | ||
| export * from './data-integrations-list-response.serializer'; | ||
| export * from './data-integrations-list-response-data.serializer'; | ||
| export * from './data-integrations-list-response-data-connected-account.serializer'; |
There was a problem hiding this comment.
deserializeDataIntegrationAccessTokenResponse (from data-integration-access-token-response.serializer.ts) is not re-exported here, even though every other serializer in this directory is. Any SDK consumer or internal utility that imports from the barrel path will silently not find it, while all sibling serializers are available. The data-integration-access-token-response-access-token serializer IS exported, making the omission appear like an accidental gap rather than an intentional design choice.
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!
| { | ||
| "active": true, | ||
| "access_token": { | ||
| "object": "access_token", | ||
| "access_token": "gho_16C7e42F292c6912E7710c838347Ae178B4a", | ||
| "expires_at": "2025-12-31T23:59:59.000Z", | ||
| "scopes": ["repo", "user:email"], | ||
| "missing_scopes": [] | ||
| }, | ||
| "error": "not_installed" | ||
| } |
There was a problem hiding this comment.
Fixture violates the discriminated-union contract
This fixture sets both "active": true (with "access_token") and "error": "not_installed" simultaneously, which is impossible at runtime — the API will only ever return one or the other. The DataIntegrationAccessTokenResponseWire type is an exclusive union keyed on active, so the error field is outright invalid in the true branch. The serializer silently ignores the extra field today, but if anyone asserts on error in a future test using this same fixture they'll get a false positive. The fixture should either represent only the happy path, or two separate fixtures should exist for the two branches.
| expect(result.url).toBe( | ||
| 'https://api.workos.com/data-integrations/q2czJKmVAraSBg8xFpT7M9uR/authorize-redirect', | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| it('returns access token without expiry date', async () => { | ||
| fetchOnce(getAccessTokenNoExpiryFixture); | ||
| const response = await workos.pipes.getAccessToken({ | ||
| provider: 'test-provider', | ||
| userId: 'user_789', | ||
| }); | ||
| describe('getAccessToken', () => { | ||
| it('sends the correct request and returns result', async () => { | ||
| fetchOnce(dataIntegrationAccessTokenResponseFixture); | ||
|
|
||
| expect(fetchURL()).toContain('/data-integrations/test-provider/token'); | ||
| expect(fetchBody()).toEqual({ | ||
| user_id: 'user_789', | ||
| organization_id: undefined, | ||
| }); | ||
| expect(response).toEqual({ | ||
| active: true, | ||
| accessToken: { | ||
| object: 'access_token', | ||
| accessToken: 'test_access_token_456', | ||
| expiresAt: null, | ||
| scopes: ['read:data'], | ||
| missingScopes: ['write:data'], | ||
| }, | ||
| const result = await workos.pipes.getAccessToken({ | ||
| provider: 'test_provider', | ||
| userId: 'user_id_01234', | ||
| }); | ||
|
|
||
| expect(fetchMethod()).toBe('POST'); | ||
| expect(new URL(String(fetchURL())).pathname).toBe( | ||
| '/data-integrations/test_provider/token', | ||
| ); |
There was a problem hiding this comment.
getAccessToken error-path coverage removed
The previous spec had four dedicated cases for getAccessToken: success-with-expiry, success-without-expiry, not_installed, needs_reauthorization, and a 500 error throw. The replacement is a single happy-path test. The two inactive branches (active: false) in DataIntegrationAccessTokenResponse are now completely untested at the integration level, meaning a regression in deserializeDataIntegrationAccessTokenResponse for the error branch would go undetected.
Description
This PR generates the Pipes API fresh from the OpenAPI spec.
The existing shape of methods is preserved. As well, new functions are added:
authorizeDataIntegrationgetUserConnectedAccountdeleteUserConnectedAccountlistUserDataProvidersBecause of this, this is a non-breaking change.