UNPKG

@salesforce/agents

Version:

Client side APIs for working with Salesforce agents

74 lines (73 loc) 2.81 kB
import { Connection, SfProject } from '@salesforce/core'; import { type AgentJson, type PublishAgent } from '../types'; /** * Service class responsible for publishing agents to Salesforce orgs */ export declare class ScriptAgentPublisher { private readonly connection; private project; private readonly agentJson; private readonly developerName; private readonly bundleMetaPath; private bundleDir; private readonly skipRetrieve; private readonly API_URL; private readonly API_HEADERS; /** * Creates a new AgentPublisher instance. * * @param connection The caller-supplied Connection. Used as the lookup key into the * ConnectionManager cache (managerFor()); never used directly for SFAP or org API calls. * @param project The Salesforce project * @param agentJson The compiled AgentJson to publish * @param skipMetadataRetrieve Whether to skip retrieving the agent metadata from the org */ constructor(connection: Connection, project: SfProject, agentJson: AgentJson, skipMetadataRetrieve?: boolean); /** * Publish an AgentJson representation to the org * * @returns Promise<PublishAgent> The publish response */ publishAgentJson(): Promise<PublishAgent>; /** * Validates and extracts the developer name from the agent configuration, * and locates the corresponding authoring bundle directory and metadata file. * * @returns An object containing: * - developerName: The agent's developer name * - bundleDir: The path to the authoring bundle directory * - bundleMetaPath: The full path to the bundle-meta.xml file * * @throws SfError if the authoring bundle directory or metadata file cannot be found */ private validateDeveloperName; /** * Retrieve the agent metadata from the org after publishing * * @param botVersionName The bot version name */ private retrieveAgentMetadata; /** * Deploys the authoring bundle to the Salesforce org after setting the correct target attribute. * The target attribute is required for deployment but should not remain in the * local source files after deployment. * * @throws SfError if the deployment fails or if there are component deployment errors * @param botVersionName */ private deployAuthoringBundle; /** * Returns the ID for the published bot. * * @param agentApiName The agent API name * @returns The ID for the published bot */ private getPublishedBotId; /** * Returns the developerName of the given bot version ID. * * @param botVersionId The Id of the bot version * @returns The developer name of the bot version */ private getVersionDeveloperName; }