-
Notifications
You must be signed in to change notification settings - Fork 11
feat(integration-service): add Connections service #554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
maninder-uipath
wants to merge
1
commit into
main
Choose a base branch
from
feat/is-connections
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,220 @@ | ||
| /** | ||
| * Integration Service — Connection models | ||
| * | ||
| * Combines raw connection data with bound entity methods (`ping`, `reauthenticate`). | ||
| */ | ||
|
|
||
| import { | ||
| RawConnectionGetResponse, | ||
| ConnectionGetAllOptions, | ||
| ConnectionGetByIdOptions, | ||
| ConnectionPingOptions, | ||
| ConnectionPingResponse, | ||
| ConnectionReauthenticateOptions, | ||
| ConnectionReauthenticateResponse, | ||
| } from './connections.types'; | ||
|
|
||
| /** | ||
| * A Connection entity enriched with bound methods. | ||
| * | ||
| * Returned by every Connection-yielding method on the {@link ConnectionsServiceModel} | ||
| * and {@link ConnectorsServiceModel}. The bound methods (`ping`, `reauthenticate`) | ||
| * close over this connection's ID so callers can act on the entity directly. | ||
| */ | ||
| export type ConnectionGetResponse = RawConnectionGetResponse & ConnectionMethods; | ||
|
|
||
| /** | ||
| * Service for managing UiPath Integration Service connections. | ||
| * | ||
| * A connection represents an authenticated link to a third-party system (Salesforce, | ||
| * Slack, OneDrive, ...) inside a UiPath folder. Use this service to list connections, | ||
| * inspect a single connection, check connectivity, or trigger re-authentication. | ||
| * | ||
| * ### Usage | ||
| * | ||
| * Prerequisites: Initialize the SDK first - see [Getting Started](/uipath-typescript/getting-started/#import-initialize) | ||
| * | ||
| * ```typescript | ||
| * import { Connections } from '@uipath/uipath-typescript/is-connections'; | ||
| * | ||
| * const connections = new Connections(sdk); | ||
| * const allConnections = await connections.getAll(); | ||
| * ``` | ||
| */ | ||
| export interface ConnectionsServiceModel { | ||
| /** | ||
| * Get all connections, optionally scoped to a folder. | ||
| * | ||
| * Returns a plain array of connection entities. Pagination is page-indexed | ||
| * via `pageIndex`/`pageSize`; there is no continuation cursor, so callers | ||
| * paginate by incrementing `pageIndex` until a short page is returned. | ||
| * | ||
| * @param options - Folder scoping, paging, sorting, and filter options | ||
| * @returns Promise resolving to an array of {@link ConnectionGetResponse} | ||
| * @example | ||
| * ```typescript | ||
| * import { Connections } from '@uipath/uipath-typescript/is-connections'; | ||
| * | ||
| * const connections = new Connections(sdk); | ||
| * | ||
| * // List the first page of connections in a folder | ||
| * const folderConnections = await connections.getAll({ | ||
| * folderKey: '<folderKey>', | ||
| * pageSize: 50, | ||
| * }); | ||
| * | ||
| * for (const conn of folderConnections) { | ||
| * console.log(`${conn.name} (${conn.state})`); | ||
| * } | ||
| * ``` | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * // Filter by name and connector | ||
| * const filtered = await connections.getAll({ | ||
| * folderKey: '<folderKey>', | ||
| * filter: "connector.key eq 'uipath-slack'", | ||
| * mostRecentFirst: true, | ||
| * }); | ||
| * ``` | ||
| */ | ||
| getAll(options?: ConnectionGetAllOptions): Promise<ConnectionGetResponse[]>; | ||
|
|
||
| /** | ||
| * Get a single connection by ID. | ||
| * | ||
| * @param connectionId - Connection GUID | ||
| * @param options - Folder scoping and optional `includeConfigs` flag | ||
| * @returns Promise resolving to a {@link ConnectionGetResponse} | ||
| * @example | ||
| * ```typescript | ||
| * import { Connections } from '@uipath/uipath-typescript/is-connections'; | ||
| * | ||
| * const connections = new Connections(sdk); | ||
| * | ||
| * // First, list connections to find the connectionId | ||
| * const list = await connections.getAll({ folderKey: '<folderKey>' }); | ||
| * const connectionId = list[0].id; | ||
| * | ||
| * const conn = await connections.getById(connectionId); | ||
| * console.log(conn.connector?.key, conn.state); | ||
| * ``` | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * // Include the full configuration blob | ||
| * const conn = await connections.getById('<connectionId>', { includeConfigs: true }); | ||
| * ``` | ||
| */ | ||
| getById(connectionId: string, options?: ConnectionGetByIdOptions): Promise<ConnectionGetResponse>; | ||
|
|
||
| /** | ||
| * Check whether a connection is currently active. | ||
| * | ||
| * Returns the resolved state plus an optional error message. Use this before | ||
| * invoking activities to surface a friendly error when the connection has | ||
| * expired or been disabled. | ||
| * | ||
| * @param connectionId - Connection GUID | ||
| * @param options - Folder scoping and `forceRefresh` flag | ||
| * @returns Promise resolving to a {@link ConnectionPingResponse} | ||
| * @example | ||
| * ```typescript | ||
| * import { Connections } from '@uipath/uipath-typescript/is-connections'; | ||
| * | ||
| * const connections = new Connections(sdk); | ||
| * | ||
| * const status = await connections.ping('<connectionId>'); | ||
| * if (status.status !== 'Enabled') { | ||
| * console.warn(`Connection unhealthy: ${status.status} — ${status.error ?? 'no detail'}`); | ||
| * } | ||
| * ``` | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * // Skip cache and force a live re-validation | ||
| * const status = await connections.ping('<connectionId>', { forceRefresh: true }); | ||
| * ``` | ||
| */ | ||
| ping(connectionId: string, options?: ConnectionPingOptions): Promise<ConnectionPingResponse>; | ||
|
|
||
| /** | ||
| * Start an OAuth re-authentication session for a connection. | ||
| * | ||
| * Returns a session handle plus the URL the end user must visit to grant or | ||
| * refresh consent. The session expires at {@link ConnectionReauthenticateResponse.expiresAt}. | ||
| * | ||
| * @param connectionId - Connection GUID | ||
| * @param options - Folder scoping options | ||
| * @returns Promise resolving to a {@link ConnectionReauthenticateResponse} | ||
| * @example | ||
| * ```typescript | ||
| * import { Connections } from '@uipath/uipath-typescript/is-connections'; | ||
| * | ||
| * const connections = new Connections(sdk); | ||
| * | ||
| * const session = await connections.reauthenticate('<connectionId>'); | ||
| * // Direct the user to session.authUrl to complete OAuth consent. | ||
| * console.log(`Visit: ${session.authUrl}`); | ||
| * ``` | ||
| */ | ||
| reauthenticate( | ||
| connectionId: string, | ||
| options?: ConnectionReauthenticateOptions, | ||
| ): Promise<ConnectionReauthenticateResponse>; | ||
| } | ||
|
|
||
| /** | ||
| * Methods bound onto every {@link ConnectionGetResponse} entity. | ||
| * | ||
| * Each method closes over the connection's ID and delegates to the | ||
| * underlying service. | ||
| */ | ||
| export interface ConnectionMethods { | ||
| /** | ||
| * Check whether this connection is currently active. | ||
| * | ||
| * @param options - Optional `forceRefresh` flag and folder scoping | ||
| * @returns Promise resolving to a {@link ConnectionPingResponse} | ||
| */ | ||
| ping(options?: ConnectionPingOptions): Promise<ConnectionPingResponse>; | ||
|
|
||
| /** | ||
| * Start an OAuth re-authentication session for this connection. | ||
| * | ||
| * @param options - Optional folder scoping | ||
| * @returns Promise resolving to a {@link ConnectionReauthenticateResponse} | ||
| */ | ||
| reauthenticate(options?: ConnectionReauthenticateOptions): Promise<ConnectionReauthenticateResponse>; | ||
| } | ||
|
|
||
| function createConnectionMethods( | ||
| data: RawConnectionGetResponse, | ||
| service: ConnectionsServiceModel, | ||
| ): ConnectionMethods { | ||
| return { | ||
| async ping(options?: ConnectionPingOptions): Promise<ConnectionPingResponse> { | ||
| if (!data.id) throw new Error('Connection id is undefined'); | ||
| return service.ping(data.id, options); | ||
| }, | ||
| async reauthenticate(options?: ConnectionReauthenticateOptions): Promise<ConnectionReauthenticateResponse> { | ||
| if (!data.id) throw new Error('Connection id is undefined'); | ||
| return service.reauthenticate(data.id, options); | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Attaches bound methods to a raw connection response. | ||
| * | ||
| * @param data - Raw connection data from the API | ||
| * @param service - The Connections service used to delegate bound-method calls | ||
| * @returns A {@link ConnectionGetResponse} (raw data + methods) | ||
| */ | ||
| export function createConnectionWithMethods( | ||
| data: RawConnectionGetResponse, | ||
| service: ConnectionsServiceModel, | ||
| ): ConnectionGetResponse { | ||
| const methods = createConnectionMethods(data, service); | ||
| return Object.assign({}, data, methods) as ConnectionGetResponse; | ||
|
Check warning on line 219 in src/models/integration-service/connections.models.ts
|
||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSDoc examples should use the enum rather than a raw string literal — per convention "Use enums for fixed value sets — NEVER leave raw strings/numbers" and "JSDoc
@exampleblocks that reference named types must include the import statement." Update the import and comparison:Also update the
importline at the top of this example block (line 122) to addConnectionState:The same fix is needed in the identical example in
src/services/integration-service/connections/connections.ts.