UNPKG

@salesforce/packaging

Version:

Packaging library for the Salesforce packaging platform

206 lines (205 loc) 8.15 kB
import { Connection } from '@salesforce/core'; import { Duration } from '@salesforce/kit'; import { Nullable, Optional } from '@salesforce/ts-types'; import { InstalledPackages, PackageDescriptorJson, PackageInstallCreateRequest, PackageInstallOptions, PackageType, PackagingSObjects, SubscriberPackageVersionOptions } from '../interfaces'; import { VersionNumber } from './versionNumber'; type SPV = PackagingSObjects.SubscriberPackageVersion; export declare const SubscriberPackageVersionFields: string[]; /** * Provides the ability to get, list, install, and uninstall 2nd * generation subscriber package versions. * * **Examples** * * List all 2GP installed packages in the org: * * `const installedPkgs = await SubscriberPackageVersion.installedList(connection);` * * Install a 2GP subscriber package version: * * `const installStatus = await new SubscriberPackageVersion(options).install(request, options);` */ export declare class SubscriberPackageVersion { private options; private readonly password; private readonly connection; private readonly id; private data?; constructor(options: SubscriberPackageVersionOptions); /** * Fetches the status of a package version install request and will wait for the install to complete, if requested * Package Version install emits the following events: * - PackageEvents.install['subscriber-status'] * * @param connection * @param packageInstallRequestOrId * @param installationKey * @param options */ static installStatus(connection: Connection, packageInstallRequestOrId: string | PackagingSObjects.PackageInstallRequest, installationKey?: string | undefined | Nullable<string>, options?: PackageInstallOptions): Promise<PackagingSObjects.PackageInstallRequest>; /** * list the packages installed in the org * * @param conn: Connection to the org */ static installedList(conn: Connection): Promise<InstalledPackages[]>; /** * Reports on the progress of a package version uninstall. * * @param id the 06y package version uninstall request id * @param connection */ static uninstallStatus(id: string, connection: Connection): Promise<PackagingSObjects.SubscriberPackageVersionUninstallRequest>; /** * Retrieves the package version create request. * * @param installRequestId * @param connection */ static getInstallRequest(installRequestId: string, connection: Connection): Promise<PackagingSObjects.PackageInstallRequest>; /** * Resolve fields from a packageDirectories entry to a SubscriberPackageVersionId (04t). * Specifically uses the `versionNumber` and `packageId` fields, as well as an optional * `branch` field. * * @param connection A connection object to the org * @param pkgDescriptor Fields from a packageDirectories entry in sfdx-project.json. * The `versionNumber` and `packageId` fields are required. Optionally, the `branch` and * `package` fields can be passed. * @returns the SubscriberPackageVersionId (04t) */ static resolveId(connection: Connection, pkgDescriptor: Partial<PackageDescriptorJson>): Promise<string>; /** * Get the package version ID for this SubscriberPackageVersion. * * @returns The SubscriberPackageVersion Id (04t). */ getId(): Promise<string>; /** * Get the package type for this SubscriberPackageVersion. * * @returns {PackageType} The package type ("Managed" or "Unlocked") for this SubscriberPackageVersion. */ getPackageType(): Promise<PackageType>; /** * Get the password passed in the constructor * * @returns {string} the password */ getPassword(): Optional<string>; /** * Get the subscriber package Id (033) for this SubscriberPackageVersion. * * @returns {string} The subscriber package Id (033). */ getSubscriberPackageId(): Promise<string>; /** * Get a VersionNumber instance for this SubscriberPackageVersion. * * @returns {VersionNumber} The version number. */ getVersionNumber(): Promise<VersionNumber>; /** * Is the package a managed package? */ isManaged(): Promise<boolean>; /** * Is the SubscriberPackageVersion deprecated? * * @returns {boolean} True if the SubscriberPackageVersion is deprecated. */ isDeprecated(): Promise<boolean>; /** * Is the SubscriberPackageVersion password protected? * * @returns {boolean} True if the SubscriberPackageVersion is password protected. */ isPasswordProtected(): Promise<boolean>; /** * Is the SubscriberPackageVersion org dependent? * * @returns {boolean} True if the SubscriberPackageVersion is org dependent. */ isOrgDependent(): Promise<boolean>; /** * Return remote site settings for the SubscriberPackageVersion. * * @returns {RemoteSiteSettings} The remote site settings. */ getRemoteSiteSettings(): Promise<PackagingSObjects.SubscriberPackageRemoteSiteSettings>; /** * Return CSP trusted sites for the SubscriberPackageVersion. * * @returns {CspTrustedSites} The CSP trusted sites. */ getCspTrustedSites(): Promise<PackagingSObjects.SubscriberPackageCspTrustedSites>; /** * Get the installation validation status for the SubscriberPackageVersion. * * @returns {InstallationValidationStatus} The installation validation status. */ getInstallValidationStatus(): Promise<PackagingSObjects.InstallValidationStatus>; /** * Get the SubscriberPackageVersion SObject data for this SubscriberPackageVersion. * * @param force - force a refresh of the subscriber package version data. * @returns {PackagingSObjects.SubscriberPackageVersion} SObject data. */ getData(options?: { force?: boolean; includeHighCostFields?: boolean; }): Promise<SPV | undefined>; /** * Wait for the subscriber package version to be replicated across instances and available to be queried against * * @param options.publishFrequency - how often to check for the package version to be published * @param options.publishTimeout - how long to wait for the package version to be published * @param options.installationKey - the installation key for the package version */ waitForPublish(options?: { publishFrequency: Duration; publishTimeout: Duration; installationKey?: string; }): Promise<void>; /** * Installs a package version in a subscriber org. * * Package Version install emits the following events: * - PackageEvents.install.warning * - PackageEvents.install.presend * - PackageEvents.install.postsend * - PackageEvents.install['subscriber-status'] * * @param pkgInstallCreateRequest * @param options */ install(pkgInstallCreateRequest: PackageInstallCreateRequest, options?: PackageInstallOptions): Promise<PackagingSObjects.PackageInstallRequest>; /** * Uninstalls a package version from a subscriber org. * * @param frequency * @param wait */ uninstall(frequency?: Duration, wait?: Duration): Promise<PackagingSObjects.SubscriberPackageVersionUninstallRequest>; /** * Returns an array of RSS and CSP external sites for the package. * * @param installationKey The installation key (if any) for the subscriber package version. * @returns an array of RSS and CSP site URLs, or undefined if the package doesn't have any. */ getExternalSites(): Promise<Optional<string[]>>; /** * Return dependencies for the SubscriberPackageVersion. * * @returns {Dependencies} The dependencies. */ getDependencies(): Promise<PackagingSObjects.SubscriberPackageDependencies>; /** * Return a field value from the SubscriberPackageVersion SObject using the field name. * * @param field */ getField<T>(field: string): Promise<T>; private getFieldsForQuery; } export {};