From 7233b38357e8a18fc9c0e8bdea3109a668dfd607 Mon Sep 17 00:00:00 2001 From: "Garen J. Torikian" Date: Thu, 2 Jul 2026 12:22:31 -0400 Subject: [PATCH] feat(generated): Add Pipes operations and models --- src/pipes/fixtures/connected-account-dto.json | 7 + .../fixtures/create-data-integration.json | 26 ++ .../fixtures/custom-provider-definition.json | 15 ++ .../fixtures/data-integration-credential.json | 5 + .../data-integration-credentials-dto.json | 5 + .../data-integration-custom-provider.json | 15 ++ src/pipes/fixtures/data-integration.json | 33 +++ src/pipes/fixtures/list-data-integration.json | 41 ++++ .../update-custom-provider-definition.json | 15 ++ .../fixtures/update-data-integration.json | 25 ++ .../connected-account-dto.interface.ts | 24 ++ .../connected-account-state.interface.ts | 1 - ...eate-data-integration-options.interface.ts | 19 ++ .../create-data-integration.interface.ts | 34 +++ ...ser-connected-account-options.interface.ts | 22 ++ ...r-definition-authenticate-via.interface.ts | 9 + .../custom-provider-definition.interface.ts | 42 ++++ ...a-integration-credential-type.interface.ts | 9 + .../data-integration-credential.interface.ts | 19 ++ ...a-integration-credentials-dto.interface.ts | 18 ++ ...-integration-credentials-type.interface.ts | 9 + ...tom-provider-authenticate-via.interface.ts | 9 + ...a-integration-custom-provider.interface.ts | 42 ++++ .../data-integration-state.interface.ts | 10 + .../interfaces/data-integration.interface.ts | 56 +++++ ...lete-data-integration-options.interface.ts | 6 + .../get-data-integration-options.interface.ts | 6 + src/pipes/interfaces/index.ts | 22 ++ ...ist-data-integrations-options.interface.ts | 5 + ...r-definition-authenticate-via.interface.ts | 9 + ...te-custom-provider-definition.interface.ts | 42 ++++ ...date-data-integration-options.interface.ts | 19 ++ .../update-data-integration.interface.ts | 31 +++ ...ser-connected-account-options.interface.ts | 22 ++ src/pipes/pipes.spec.ts | 159 +++++++++++++ src/pipes/pipes.ts | 225 +++++++++++++++++- src/pipes/serializers.spec.ts | 53 +++++ .../connected-account-dto.serializer.ts | 17 ++ .../create-data-integration.serializer.ts | 25 ++ .../custom-provider-definition.serializer.ts | 22 ++ .../data-integration-credential.serializer.ts | 14 ++ ...-integration-credentials-dto.serializer.ts | 14 ++ ...-integration-custom-provider.serializer.ts | 23 ++ .../data-integration.serializer.ts | 29 +++ src/pipes/serializers/index.ts | 9 + ...e-custom-provider-definition.serializer.ts | 22 ++ .../update-data-integration.serializer.ts | 24 ++ 47 files changed, 1305 insertions(+), 3 deletions(-) create mode 100644 src/pipes/fixtures/connected-account-dto.json create mode 100644 src/pipes/fixtures/create-data-integration.json create mode 100644 src/pipes/fixtures/custom-provider-definition.json create mode 100644 src/pipes/fixtures/data-integration-credential.json create mode 100644 src/pipes/fixtures/data-integration-credentials-dto.json create mode 100644 src/pipes/fixtures/data-integration-custom-provider.json create mode 100644 src/pipes/fixtures/data-integration.json create mode 100644 src/pipes/fixtures/list-data-integration.json create mode 100644 src/pipes/fixtures/update-custom-provider-definition.json create mode 100644 src/pipes/fixtures/update-data-integration.json create mode 100644 src/pipes/interfaces/connected-account-dto.interface.ts create mode 100644 src/pipes/interfaces/create-data-integration-options.interface.ts create mode 100644 src/pipes/interfaces/create-data-integration.interface.ts create mode 100644 src/pipes/interfaces/create-user-connected-account-options.interface.ts create mode 100644 src/pipes/interfaces/custom-provider-definition-authenticate-via.interface.ts create mode 100644 src/pipes/interfaces/custom-provider-definition.interface.ts create mode 100644 src/pipes/interfaces/data-integration-credential-type.interface.ts create mode 100644 src/pipes/interfaces/data-integration-credential.interface.ts create mode 100644 src/pipes/interfaces/data-integration-credentials-dto.interface.ts create mode 100644 src/pipes/interfaces/data-integration-credentials-type.interface.ts create mode 100644 src/pipes/interfaces/data-integration-custom-provider-authenticate-via.interface.ts create mode 100644 src/pipes/interfaces/data-integration-custom-provider.interface.ts create mode 100644 src/pipes/interfaces/data-integration-state.interface.ts create mode 100644 src/pipes/interfaces/data-integration.interface.ts create mode 100644 src/pipes/interfaces/delete-data-integration-options.interface.ts create mode 100644 src/pipes/interfaces/get-data-integration-options.interface.ts create mode 100644 src/pipes/interfaces/list-data-integrations-options.interface.ts create mode 100644 src/pipes/interfaces/update-custom-provider-definition-authenticate-via.interface.ts create mode 100644 src/pipes/interfaces/update-custom-provider-definition.interface.ts create mode 100644 src/pipes/interfaces/update-data-integration-options.interface.ts create mode 100644 src/pipes/interfaces/update-data-integration.interface.ts create mode 100644 src/pipes/interfaces/update-user-connected-account-options.interface.ts create mode 100644 src/pipes/serializers/connected-account-dto.serializer.ts create mode 100644 src/pipes/serializers/create-data-integration.serializer.ts create mode 100644 src/pipes/serializers/custom-provider-definition.serializer.ts create mode 100644 src/pipes/serializers/data-integration-credential.serializer.ts create mode 100644 src/pipes/serializers/data-integration-credentials-dto.serializer.ts create mode 100644 src/pipes/serializers/data-integration-custom-provider.serializer.ts create mode 100644 src/pipes/serializers/data-integration.serializer.ts create mode 100644 src/pipes/serializers/update-custom-provider-definition.serializer.ts create mode 100644 src/pipes/serializers/update-data-integration.serializer.ts diff --git a/src/pipes/fixtures/connected-account-dto.json b/src/pipes/fixtures/connected-account-dto.json new file mode 100644 index 000000000..b63b73cd8 --- /dev/null +++ b/src/pipes/fixtures/connected-account-dto.json @@ -0,0 +1,7 @@ +{ + "access_token": "gho_16C7e42F292c6912E7710c838347Ae178B4a", + "refresh_token": "ghr_xxxxxxxxxxxxxxxxxxxx", + "expires_at": "2025-12-31T23:59:59.000Z", + "scopes": ["repo", "user:email"], + "state": "connected" +} diff --git a/src/pipes/fixtures/create-data-integration.json b/src/pipes/fixtures/create-data-integration.json new file mode 100644 index 000000000..0b2ef4f3f --- /dev/null +++ b/src/pipes/fixtures/create-data-integration.json @@ -0,0 +1,26 @@ +{ + "provider": "github", + "description": "Production GitHub app", + "enabled": true, + "scopes": ["repo", "read:org"], + "credentials": { + "type": "custom", + "client_id": "Iv1.abc123", + "client_secret": "secret_…" + }, + "custom_provider": { + "name": "My OAuth App", + "authorization_url": "https://provider.example.com/oauth/authorize", + "token_url": "https://provider.example.com/oauth/token", + "refresh_token_url": "https://provider.example.com/oauth/token", + "pkce_enabled": true, + "request_scope_separator": " ", + "scopes_required": false, + "client_secret_required": true, + "additional_authorization_parameters": { + "prompt": "consent" + }, + "token_body_content_type": "application/x-www-form-urlencoded", + "authenticate_via": "request_body" + } +} diff --git a/src/pipes/fixtures/custom-provider-definition.json b/src/pipes/fixtures/custom-provider-definition.json new file mode 100644 index 000000000..9909168b8 --- /dev/null +++ b/src/pipes/fixtures/custom-provider-definition.json @@ -0,0 +1,15 @@ +{ + "name": "My OAuth App", + "authorization_url": "https://provider.example.com/oauth/authorize", + "token_url": "https://provider.example.com/oauth/token", + "refresh_token_url": "https://provider.example.com/oauth/token", + "pkce_enabled": true, + "request_scope_separator": " ", + "scopes_required": false, + "client_secret_required": true, + "additional_authorization_parameters": { + "prompt": "consent" + }, + "token_body_content_type": "application/x-www-form-urlencoded", + "authenticate_via": "request_body" +} diff --git a/src/pipes/fixtures/data-integration-credential.json b/src/pipes/fixtures/data-integration-credential.json new file mode 100644 index 000000000..60dfe77a3 --- /dev/null +++ b/src/pipes/fixtures/data-integration-credential.json @@ -0,0 +1,5 @@ +{ + "type": "custom", + "client_id": "Iv1.abc123", + "redacted_client_secret": "6789" +} diff --git a/src/pipes/fixtures/data-integration-credentials-dto.json b/src/pipes/fixtures/data-integration-credentials-dto.json new file mode 100644 index 000000000..e50987654 --- /dev/null +++ b/src/pipes/fixtures/data-integration-credentials-dto.json @@ -0,0 +1,5 @@ +{ + "type": "custom", + "client_id": "Iv1.abc123", + "client_secret": "secret_…" +} diff --git a/src/pipes/fixtures/data-integration-custom-provider.json b/src/pipes/fixtures/data-integration-custom-provider.json new file mode 100644 index 000000000..9909168b8 --- /dev/null +++ b/src/pipes/fixtures/data-integration-custom-provider.json @@ -0,0 +1,15 @@ +{ + "name": "My OAuth App", + "authorization_url": "https://provider.example.com/oauth/authorize", + "token_url": "https://provider.example.com/oauth/token", + "refresh_token_url": "https://provider.example.com/oauth/token", + "pkce_enabled": true, + "request_scope_separator": " ", + "scopes_required": false, + "client_secret_required": true, + "additional_authorization_parameters": { + "prompt": "consent" + }, + "token_body_content_type": "application/x-www-form-urlencoded", + "authenticate_via": "request_body" +} diff --git a/src/pipes/fixtures/data-integration.json b/src/pipes/fixtures/data-integration.json new file mode 100644 index 000000000..84883e642 --- /dev/null +++ b/src/pipes/fixtures/data-integration.json @@ -0,0 +1,33 @@ +{ + "object": "data_integration", + "id": "data_integration_01EHZNVPK3SFK441A1RGBFSHRT", + "slug": "github", + "integration_type": "github", + "description": "Production GitHub app", + "enabled": true, + "state": "valid", + "scopes": ["repo", "read:org"], + "redirect_uri": "https://api.workos.com/data-integrations/github/dik_01EHZNVPK3SFK441A1RGBFSHRT/callback", + "credentials": { + "type": "custom", + "client_id": "Iv1.abc123", + "redacted_client_secret": "6789" + }, + "custom_provider": { + "name": "My OAuth App", + "authorization_url": "https://provider.example.com/oauth/authorize", + "token_url": "https://provider.example.com/oauth/token", + "refresh_token_url": "https://provider.example.com/oauth/token", + "pkce_enabled": true, + "request_scope_separator": " ", + "scopes_required": false, + "client_secret_required": true, + "additional_authorization_parameters": { + "prompt": "consent" + }, + "token_body_content_type": "application/x-www-form-urlencoded", + "authenticate_via": "request_body" + }, + "created_at": "2026-01-15T12:00:00.000Z", + "updated_at": "2026-01-15T12:00:00.000Z" +} diff --git a/src/pipes/fixtures/list-data-integration.json b/src/pipes/fixtures/list-data-integration.json new file mode 100644 index 000000000..8668f7d1d --- /dev/null +++ b/src/pipes/fixtures/list-data-integration.json @@ -0,0 +1,41 @@ +{ + "data": [ + { + "object": "data_integration", + "id": "data_integration_01EHZNVPK3SFK441A1RGBFSHRT", + "slug": "github", + "integration_type": "github", + "description": "Production GitHub app", + "enabled": true, + "state": "valid", + "scopes": ["repo", "read:org"], + "redirect_uri": "https://api.workos.com/data-integrations/github/dik_01EHZNVPK3SFK441A1RGBFSHRT/callback", + "credentials": { + "type": "custom", + "client_id": "Iv1.abc123", + "redacted_client_secret": "6789" + }, + "custom_provider": { + "name": "My OAuth App", + "authorization_url": "https://provider.example.com/oauth/authorize", + "token_url": "https://provider.example.com/oauth/token", + "refresh_token_url": "https://provider.example.com/oauth/token", + "pkce_enabled": true, + "request_scope_separator": " ", + "scopes_required": false, + "client_secret_required": true, + "additional_authorization_parameters": { + "prompt": "consent" + }, + "token_body_content_type": "application/x-www-form-urlencoded", + "authenticate_via": "request_body" + }, + "created_at": "2026-01-15T12:00:00.000Z", + "updated_at": "2026-01-15T12:00:00.000Z" + } + ], + "list_metadata": { + "before": null, + "after": null + } +} diff --git a/src/pipes/fixtures/update-custom-provider-definition.json b/src/pipes/fixtures/update-custom-provider-definition.json new file mode 100644 index 000000000..9909168b8 --- /dev/null +++ b/src/pipes/fixtures/update-custom-provider-definition.json @@ -0,0 +1,15 @@ +{ + "name": "My OAuth App", + "authorization_url": "https://provider.example.com/oauth/authorize", + "token_url": "https://provider.example.com/oauth/token", + "refresh_token_url": "https://provider.example.com/oauth/token", + "pkce_enabled": true, + "request_scope_separator": " ", + "scopes_required": false, + "client_secret_required": true, + "additional_authorization_parameters": { + "prompt": "consent" + }, + "token_body_content_type": "application/x-www-form-urlencoded", + "authenticate_via": "request_body" +} diff --git a/src/pipes/fixtures/update-data-integration.json b/src/pipes/fixtures/update-data-integration.json new file mode 100644 index 000000000..260c76ac3 --- /dev/null +++ b/src/pipes/fixtures/update-data-integration.json @@ -0,0 +1,25 @@ +{ + "description": "Production GitHub app", + "enabled": true, + "scopes": ["repo", "read:org"], + "credentials": { + "type": "custom", + "client_id": "Iv1.abc123", + "client_secret": "secret_…" + }, + "custom_provider": { + "name": "My OAuth App", + "authorization_url": "https://provider.example.com/oauth/authorize", + "token_url": "https://provider.example.com/oauth/token", + "refresh_token_url": "https://provider.example.com/oauth/token", + "pkce_enabled": true, + "request_scope_separator": " ", + "scopes_required": false, + "client_secret_required": true, + "additional_authorization_parameters": { + "prompt": "consent" + }, + "token_body_content_type": "application/x-www-form-urlencoded", + "authenticate_via": "request_body" + } +} diff --git a/src/pipes/interfaces/connected-account-dto.interface.ts b/src/pipes/interfaces/connected-account-dto.interface.ts new file mode 100644 index 000000000..85a135513 --- /dev/null +++ b/src/pipes/interfaces/connected-account-dto.interface.ts @@ -0,0 +1,24 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { ConnectedAccountState } from './connected-account-state.interface'; + +export interface ConnectedAccountDto { + /** The OAuth access token for the connected account. */ + accessToken?: string; + /** The OAuth refresh token for the connected account. */ + refreshToken?: string; + /** The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire. */ + expiresAt?: Date; + /** The OAuth scopes granted for this connection. */ + scopes?: string[]; + /** Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided. */ + state?: ConnectedAccountState; +} + +export interface ConnectedAccountDtoResponse { + access_token?: string; + refresh_token?: string; + expires_at?: string; + scopes?: string[]; + state?: ConnectedAccountState; +} diff --git a/src/pipes/interfaces/connected-account-state.interface.ts b/src/pipes/interfaces/connected-account-state.interface.ts index 49beb89e4..50c2be5ad 100644 --- a/src/pipes/interfaces/connected-account-state.interface.ts +++ b/src/pipes/interfaces/connected-account-state.interface.ts @@ -3,7 +3,6 @@ export const ConnectedAccountState = { Connected: 'connected', NeedsReauthorization: 'needs_reauthorization', - Disconnected: 'disconnected', } as const; export type ConnectedAccountState = diff --git a/src/pipes/interfaces/create-data-integration-options.interface.ts b/src/pipes/interfaces/create-data-integration-options.interface.ts new file mode 100644 index 000000000..0c359badc --- /dev/null +++ b/src/pipes/interfaces/create-data-integration-options.interface.ts @@ -0,0 +1,19 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { DataIntegrationCredentialsDto } from './data-integration-credentials-dto.interface'; +import type { CustomProviderDefinition } from './custom-provider-definition.interface'; + +export interface CreateDataIntegrationOptions { + /** The provider to create a Data Integration for. For a built-in provider use its slug (e.g. `github`, `slack`). For a custom provider, this is the new provider slug and `custom_provider` must be supplied. A custom provider slug cannot shadow an existing global provider slug. */ + provider: string; + /** An optional description of the Data Integration. */ + description?: string | null; + /** Whether the Data Integration is enabled. Defaults to `false`. */ + enabled?: boolean; + /** The OAuth scopes to request for the Data Integration. Defaults to the provider's configured scopes when omitted. */ + scopes?: string[] | null; + /** The credentials to configure for the Data Integration. Required for both built-in and custom providers. */ + credentials?: DataIntegrationCredentialsDto; + /** The OAuth definition for a custom provider. Supply this to define a custom provider; omit it to create an integration for a built-in provider. */ + customProvider?: CustomProviderDefinition; +} diff --git a/src/pipes/interfaces/create-data-integration.interface.ts b/src/pipes/interfaces/create-data-integration.interface.ts new file mode 100644 index 000000000..14462c011 --- /dev/null +++ b/src/pipes/interfaces/create-data-integration.interface.ts @@ -0,0 +1,34 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { + DataIntegrationCredentialsDto, + DataIntegrationCredentialsDtoResponse, +} from './data-integration-credentials-dto.interface'; +import type { + CustomProviderDefinition, + CustomProviderDefinitionResponse, +} from './custom-provider-definition.interface'; + +export interface CreateDataIntegration { + /** The provider to create a Data Integration for. For a built-in provider use its slug (e.g. `github`, `slack`). For a custom provider, this is the new provider slug and `custom_provider` must be supplied. A custom provider slug cannot shadow an existing global provider slug. */ + provider: string; + /** An optional description of the Data Integration. */ + description?: string | null; + /** Whether the Data Integration is enabled. Defaults to `false`. */ + enabled?: boolean; + /** The OAuth scopes to request for the Data Integration. Defaults to the provider's configured scopes when omitted. */ + scopes?: string[] | null; + /** The credentials to configure for the Data Integration. Required for both built-in and custom providers. */ + credentials?: DataIntegrationCredentialsDto; + /** The OAuth definition for a custom provider. Supply this to define a custom provider; omit it to create an integration for a built-in provider. */ + customProvider?: CustomProviderDefinition; +} + +export interface CreateDataIntegrationResponse { + provider: string; + description?: string | null; + enabled?: boolean; + scopes?: string[] | null; + credentials?: DataIntegrationCredentialsDtoResponse; + custom_provider?: CustomProviderDefinitionResponse; +} diff --git a/src/pipes/interfaces/create-user-connected-account-options.interface.ts b/src/pipes/interfaces/create-user-connected-account-options.interface.ts new file mode 100644 index 000000000..9b6139429 --- /dev/null +++ b/src/pipes/interfaces/create-user-connected-account-options.interface.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { ConnectedAccountState } from './connected-account-state.interface'; + +export interface CreateUserConnectedAccountOptions { + /** A [User](https://workos.com/docs/reference/authkit/user) identifier. */ + userId: string; + /** The slug identifier of the provider (e.g., `github`, `slack`, `notion`). */ + slug: string; + /** An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization. */ + organizationId?: string; + /** The OAuth access token for the connected account. */ + accessToken?: string; + /** The OAuth refresh token for the connected account. */ + refreshToken?: string; + /** The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire. */ + expiresAt?: Date; + /** The OAuth scopes granted for this connection. */ + scopes?: string[]; + /** Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided. */ + state?: ConnectedAccountState; +} diff --git a/src/pipes/interfaces/custom-provider-definition-authenticate-via.interface.ts b/src/pipes/interfaces/custom-provider-definition-authenticate-via.interface.ts new file mode 100644 index 000000000..09499f7a0 --- /dev/null +++ b/src/pipes/interfaces/custom-provider-definition-authenticate-via.interface.ts @@ -0,0 +1,9 @@ +// This file is auto-generated by oagen. Do not edit. + +export const CustomProviderDefinitionAuthenticateVia = { + RequestBody: 'request_body', + BasicAuthHeader: 'basic_auth_header', +} as const; + +export type CustomProviderDefinitionAuthenticateVia = + (typeof CustomProviderDefinitionAuthenticateVia)[keyof typeof CustomProviderDefinitionAuthenticateVia]; diff --git a/src/pipes/interfaces/custom-provider-definition.interface.ts b/src/pipes/interfaces/custom-provider-definition.interface.ts new file mode 100644 index 000000000..d470e9c78 --- /dev/null +++ b/src/pipes/interfaces/custom-provider-definition.interface.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { CustomProviderDefinitionAuthenticateVia } from './custom-provider-definition-authenticate-via.interface'; + +export interface CustomProviderDefinition { + /** A descriptive name for the custom provider. */ + name: string; + /** The provider's OAuth authorization endpoint. */ + authorizationUrl: string; + /** The provider's OAuth token endpoint. */ + tokenUrl: string; + /** The endpoint used to refresh tokens, if different from the token endpoint. */ + refreshTokenUrl?: string | null; + /** Whether PKCE is used during the authorization code flow. Defaults to `true`. */ + pkceEnabled?: boolean; + /** The separator used to join requested scopes. Defaults to a space. */ + requestScopeSeparator?: string; + /** Whether at least one scope must be selected when connecting an account. Defaults to `false`. */ + scopesRequired?: boolean; + /** Whether a client secret is required for this provider. Defaults to `true`. */ + clientSecretRequired?: boolean; + /** Additional static query parameters appended to the authorization request. */ + additionalAuthorizationParameters?: Record; + /** The Content-Type used when exchanging the token request. */ + tokenBodyContentType?: string; + /** How client credentials are sent when exchanging authorization codes and refreshing tokens. */ + authenticateVia?: CustomProviderDefinitionAuthenticateVia; +} + +export interface CustomProviderDefinitionResponse { + name: string; + authorization_url: string; + token_url: string; + refresh_token_url?: string | null; + pkce_enabled?: boolean; + request_scope_separator?: string; + scopes_required?: boolean; + client_secret_required?: boolean; + additional_authorization_parameters?: Record; + token_body_content_type?: string; + authenticate_via?: CustomProviderDefinitionAuthenticateVia; +} diff --git a/src/pipes/interfaces/data-integration-credential-type.interface.ts b/src/pipes/interfaces/data-integration-credential-type.interface.ts new file mode 100644 index 000000000..f6698991c --- /dev/null +++ b/src/pipes/interfaces/data-integration-credential-type.interface.ts @@ -0,0 +1,9 @@ +// This file is auto-generated by oagen. Do not edit. + +export const DataIntegrationCredentialType = { + Custom: 'custom', + Organization: 'organization', +} as const; + +export type DataIntegrationCredentialType = + (typeof DataIntegrationCredentialType)[keyof typeof DataIntegrationCredentialType]; diff --git a/src/pipes/interfaces/data-integration-credential.interface.ts b/src/pipes/interfaces/data-integration-credential.interface.ts new file mode 100644 index 000000000..72b53bf45 --- /dev/null +++ b/src/pipes/interfaces/data-integration-credential.interface.ts @@ -0,0 +1,19 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { DataIntegrationCredentialType } from './data-integration-credential-type.interface'; + +/** The credentials configured for the Data Integration. */ +export interface DataIntegrationCredential { + /** The credentials type. `custom` uses your own OAuth app credentials; `organization` has each organization supply its own credentials (so `client_id`/`redacted_client_secret` are null on the integration itself). */ + type: DataIntegrationCredentialType; + /** The OAuth client ID configured for the provider app. Null for `organization` credentials. */ + clientId: string | null; + /** The last four characters of the OAuth client secret. The full secret is never returned. Null for `organization` credentials. */ + redactedClientSecret: string | null; +} + +export interface DataIntegrationCredentialResponse { + type: DataIntegrationCredentialType; + client_id: string | null; + redacted_client_secret: string | null; +} diff --git a/src/pipes/interfaces/data-integration-credentials-dto.interface.ts b/src/pipes/interfaces/data-integration-credentials-dto.interface.ts new file mode 100644 index 000000000..e141828e5 --- /dev/null +++ b/src/pipes/interfaces/data-integration-credentials-dto.interface.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { DataIntegrationCredentialsType } from './data-integration-credentials-type.interface'; + +export interface DataIntegrationCredentialsDto { + /** The credentials type. `custom` uses your own OAuth app credentials; `organization` has each organization supply its own credentials (configured per-organization). */ + type: DataIntegrationCredentialsType; + /** OAuth client ID for the provider app. Required when `type` is `custom`; omit for `organization`. */ + clientId?: string; + /** OAuth client secret for the provider app. Required when `type` is `custom`; omit for `organization`. */ + clientSecret?: string; +} + +export interface DataIntegrationCredentialsDtoResponse { + type: DataIntegrationCredentialsType; + client_id?: string; + client_secret?: string; +} diff --git a/src/pipes/interfaces/data-integration-credentials-type.interface.ts b/src/pipes/interfaces/data-integration-credentials-type.interface.ts new file mode 100644 index 000000000..c8e4719ac --- /dev/null +++ b/src/pipes/interfaces/data-integration-credentials-type.interface.ts @@ -0,0 +1,9 @@ +// This file is auto-generated by oagen. Do not edit. + +export const DataIntegrationCredentialsType = { + Custom: 'custom', + Organization: 'organization', +} as const; + +export type DataIntegrationCredentialsType = + (typeof DataIntegrationCredentialsType)[keyof typeof DataIntegrationCredentialsType]; diff --git a/src/pipes/interfaces/data-integration-custom-provider-authenticate-via.interface.ts b/src/pipes/interfaces/data-integration-custom-provider-authenticate-via.interface.ts new file mode 100644 index 000000000..70077a6aa --- /dev/null +++ b/src/pipes/interfaces/data-integration-custom-provider-authenticate-via.interface.ts @@ -0,0 +1,9 @@ +// This file is auto-generated by oagen. Do not edit. + +export const DataIntegrationCustomProviderAuthenticateVia = { + RequestBody: 'request_body', + BasicAuthHeader: 'basic_auth_header', +} as const; + +export type DataIntegrationCustomProviderAuthenticateVia = + (typeof DataIntegrationCustomProviderAuthenticateVia)[keyof typeof DataIntegrationCustomProviderAuthenticateVia]; diff --git a/src/pipes/interfaces/data-integration-custom-provider.interface.ts b/src/pipes/interfaces/data-integration-custom-provider.interface.ts new file mode 100644 index 000000000..b12cff78c --- /dev/null +++ b/src/pipes/interfaces/data-integration-custom-provider.interface.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { DataIntegrationCustomProviderAuthenticateVia } from './data-integration-custom-provider-authenticate-via.interface'; + +export interface DataIntegrationCustomProvider { + /** A descriptive name for the custom provider. */ + name: string; + /** The provider's OAuth authorization endpoint. */ + authorizationUrl: string | null; + /** The provider's OAuth token endpoint. */ + tokenUrl: string | null; + /** The endpoint used to refresh tokens, if different from the token endpoint. */ + refreshTokenUrl: string | null; + /** Whether PKCE is used during the authorization code flow. */ + pkceEnabled: boolean; + /** The separator used to join requested scopes. */ + requestScopeSeparator: string; + /** Whether at least one scope must be selected when connecting an account. */ + scopesRequired: boolean; + /** Whether a client secret is required for this provider. */ + clientSecretRequired: boolean; + /** Additional static query parameters appended to the authorization request. */ + additionalAuthorizationParameters: Record; + /** The Content-Type used when exchanging the token request. */ + tokenBodyContentType: string; + /** How client credentials are sent when exchanging authorization codes and refreshing tokens. */ + authenticateVia: DataIntegrationCustomProviderAuthenticateVia; +} + +export interface DataIntegrationCustomProviderResponse { + name: string; + authorization_url: string | null; + token_url: string | null; + refresh_token_url: string | null; + pkce_enabled: boolean; + request_scope_separator: string; + scopes_required: boolean; + client_secret_required: boolean; + additional_authorization_parameters: Record; + token_body_content_type: string; + authenticate_via: DataIntegrationCustomProviderAuthenticateVia; +} diff --git a/src/pipes/interfaces/data-integration-state.interface.ts b/src/pipes/interfaces/data-integration-state.interface.ts new file mode 100644 index 000000000..932988fb6 --- /dev/null +++ b/src/pipes/interfaces/data-integration-state.interface.ts @@ -0,0 +1,10 @@ +// This file is auto-generated by oagen. Do not edit. + +export const DataIntegrationState = { + Valid: 'valid', + Invalid: 'invalid', + Requested: 'requested', +} as const; + +export type DataIntegrationState = + (typeof DataIntegrationState)[keyof typeof DataIntegrationState]; diff --git a/src/pipes/interfaces/data-integration.interface.ts b/src/pipes/interfaces/data-integration.interface.ts new file mode 100644 index 000000000..afd94340b --- /dev/null +++ b/src/pipes/interfaces/data-integration.interface.ts @@ -0,0 +1,56 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { + DataIntegrationCredential, + DataIntegrationCredentialResponse, +} from './data-integration-credential.interface'; +import type { + DataIntegrationCustomProvider, + DataIntegrationCustomProviderResponse, +} from './data-integration-custom-provider.interface'; +import type { DataIntegrationState } from './data-integration-state.interface'; + +export interface DataIntegration { + /** Distinguishes the Data Integration object. */ + object: 'data_integration'; + /** Unique identifier of the Data Integration. */ + id: string; + /** The provider slug for this Data Integration. */ + slug: string; + /** The integration type derived from the provider. */ + integrationType: string; + /** An optional description of the Data Integration. */ + description: string | null; + /** Whether the Data Integration is enabled. */ + enabled: boolean; + /** The state of the Data Integration. */ + state: DataIntegrationState; + /** The OAuth scopes configured for the Data Integration. `null` when the provider's configured scopes are used. */ + scopes: string[] | null; + /** The OAuth redirect URI to register with the provider when configuring the custom application. */ + redirectUri: string; + /** The credentials configured for the Data Integration. */ + credentials: DataIntegrationCredential; + /** The OAuth definition when this is a custom provider; `null` for built-in providers. */ + customProvider: DataIntegrationCustomProvider | null; + /** An ISO 8601 timestamp. */ + createdAt: Date; + /** An ISO 8601 timestamp. */ + updatedAt: Date; +} + +export interface DataIntegrationResponse { + object: 'data_integration'; + id: string; + slug: string; + integration_type: string; + description: string | null; + enabled: boolean; + state: DataIntegrationState; + scopes: string[] | null; + redirect_uri: string; + credentials: DataIntegrationCredentialResponse; + custom_provider: DataIntegrationCustomProviderResponse | null; + created_at: string; + updated_at: string; +} diff --git a/src/pipes/interfaces/delete-data-integration-options.interface.ts b/src/pipes/interfaces/delete-data-integration-options.interface.ts new file mode 100644 index 000000000..f4515e27a --- /dev/null +++ b/src/pipes/interfaces/delete-data-integration-options.interface.ts @@ -0,0 +1,6 @@ +// This file is auto-generated by oagen. Do not edit. + +export interface DeleteDataIntegrationOptions { + /** The slug identifier of the data integration. */ + slug: string; +} diff --git a/src/pipes/interfaces/get-data-integration-options.interface.ts b/src/pipes/interfaces/get-data-integration-options.interface.ts new file mode 100644 index 000000000..205b86ce7 --- /dev/null +++ b/src/pipes/interfaces/get-data-integration-options.interface.ts @@ -0,0 +1,6 @@ +// This file is auto-generated by oagen. Do not edit. + +export interface GetDataIntegrationOptions { + /** The slug identifier of the data integration. */ + slug: string; +} diff --git a/src/pipes/interfaces/index.ts b/src/pipes/interfaces/index.ts index e573b302b..ef2be9722 100644 --- a/src/pipes/interfaces/index.ts +++ b/src/pipes/interfaces/index.ts @@ -3,16 +3,30 @@ export * from './access-token.interface'; export * from './authorize-data-integration-options.interface'; export * from './connected-account-auth-method.interface'; +export * from './connected-account-dto.interface'; export * from './connected-account-state.interface'; export * from './connected-account.interface'; export * from './create-data-integration-credential-options.interface'; +export * from './create-data-integration-options.interface'; export * from './create-data-integration-token-options.interface'; +export * from './create-data-integration.interface'; +export * from './create-user-connected-account-options.interface'; +export * from './custom-provider-definition-authenticate-via.interface'; +export * from './custom-provider-definition.interface'; export * from './data-integration-access-token-response-access-token.interface'; export * from './data-integration-access-token-response-error.interface'; export * from './data-integration-access-token-response.interface'; export * from './data-integration-authorize-url-response.interface'; +export * from './data-integration-credential-type.interface'; +export * from './data-integration-credential.interface'; +export * from './data-integration-credentials-dto.interface'; export * from './data-integration-credentials-response-credential.interface'; export * from './data-integration-credentials-response-error.interface'; +export * from './data-integration-credentials-type.interface'; +export * from './data-integration-custom-provider-authenticate-via.interface'; +export * from './data-integration-custom-provider.interface'; +export * from './data-integration-state.interface'; +export * from './data-integration.interface'; export * from './data-integrations-get-data-integration-authorize-url-request.interface'; export * from './data-integrations-get-user-token-request.interface'; export * from './data-integrations-list-response-data-auth-methods.interface'; @@ -24,8 +38,16 @@ export * from './data-integrations-list-response-data.interface'; export * from './data-integrations-list-response.interface'; export * from './data-integrations-upsert-api-key-request.interface'; export * from './data-integrations-vend-credentials-request.interface'; +export * from './delete-data-integration-options.interface'; export * from './delete-user-connected-account-options.interface'; export * from './get-access-token-options.interface'; +export * from './get-data-integration-options.interface'; export * from './get-user-connected-account-options.interface'; +export * from './list-data-integrations-options.interface'; export * from './list-user-data-providers-options.interface'; +export * from './update-custom-provider-definition-authenticate-via.interface'; +export * from './update-custom-provider-definition.interface'; export * from './update-data-integration-api-key-options.interface'; +export * from './update-data-integration-options.interface'; +export * from './update-data-integration.interface'; +export * from './update-user-connected-account-options.interface'; diff --git a/src/pipes/interfaces/list-data-integrations-options.interface.ts b/src/pipes/interfaces/list-data-integrations-options.interface.ts new file mode 100644 index 000000000..9b6b684e4 --- /dev/null +++ b/src/pipes/interfaces/list-data-integrations-options.interface.ts @@ -0,0 +1,5 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { PaginationOptions } from '../../common/interfaces/pagination-options.interface'; + +export type ListDataIntegrationsOptions = PaginationOptions; diff --git a/src/pipes/interfaces/update-custom-provider-definition-authenticate-via.interface.ts b/src/pipes/interfaces/update-custom-provider-definition-authenticate-via.interface.ts new file mode 100644 index 000000000..86b9fe05e --- /dev/null +++ b/src/pipes/interfaces/update-custom-provider-definition-authenticate-via.interface.ts @@ -0,0 +1,9 @@ +// This file is auto-generated by oagen. Do not edit. + +export const UpdateCustomProviderDefinitionAuthenticateVia = { + RequestBody: 'request_body', + BasicAuthHeader: 'basic_auth_header', +} as const; + +export type UpdateCustomProviderDefinitionAuthenticateVia = + (typeof UpdateCustomProviderDefinitionAuthenticateVia)[keyof typeof UpdateCustomProviderDefinitionAuthenticateVia]; diff --git a/src/pipes/interfaces/update-custom-provider-definition.interface.ts b/src/pipes/interfaces/update-custom-provider-definition.interface.ts new file mode 100644 index 000000000..ed7804877 --- /dev/null +++ b/src/pipes/interfaces/update-custom-provider-definition.interface.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { UpdateCustomProviderDefinitionAuthenticateVia } from './update-custom-provider-definition-authenticate-via.interface'; + +export interface UpdateCustomProviderDefinition { + /** A descriptive name for the custom provider. */ + name?: string; + /** The provider's OAuth authorization endpoint. */ + authorizationUrl?: string; + /** The provider's OAuth token endpoint. */ + tokenUrl?: string; + /** The endpoint used to refresh tokens, if different from the token endpoint. */ + refreshTokenUrl?: string | null; + /** Whether PKCE is used during the authorization code flow. */ + pkceEnabled?: boolean; + /** The separator used to join requested scopes. */ + requestScopeSeparator?: string; + /** Whether at least one scope must be selected when connecting an account. */ + scopesRequired?: boolean; + /** Whether a client secret is required for this provider. */ + clientSecretRequired?: boolean; + /** Additional static query parameters appended to the authorization request. */ + additionalAuthorizationParameters?: Record; + /** The Content-Type used when exchanging the token request. */ + tokenBodyContentType?: string; + /** How client credentials are sent when exchanging authorization codes and refreshing tokens. */ + authenticateVia?: UpdateCustomProviderDefinitionAuthenticateVia; +} + +export interface UpdateCustomProviderDefinitionResponse { + name?: string; + authorization_url?: string; + token_url?: string; + refresh_token_url?: string | null; + pkce_enabled?: boolean; + request_scope_separator?: string; + scopes_required?: boolean; + client_secret_required?: boolean; + additional_authorization_parameters?: Record; + token_body_content_type?: string; + authenticate_via?: UpdateCustomProviderDefinitionAuthenticateVia; +} diff --git a/src/pipes/interfaces/update-data-integration-options.interface.ts b/src/pipes/interfaces/update-data-integration-options.interface.ts new file mode 100644 index 000000000..50272096c --- /dev/null +++ b/src/pipes/interfaces/update-data-integration-options.interface.ts @@ -0,0 +1,19 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { DataIntegrationCredentialsDto } from './data-integration-credentials-dto.interface'; +import type { UpdateCustomProviderDefinition } from './update-custom-provider-definition.interface'; + +export interface UpdateDataIntegrationOptions { + /** The slug identifier of the data integration. */ + slug: string; + /** An optional description of the Data Integration. */ + description?: string | null; + /** Whether the Data Integration is enabled. */ + enabled?: boolean; + /** The OAuth scopes to request for the Data Integration. Pass `null` to reset to the provider's configured scopes. */ + scopes?: string[] | null; + /** New credentials for the Data Integration. When provided, rotates the stored client secret. */ + credentials?: DataIntegrationCredentialsDto; + /** Updates to a custom provider's OAuth definition. Only valid for custom-provider integrations. */ + customProvider?: UpdateCustomProviderDefinition; +} diff --git a/src/pipes/interfaces/update-data-integration.interface.ts b/src/pipes/interfaces/update-data-integration.interface.ts new file mode 100644 index 000000000..08ec172ed --- /dev/null +++ b/src/pipes/interfaces/update-data-integration.interface.ts @@ -0,0 +1,31 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { + DataIntegrationCredentialsDto, + DataIntegrationCredentialsDtoResponse, +} from './data-integration-credentials-dto.interface'; +import type { + UpdateCustomProviderDefinition, + UpdateCustomProviderDefinitionResponse, +} from './update-custom-provider-definition.interface'; + +export interface UpdateDataIntegration { + /** An optional description of the Data Integration. */ + description?: string | null; + /** Whether the Data Integration is enabled. */ + enabled?: boolean; + /** The OAuth scopes to request for the Data Integration. Pass `null` to reset to the provider's configured scopes. */ + scopes?: string[] | null; + /** New credentials for the Data Integration. When provided, rotates the stored client secret. */ + credentials?: DataIntegrationCredentialsDto; + /** Updates to a custom provider's OAuth definition. Only valid for custom-provider integrations. */ + customProvider?: UpdateCustomProviderDefinition; +} + +export interface UpdateDataIntegrationResponse { + description?: string | null; + enabled?: boolean; + scopes?: string[] | null; + credentials?: DataIntegrationCredentialsDtoResponse; + custom_provider?: UpdateCustomProviderDefinitionResponse; +} diff --git a/src/pipes/interfaces/update-user-connected-account-options.interface.ts b/src/pipes/interfaces/update-user-connected-account-options.interface.ts new file mode 100644 index 000000000..6ab1ab3af --- /dev/null +++ b/src/pipes/interfaces/update-user-connected-account-options.interface.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { ConnectedAccountState } from './connected-account-state.interface'; + +export interface UpdateUserConnectedAccountOptions { + /** A [User](https://workos.com/docs/reference/authkit/user) identifier. */ + userId: string; + /** The slug identifier of the provider (e.g., `github`, `slack`, `notion`). */ + slug: string; + /** An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization. */ + organizationId?: string; + /** The OAuth access token for the connected account. */ + accessToken?: string; + /** The OAuth refresh token for the connected account. */ + refreshToken?: string; + /** The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire. */ + expiresAt?: Date; + /** The OAuth scopes granted for this connection. */ + scopes?: string[]; + /** Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided. */ + state?: ConnectedAccountState; +} diff --git a/src/pipes/pipes.spec.ts b/src/pipes/pipes.spec.ts index 2a8de4c25..944e58bfd 100644 --- a/src/pipes/pipes.spec.ts +++ b/src/pipes/pipes.spec.ts @@ -5,10 +5,13 @@ import { fetchOnce, fetchURL, fetchMethod, + fetchSearchParams, fetchBody, } from '../common/utils/test-utils'; import { WorkOS } from '../workos'; +import listDataIntegrationFixture from './fixtures/list-data-integration.json'; +import dataIntegrationFixture from './fixtures/data-integration.json'; import connectedAccountFixture from './fixtures/connected-account.json'; import dataIntegrationAuthorizeUrlResponseFixture from './fixtures/data-integration-authorize-url-response.json'; import dataIntegrationCredentialsResponseFixture from './fixtures/data-integration-credentials-response.json'; @@ -17,6 +20,22 @@ import dataIntegrationsListResponseFixture from './fixtures/data-integrations-li const workos = new WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU'); +function expectDataIntegration(result: any) { + expect(result.object).toBe('data_integration'); + expect(result.id).toBe('data_integration_01EHZNVPK3SFK441A1RGBFSHRT'); + expect(result.slug).toBe('github'); + expect(result.integrationType).toBe('github'); + expect(result.description).toBe('Production GitHub app'); + expect(result.enabled).toBe(true); + expect(result.state).toBe('valid'); + expect(result.scopes).toEqual(['repo', 'read:org']); + expect(result.redirectUri).toBe( + 'https://api.workos.com/data-integrations/github/dik_01EHZNVPK3SFK441A1RGBFSHRT/callback', + ); + expect(result.createdAt.toISOString()).toBe('2026-01-15T12:00:00.000Z'); + expect(result.updatedAt.toISOString()).toBe('2026-01-15T12:00:00.000Z'); +} + function expectConnectedAccount(result: any) { expect(result.object).toBe('connected_account'); expect(result.id).toBe('data_installation_01EHZNVPK3SFK441A1RGBFSHRT'); @@ -31,6 +50,94 @@ function expectConnectedAccount(result: any) { describe('Pipes', () => { beforeEach(() => fetch.resetMocks()); + describe('listDataIntegrations', () => { + it('returns paginated results', async () => { + fetchOnce(listDataIntegrationFixture); + + const { data, listMetadata } = await workos.pipes.listDataIntegrations({ + order: 'desc', + }); + + expect(fetchMethod()).toBe('GET'); + expect(new URL(String(fetchURL())).pathname).toBe('/data-integrations'); + expect(fetchSearchParams()).toHaveProperty('order'); + expect(Array.isArray(data)).toBe(true); + expect(listMetadata).toBeDefined(); + expect(data.length).toBeGreaterThan(0); + expectDataIntegration(data[0]); + }); + }); + + describe('createDataIntegration', () => { + it('sends the correct request and returns result', async () => { + fetchOnce(dataIntegrationFixture); + + const result = await workos.pipes.createDataIntegration({ + provider: 'provider_01234', + }); + + expect(fetchMethod()).toBe('POST'); + expect(new URL(String(fetchURL())).pathname).toBe('/data-integrations'); + expect(fetchBody()).toEqual( + expect.objectContaining({ provider: 'provider_01234' }), + ); + expectDataIntegration(result); + }); + }); + + describe('getDataIntegration', () => { + it('returns the expected result', async () => { + fetchOnce(dataIntegrationFixture); + + const result = await workos.pipes.getDataIntegration({ + slug: 'test_slug', + }); + + expect(fetchMethod()).toBe('GET'); + expect(new URL(String(fetchURL())).pathname).toBe( + '/data-integrations/test_slug', + ); + expectDataIntegration(result); + }); + }); + + describe('updateDataIntegration', () => { + it('sends the correct request and returns result', async () => { + fetchOnce(dataIntegrationFixture); + + const result = await workos.pipes.updateDataIntegration({ + slug: 'test_slug', + enabled: true, + credentials: { type: 'custom' }, + }); + + expect(fetchMethod()).toBe('PUT'); + expect(new URL(String(fetchURL())).pathname).toBe( + '/data-integrations/test_slug', + ); + expect(fetchBody()).toEqual( + expect.objectContaining({ + enabled: true, + credentials: { type: 'custom' }, + }), + ); + expectDataIntegration(result); + }); + }); + + describe('deleteDataIntegration', () => { + it('sends a DELETE request', async () => { + fetchOnce({}, { status: 204 }); + + await workos.pipes.deleteDataIntegration({ slug: 'test_slug' }); + + expect(fetchMethod()).toBe('DELETE'); + expect(new URL(String(fetchURL())).pathname).toBe( + '/data-integrations/test_slug', + ); + }); + }); + describe('updateDataIntegrationApiKey', () => { it('sends the correct request and returns result', async () => { fetchOnce(connectedAccountFixture); @@ -135,6 +242,58 @@ describe('Pipes', () => { }); }); + describe('createUserConnectedAccount', () => { + it('sends the correct request and returns result', async () => { + fetchOnce(connectedAccountFixture); + + const result = await workos.pipes.createUserConnectedAccount({ + userId: 'test_userId', + slug: 'test_slug', + organizationId: 'org_01EHZNVPK3SFK441A1RGBFSHRT', + accessToken: 'test_access_token', + refreshToken: 'test_refresh_token', + }); + + expect(fetchMethod()).toBe('POST'); + expect(new URL(String(fetchURL())).pathname).toBe( + '/user_management/users/test_userId/connected_accounts/test_slug', + ); + expect(fetchBody()).toEqual( + expect.objectContaining({ + access_token: 'test_access_token', + refresh_token: 'test_refresh_token', + }), + ); + expectConnectedAccount(result); + }); + }); + + describe('updateUserConnectedAccount', () => { + it('sends the correct request and returns result', async () => { + fetchOnce(connectedAccountFixture); + + const result = await workos.pipes.updateUserConnectedAccount({ + userId: 'test_userId', + slug: 'test_slug', + organizationId: 'org_01EHZNVPK3SFK441A1RGBFSHRT', + accessToken: 'test_access_token', + refreshToken: 'test_refresh_token', + }); + + expect(fetchMethod()).toBe('PUT'); + expect(new URL(String(fetchURL())).pathname).toBe( + '/user_management/users/test_userId/connected_accounts/test_slug', + ); + expect(fetchBody()).toEqual( + expect.objectContaining({ + access_token: 'test_access_token', + refresh_token: 'test_refresh_token', + }), + ); + expectConnectedAccount(result); + }); + }); + describe('deleteUserConnectedAccount', () => { it('sends a DELETE request', async () => { fetchOnce({}, { status: 204 }); diff --git a/src/pipes/pipes.ts b/src/pipes/pipes.ts index bee9465c3..11ccf4f85 100644 --- a/src/pipes/pipes.ts +++ b/src/pipes/pipes.ts @@ -1,13 +1,26 @@ // This file is auto-generated by oagen. Do not edit. import type { WorkOS } from '../workos'; +import { AutoPaginatable } from '../common/utils/pagination'; +import { fetchAndDeserialize } from '../common/utils/fetch-and-deserialize'; +import type { ListDataIntegrationsOptions } from './interfaces/list-data-integrations-options.interface'; +import type { CreateDataIntegrationOptions } from './interfaces/create-data-integration-options.interface'; +import type { GetDataIntegrationOptions } from './interfaces/get-data-integration-options.interface'; +import type { UpdateDataIntegrationOptions } from './interfaces/update-data-integration-options.interface'; +import type { DeleteDataIntegrationOptions } from './interfaces/delete-data-integration-options.interface'; import type { UpdateDataIntegrationApiKeyOptions } from './interfaces/update-data-integration-api-key-options.interface'; import type { AuthorizeDataIntegrationOptions } from './interfaces/authorize-data-integration-options.interface'; import type { CreateDataIntegrationCredentialOptions } from './interfaces/create-data-integration-credential-options.interface'; import type { GetAccessTokenOptions } from './interfaces/get-access-token-options.interface'; import type { GetUserConnectedAccountOptions } from './interfaces/get-user-connected-account-options.interface'; +import type { CreateUserConnectedAccountOptions } from './interfaces/create-user-connected-account-options.interface'; +import type { UpdateUserConnectedAccountOptions } from './interfaces/update-user-connected-account-options.interface'; import type { DeleteUserConnectedAccountOptions } from './interfaces/delete-user-connected-account-options.interface'; import type { ListUserDataProvidersOptions } from './interfaces/list-user-data-providers-options.interface'; +import type { + DataIntegration, + DataIntegrationResponse, +} from './interfaces/data-integration.interface'; import type { ConnectedAccount, ConnectedAccountResponse, @@ -28,30 +41,160 @@ import type { DataIntegrationsListResponse, DataIntegrationsListResponseWire, } from './interfaces/data-integrations-list-response.interface'; +import type { CreateDataIntegrationResponse } from './interfaces/create-data-integration.interface'; +import type { UpdateDataIntegrationResponse } from './interfaces/update-data-integration.interface'; import type { DataIntegrationsUpsertApiKeyRequestResponse } from './interfaces/data-integrations-upsert-api-key-request.interface'; import type { DataIntegrationsGetDataIntegrationAuthorizeUrlRequestResponse } from './interfaces/data-integrations-get-data-integration-authorize-url-request.interface'; import type { DataIntegrationsVendCredentialsRequestResponse } from './interfaces/data-integrations-vend-credentials-request.interface'; import type { DataIntegrationsGetUserTokenRequestResponse } from './interfaces/data-integrations-get-user-token-request.interface'; +import type { ConnectedAccountDtoResponse } from './interfaces/connected-account-dto.interface'; +import { deserializeDataIntegration } from './serializers/data-integration.serializer'; import { deserializeConnectedAccount } from './serializers/connected-account.serializer'; import { deserializeDataIntegrationAuthorizeUrlResponse } from './serializers/data-integration-authorize-url-response.serializer'; import { deserializeDataIntegrationCredentialsResponse } from './serializers/data-integration-credentials-response.serializer'; import { deserializeDataIntegrationAccessTokenResponse } from './serializers/data-integration-access-token-response.serializer'; import { deserializeDataIntegrationsListResponse } from './serializers/data-integrations-list-response.serializer'; +import { serializeCreateDataIntegration } from './serializers/create-data-integration.serializer'; +import { serializeUpdateDataIntegration } from './serializers/update-data-integration.serializer'; import { serializeDataIntegrationsUpsertApiKeyRequest } from './serializers/data-integrations-upsert-api-key-request.serializer'; import { serializeDataIntegrationsGetDataIntegrationAuthorizeUrlRequest } from './serializers/data-integrations-get-data-integration-authorize-url-request.serializer'; import { serializeDataIntegrationsVendCredentialsRequest } from './serializers/data-integrations-vend-credentials-request.serializer'; import { serializeDataIntegrationsGetUserTokenRequest } from './serializers/data-integrations-get-user-token-request.serializer'; +import { serializeConnectedAccountDto } from './serializers/connected-account-dto.serializer'; export class Pipes { constructor(private readonly workos: WorkOS) {} + /** + * List data integrations + * + * Lists the environment's data integrations configured with `custom` or `organization` credentials, including custom providers. + * @param options - Pagination and filter options. + * @returns {Promise>} + * @throws {UnauthorizedException} 401 + */ + async listDataIntegrations( + options?: ListDataIntegrationsOptions, + ): Promise> { + const paginationOptions = options; + return new AutoPaginatable( + await fetchAndDeserialize( + this.workos, + '/data-integrations', + deserializeDataIntegration, + paginationOptions, + ), + (params) => + fetchAndDeserialize( + this.workos, + '/data-integrations', + deserializeDataIntegration, + params, + ), + paginationOptions, + ); + } + + /** + * Create a data integration + * + * Creates a data integration for a provider. Set `credentials.type` to `custom` to use your own OAuth app credentials, or `organization` to have each organization supply its own. For a built-in provider, pass its slug as `provider`. For a custom provider, pass a new slug plus a `custom_provider` definition. + * @returns {Promise} + * @throws {BadRequestException} 400 + * @throws {UnauthorizedException} 401 + * @throws {NotFoundException} 404 + * @throws {UnprocessableEntityException} 422 + */ + async createDataIntegration( + options: CreateDataIntegrationOptions, + ): Promise { + const payload = options; + const { data } = await this.workos.post< + DataIntegrationResponse, + CreateDataIntegrationResponse + >('/data-integrations', serializeCreateDataIntegration(payload)); + return deserializeDataIntegration(data); + } + + /** + * Get a data integration + * + * Retrieves a data integration by its slug. + * @param options - The request options. + * @param options.slug - The slug identifier of the data integration. + * @example "github" + * @returns {Promise} + * @throws {UnauthorizedException} 401 + * @throws {NotFoundException} 404 + */ + async getDataIntegration( + options: GetDataIntegrationOptions, + ): Promise { + const { slug } = options; + const { data } = await this.workos.get( + `/data-integrations/${encodeURIComponent(slug)}`, + ); + return deserializeDataIntegration(data); + } + + /** + * Update a data integration + * + * Updates the description, enabled state, or custom credentials of a data integration. For custom providers, `custom_provider` updates the OAuth definition. + * @param options - The request options. + * @param options.slug - The slug identifier of the data integration. + * @example "github" + * @returns {Promise} + * @throws {BadRequestException} 400 + * @throws {UnauthorizedException} 401 + * @throws {NotFoundException} 404 + * @throws {UnprocessableEntityException} 422 + */ + async updateDataIntegration( + options: UpdateDataIntegrationOptions, + ): Promise { + const { slug, ...payload } = options; + const { data } = await this.workos.put< + DataIntegrationResponse, + UpdateDataIntegrationResponse + >( + `/data-integrations/${encodeURIComponent(slug)}`, + serializeUpdateDataIntegration(payload), + ); + return deserializeDataIntegration(data); + } + + /** + * Delete a data integration + * + * Deletes a data integration and all of its connected installations. For a custom provider, also deletes the custom provider definition. + * @param options - The request options. + * @param options.slug - The slug identifier of the data integration. + * @example "github" + * @returns {Promise} + * @throws {UnauthorizedException} 401 + * @throws {NotFoundException} 404 + */ + async deleteDataIntegration( + options: DeleteDataIntegrationOptions, + ): Promise { + const { slug } = options; + await this.workos.delete(`/data-integrations/${encodeURIComponent(slug)}`); + } + /** * Upsert an API key for a connected account * * Creates or updates an API-key-based installation for the specified integration and user. If an installation already exists, the stored API key is rotated to the new value. - * @param options - The request options. + * @param options - Object containing userId, secret. * @param options.slug - The identifier of the integration. * @example "github" + * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier. + * @example "user_01EHZNVPK3SFK441A1RGBFSHRT" + * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization. + * @example "org_01EHZNVPK3SFK441A1RGBFSHRT" + * @param options.secret - The API key secret to store for this integration. + * @example "sk-1234567890abcdef" * @returns {Promise} * @throws {BadRequestException} 400 * @throws {UnauthorizedException} 401 @@ -110,9 +253,13 @@ export class Pipes { * Vend credentials for a connected account * * Returns credentials for a user's connected account. Branches on the installation's `auth_method`: OAuth installations return an access token (refreshed if needed); API-key installations return the stored secret. - * @param options - The request options. + * @param options - Object containing userId. * @param options.slug - The identifier of the integration. * @example "github" + * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier. + * @example "user_01EHZNVPK3SFK441A1RGBFSHRT" + * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization. + * @example "org_01EHZNVPK3SFK441A1RGBFSHRT" * @returns {Promise} * @throws {BadRequestException} 400 * @throws {UnauthorizedException} 401 @@ -195,6 +342,80 @@ export class Pipes { return deserializeConnectedAccount(data); } + /** + * Import a connected account + * + * Imports a [connected account](https://workos.com/docs/reference/pipes/connected-account) for a user by providing OAuth tokens directly. Use this to migrate existing connections or set up connections without going through the OAuth flow. + * @param options - Additional query options. + * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier. + * @example "user_01EHZNVPK3SFK441A1RGBFSHRT" + * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`). + * @example "github" + * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization. + * @example "org_01EHZNVPK3SFK441A1RGBFSHRT" + * @returns {Promise} + * @throws {UnauthorizedException} 401 + * @throws {NotFoundException} 404 + * @throws {ConflictException} 409 + * @throws {UnprocessableEntityException} 422 + */ + async createUserConnectedAccount( + options: CreateUserConnectedAccountOptions, + ): Promise { + const { userId, slug, organizationId, ...payload } = options; + const { data } = await this.workos.post< + ConnectedAccountResponse, + ConnectedAccountDtoResponse + >( + `/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, + serializeConnectedAccountDto(payload), + { + query: { + ...(options.organizationId !== undefined && { + organization_id: options.organizationId, + }), + }, + }, + ); + return deserializeConnectedAccount(data); + } + + /** + * Update a connected account + * + * Updates a user's [connected account](https://workos.com/docs/reference/pipes/connected-account) tokens, scopes, or state for a specific provider. + * @param options - Additional query options. + * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier. + * @example "user_01EHZNVPK3SFK441A1RGBFSHRT" + * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`). + * @example "github" + * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization. + * @example "org_01EHZNVPK3SFK441A1RGBFSHRT" + * @returns {Promise} + * @throws {UnauthorizedException} 401 + * @throws {NotFoundException} 404 + */ + async updateUserConnectedAccount( + options: UpdateUserConnectedAccountOptions, + ): Promise { + const { userId, slug, organizationId, ...payload } = options; + const { data } = await this.workos.put< + ConnectedAccountResponse, + ConnectedAccountDtoResponse + >( + `/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, + serializeConnectedAccountDto(payload), + { + query: { + ...(options.organizationId !== undefined && { + organization_id: options.organizationId, + }), + }, + }, + ); + return deserializeConnectedAccount(data); + } + /** * Delete a connected account * diff --git a/src/pipes/serializers.spec.ts b/src/pipes/serializers.spec.ts index 02474bce3..cefec2676 100644 --- a/src/pipes/serializers.spec.ts +++ b/src/pipes/serializers.spec.ts @@ -1,27 +1,39 @@ // This file is auto-generated by oagen. Do not edit. import { deserializeDataIntegrationAuthorizeUrlResponse } from './serializers/data-integration-authorize-url-response.serializer'; +import { deserializeDataIntegrationCredentialsResponse } from './serializers/data-integration-credentials-response.serializer'; import { deserializeConnectedAccount } from './serializers/connected-account.serializer'; import { deserializeDataIntegrationsListResponse } from './serializers/data-integrations-list-response.serializer'; import { deserializeDataIntegrationsListResponseData } from './serializers/data-integrations-list-response-data.serializer'; +import { deserializeDataIntegrationCredentialsResponseCredential } from './serializers/data-integration-credentials-response-credential.serializer'; import { deserializeDataIntegrationAccessTokenResponseAccessToken } from './serializers/data-integration-access-token-response-access-token.serializer'; +import { serializeDataIntegrationsUpsertApiKeyRequest } from './serializers/data-integrations-upsert-api-key-request.serializer'; import { serializeDataIntegrationsGetDataIntegrationAuthorizeUrlRequest } from './serializers/data-integrations-get-data-integration-authorize-url-request.serializer'; +import { serializeDataIntegrationsVendCredentialsRequest } from './serializers/data-integrations-vend-credentials-request.serializer'; import { serializeDataIntegrationsGetUserTokenRequest } from './serializers/data-integrations-get-user-token-request.serializer'; import { deserializeDataIntegrationsListResponseDataConnectedAccount } from './serializers/data-integrations-list-response-data-connected-account.serializer'; import type { DataIntegrationAuthorizeUrlResponseWire } from './interfaces/data-integration-authorize-url-response.interface'; +import type { DataIntegrationCredentialsResponseWire } from './interfaces/data-integration-credentials-response.interface'; import type { ConnectedAccountResponse } from './interfaces/connected-account.interface'; import type { DataIntegrationsListResponseWire } from './interfaces/data-integrations-list-response.interface'; import type { DataIntegrationsListResponseDataResponse } from './interfaces/data-integrations-list-response-data.interface'; +import type { DataIntegrationCredentialsResponseCredentialResponse } from './interfaces/data-integration-credentials-response-credential.interface'; import type { DataIntegrationAccessTokenResponseAccessTokenResponse } from './interfaces/data-integration-access-token-response-access-token.interface'; +import type { DataIntegrationsUpsertApiKeyRequestResponse } from './interfaces/data-integrations-upsert-api-key-request.interface'; import type { DataIntegrationsGetDataIntegrationAuthorizeUrlRequestResponse } from './interfaces/data-integrations-get-data-integration-authorize-url-request.interface'; +import type { DataIntegrationsVendCredentialsRequestResponse } from './interfaces/data-integrations-vend-credentials-request.interface'; import type { DataIntegrationsGetUserTokenRequestResponse } from './interfaces/data-integrations-get-user-token-request.interface'; import type { DataIntegrationsListResponseDataConnectedAccountResponse } from './interfaces/data-integrations-list-response-data-connected-account.interface'; import dataIntegrationAuthorizeUrlResponseFixture from './fixtures/data-integration-authorize-url-response.json'; +import dataIntegrationCredentialsResponseFixture from './fixtures/data-integration-credentials-response.json'; import connectedAccountFixture from './fixtures/connected-account.json'; import dataIntegrationsListResponseFixture from './fixtures/data-integrations-list-response.json'; import dataIntegrationsListResponseDataFixture from './fixtures/data-integrations-list-response-data.json'; +import dataIntegrationCredentialsResponseCredentialFixture from './fixtures/data-integration-credentials-response-credential.json'; import dataIntegrationAccessTokenResponseAccessTokenFixture from './fixtures/data-integration-access-token-response-access-token.json'; +import dataIntegrationsUpsertApiKeyRequestFixture from './fixtures/data-integrations-upsert-api-key-request.json'; import dataIntegrationsGetDataIntegrationAuthorizeUrlRequestFixture from './fixtures/data-integrations-get-data-integration-authorize-url-request.json'; +import dataIntegrationsVendCredentialsRequestFixture from './fixtures/data-integrations-vend-credentials-request.json'; import dataIntegrationsGetUserTokenRequestFixture from './fixtures/data-integrations-get-user-token-request.json'; import dataIntegrationsListResponseDataConnectedAccountFixture from './fixtures/data-integrations-list-response-data-connected-account.json'; @@ -35,6 +47,15 @@ describe('DataIntegrationAuthorizeUrlResponseSerializer', () => { }); }); +describe('DataIntegrationCredentialsResponseSerializer', () => { + it('deserializes correctly', () => { + const fixture = + dataIntegrationCredentialsResponseFixture as DataIntegrationCredentialsResponseWire; + const deserialized = deserializeDataIntegrationCredentialsResponse(fixture); + expect(deserialized).toBeDefined(); + }); +}); + describe('ConnectedAccountSerializer', () => { it('deserializes correctly', () => { const fixture = connectedAccountFixture as ConnectedAccountResponse; @@ -61,6 +82,16 @@ describe('DataIntegrationsListResponseDataSerializer', () => { }); }); +describe('DataIntegrationCredentialsResponseCredentialSerializer', () => { + it('deserializes correctly', () => { + const fixture = + dataIntegrationCredentialsResponseCredentialFixture as DataIntegrationCredentialsResponseCredentialResponse; + const deserialized = + deserializeDataIntegrationCredentialsResponseCredential(fixture); + expect(deserialized).toBeDefined(); + }); +}); + describe('DataIntegrationAccessTokenResponseAccessTokenSerializer', () => { it('deserializes correctly', () => { const fixture = @@ -71,6 +102,17 @@ describe('DataIntegrationAccessTokenResponseAccessTokenSerializer', () => { }); }); +describe('DataIntegrationsUpsertApiKeyRequestSerializer', () => { + it('serializes correctly', () => { + const fixture = + dataIntegrationsUpsertApiKeyRequestFixture as DataIntegrationsUpsertApiKeyRequestResponse; + const serialized = serializeDataIntegrationsUpsertApiKeyRequest( + fixture as any, + ); + expect(serialized).toBeDefined(); + }); +}); + describe('DataIntegrationsGetDataIntegrationAuthorizeUrlRequestSerializer', () => { it('serializes correctly', () => { const fixture = @@ -83,6 +125,17 @@ describe('DataIntegrationsGetDataIntegrationAuthorizeUrlRequestSerializer', () = }); }); +describe('DataIntegrationsVendCredentialsRequestSerializer', () => { + it('serializes correctly', () => { + const fixture = + dataIntegrationsVendCredentialsRequestFixture as DataIntegrationsVendCredentialsRequestResponse; + const serialized = serializeDataIntegrationsVendCredentialsRequest( + fixture as any, + ); + expect(serialized).toBeDefined(); + }); +}); + describe('DataIntegrationsGetUserTokenRequestSerializer', () => { it('serializes correctly', () => { const fixture = diff --git a/src/pipes/serializers/connected-account-dto.serializer.ts b/src/pipes/serializers/connected-account-dto.serializer.ts new file mode 100644 index 000000000..0cb5fb241 --- /dev/null +++ b/src/pipes/serializers/connected-account-dto.serializer.ts @@ -0,0 +1,17 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { + ConnectedAccountDto, + ConnectedAccountDtoResponse, +} from '../interfaces/connected-account-dto.interface'; + +export const serializeConnectedAccountDto = ( + model: ConnectedAccountDto, +): ConnectedAccountDtoResponse => ({ + access_token: model.accessToken, + refresh_token: model.refreshToken, + expires_at: + model.expiresAt != null ? model.expiresAt.toISOString() : undefined, + scopes: model.scopes, + state: model.state, +}); diff --git a/src/pipes/serializers/create-data-integration.serializer.ts b/src/pipes/serializers/create-data-integration.serializer.ts new file mode 100644 index 000000000..20de7b81c --- /dev/null +++ b/src/pipes/serializers/create-data-integration.serializer.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { + CreateDataIntegration, + CreateDataIntegrationResponse, +} from '../interfaces/create-data-integration.interface'; +import { serializeDataIntegrationCredentialsDto } from './data-integration-credentials-dto.serializer'; +import { serializeCustomProviderDefinition } from './custom-provider-definition.serializer'; + +export const serializeCreateDataIntegration = ( + model: CreateDataIntegration, +): CreateDataIntegrationResponse => ({ + provider: model.provider, + description: model.description ?? null, + enabled: model.enabled, + scopes: model.scopes ?? null, + credentials: + model.credentials != null + ? serializeDataIntegrationCredentialsDto(model.credentials) + : undefined, + custom_provider: + model.customProvider != null + ? serializeCustomProviderDefinition(model.customProvider) + : undefined, +}); diff --git a/src/pipes/serializers/custom-provider-definition.serializer.ts b/src/pipes/serializers/custom-provider-definition.serializer.ts new file mode 100644 index 000000000..f26dc336f --- /dev/null +++ b/src/pipes/serializers/custom-provider-definition.serializer.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { + CustomProviderDefinition, + CustomProviderDefinitionResponse, +} from '../interfaces/custom-provider-definition.interface'; + +export const serializeCustomProviderDefinition = ( + model: CustomProviderDefinition, +): CustomProviderDefinitionResponse => ({ + name: model.name, + authorization_url: model.authorizationUrl, + token_url: model.tokenUrl, + refresh_token_url: model.refreshTokenUrl ?? null, + pkce_enabled: model.pkceEnabled, + request_scope_separator: model.requestScopeSeparator, + scopes_required: model.scopesRequired, + client_secret_required: model.clientSecretRequired, + additional_authorization_parameters: model.additionalAuthorizationParameters, + token_body_content_type: model.tokenBodyContentType, + authenticate_via: model.authenticateVia, +}); diff --git a/src/pipes/serializers/data-integration-credential.serializer.ts b/src/pipes/serializers/data-integration-credential.serializer.ts new file mode 100644 index 000000000..57032a700 --- /dev/null +++ b/src/pipes/serializers/data-integration-credential.serializer.ts @@ -0,0 +1,14 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { + DataIntegrationCredential, + DataIntegrationCredentialResponse, +} from '../interfaces/data-integration-credential.interface'; + +export const deserializeDataIntegrationCredential = ( + response: DataIntegrationCredentialResponse, +): DataIntegrationCredential => ({ + type: response.type, + clientId: response.client_id ?? null, + redactedClientSecret: response.redacted_client_secret ?? null, +}); diff --git a/src/pipes/serializers/data-integration-credentials-dto.serializer.ts b/src/pipes/serializers/data-integration-credentials-dto.serializer.ts new file mode 100644 index 000000000..e0d056371 --- /dev/null +++ b/src/pipes/serializers/data-integration-credentials-dto.serializer.ts @@ -0,0 +1,14 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { + DataIntegrationCredentialsDto, + DataIntegrationCredentialsDtoResponse, +} from '../interfaces/data-integration-credentials-dto.interface'; + +export const serializeDataIntegrationCredentialsDto = ( + model: DataIntegrationCredentialsDto, +): DataIntegrationCredentialsDtoResponse => ({ + type: model.type, + client_id: model.clientId, + client_secret: model.clientSecret, +}); diff --git a/src/pipes/serializers/data-integration-custom-provider.serializer.ts b/src/pipes/serializers/data-integration-custom-provider.serializer.ts new file mode 100644 index 000000000..886394e16 --- /dev/null +++ b/src/pipes/serializers/data-integration-custom-provider.serializer.ts @@ -0,0 +1,23 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { + DataIntegrationCustomProvider, + DataIntegrationCustomProviderResponse, +} from '../interfaces/data-integration-custom-provider.interface'; + +export const deserializeDataIntegrationCustomProvider = ( + response: DataIntegrationCustomProviderResponse, +): DataIntegrationCustomProvider => ({ + name: response.name, + authorizationUrl: response.authorization_url ?? null, + tokenUrl: response.token_url ?? null, + refreshTokenUrl: response.refresh_token_url ?? null, + pkceEnabled: response.pkce_enabled, + requestScopeSeparator: response.request_scope_separator, + scopesRequired: response.scopes_required, + clientSecretRequired: response.client_secret_required, + additionalAuthorizationParameters: + response.additional_authorization_parameters, + tokenBodyContentType: response.token_body_content_type, + authenticateVia: response.authenticate_via, +}); diff --git a/src/pipes/serializers/data-integration.serializer.ts b/src/pipes/serializers/data-integration.serializer.ts new file mode 100644 index 000000000..ba6282f17 --- /dev/null +++ b/src/pipes/serializers/data-integration.serializer.ts @@ -0,0 +1,29 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { + DataIntegration, + DataIntegrationResponse, +} from '../interfaces/data-integration.interface'; +import { deserializeDataIntegrationCredential } from './data-integration-credential.serializer'; +import { deserializeDataIntegrationCustomProvider } from './data-integration-custom-provider.serializer'; + +export const deserializeDataIntegration = ( + response: DataIntegrationResponse, +): DataIntegration => ({ + object: response.object, + id: response.id, + slug: response.slug, + integrationType: response.integration_type, + description: response.description ?? null, + enabled: response.enabled, + state: response.state, + scopes: response.scopes ?? null, + redirectUri: response.redirect_uri, + credentials: deserializeDataIntegrationCredential(response.credentials), + customProvider: + response.custom_provider != null + ? deserializeDataIntegrationCustomProvider(response.custom_provider) + : null, + createdAt: new Date(response.created_at), + updatedAt: new Date(response.updated_at), +}); diff --git a/src/pipes/serializers/index.ts b/src/pipes/serializers/index.ts index d14594c28..6157e2e3c 100644 --- a/src/pipes/serializers/index.ts +++ b/src/pipes/serializers/index.ts @@ -1,10 +1,17 @@ // This file is auto-generated by oagen. Do not edit. export * from './connected-account.serializer'; +export * from './connected-account-dto.serializer'; +export * from './create-data-integration.serializer'; +export * from './custom-provider-definition.serializer'; +export * from './data-integration.serializer'; export * from './data-integration-access-token-response-access-token.serializer'; export * from './data-integration-authorize-url-response.serializer'; +export * from './data-integration-credential.serializer'; +export * from './data-integration-credentials-dto.serializer'; export * from './data-integration-credentials-response.serializer'; export * from './data-integration-credentials-response-credential.serializer'; +export * from './data-integration-custom-provider.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'; @@ -12,3 +19,5 @@ export * from './data-integrations-list-response-data.serializer'; export * from './data-integrations-list-response-data-connected-account.serializer'; export * from './data-integrations-upsert-api-key-request.serializer'; export * from './data-integrations-vend-credentials-request.serializer'; +export * from './update-custom-provider-definition.serializer'; +export * from './update-data-integration.serializer'; diff --git a/src/pipes/serializers/update-custom-provider-definition.serializer.ts b/src/pipes/serializers/update-custom-provider-definition.serializer.ts new file mode 100644 index 000000000..517aada92 --- /dev/null +++ b/src/pipes/serializers/update-custom-provider-definition.serializer.ts @@ -0,0 +1,22 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { + UpdateCustomProviderDefinition, + UpdateCustomProviderDefinitionResponse, +} from '../interfaces/update-custom-provider-definition.interface'; + +export const serializeUpdateCustomProviderDefinition = ( + model: UpdateCustomProviderDefinition, +): UpdateCustomProviderDefinitionResponse => ({ + name: model.name, + authorization_url: model.authorizationUrl, + token_url: model.tokenUrl, + refresh_token_url: model.refreshTokenUrl ?? null, + pkce_enabled: model.pkceEnabled, + request_scope_separator: model.requestScopeSeparator, + scopes_required: model.scopesRequired, + client_secret_required: model.clientSecretRequired, + additional_authorization_parameters: model.additionalAuthorizationParameters, + token_body_content_type: model.tokenBodyContentType, + authenticate_via: model.authenticateVia, +}); diff --git a/src/pipes/serializers/update-data-integration.serializer.ts b/src/pipes/serializers/update-data-integration.serializer.ts new file mode 100644 index 000000000..b464636bd --- /dev/null +++ b/src/pipes/serializers/update-data-integration.serializer.ts @@ -0,0 +1,24 @@ +// This file is auto-generated by oagen. Do not edit. + +import type { + UpdateDataIntegration, + UpdateDataIntegrationResponse, +} from '../interfaces/update-data-integration.interface'; +import { serializeDataIntegrationCredentialsDto } from './data-integration-credentials-dto.serializer'; +import { serializeUpdateCustomProviderDefinition } from './update-custom-provider-definition.serializer'; + +export const serializeUpdateDataIntegration = ( + model: UpdateDataIntegration, +): UpdateDataIntegrationResponse => ({ + description: model.description ?? null, + enabled: model.enabled, + scopes: model.scopes ?? null, + credentials: + model.credentials != null + ? serializeDataIntegrationCredentialsDto(model.credentials) + : undefined, + custom_provider: + model.customProvider != null + ? serializeUpdateCustomProviderDefinition(model.customProvider) + : undefined, +});