UNPKG

@salesforce/packaging

Version:

Packaging library for the Salesforce packaging platform

187 lines (186 loc) 7.53 kB
import { Connection, SfProject } from '@salesforce/core'; import { Duration } from '@salesforce/kit'; import { PackageSaveResult, PackageType, PackageVersionCreateOptions, PackageVersionCreateRequestQueryOptions, PackageVersionCreateRequestResult, PackageVersionOptions, PackageVersionReportResult, PackageVersionUpdateOptions, PackagingSObjects } from '../interfaces'; type Package2Version = PackagingSObjects.Package2Version; export declare const Package2VersionFields: Array<keyof Package2Version>; export type Package2VersionFieldTypes = Array<(typeof Package2VersionFields)[number]>; export type Package2VersionQueryOptions = { /** * The fields to include in the returned data. Defaults to all fields. */ fields?: Package2VersionFieldTypes; /** * The where clause to filter the query. E.g., "WHERE Id IN ('%IDS%')"; */ whereClause?: string; /** * An array of where clause items to match. The query is chunked,meaning broken into * multiple queries when the query length would exceed the maximum char limit. * When defining items here, the `whereClause` argument must use this token for the * item replacement: `'%IDS%'`. */ whereClauseItems?: string[]; /** * The order-by clause for the query. Defaults to LastModifiedDate descending. */ orderBy?: string; }; /** * Provides the ability to create, update, delete, and promote 2nd * generation package versions. * * **Examples** * * Create a new instance and get the ID (05i): * * `const id = new PackageVersion({connection, project, idOrAlias}).getId();` * * Create a new package version in the org: * * `const myPkgVersion = await PackageVersion.create(options, pollingOptions);` * * Promote a package version: * * `new PackageVersion({connection, project, idOrAlias}).promote();` */ export declare class PackageVersion { private options; private readonly project?; private readonly connection; private data?; private packageType?; private id; constructor(options: PackageVersionOptions); /** * Sends a request to create a new package version and optionally polls for * the status of the request until the package version is created or the * polling timeout is reached. * * @param options PackageVersionCreateOptions * @param polling frequency and timeout Durations to be used in polling * @returns PackageVersionCreateRequestResult */ static create(options: PackageVersionCreateOptions, polling?: { frequency: Duration; timeout: Duration; }): Promise<PackageVersionCreateRequestResult>; /** * Gets current state of a package version create request. * * @param createPackageRequestId * @param connection */ static getCreateStatus(createPackageRequestId: string, connection: Connection): Promise<PackageVersionCreateRequestResult>; /** * Fetch a list of package version create requests based on the given options. * * @param connection connection to an org * @param options PackageVersionCreateRequestQueryOptions * @returns the list of package version create requests. */ static getPackageVersionCreateRequests(connection: Connection, options?: PackageVersionCreateRequestQueryOptions): Promise<PackageVersionCreateRequestResult[]>; /** * Convenience function that will wait for a package version to be created. * * This function emits LifeCycle events, "enqueued", "in-progress", "success", "error" and "timed-out" to * progress and current status. Events also carry a payload of type PackageVersionCreateRequestResult. * * @param createPackageVersionRequestId * @param connection Connection to the org * @param project SfProject to read/write aliases from * @param polling frequency and timeout Durations to be used in polling * */ static pollCreateStatus(createPackageVersionRequestId: string, connection: Connection, project: SfProject, polling: { frequency: Duration; timeout: Duration; }): Promise<PackageVersionCreateRequestResult>; /** * Gets current state of a package version create request. * * @param createPackageRequestId * @param connection */ static getCreateVersionReport(createPackageRequestId: string, connection: Connection): Promise<PackageVersionCreateRequestResult>; /** * Convenience function that will wait for a package version to be created. * * This function emits LifeCycle events, "enqueued", "in-progress", "success", "error" and "timed-out" to * progress and current status. Events also carry a payload of type PackageVersionCreateRequestResult. * * @param createPackageVersionRequestId * @param project * @param connection * @param polling frequency and timeout Durations to be used in polling * */ static waitForCreateVersion(createPackageVersionRequestId: string, project: SfProject, connection: Connection, polling: { frequency: Duration; timeout: Duration; }): Promise<PackageVersionCreateRequestResult>; /** * Query the Package2Version SObject and return data with the provided type. * * NOTE: There is a limit of 2000 records that can be returned, otherwise * a GACK might be thrown. If more than 2000 records are desired you should * filter the query by date and aggregate all results. * * @param connection jsForce Connection to the org. * @param options Package2Version query options * @returns Results from querying the Package2Version SObject. */ static queryPackage2Version(connection: Connection, options?: Package2VersionQueryOptions): Promise<Partial<Package2Version[]>>; private static getPackage2VersionFields; /** * Get the package version ID for this PackageVersion. * * @returns The PackageVersionId (05i). */ getId(): Promise<string | undefined>; /** * Get the subscriber package version ID for this PackageVersion. * * @returns The SubscriberPackageVersionId (04t). */ getSubscriberId(): Promise<string | undefined>; /** * Get the package Id for this PackageVersion. * * @returns The PackageId (0Ho). */ getPackageId(): Promise<string | undefined>; /** * Get the package type for this PackageVersion. * * @returns The PackageType (Managed, Unlocked). */ getPackageType(): Promise<PackageType>; /** * Get the Package2Version SObject data for this PackageVersion. * * @param force force a refresh of the package version data. * @returns Package2Version */ getData(force?: boolean): Promise<Package2Version> | never; /** * Deletes this PackageVersion. */ delete(): Promise<PackageSaveResult>; /** * Undeletes this PackageVersion. */ undelete(): Promise<PackageSaveResult>; /** * Reports details about this PackageVersion. * * @param verbose Whether to get a detailed version of the report, at the expense of performance. */ report(verbose?: boolean): Promise<PackageVersionReportResult>; /** * Promotes this PackageVersion to released state. */ promote(): Promise<PackageSaveResult>; update(options: PackageVersionUpdateOptions): Promise<PackageSaveResult>; private updateDeprecation; private updateProjectWithPackageVersion; private resolveId; } export {};