@salesforce/packaging 0.0.31 → 0.0.32

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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.32](https://github.com/forcedotcom/packaging/compare/v0.0.31...v0.0.32) (2022-09-07)
6
+
7
+ ### Bug Fixes
8
+
9
+ - add Package.uninstallReport method, NUT ([9269c9b](https://github.com/forcedotcom/packaging/commit/9269c9b999dcac25ac52c4ee64bf261ffebfb0e0))
10
+
5
11
  ### [0.0.31](https://github.com/forcedotcom/packaging/compare/v0.0.30...v0.0.31) (2022-09-07)
6
12
 
7
13
  ### Bug Fixes
@@ -175,7 +175,7 @@ export declare namespace PackagingSObjects {
175
175
  LastModifiedById: string;
176
176
  SystemModstamp: number;
177
177
  SubscriberPackageVersionId: string;
178
- Status: string;
178
+ Status: 'Error' | 'InProgress' | 'Queued' | 'Success';
179
179
  };
180
180
  type PackageVersionUninstallRequestError = {
181
181
  Id: string;
@@ -32,6 +32,12 @@ export declare class Package extends AsyncCreatable<PackageOptions> implements I
32
32
  getInstallStatus(installRequestId: string): Promise<PackageInstallRequest>;
33
33
  list(): Promise<QueryResult<PackagingSObjects.Package2>>;
34
34
  uninstall(): Promise<void>;
35
+ /**
36
+ * Reports on the uninstall progress of a package.
37
+ *
38
+ * @param id the 06y package uninstall request id
39
+ */
40
+ uninstallReport(id: string): Promise<PackagingSObjects.SubscriberPackageVersionUninstallRequest>;
35
41
  update(options: PackageUpdateOptions): Promise<PackageSaveResult>;
36
42
  getPackage(packageId: string): Promise<PackagingSObjects.Package2>;
37
43
  getExternalSites(subscriberPackageVersionId: string, installationKey?: string): Promise<Optional<string[]>>;
@@ -72,6 +72,25 @@ class Package extends kit_1.AsyncCreatable {
72
72
  uninstall() {
73
73
  return Promise.resolve(undefined);
74
74
  }
75
+ /**
76
+ * Reports on the uninstall progress of a package.
77
+ *
78
+ * @param id the 06y package uninstall request id
79
+ */
80
+ async uninstallReport(id) {
81
+ const result = (await this.options.connection.tooling.retrieve('SubscriberPackageVersionUninstallRequest', id));
82
+ if (result.Status === 'Error') {
83
+ const errorDetails = await this.options.connection.tooling.query(`SELECT Message FROM PackageVersionUninstallRequestError WHERE ParentRequest.Id = '${id}' ORDER BY Message`);
84
+ const errors = [];
85
+ errorDetails.records.forEach((record) => {
86
+ errors.push(`(${errors.length + 1}) ${record.Message}`);
87
+ });
88
+ const errHeader = errors.length > 0 ? `\n=== Errors\n${errors.join('\n')}` : '';
89
+ const err = messages.getMessage('defaultErrorMessage', [id, result.Id]);
90
+ throw new core_1.SfError(`${err}${errHeader}`, 'UNINSTALL_ERROR', [messages.getMessage('action')]);
91
+ }
92
+ return result;
93
+ }
75
94
  async update(options) {
76
95
  // filter out any undefined values and their keys
77
96
  Object.keys(options).forEach((key) => options[key] === undefined && delete options[key]);
@@ -105,8 +105,7 @@ async function getExternalSites(connection, subscriberPackageVersionId, installa
105
105
  }
106
106
  exports.getExternalSites = getExternalSites;
107
107
  async function getStatus(connection, installRequestId) {
108
- const result = await connection.tooling.retrieve('PackageInstallRequest', installRequestId);
109
- return result;
108
+ return (await connection.tooling.retrieve('PackageInstallRequest', installRequestId));
110
109
  }
111
110
  exports.getStatus = getStatus;
112
111
  // internal
@@ -5,3 +5,11 @@ The %s: [%s] is invalid. It must start with "%s".
5
5
  # invalidIdLength
6
6
 
7
7
  The %s: [%s] is invalid. It must be either 15 or 18 characters.
8
+
9
+ # defaultErrorMessage
10
+
11
+ Can't uninstall the package %s during uninstall request %s.
12
+
13
+ # action
14
+
15
+ Verify installed package ID and resolve errors, then try again.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/packaging",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
4
4
  "description": "packing libraries to Salesforce packaging platform",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",