@salesforce/packaging 4.11.0 → 4.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/exported.d.ts CHANGED
@@ -2,3 +2,6 @@ export * from './interfaces';
2
2
  export * from './package';
3
3
  export * from './package1';
4
4
  export * from './utils';
5
+ export * from './package/packageBundle';
6
+ export * from './package/packageBundleVersionCreate';
7
+ export * from './package/packageBundleInstall';
package/lib/exported.js CHANGED
@@ -24,4 +24,7 @@ __exportStar(require("./interfaces"), exports);
24
24
  __exportStar(require("./package"), exports);
25
25
  __exportStar(require("./package1"), exports);
26
26
  __exportStar(require("./utils"), exports);
27
+ __exportStar(require("./package/packageBundle"), exports);
28
+ __exportStar(require("./package/packageBundleVersionCreate"), exports);
29
+ __exportStar(require("./package/packageBundleInstall"), exports);
27
30
  //# sourceMappingURL=exported.js.map
@@ -0,0 +1,33 @@
1
+ import { Nullable } from '@salesforce/ts-types';
2
+ import { Connection, SfProject } from '@salesforce/core';
3
+ import { Duration } from '@salesforce/kit';
4
+ import { SaveResult } from '@jsforce/jsforce-node';
5
+ export type BundleCreateOptions = {
6
+ BundleName: string;
7
+ Description: string;
8
+ };
9
+ export type BundleVersionCreateOptions = {
10
+ connection: Connection;
11
+ project: SfProject;
12
+ PackageBundle: string;
13
+ MajorVersion: string;
14
+ MinorVersion: string;
15
+ Ancestor: Nullable<string>;
16
+ BundleVersionComponentsPath: string;
17
+ Description?: string;
18
+ polling?: {
19
+ timeout: Duration;
20
+ frequency: Duration;
21
+ };
22
+ };
23
+ export type BundleInstallOptions = {
24
+ connection: Connection;
25
+ project: SfProject;
26
+ PackageBundleVersion: string;
27
+ DevelopmentOrganization: string;
28
+ polling?: {
29
+ timeout: Duration;
30
+ frequency: Duration;
31
+ };
32
+ };
33
+ export type BundleSaveResult = SaveResult;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025, salesforce.com, inc.
4
+ * All rights reserved.
5
+ * Licensed under the BSD 3-Clause license.
6
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ //# sourceMappingURL=bundleInterfacesAndType.js.map
@@ -0,0 +1,146 @@
1
+ import { Nullable } from '@salesforce/ts-types';
2
+ import { BundleEntry } from '@salesforce/schemas';
3
+ import type { Schema } from '@jsforce/jsforce-node';
4
+ export { BundleEntry };
5
+ export type QueryRecord = Schema & {
6
+ Id: string;
7
+ PackageBundle?: {
8
+ Id: string;
9
+ BundleName: string;
10
+ Description?: string;
11
+ IsDeleted: boolean;
12
+ CreatedDate: string;
13
+ CreatedById: string;
14
+ LastModifiedDate: string;
15
+ LastModifiedById: string;
16
+ SystemModstamp: string;
17
+ };
18
+ VersionName: string;
19
+ MajorVersion: string;
20
+ MinorVersion: string;
21
+ IsReleased: boolean;
22
+ Ancestor?: {
23
+ Id: string;
24
+ PackageBundle?: {
25
+ Id: string;
26
+ BundleName: string;
27
+ Description?: string;
28
+ IsDeleted: boolean;
29
+ CreatedDate: string;
30
+ CreatedById: string;
31
+ LastModifiedDate: string;
32
+ LastModifiedById: string;
33
+ SystemModstamp: string;
34
+ };
35
+ VersionName: string;
36
+ MajorVersion: string;
37
+ MinorVersion: string;
38
+ IsReleased: boolean;
39
+ };
40
+ };
41
+ export type AncestorRecord = {
42
+ Id: string;
43
+ PackageBundle?: {
44
+ Id: string;
45
+ BundleName: string;
46
+ Description?: string;
47
+ IsDeleted: boolean;
48
+ CreatedDate: string;
49
+ CreatedById: string;
50
+ LastModifiedDate: string;
51
+ LastModifiedById: string;
52
+ SystemModstamp: string;
53
+ };
54
+ VersionName: string;
55
+ MajorVersion: string;
56
+ MinorVersion: string;
57
+ IsReleased: boolean;
58
+ };
59
+ export declare namespace BundleSObjects {
60
+ type Bundle = {
61
+ BundleName: string;
62
+ Description?: string;
63
+ Id: string;
64
+ IsDeleted: boolean;
65
+ CreatedDate: string;
66
+ CreatedById: string;
67
+ LastModifiedDate: string;
68
+ LastModifiedById: string;
69
+ SystemModstamp: string;
70
+ };
71
+ type BundleVersion = {
72
+ Id: string;
73
+ PackageBundle: Bundle;
74
+ VersionName: string;
75
+ MajorVersion: string;
76
+ MinorVersion: string;
77
+ Ancestor: Nullable<BundleVersion>;
78
+ IsReleased: boolean;
79
+ CreatedDate: string;
80
+ CreatedById: string;
81
+ LastModifiedDate: string;
82
+ LastModifiedById: string;
83
+ };
84
+ type PkgBundleVersionCreateReq = {
85
+ PackageBundleId: string;
86
+ VersionName: string;
87
+ MajorVersion: string;
88
+ MinorVersion: string;
89
+ BundleVersionComponents: string;
90
+ Ancestor?: string | null;
91
+ };
92
+ type PackageBundleVersionCreateRequestResult = PkgBundleVersionCreateReq & {
93
+ Id: string;
94
+ PackageBundleVersionId: string;
95
+ RequestStatus: PkgBundleVersionCreateReqStatus;
96
+ CreatedDate: string;
97
+ CreatedById: string;
98
+ Error?: string[];
99
+ };
100
+ enum PkgBundleVersionCreateReqStatus {
101
+ queued = "Queued",
102
+ success = "Success",
103
+ error = "Error"
104
+ }
105
+ enum PkgBundleVersionInstallReqStatus {
106
+ queued = "Queued",
107
+ success = "Success",
108
+ error = "Error"
109
+ }
110
+ type PkgBundleVersionQueryRecord = {
111
+ Id: string;
112
+ RequestStatus: BundleSObjects.PkgBundleVersionCreateReqStatus;
113
+ PackageBundle: Bundle;
114
+ PackageBundleVersion: BundleVersion;
115
+ VersionName: string;
116
+ MajorVersion: string;
117
+ MinorVersion: string;
118
+ Ancestor: BundleVersion;
119
+ BundleVersionComponents: string;
120
+ CreatedDate: string;
121
+ CreatedById: string;
122
+ Error?: string[];
123
+ } & Schema;
124
+ type PkgBundleVersionInstallReq = {
125
+ PackageBundleVersionID: string;
126
+ DevelopmentOrganization: string;
127
+ };
128
+ type PkgBundleVersionInstallReqResult = PkgBundleVersionInstallReq & {
129
+ Id: string;
130
+ InstallStatus: PkgBundleVersionInstallReqStatus;
131
+ ValidationError: string;
132
+ CreatedDate: string;
133
+ CreatedById: string;
134
+ Error?: string[];
135
+ };
136
+ type PkgBundleVersionInstallQueryRecord = {
137
+ Id: string;
138
+ InstallStatus: BundleSObjects.PkgBundleVersionInstallReqStatus;
139
+ PackageBundleVersionID: string;
140
+ DevelopmentOrganization: string;
141
+ ValidationError: string;
142
+ CreatedDate: string;
143
+ CreatedById: string;
144
+ Error?: string[];
145
+ } & Schema;
146
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BundleSObjects = void 0;
4
+ var BundleSObjects;
5
+ (function (BundleSObjects) {
6
+ let PkgBundleVersionCreateReqStatus;
7
+ (function (PkgBundleVersionCreateReqStatus) {
8
+ PkgBundleVersionCreateReqStatus["queued"] = "Queued";
9
+ PkgBundleVersionCreateReqStatus["success"] = "Success";
10
+ PkgBundleVersionCreateReqStatus["error"] = "Error";
11
+ })(PkgBundleVersionCreateReqStatus = BundleSObjects.PkgBundleVersionCreateReqStatus || (BundleSObjects.PkgBundleVersionCreateReqStatus = {}));
12
+ let PkgBundleVersionInstallReqStatus;
13
+ (function (PkgBundleVersionInstallReqStatus) {
14
+ PkgBundleVersionInstallReqStatus["queued"] = "Queued";
15
+ PkgBundleVersionInstallReqStatus["success"] = "Success";
16
+ PkgBundleVersionInstallReqStatus["error"] = "Error";
17
+ })(PkgBundleVersionInstallReqStatus = BundleSObjects.PkgBundleVersionInstallReqStatus || (BundleSObjects.PkgBundleVersionInstallReqStatus = {}));
18
+ })(BundleSObjects || (exports.BundleSObjects = BundleSObjects = {}));
19
+ //# sourceMappingURL=bundleSObjects.js.map
@@ -1,2 +1,4 @@
1
1
  export * from './packagingInterfacesAndType';
2
2
  export * from './packagingSObjects';
3
+ export * from './bundleInterfacesAndType';
4
+ export * from './bundleSObjects';
@@ -22,4 +22,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
22
22
  */
23
23
  __exportStar(require("./packagingInterfacesAndType"), exports);
24
24
  __exportStar(require("./packagingSObjects"), exports);
25
+ __exportStar(require("./bundleInterfacesAndType"), exports);
26
+ __exportStar(require("./bundleSObjects"), exports);
25
27
  //# sourceMappingURL=index.js.map
@@ -3,3 +3,6 @@ export * from './packageVersion';
3
3
  export * from './subscriberPackageVersion';
4
4
  export * from './packagePushUpgrade';
5
5
  export { VersionNumber } from './versionNumber';
6
+ export * from './packageBundle';
7
+ export * from './packageBundleVersion';
8
+ export * from './packageBundleInstall';
@@ -27,4 +27,7 @@ __exportStar(require("./subscriberPackageVersion"), exports);
27
27
  __exportStar(require("./packagePushUpgrade"), exports);
28
28
  var versionNumber_1 = require("./versionNumber");
29
29
  Object.defineProperty(exports, "VersionNumber", { enumerable: true, get: function () { return versionNumber_1.VersionNumber; } });
30
+ __exportStar(require("./packageBundle"), exports);
31
+ __exportStar(require("./packageBundleVersion"), exports);
32
+ __exportStar(require("./packageBundleInstall"), exports);
30
33
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,37 @@
1
+ import { Connection, SfProject } from '@salesforce/core';
2
+ import { SaveResult } from '@jsforce/jsforce-node';
3
+ import { Duration } from '@salesforce/kit';
4
+ import { BundleCreateOptions, BundleSObjects, BundleVersionCreateOptions } from '../interfaces';
5
+ export declare class PackageBundle {
6
+ /**
7
+ * Create a new package bundle.
8
+ *
9
+ * @param connection - instance of Connection
10
+ * @param project - instance of SfProject
11
+ * @param options - options for creating a bundle - see BundleCreateOptions
12
+ * @returns PackageBundle
13
+ */
14
+ static create(connection: Connection, project: SfProject, options: BundleCreateOptions): Promise<{
15
+ Id: string;
16
+ }>;
17
+ /**
18
+ * Create a new package bundle version.
19
+ *
20
+ * @param connection - instance of Connection
21
+ * @param project - instance of SfProject
22
+ * @param options - options for creating a bundle version - see BundleVersionCreateOptions
23
+ * @returns PackageBundle
24
+ */
25
+ static createVersion(options: BundleVersionCreateOptions, polling?: {
26
+ frequency: Duration;
27
+ timeout: Duration;
28
+ }): Promise<BundleSObjects.PackageBundleVersionCreateRequestResult>;
29
+ static delete(connection: Connection, project: SfProject, idOrAlias: string): Promise<SaveResult>;
30
+ /**
31
+ * Returns all the package bundles that are available in the org, up to 10,000. If more records are
32
+ * needed use the `SF_ORG_MAX_QUERY_LIMIT` env var.
33
+ *
34
+ * @param connection
35
+ */
36
+ static list(connection: Connection): Promise<BundleSObjects.Bundle[]>;
37
+ }
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025, salesforce.com, inc.
4
+ * All rights reserved.
5
+ * Licensed under the BSD 3-Clause license.
6
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.PackageBundle = void 0;
10
+ const core_1 = require("@salesforce/core");
11
+ const kit_1 = require("@salesforce/kit");
12
+ const packageBundleCreate_1 = require("./packageBundleCreate");
13
+ const packageBundleVersion_1 = require("./packageBundleVersion");
14
+ const BundleFields = [
15
+ 'BundleName',
16
+ 'Description',
17
+ 'Id',
18
+ 'IsDeleted',
19
+ 'CreatedDate',
20
+ 'CreatedById',
21
+ 'LastModifiedDate',
22
+ 'LastModifiedById',
23
+ 'SystemModstamp',
24
+ ];
25
+ class PackageBundle {
26
+ /**
27
+ * Create a new package bundle.
28
+ *
29
+ * @param connection - instance of Connection
30
+ * @param project - instance of SfProject
31
+ * @param options - options for creating a bundle - see BundleCreateOptions
32
+ * @returns PackageBundle
33
+ */
34
+ static async create(connection, project, options) {
35
+ return (0, packageBundleCreate_1.createBundle)(connection, project, options);
36
+ }
37
+ /**
38
+ * Create a new package bundle version.
39
+ *
40
+ * @param connection - instance of Connection
41
+ * @param project - instance of SfProject
42
+ * @param options - options for creating a bundle version - see BundleVersionCreateOptions
43
+ * @returns PackageBundle
44
+ */
45
+ static async createVersion(options, polling = {
46
+ frequency: kit_1.Duration.seconds(0),
47
+ timeout: kit_1.Duration.seconds(0),
48
+ }) {
49
+ return packageBundleVersion_1.PackageBundleVersion.create(options, polling);
50
+ }
51
+ static async delete(connection, project, idOrAlias) {
52
+ // Check if it's already an ID (1Fl followed by 15 characters)
53
+ if (/^1Fl.{15}$/.test(idOrAlias)) {
54
+ return connection.tooling.sobject('PackageBundle').delete(idOrAlias);
55
+ }
56
+ // Validate that project is provided when using aliases
57
+ if (!project) {
58
+ throw new core_1.SfError('Project instance is required when deleting package bundle by alias');
59
+ }
60
+ // eslint-disable-next-line no-param-reassign
61
+ idOrAlias = project.getPackageBundleIdFromAlias(idOrAlias) ?? idOrAlias;
62
+ return connection.tooling.sobject('PackageBundle').delete(idOrAlias);
63
+ }
64
+ /**
65
+ * Returns all the package bundles that are available in the org, up to 10,000. If more records are
66
+ * needed use the `SF_ORG_MAX_QUERY_LIMIT` env var.
67
+ *
68
+ * @param connection
69
+ */
70
+ static async list(connection) {
71
+ const query = `select ${BundleFields.join(', ')} from PackageBundle ORDER BY BundleName`;
72
+ return (await connection.autoFetchQuery(query, { tooling: true }))?.records;
73
+ }
74
+ }
75
+ exports.PackageBundle = PackageBundle;
76
+ //# sourceMappingURL=packageBundle.js.map
@@ -0,0 +1,7 @@
1
+ import { Connection, SfProject } from '@salesforce/core';
2
+ import { BundleEntry } from '@salesforce/schemas';
3
+ import { BundleCreateOptions } from '../interfaces';
4
+ export declare function createPackageDirEntry(project: SfProject, options: BundleCreateOptions): BundleEntry;
5
+ export declare function createBundle(connection: Connection, project: SfProject, options: BundleCreateOptions): Promise<{
6
+ Id: string;
7
+ }>;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPackageDirEntry = createPackageDirEntry;
4
+ exports.createBundle = createBundle;
5
+ /*
6
+ * Copyright (c) 2025, salesforce.com, inc.
7
+ * All rights reserved.
8
+ * Licensed under the BSD 3-Clause license.
9
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
10
+ */
11
+ const core_1 = require("@salesforce/core");
12
+ const bundleUtils_1 = require("../utils/bundleUtils");
13
+ core_1.Messages.importMessagesDirectory(__dirname);
14
+ const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'bundle_create');
15
+ function createPackageDirEntry(project, options) {
16
+ return {
17
+ versionName: 'ver 0.1',
18
+ versionNumber: '0.1',
19
+ name: options.BundleName,
20
+ versionDescription: options.Description,
21
+ };
22
+ }
23
+ async function createBundle(connection, project, options) {
24
+ const request = { BundleName: options.BundleName, Description: options.Description };
25
+ let createResult;
26
+ try {
27
+ createResult = await connection.tooling.sobject('PackageBundle').create(request);
28
+ }
29
+ catch (err) {
30
+ const error = err instanceof Error
31
+ ? err
32
+ : new Error(typeof err === 'string' ? err : messages.getMessage('failedToCreatePackageBundle'));
33
+ throw core_1.SfError.wrap((0, bundleUtils_1.massageErrorMessage)(error));
34
+ }
35
+ if (!createResult?.success) {
36
+ throw core_1.SfError.wrap((0, bundleUtils_1.massageErrorMessage)(new Error(messages.getMessage('failedToCreatePackageBundle'))));
37
+ }
38
+ const bundleEntry = createPackageDirEntry(project, options);
39
+ project.getSfProjectJson().addPackageBundle(bundleEntry);
40
+ project.getSfProjectJson().addPackageBundleAlias(bundleEntry.name, createResult.id);
41
+ await project.getSfProjectJson().write();
42
+ return { Id: createResult.id };
43
+ }
44
+ //# sourceMappingURL=packageBundleCreate.js.map
@@ -0,0 +1,9 @@
1
+ import { Connection, SfProject } from '@salesforce/core';
2
+ import { BundleSObjects, BundleInstallOptions } from '../interfaces';
3
+ export declare class PackageBundleInstall {
4
+ static getInstallStatus(installRequestId: string, connection: Connection): Promise<BundleSObjects.PkgBundleVersionInstallReqResult>;
5
+ static getInstallStatuses(connection: Connection, status?: BundleSObjects.PkgBundleVersionInstallReqStatus, createdLastDays?: number): Promise<BundleSObjects.PkgBundleVersionInstallReqResult[]>;
6
+ static installBundle(connection: Connection, project: SfProject, options: BundleInstallOptions): Promise<BundleSObjects.PkgBundleVersionInstallReqResult>;
7
+ private static parsePackageBundleVersionId;
8
+ private static pollInstallStatus;
9
+ }
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PackageBundleInstall = void 0;
4
+ /*
5
+ * Copyright (c) 2025, salesforce.com, inc.
6
+ * All rights reserved.
7
+ * Licensed under the BSD 3-Clause license.
8
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
9
+ */
10
+ const core_1 = require("@salesforce/core");
11
+ const interfaces_1 = require("../interfaces");
12
+ const bundleUtils_1 = require("../utils/bundleUtils");
13
+ core_1.Messages.importMessagesDirectory(__dirname);
14
+ const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'bundle_install');
15
+ class PackageBundleInstall {
16
+ static async getInstallStatus(installRequestId, connection) {
17
+ try {
18
+ const result = await connection.tooling.sobject('PkgBundleVersionInstallReq').retrieve(installRequestId);
19
+ return result;
20
+ }
21
+ catch (err) {
22
+ const error = err instanceof Error ? err : new Error(messages.getMessage('failedToGetPackageBundleInstallStatus'));
23
+ throw core_1.SfError.wrap((0, bundleUtils_1.massageErrorMessage)(error));
24
+ }
25
+ }
26
+ static async getInstallStatuses(connection, status, createdLastDays) {
27
+ let query = 'SELECT Id, InstallStatus, PackageBundleVersionID, DevelopmentOrganization, ValidationError, ' +
28
+ 'CreatedDate, CreatedById ' +
29
+ 'FROM PkgBundleVersionInstallReq';
30
+ if (status && createdLastDays) {
31
+ query += ` WHERE InstallStatus = '${status}' AND CreatedDate = LAST_N_DAYS: ${createdLastDays}`;
32
+ }
33
+ else if (status) {
34
+ query += ` WHERE InstallStatus = '${status}'`;
35
+ }
36
+ else if (createdLastDays) {
37
+ query += ` WHERE CreatedDate = LAST_N_DAYS: ${createdLastDays}`;
38
+ }
39
+ const queryResult = await connection.autoFetchQuery(query, {
40
+ tooling: true,
41
+ });
42
+ return queryResult.records.map((record) => ({
43
+ Id: record.Id,
44
+ InstallStatus: record.InstallStatus,
45
+ PackageBundleVersionID: record.PackageBundleVersionID ?? '',
46
+ DevelopmentOrganization: record.DevelopmentOrganization ?? '',
47
+ ValidationError: record.ValidationError ?? '',
48
+ CreatedDate: record.CreatedDate ?? '',
49
+ CreatedById: record.CreatedById ?? '',
50
+ }));
51
+ }
52
+ static async installBundle(connection, project, options) {
53
+ const packageBundleVersionId = PackageBundleInstall.parsePackageBundleVersionId(options.PackageBundleVersion, project);
54
+ const request = {
55
+ PackageBundleVersionID: packageBundleVersionId,
56
+ DevelopmentOrganization: options.DevelopmentOrganization,
57
+ };
58
+ let installResult;
59
+ try {
60
+ installResult = await connection.tooling.sobject('PkgBundleVersionInstallReq').create(request);
61
+ }
62
+ catch (err) {
63
+ const error = err instanceof Error
64
+ ? err
65
+ : new Error(typeof err === 'string' ? err : messages.getMessage('failedToInstallPackageBundle'));
66
+ throw core_1.SfError.wrap((0, bundleUtils_1.massageErrorMessage)(error));
67
+ }
68
+ if (!installResult?.success) {
69
+ throw core_1.SfError.wrap((0, bundleUtils_1.massageErrorMessage)(new Error(messages.getMessage('failedToInstallPackageBundle'))));
70
+ }
71
+ if (options.polling) {
72
+ return PackageBundleInstall.pollInstallStatus(installResult.id, connection, options.polling);
73
+ }
74
+ return {
75
+ Id: installResult.id,
76
+ PackageBundleVersionID: packageBundleVersionId,
77
+ DevelopmentOrganization: options.DevelopmentOrganization,
78
+ InstallStatus: interfaces_1.BundleSObjects.PkgBundleVersionInstallReqStatus.queued,
79
+ ValidationError: '',
80
+ CreatedDate: new Date().toISOString(),
81
+ CreatedById: connection.getUsername() ?? 'unknown',
82
+ };
83
+ }
84
+ static parsePackageBundleVersionId(packageBundleVersion, project) {
85
+ // Check if it's already an ID (starts with appropriate prefix)
86
+ if (/^1Q8.{15}$/.test(packageBundleVersion)) {
87
+ return packageBundleVersion;
88
+ }
89
+ // Otherwise, treat it as an alias and resolve it from sfdx-project.json
90
+ const packageBundleVersionId = project.getPackageBundleIdFromAlias(packageBundleVersion);
91
+ if (!packageBundleVersionId) {
92
+ throw new core_1.SfError(messages.getMessage('noPackageBundleVersionFoundWithAlias', [packageBundleVersion]));
93
+ }
94
+ return packageBundleVersionId;
95
+ }
96
+ static async pollInstallStatus(installRequestId, connection, polling) {
97
+ if (polling.timeout?.milliseconds <= 0) {
98
+ return PackageBundleInstall.getInstallStatus(installRequestId, connection);
99
+ }
100
+ const pollingClient = await core_1.PollingClient.create({
101
+ poll: async () => {
102
+ const status = await PackageBundleInstall.getInstallStatus(installRequestId, connection);
103
+ if (status.InstallStatus === interfaces_1.BundleSObjects.PkgBundleVersionInstallReqStatus.success) {
104
+ return { completed: true, payload: status };
105
+ }
106
+ return { completed: false, payload: status };
107
+ },
108
+ frequency: polling.frequency,
109
+ timeout: polling.timeout,
110
+ });
111
+ try {
112
+ return await pollingClient.subscribe();
113
+ }
114
+ catch (err) {
115
+ if (err instanceof Error) {
116
+ throw new Error('Install request timed out');
117
+ }
118
+ throw err;
119
+ }
120
+ }
121
+ }
122
+ exports.PackageBundleInstall = PackageBundleInstall;
123
+ //# sourceMappingURL=packageBundleInstall.js.map
@@ -0,0 +1,21 @@
1
+ import { Connection } from '@salesforce/core';
2
+ import { SfProject } from '@salesforce/core';
3
+ import { Duration } from '@salesforce/kit';
4
+ import { BundleVersionCreateOptions, BundleSObjects, PackagingSObjects } from '../interfaces';
5
+ export declare class PackageBundleVersion {
6
+ static create(options: BundleVersionCreateOptions, polling?: {
7
+ frequency: Duration;
8
+ timeout: Duration;
9
+ }): Promise<BundleSObjects.PackageBundleVersionCreateRequestResult>;
10
+ static pollCreateStatus(createPackageVersionRequestId: string, connection: Connection, project: SfProject, polling: {
11
+ frequency: Duration;
12
+ timeout: Duration;
13
+ }): Promise<BundleSObjects.PackageBundleVersionCreateRequestResult>;
14
+ static report(connection: Connection, id: string): Promise<BundleSObjects.BundleVersion | null>;
15
+ static list(connection: Connection): Promise<BundleSObjects.BundleVersion[]>;
16
+ static getComponentPackages(connection: Connection, id: string): Promise<PackagingSObjects.SubscriberPackageVersion[]>;
17
+ private static mapRecordToBundleVersion;
18
+ private static mapPackageBundle;
19
+ private static mapAncestor;
20
+ private static mapAncestorPackageBundle;
21
+ }