@salesforce/packaging 0.0.14 → 0.0.17
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 +21 -0
- package/lib/interfaces/packagingInterfacesAndType.d.ts +9 -0
- package/lib/interfaces/packagingSObjects.d.ts +8 -3
- package/lib/package/index.d.ts +2 -0
- package/lib/package/index.js +4 -1
- package/lib/package/packageInstall.js +3 -3
- package/lib/package/packageInstalledList.d.ts +3 -0
- package/lib/package/packageInstalledList.js +9 -0
- package/lib/package/packageUninstall.d.ts +6 -0
- package/lib/package/packageUninstall.js +63 -0
- package/messages/messages.md +8 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
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.17](https://github.com/forcedotcom/packaging/compare/v0.0.16...v0.0.17) (2022-08-10)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- package insstalled list method ([40efd4d](https://github.com/forcedotcom/packaging/commit/40efd4d1dd30289782129d7fe3d56a1df7717517))
|
|
10
|
+
|
|
11
|
+
### [0.0.16](https://github.com/forcedotcom/packaging/compare/v0.0.15...v0.0.16) (2022-08-08)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- add method to uninstall package ([243f4e8](https://github.com/forcedotcom/packaging/commit/243f4e867d5b71a4a24afc70a8551f071dcbbc34))
|
|
16
|
+
|
|
17
|
+
### [0.0.15](https://github.com/forcedotcom/packaging/compare/v0.0.14...v0.0.15) (2022-08-08)
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
- better callCount expectation ([b009e67](https://github.com/forcedotcom/packaging/commit/b009e67445a6e00990fd19fbd048d87008ee49ab))
|
|
22
|
+
- better timeout number for test ([3240911](https://github.com/forcedotcom/packaging/commit/3240911ef5b58ea6179290de066471f9e87ebda5))
|
|
23
|
+
- higher polling timeout for windows ([e6ce60c](https://github.com/forcedotcom/packaging/commit/e6ce60c0583e0b5b92be5b9b86b78de7603dfa77))
|
|
24
|
+
- unit tests and type updates ([23d8648](https://github.com/forcedotcom/packaging/commit/23d8648f570f326873b6e1ff1149067aba07e015))
|
|
25
|
+
|
|
5
26
|
### [0.0.14](https://github.com/forcedotcom/packaging/compare/v0.0.13...v0.0.14) (2022-08-05)
|
|
6
27
|
|
|
7
28
|
### Bug Fixes
|
|
@@ -5,6 +5,7 @@ import { PackageProfileApi } from '../package/packageProfileApi';
|
|
|
5
5
|
import { PackagingSObjects } from './packagingSObjects';
|
|
6
6
|
import Package2VersionStatus = PackagingSObjects.Package2VersionStatus;
|
|
7
7
|
import PackageInstallRequest = PackagingSObjects.PackageInstallRequest;
|
|
8
|
+
import MetadataPackageVersion = PackagingSObjects.MetadataPackageVersion;
|
|
8
9
|
export interface IPackage {
|
|
9
10
|
create(): Promise<void>;
|
|
10
11
|
convert(): Promise<void>;
|
|
@@ -209,3 +210,11 @@ export declare type PackageVersionCreateReportProgress = PackageVersionCreateReq
|
|
|
209
210
|
remainingWaitTime: Duration;
|
|
210
211
|
};
|
|
211
212
|
export declare type Package1VersionCreateRequest = Pick<PackagingSObjects.PackageUploadRequest, 'VersionName'> & Partial<Pick<PackagingSObjects.PackageUploadRequest, 'MetadataPackageId' | 'Description' | 'MajorVersion' | 'MinorVersion' | 'IsReleaseVersion' | 'ReleaseNotesUrl' | 'PostInstallUrl' | 'Password'>>;
|
|
213
|
+
export declare type InstalledPackages = {
|
|
214
|
+
Id: string;
|
|
215
|
+
SubscriberPackageId: string;
|
|
216
|
+
SubscriberPackageVersionId: string;
|
|
217
|
+
MinPackageVersionId: string;
|
|
218
|
+
SubscriberPackage?: PackagingSObjects.SubscriberPackage;
|
|
219
|
+
SubscriberPackageVersion?: Omit<MetadataPackageVersion, 'MetadataPackageId' | 'ReleaseState' | 'IsDeprecated'>;
|
|
220
|
+
};
|
|
@@ -198,14 +198,19 @@ export declare namespace PackagingSObjects {
|
|
|
198
198
|
type SubscriberPackageProfileMappings = {
|
|
199
199
|
profileMappings: SubscriberPackageProfileMapping[];
|
|
200
200
|
};
|
|
201
|
+
type Attributes = {
|
|
202
|
+
type: string;
|
|
203
|
+
url: string;
|
|
204
|
+
};
|
|
201
205
|
type PackageInstallRequest = {
|
|
206
|
+
attributes: Attributes;
|
|
202
207
|
Id: string;
|
|
203
208
|
IsDeleted: boolean;
|
|
204
|
-
CreatedDate:
|
|
209
|
+
CreatedDate: string;
|
|
205
210
|
CreatedById: string;
|
|
206
|
-
LastModifiedDate:
|
|
211
|
+
LastModifiedDate: string;
|
|
207
212
|
LastModifiedById: string;
|
|
208
|
-
SystemModstamp:
|
|
213
|
+
SystemModstamp: string;
|
|
209
214
|
SubscriberPackageVersionKey: string;
|
|
210
215
|
NameConflictResolution: 'Block' | 'RenameMetadata';
|
|
211
216
|
SecurityType: 'Custom' | 'Full' | 'None';
|
package/lib/package/index.d.ts
CHANGED
|
@@ -6,3 +6,5 @@ export * from './packageVersionCreateRequest';
|
|
|
6
6
|
export { listPackageVersions } from './packageVersionList';
|
|
7
7
|
export { createPackage } from './packageCreate';
|
|
8
8
|
export { deletePackage } from './packageDelete';
|
|
9
|
+
export { uninstallPackage } from './packageUninstall';
|
|
10
|
+
export * from './packageInstalledList';
|
package/lib/package/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.deletePackage = exports.createPackage = exports.listPackageVersions = void 0;
|
|
17
|
+
exports.uninstallPackage = exports.deletePackage = exports.createPackage = exports.listPackageVersions = void 0;
|
|
18
18
|
/*
|
|
19
19
|
* Copyright (c) 2022, salesforce.com, inc.
|
|
20
20
|
* All rights reserved.
|
|
@@ -32,4 +32,7 @@ var packageCreate_1 = require("./packageCreate");
|
|
|
32
32
|
Object.defineProperty(exports, "createPackage", { enumerable: true, get: function () { return packageCreate_1.createPackage; } });
|
|
33
33
|
var packageDelete_1 = require("./packageDelete");
|
|
34
34
|
Object.defineProperty(exports, "deletePackage", { enumerable: true, get: function () { return packageDelete_1.deletePackage; } });
|
|
35
|
+
var packageUninstall_1 = require("./packageUninstall");
|
|
36
|
+
Object.defineProperty(exports, "uninstallPackage", { enumerable: true, get: function () { return packageUninstall_1.uninstallPackage; } });
|
|
37
|
+
__exportStar(require("./packageInstalledList"), exports);
|
|
35
38
|
//# sourceMappingURL=index.js.map
|
|
@@ -27,7 +27,7 @@ async function installPackage(connection, pkgInstallCreateRequest, options) {
|
|
|
27
27
|
EnableRss: false,
|
|
28
28
|
NameConflictResolution: 'Block',
|
|
29
29
|
PackageInstallSource: 'U',
|
|
30
|
-
SecurityType: '
|
|
30
|
+
SecurityType: 'None',
|
|
31
31
|
UpgradeType: 'mixed-mode',
|
|
32
32
|
};
|
|
33
33
|
const request = Object.assign({}, defaults, pkgInstallCreateRequest);
|
|
@@ -75,11 +75,11 @@ exports.installPackage = installPackage;
|
|
|
75
75
|
* @returns an array of RSS and CSP site URLs, or undefined if the package doesn't have any.
|
|
76
76
|
*/
|
|
77
77
|
async function getExternalSites(connection, subscriberPackageVersionId, installationKey) {
|
|
78
|
-
const installKey = (0, packageUtils_1.escapeInstallationKey)(installationKey);
|
|
79
78
|
const queryNoKey = `SELECT RemoteSiteSettings, CspTrustedSites FROM SubscriberPackageVersion WHERE Id ='${subscriberPackageVersionId}'`;
|
|
80
|
-
const queryWithKey = `SELECT RemoteSiteSettings, CspTrustedSites FROM SubscriberPackageVersion WHERE Id ='${subscriberPackageVersionId}' AND InstallationKey ='${installKey}'`;
|
|
81
79
|
let queryResult;
|
|
82
80
|
try {
|
|
81
|
+
const escapedInstallationKey = installationKey ? (0, packageUtils_1.escapeInstallationKey)(installationKey) : null;
|
|
82
|
+
const queryWithKey = `${queryNoKey} AND InstallationKey ='${escapedInstallationKey}'`;
|
|
83
83
|
getLogger().debug(`Checking package: [${subscriberPackageVersionId}] for external sites`);
|
|
84
84
|
queryResult = await connection.tooling.query(queryWithKey);
|
|
85
85
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.packageInstalledList = void 0;
|
|
4
|
+
async function packageInstalledList(conn) {
|
|
5
|
+
const query = 'SELECT Id, SubscriberPackageId, SubscriberPackage.NamespacePrefix, SubscriberPackage.Name, SubscriberPackageVersion.Id, SubscriberPackageVersion.Name, SubscriberPackageVersion.MajorVersion, SubscriberPackageVersion.MinorVersion, SubscriberPackageVersion.PatchVersion, SubscriberPackageVersion.BuildNumber FROM InstalledSubscriberPackage ORDER BY SubscriberPackageId';
|
|
6
|
+
return (await conn.tooling.query(query)).records;
|
|
7
|
+
}
|
|
8
|
+
exports.packageInstalledList = packageInstalledList;
|
|
9
|
+
//# sourceMappingURL=packageInstalledList.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
import { Duration } from '@salesforce/kit';
|
|
3
|
+
import { PackagingSObjects } from '../interfaces';
|
|
4
|
+
declare type UninstallResult = PackagingSObjects.SubscriberPackageVersionUninstallRequest;
|
|
5
|
+
export declare function uninstallPackage(id: string, conn: Connection, wait?: Duration): Promise<UninstallResult>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uninstallPackage = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2020, 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 os = require("os");
|
|
11
|
+
const core_1 = require("@salesforce/core");
|
|
12
|
+
const kit_1 = require("@salesforce/kit");
|
|
13
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
14
|
+
const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'messages');
|
|
15
|
+
async function poll(id, conn) {
|
|
16
|
+
const uninstallRequest = await conn.tooling.sobject('SubscriberPackageVersionUninstallRequest').retrieve(id);
|
|
17
|
+
switch (uninstallRequest.Status) {
|
|
18
|
+
case 'Success': {
|
|
19
|
+
return { completed: true, payload: uninstallRequest };
|
|
20
|
+
}
|
|
21
|
+
case 'InProgress':
|
|
22
|
+
case 'Queued': {
|
|
23
|
+
core_1.Lifecycle.getInstance().emit('packageUninstall', {
|
|
24
|
+
...uninstallRequest,
|
|
25
|
+
});
|
|
26
|
+
return { completed: false, payload: uninstallRequest };
|
|
27
|
+
}
|
|
28
|
+
default: {
|
|
29
|
+
const err = messages.getMessage('defaultErrorMessage', [id, uninstallRequest.Id]);
|
|
30
|
+
const errorQueryResult = await conn.tooling.query(`"SELECT Message FROM PackageVersionUninstallRequestError WHERE ParentRequest.Id = '${id}' ORDER BY Message"`);
|
|
31
|
+
const errors = [];
|
|
32
|
+
if (errorQueryResult.records.length) {
|
|
33
|
+
errors.push('\n=== Errors\n');
|
|
34
|
+
errorQueryResult.records.forEach((record) => {
|
|
35
|
+
errors.push(`(${errors.length}) ${record.Message}${os.EOL}`);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
throw new core_1.SfError(`${err}${errors.join(os.EOL)}`, 'UNINSTALL_ERROR', [
|
|
39
|
+
messages.getMessage('uninstallErrorAction'),
|
|
40
|
+
]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async function uninstallPackage(id, conn, wait = kit_1.Duration.seconds(0)) {
|
|
45
|
+
const uninstallRequest = await conn.tooling.sobject('SubscriberPackageVersionUninstallRequest').create({
|
|
46
|
+
SubscriberPackageVersionId: id,
|
|
47
|
+
});
|
|
48
|
+
if (wait.seconds === 0) {
|
|
49
|
+
return (await conn.tooling
|
|
50
|
+
.sobject('SubscriberPackageVersionUninstallRequest')
|
|
51
|
+
.retrieve(uninstallRequest.id));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const pollingClient = await core_1.PollingClient.create({
|
|
55
|
+
poll: () => poll(uninstallRequest.id, conn),
|
|
56
|
+
frequency: kit_1.Duration.seconds(5),
|
|
57
|
+
timeout: wait,
|
|
58
|
+
});
|
|
59
|
+
return pollingClient.subscribe();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.uninstallPackage = uninstallPackage;
|
|
63
|
+
//# sourceMappingURL=packageUninstall.js.map
|
package/messages/messages.md
CHANGED
|
@@ -247,3 +247,11 @@ Package version creation failed with unknown error
|
|
|
247
247
|
|
|
248
248
|
Package upload failed.
|
|
249
249
|
%s
|
|
250
|
+
|
|
251
|
+
# defaultErrorMessage
|
|
252
|
+
|
|
253
|
+
Can't uninstall the package %s during uninstall request %s.
|
|
254
|
+
|
|
255
|
+
# uninstallErrorAction
|
|
256
|
+
|
|
257
|
+
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.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "packing libraries to Salesforce packaging platform",
|
|
5
5
|
"main": "lib/exported",
|
|
6
6
|
"types": "lib/exported.d.ts",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@salesforce/cli-plugins-testkit": "^2.3.4",
|
|
55
55
|
"@salesforce/dev-config": "^3.0.1",
|
|
56
|
-
"@salesforce/dev-scripts": "^2.0.
|
|
56
|
+
"@salesforce/dev-scripts": "^2.0.4",
|
|
57
57
|
"@salesforce/prettier-config": "^0.0.2",
|
|
58
58
|
"@salesforce/ts-sinon": "^1.3.21",
|
|
59
59
|
"@types/debug": "4.1.7",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"pretty-quick": "^3.1.3",
|
|
81
81
|
"shelljs": "0.8.5",
|
|
82
82
|
"sinon": "14.0.0",
|
|
83
|
-
"ts-node": "^10.
|
|
83
|
+
"ts-node": "^10.9.1",
|
|
84
84
|
"typescript": "4.6.4"
|
|
85
85
|
},
|
|
86
86
|
"repository": "forcedotcom/packaging",
|