import type { ConnectorInstance, Credential, OauthAppConfig, SyncLog } from "../_internal/types.gen"; import type { RequestOptions } from "../base-client"; import { RequestBuilder } from "../request-builder"; /** * Attributes accepted by the ConnectorInstance `:create` action. * Mirrors `connector_instance.ex :create accept` list. */ export interface CreateConnectorInstanceAttributes { workspace_id: string; name: string; connector_type: string; config?: Record; enabled?: boolean; sync_interval_minutes?: number; metadata?: Record; } /** * Attributes accepted by the ConnectorInstance `:update` action. * Mirrors `connector_instance.ex :update accept` list. */ export interface UpdateConnectorInstanceAttributes { name?: string; config?: Record; enabled?: boolean; sync_interval_minutes?: number; health_status?: string; metadata?: Record; } /** * Attributes for creating an OAuthAppConfig. * Mirrors `oauth_app_config.ex :create` accept list. `platform` and * `scope_type` are required by the resource; `application_id`/`tenant_id` * are required depending on `scope_type` (enforced server-side). */ export interface CreateOAuthAppConfigAttributes { platform: "facebook" | "instagram" | "threads" | "twitter" | "linkedin" | "reddit" | "bluesky"; client_id: string; client_secret: string; scopes?: string[]; scope_type: "application" | "tenant"; application_id?: string; tenant_id?: string; } /** * Attributes for updating an OAuthAppConfig. * Mirrors `oauth_app_config.ex :update` accept list. */ export interface UpdateOAuthAppConfigAttributes { client_id?: string; client_secret?: string; scopes?: string[]; } /** Attributes for creating a ConnectorTool via ISV API. */ export interface CreateConnectorToolAttributes { name: string; display_name: string; description: string; execution_type: "http" | "mcp"; method?: "get" | "post" | "put" | "patch" | "delete"; path_template?: string; parameters?: Record[]; request_body_schema?: Record; headers?: Record; mcp_server_url?: string; mcp_tool_name?: string; mcp_input_schema?: Record; timeout_ms?: number; rate_limit_per_minute?: number; workspace_id: string; } /** Attributes for updating a ConnectorTool. */ export interface UpdateConnectorToolAttributes { display_name?: string; description?: string; method?: string; path_template?: string; parameters?: Record[]; request_body_schema?: Record; headers?: Record; timeout_ms?: number; } /** * A ConnectorTool record as returned by the ISV API. * * The ISV controller (`lib/gpt_core_web/controllers/isv_connector_tool_controller.ex`) * is NOT an AshJsonApi endpoint — it returns a flat map wrapped in `{data: ...}`, * not the JSON:API `{id, type, attributes}` envelope. */ export interface ConnectorTool { id: string; name: string; display_name: string | null; description: string | null; execution_type: "http" | "mcp"; method: string | null; path_template: string | null; parameters: Record[] | null; headers: Record | null; response_mapping: Record | null; request_body_schema: Record | null; confirmation_level: string | null; rate_limit_per_minute: number | null; timeout_ms: number | null; retry_count: number | null; retry_backoff_ms: number | null; retryable_status_codes: number[] | null; mock_response: Record | null; test_parameters: Record | null; source_metadata: Record | null; status: "draft" | "active" | "inactive"; version: number; source: string | null; connector_instance_id: string; } /** * Admin connectors namespace — ISV-level connector management. * * Provides full CRUD for connector instances, credentials, OAuth app configs, * sync logs, and ISV-defined connector tools. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * * // Manage OAuth app configs * const configs = await admin.connectors.oauthAppConfigs.list(); * * // Manage ISV-defined connector tools * const tools = await admin.connectors.tools.list('connector-id-123'); * ``` */ export declare function createConnectorsNamespace(rb: RequestBuilder): { /** Connector instances — configured external system connections. */ instances: { /** * List connector instances for a workspace. * * @param workspaceId - UUID of the workspace whose connector instances to list. * @returns Array of `ConnectorInstance` records. * @example * ```typescript * const instances = await admin.connectors.instances.list(workspaceId); * ``` */ list: (workspaceId: string, options?: RequestOptions) => Promise; /** * Get a connector instance by ID. * * @param id - UUID of the `ConnectorInstance` to fetch. * @returns The matching `ConnectorInstance` record. * @example * ```typescript * const instance = await admin.connectors.instances.get(instanceId); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** * Create a connector instance. * * @param attributes - Required fields (`workspace_id`, `name`, `connector_type`) plus optional `config`, `enabled`, `sync_interval_minutes`, `metadata`. * @returns The newly created `ConnectorInstance`. * @example * ```typescript * const instance = await admin.connectors.instances.create({ * workspace_id: workspaceId, * name: "Acme Salesforce", * connector_type: "salesforce", * }); * ``` */ create: (attributes: CreateConnectorInstanceAttributes, options?: RequestOptions) => Promise; /** * Update a connector instance. * * @param id - UUID of the `ConnectorInstance` to update. * @param attributes - Mutable fields: `name`, `config`, `enabled`, `sync_interval_minutes`, `health_status`, `metadata`. Omit any field to leave it unchanged. * @returns The updated `ConnectorInstance`. * @example * ```typescript * await admin.connectors.instances.update(instanceId, { * name: "Acme Salesforce — Production", * enabled: true, * }); * ``` */ update: (id: string, attributes: UpdateConnectorInstanceAttributes, options?: RequestOptions) => Promise; /** * Delete a connector instance (hard delete — also destroys credentials). * * @param id - UUID of the `ConnectorInstance` to delete. * @returns `true` once the deletion completes. * @example * ```typescript * await admin.connectors.instances.delete(instanceId); * ``` */ delete: (id: string, options?: RequestOptions) => Promise; }; /** Credentials — OAuth tokens and API keys. */ credentials: { /** * List all credentials across the admin's workspaces. * * @param options - Optional per-request configuration (e.g. abort `signal`, extra `headers`). * @returns Array of `Credential` records visible to the calling admin actor. * @example * ```typescript * const credentials = await admin.connectors.credentials.list(); * ``` */ list: (options?: RequestOptions) => Promise; /** * Get a credential by ID. * * @param id - UUID of the `Credential` to fetch. * @returns The matching `Credential` record (secret material is never returned in full — only metadata). * @example * ```typescript * const credential = await admin.connectors.credentials.get(credentialId); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** * Refresh an OAuth credential, exchanging the stored refresh token for * a new access token. Returns the updated credential. * * @param id - UUID of the `Credential` to refresh. * @param workspaceId - UUID of the workspace the credential belongs to (used for tenant scoping). * @returns The refreshed `Credential` with rotated access token metadata. * @example * ```typescript * const refreshed = await admin.connectors.credentials.refresh( * credentialId, * workspaceId, * ); * ``` */ refresh: (id: string, workspaceId: string, options?: RequestOptions) => Promise; }; /** Sync log access — read-only audit of sync activity. */ sync: { /** * List sync logs for the admin's workspaces. * * @param options - Optional per-request configuration (e.g. abort `signal`, extra `headers`). * @returns Array of `SyncLog` records describing recent sync activity. * @example * ```typescript * const logs = await admin.connectors.sync.logs(); * ``` */ logs: (options?: RequestOptions) => Promise; /** * Get a single sync log by ID. * * @param id - UUID of the `SyncLog` to fetch. * @returns The matching `SyncLog` record. * @example * ```typescript * const log = await admin.connectors.sync.log(syncLogId); * ``` */ log: (id: string, options?: RequestOptions) => Promise; }; /** OAuth — initiate and complete OAuth authorization flows. */ oauth: { /** * Get the OAuth authorization URL for a connector type. * Returns `{ auth_url, state }`; redirect the user to `auth_url` and * pass `state` back to `oauth.callback` to complete the flow. * * @param connectorType - Connector slug (e.g. `"salesforce"`, `"sharepoint"`, `"hubspot"`) registered in `AdapterRegistry`. * @param workspaceId - UUID of the workspace the resulting credential will belong to. * @returns Object with `auth_url` (provider authorization URL to redirect the browser to) and opaque `state` (echo back in the callback). * @example * ```typescript * const { auth_url, state } = await admin.connectors.oauth.connect( * "salesforce", * workspaceId, * ); * window.location.href = auth_url; * ``` */ connect: (connectorType: string, workspaceId: string, options?: RequestOptions) => Promise<{ auth_url: string; state: string; }>; /** * Exchange an OAuth authorization code for a stored credential. * * @param connectorType - Connector slug previously passed to `oauth.connect`. * @param code - Authorization code received from the provider redirect. * @param state - Opaque value originally returned by `oauth.connect`; verified server-side. * @param workspaceId - UUID of the workspace the credential will be persisted to. * @param redirectUri - Optional override for the OAuth redirect URI. Must match the value used in `oauth.connect` if supplied. * @returns The `ConnectorInstance` linked to the newly stored credential. * @example * ```typescript * const instance = await admin.connectors.oauth.callback( * "salesforce", * code, * state, * workspaceId, * ); * ``` */ callback: (connectorType: string, code: string, state: string, workspaceId: string, redirectUri?: string, options?: RequestOptions) => Promise; }; /** OAuth App Configs — ISV-managed OAuth client credentials per connector type. */ oauthAppConfigs: { /** * List all OAuth app configs. * * @param options - Optional per-request configuration (e.g. abort `signal`, extra `headers`). * @returns Array of `OauthAppConfig` records visible to the calling admin actor. * @example * ```typescript * const configs = await admin.connectors.oauthAppConfigs.list(); * ``` */ list: (options?: RequestOptions) => Promise; /** * Get an OAuth app config by ID. * * @param id - UUID of the `OAuthAppConfig` to fetch. * @returns The matching `OauthAppConfig` record. * @example * ```typescript * const config = await admin.connectors.oauthAppConfigs.get(configId); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** * Create an OAuth app config. * * Exactly one of `application_id` / `tenant_id` must match the * `scope_type`. `platform` is required and must be one of the social * platforms supported by OAuthAppConfig. * * @param attributes - Required `platform`, `client_id`, `client_secret`, `scope_type`; plus the matching `application_id` or `tenant_id` and optional `scopes`. * @returns The newly created `OauthAppConfig`. * @example * ```typescript * await admin.connectors.oauthAppConfigs.create({ * platform: "linkedin", * client_id: "xxx", * client_secret: "yyy", * scope_type: "application", * application_id: appId, * }); * ``` */ create: (attributes: CreateOAuthAppConfigAttributes, options?: RequestOptions) => Promise; /** * Update an OAuth app config. Only the mutable credential fields * (`client_id`, `client_secret`, `scopes`) can be updated. * * @param id - UUID of the `OAuthAppConfig` to update. * @param attributes - Optional `client_id`, `client_secret`, `scopes`. Omit any field to leave it unchanged. * @returns The updated `OauthAppConfig`. * @example * ```typescript * await admin.connectors.oauthAppConfigs.update(configId, { * client_secret: "rotated-secret", * }); * ``` */ update: (id: string, attributes: UpdateOAuthAppConfigAttributes, options?: RequestOptions) => Promise; /** * Delete an OAuth app config. * * @param id - UUID of the `OAuthAppConfig` to delete. * @returns `true` once the deletion completes. * @example * ```typescript * await admin.connectors.oauthAppConfigs.delete(configId); * ``` */ delete: (id: string, options?: RequestOptions) => Promise; }; /** * ISV-Defined Connector Tools — custom API integration tools. * * These use custom Phoenix controller routes (not JSON:API), so methods * make raw HTTP calls via the request builder. */ tools: { /** * List all tools defined for a connector instance, including drafts. * * @param connectorId - UUID of the parent `ConnectorInstance`. * @returns Array of `ConnectorTool` records (draft, active, and inactive). * @example * ```typescript * const tools = await admin.connectors.tools.list(connectorId); * ``` */ list: (connectorId: string, options?: RequestOptions) => Promise; /** * Get a specific tool by ID. * * @param connectorId - UUID of the parent `ConnectorInstance`. * @param toolId - UUID of the `ConnectorTool` to fetch. * @returns The matching `ConnectorTool` record. * @example * ```typescript * const tool = await admin.connectors.tools.get(connectorId, toolId); * ``` */ get: (connectorId: string, toolId: string, options?: RequestOptions) => Promise; /** * Create a new connector tool. Tools start in `status: "draft"` — * call `tools.activate()` to enable them. * * @param connectorId - UUID of the parent `ConnectorInstance` the tool belongs to. * @param attributes - Tool definition: `name`, `display_name`, `description`, `execution_type`, `workspace_id`, plus HTTP-specific (`method`, `path_template`, `parameters`, etc.) or MCP-specific (`mcp_server_url`, `mcp_tool_name`, `mcp_input_schema`) fields. * @returns The newly created `ConnectorTool` in draft status. * @example * ```typescript * const tool = await admin.connectors.tools.create(connectorId, { * name: "list_contacts", * display_name: "List Contacts", * description: "Retrieve contacts from the CRM", * execution_type: "http", * method: "get", * path_template: "/api/v1/contacts", * workspace_id: workspaceId, * }); * ``` */ create: (connectorId: string, attributes: CreateConnectorToolAttributes, options?: RequestOptions) => Promise; /** * Update a connector tool. Updating attributes increments the tool * version and busts the workspace tool cache. * * @param connectorId - UUID of the parent `ConnectorInstance`. * @param toolId - UUID of the `ConnectorTool` to update. * @param attributes - Mutable fields: `display_name`, `description`, `method`, `path_template`, `parameters`, `request_body_schema`, `headers`, `timeout_ms`. Omit any field to leave it unchanged. * @returns The updated `ConnectorTool` with an incremented `version`. * @example * ```typescript * await admin.connectors.tools.update(connectorId, toolId, { * description: "Updated description", * }); * ``` */ update: (connectorId: string, toolId: string, attributes: UpdateConnectorToolAttributes, options?: RequestOptions) => Promise; /** * Delete a connector tool. * * @param connectorId - UUID of the parent `ConnectorInstance`. * @param toolId - UUID of the `ConnectorTool` to delete. * @returns `true` once the deletion completes. * @example * ```typescript * await admin.connectors.tools.delete(connectorId, toolId); * ``` */ delete: (connectorId: string, toolId: string, options?: RequestOptions) => Promise; /** * Activate a draft or inactive tool. MCP tools are health-checked * before activation; unreachable servers reject the call. * * @param connectorId - UUID of the parent `ConnectorInstance`. * @param toolId - UUID of the `ConnectorTool` to activate. * @returns The updated `ConnectorTool` with `status: "active"`. * @example * ```typescript * await admin.connectors.tools.activate(connectorId, toolId); * ``` */ activate: (connectorId: string, toolId: string, options?: RequestOptions) => Promise; /** * Deactivate an active tool. * * @param connectorId - UUID of the parent `ConnectorInstance`. * @param toolId - UUID of the `ConnectorTool` to deactivate. * @returns The updated `ConnectorTool` with `status: "inactive"`. * @example * ```typescript * await admin.connectors.tools.deactivate(connectorId, toolId); * ``` */ deactivate: (connectorId: string, toolId: string, options?: RequestOptions) => Promise; /** * Test-execute a tool using its stored `test_parameters` (mock run). * Returns the provider response for verification before activation. * * @param connectorId - UUID of the parent `ConnectorInstance`. * @param toolId - UUID of the `ConnectorTool` to test-execute. * @returns The raw provider response payload (shape varies by tool). * @example * ```typescript * const result = await admin.connectors.tools.test(connectorId, toolId); * ``` */ test: (connectorId: string, toolId: string, options?: RequestOptions) => Promise>; /** * Import tools from an OpenAPI spec. The server parses the spec, * ranks endpoints by usefulness, and persists the top matches as * draft tools. * * @param connectorId - UUID of the parent `ConnectorInstance` the imported tools will belong to. * @param spec - Import payload — typically `{ spec_url }` (URL to fetch) or `{ spec }` (inline OpenAPI document), plus optional `limit` and AI-ranking knobs. * @returns Array of newly created `ConnectorTool` records, all in `status: "draft"`. * @example * ```typescript * const result = await admin.connectors.tools.import(connectorId, { * spec_url: "https://api.example.com/openapi.json", * limit: 20, * }); * ``` */ import: (connectorId: string, spec: Record, options?: RequestOptions) => Promise; }; }; //# sourceMappingURL=connectors.d.ts.map