@salesforce/packaging 0.1.11 → 0.1.13
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/constants.d.ts +3 -0
- package/lib/constants.js +4 -1
- package/lib/interfaces/packagingInterfacesAndType.d.ts +20 -13
- package/lib/interfaces/packagingSObjects.d.ts +1 -1
- package/lib/package/index.d.ts +1 -5
- package/lib/package/index.js +1 -10
- package/lib/package/package.d.ts +79 -32
- package/lib/package/package.js +159 -71
- package/lib/package/packageAncestry.d.ts +3 -1
- package/lib/package/packageAncestry.js +43 -25
- package/lib/package/packageConvert.js +2 -3
- package/lib/package/packageCreate.d.ts +2 -12
- package/lib/package/packageCreate.js +30 -53
- package/lib/package/packageDelete.js +4 -1
- package/lib/package/packageInstall.d.ts +7 -14
- package/lib/package/packageInstall.js +65 -148
- package/lib/package/packageInstalledList.js +8 -2
- package/lib/package/packageUninstall.d.ts +5 -1
- package/lib/package/packageUninstall.js +51 -41
- package/lib/package/packageVersion.d.ts +53 -6
- package/lib/package/packageVersion.js +139 -29
- package/lib/package/packageVersionCreate.d.ts +2 -2
- package/lib/package/packageVersionCreate.js +27 -25
- package/lib/package/packageVersionCreateRequest.js +15 -6
- package/lib/package/packageVersionCreateRequestReport.js +9 -3
- package/lib/package/packageVersionList.js +3 -1
- package/lib/package/packageVersionReport.js +1 -27
- package/lib/package/subscriberPackageVersion.d.ts +156 -0
- package/lib/package/subscriberPackageVersion.js +346 -0
- package/lib/utils/packageUtils.d.ts +10 -11
- package/lib/utils/packageUtils.js +35 -24
- package/messages/package.md +18 -2
- package/messages/package_version.md +12 -0
- package/messages/pkg_utils.md +5 -33
- package/messages/subscriber_package_version.md +19 -0
- package/package.json +3 -3
- package/lib/package/packageList.d.ts +0 -4
- package/lib/package/packageList.js +0 -19
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.combineSaveErrors = exports.formatDate = exports.generatePackageAliasEntry = exports.getPackageAliasesFromId = exports.getPackageIdFromAlias = exports.getConfigPackageDirectory = exports.getPackageVersionNumber = exports.concatVersion = exports.getInClauseItemsCount = exports.queryWithInConditionChunking = exports.getPackageVersionStrings = exports.getHasMetadataRemoved = exports.getContainerOptions = exports.
|
|
3
|
+
exports.numberToDuration = exports.combineSaveErrors = exports.formatDate = exports.generatePackageAliasEntry = exports.getPackageAliasesFromId = exports.getPackageIdFromAlias = exports.getConfigPackageDirectory = exports.getPackageVersionNumber = exports.concatVersion = exports.getInClauseItemsCount = exports.queryWithInConditionChunking = exports.getPackageVersionStrings = exports.getHasMetadataRemoved = exports.getContainerOptions = exports.escapeInstallationKey = exports.getPackageVersionId = exports.massageErrorMessage = exports.applyErrorAction = exports.validateIdNoThrow = exports.getSourceApiVersion = exports.validateId = exports.BY_LABEL = exports.BY_PREFIX = exports.DEFAULT_PACKAGE_DIR = exports.POLL_INTERVAL_SECONDS = exports.SOQL_WHERE_CLAUSE_MAX_LENGTH = exports.INSTALL_URL_BASE = exports.VERSION_NUMBER_SEP = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (c) 2022, salesforce.com, inc.
|
|
6
6
|
* All rights reserved.
|
|
@@ -9,6 +9,8 @@ exports.combineSaveErrors = exports.formatDate = exports.generatePackageAliasEnt
|
|
|
9
9
|
*/
|
|
10
10
|
const os = require("os");
|
|
11
11
|
const core_1 = require("@salesforce/core");
|
|
12
|
+
const ts_types_1 = require("@salesforce/ts-types");
|
|
13
|
+
const kit_1 = require("@salesforce/kit");
|
|
12
14
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
13
15
|
const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'pkg_utils');
|
|
14
16
|
exports.VERSION_NUMBER_SEP = '.';
|
|
@@ -96,7 +98,7 @@ function applyErrorAction(err) {
|
|
|
96
98
|
if (err.name === 'INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST') {
|
|
97
99
|
actions.push(messages.getMessage('invalidPackageTypeAction'));
|
|
98
100
|
}
|
|
99
|
-
if (err.name === 'MALFORMED_ID' && err.message === messages.getMessage('malformedPackageIdMessage')) {
|
|
101
|
+
if (err.name === 'MALFORMED_ID' && err.message === messages.getMessage('malformedPackageIdMessage', [''])) {
|
|
100
102
|
actions.push(messages.getMessage('malformedPackageIdAction'));
|
|
101
103
|
}
|
|
102
104
|
if (err.name === 'MALFORMED_ID' && err.message === messages.getMessage('malformedPackageVersionIdMessage')) {
|
|
@@ -114,6 +116,24 @@ function applyErrorAction(err) {
|
|
|
114
116
|
return err;
|
|
115
117
|
}
|
|
116
118
|
exports.applyErrorAction = applyErrorAction;
|
|
119
|
+
function massageErrorMessage(err) {
|
|
120
|
+
if (err.name === 'INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST') {
|
|
121
|
+
err['message'] = messages.getMessage('invalidPackageTypeMessage');
|
|
122
|
+
}
|
|
123
|
+
if (err.name === 'MALFORMED_ID' &&
|
|
124
|
+
(err.message.includes('Version ID') || err.message.includes('Version Definition ID'))) {
|
|
125
|
+
err['message'] = messages.getMessage('malformedPackageVersionIdMessage');
|
|
126
|
+
}
|
|
127
|
+
if (err.name === 'MALFORMED_ID' && err.message.includes('Package2 ID')) {
|
|
128
|
+
err['message'] = messages.getMessage('malformedPackageIdMessage');
|
|
129
|
+
}
|
|
130
|
+
// remove references to Second Generation
|
|
131
|
+
if (err.message.includes('Second Generation ')) {
|
|
132
|
+
err['message'] = err.message.replace('Second Generation ', '');
|
|
133
|
+
}
|
|
134
|
+
return err;
|
|
135
|
+
}
|
|
136
|
+
exports.massageErrorMessage = massageErrorMessage;
|
|
117
137
|
/**
|
|
118
138
|
* Given a subscriber package version ID (04t) or package version ID (05i), return the package version ID (05i)
|
|
119
139
|
*
|
|
@@ -142,22 +162,6 @@ function escapeInstallationKey(key) {
|
|
|
142
162
|
return key ? key.replace(/\\/g, '\\\\').replace(/'/g, "\\'") : null;
|
|
143
163
|
}
|
|
144
164
|
exports.escapeInstallationKey = escapeInstallationKey;
|
|
145
|
-
/**
|
|
146
|
-
* Given 0Ho the package type type (Managed, Unlocked, Locked(deprecated?))
|
|
147
|
-
*
|
|
148
|
-
* @param packageId the 0Ho
|
|
149
|
-
* @param connection For tooling query
|
|
150
|
-
* @throws Error with message when package2 cannot be found
|
|
151
|
-
*/
|
|
152
|
-
async function getPackageType(packageId, connection) {
|
|
153
|
-
const query = `SELECT ContainerOptions FROM Package2 WHERE id ='${packageId}'`;
|
|
154
|
-
const queryResult = await connection.tooling.query(query);
|
|
155
|
-
if (queryResult.records.length === 0) {
|
|
156
|
-
throw messages.createError('errorInvalidPackageId', [packageId]);
|
|
157
|
-
}
|
|
158
|
-
return queryResult.records[0].ContainerOptions;
|
|
159
|
-
}
|
|
160
|
-
exports.getPackageType = getPackageType;
|
|
161
165
|
/**
|
|
162
166
|
* Get the ContainerOptions for the specified Package2 (0Ho) IDs.
|
|
163
167
|
*
|
|
@@ -344,13 +348,11 @@ exports.getPackageAliasesFromId = getPackageAliasesFromId;
|
|
|
344
348
|
* @param packageId the 0Ho id
|
|
345
349
|
* @private
|
|
346
350
|
*/
|
|
347
|
-
// TODO:
|
|
351
|
+
// TODO: move sfProject
|
|
348
352
|
async function generatePackageAliasEntry(connection, project, packageVersionId, packageVersionNumber, branch, packageId) {
|
|
349
|
-
const configContent = project.getSfProjectJson().getContents();
|
|
350
|
-
const packageAliases = configContent.packageAliases || {};
|
|
351
353
|
const aliasForPackageId = getPackageAliasesFromId(packageId, project);
|
|
352
354
|
let packageName;
|
|
353
|
-
if (
|
|
355
|
+
if (aliasForPackageId?.length === 0) {
|
|
354
356
|
const query = `SELECT Name FROM Package2 WHERE Id = '${packageId}'`;
|
|
355
357
|
const package2 = await connection.singleRecordQuery(query, { tooling: true });
|
|
356
358
|
packageName = package2.Name;
|
|
@@ -361,8 +363,7 @@ async function generatePackageAliasEntry(connection, project, packageVersionId,
|
|
|
361
363
|
const packageAlias = branch
|
|
362
364
|
? `${packageName}@${packageVersionNumber}-${branch}`
|
|
363
365
|
: `${packageName}@${packageVersionNumber}`;
|
|
364
|
-
|
|
365
|
-
return packageAliases;
|
|
366
|
+
return [packageAlias, packageVersionId];
|
|
366
367
|
}
|
|
367
368
|
exports.generatePackageAliasEntry = generatePackageAliasEntry;
|
|
368
369
|
function formatDate(date) {
|
|
@@ -380,4 +381,14 @@ function combineSaveErrors(sObject, crudOperation, errors) {
|
|
|
380
381
|
return messages.createError('errorDuringSObjectCRUDOperation', [crudOperation, sObject, errorMessages.join(os.EOL)]);
|
|
381
382
|
}
|
|
382
383
|
exports.combineSaveErrors = combineSaveErrors;
|
|
384
|
+
/**
|
|
385
|
+
* Returns a Duration object from param duration when it is a number, otherwise return itself
|
|
386
|
+
*
|
|
387
|
+
* @param duration = number to be converted to a Duration or Duration object
|
|
388
|
+
* @param unit = (Default Duration.Unit.MILLISECONDS) Duration unit of number - See @link {Duration.Unit} for valid values
|
|
389
|
+
*/
|
|
390
|
+
function numberToDuration(duration, unit = kit_1.Duration.Unit.MILLISECONDS) {
|
|
391
|
+
return (0, ts_types_1.isNumber)(duration) ? new kit_1.Duration(duration, unit) : duration;
|
|
392
|
+
}
|
|
393
|
+
exports.numberToDuration = numberToDuration;
|
|
383
394
|
//# sourceMappingURL=packageUtils.js.map
|
package/messages/package.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# invalidPackageId
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The id [%s] is invalid. It must start with "%s".
|
|
4
4
|
|
|
5
5
|
# invalidIdLength
|
|
6
6
|
|
|
7
|
-
The
|
|
7
|
+
The id [%s] is invalid. It must be either 15 or 18 characters.
|
|
8
8
|
|
|
9
9
|
# defaultErrorMessage
|
|
10
10
|
|
|
@@ -13,3 +13,19 @@ Can't uninstall the package %s during uninstall request %s.
|
|
|
13
13
|
# action
|
|
14
14
|
|
|
15
15
|
Verify installed package ID and resolve errors, then try again.
|
|
16
|
+
|
|
17
|
+
# couldNotFindAliasForId
|
|
18
|
+
|
|
19
|
+
Could not find an alias for the ID %s.
|
|
20
|
+
|
|
21
|
+
# packageAliasNotFound
|
|
22
|
+
|
|
23
|
+
Package alias %s not found in project.
|
|
24
|
+
|
|
25
|
+
# noPackageAliases
|
|
26
|
+
|
|
27
|
+
The project doesn't have any package aliases.
|
|
28
|
+
|
|
29
|
+
# package2VersionNotFoundFor04t
|
|
30
|
+
|
|
31
|
+
Could not find a Package2Version record for SubscriberPackageVersionId %s.
|
|
@@ -5,3 +5,15 @@ The %s %s is invalid, as a corresponding %s was not found
|
|
|
5
5
|
# errorInvalidPackageVersionId
|
|
6
6
|
|
|
7
7
|
The provided alias or ID: [%s] could not be resolved to a valid package version ID (05i) or subscriber package version ID (04t).
|
|
8
|
+
|
|
9
|
+
# packageVersionInstallRequestIdInvalid
|
|
10
|
+
|
|
11
|
+
The provided package install request ID: [%s] is invalid. It must be a 15 or 18 character package install request ID (0Hf).
|
|
12
|
+
|
|
13
|
+
# packageVersionUninstallRequestIdInvalid
|
|
14
|
+
|
|
15
|
+
The provided package uninstall request ID: [%s] is invalid. It must be a 15 or 18 character package install request ID (06y).
|
|
16
|
+
|
|
17
|
+
# packageVersionInstallRequestNotFound
|
|
18
|
+
|
|
19
|
+
The provided package install request ID: [%s] could not be found.
|
package/messages/pkg_utils.md
CHANGED
|
@@ -3,34 +3,6 @@
|
|
|
3
3
|
An error occurred during CRUD operation %s on entity %s.
|
|
4
4
|
%s
|
|
5
5
|
|
|
6
|
-
# errorInvalidPatchNumber
|
|
7
|
-
|
|
8
|
-
The provided VersionNumber '%s' is not supported. Provide a patch number of 0.
|
|
9
|
-
|
|
10
|
-
# errorInvalidAncestorVersionFormat
|
|
11
|
-
|
|
12
|
-
The ancestor versionNumber must be in the format major.minor.patch but the value found is [%s].
|
|
13
|
-
|
|
14
|
-
# errorNoMatchingMajorMinorForPatch
|
|
15
|
-
|
|
16
|
-
Can’t create patch version. The specified package ancestor [%s] either isn’t a promoted and released version, or can’t be found. Check the specified ancestor version, and then retry creating the patch version.
|
|
17
|
-
|
|
18
|
-
# errorNoMatchingAncestor
|
|
19
|
-
|
|
20
|
-
The ancestorId for ancestorVersion [%s] can't be found. Package ID [%s].
|
|
21
|
-
|
|
22
|
-
# errorAncestorNotReleased
|
|
23
|
-
|
|
24
|
-
The ancestor package version [%s] specified in the sfdx-project.json file hasn’t been promoted and released. Release the ancestor package version before specifying it as the ancestor in a new package or patch version.
|
|
25
|
-
|
|
26
|
-
# errorAncestorIdVersionMismatch
|
|
27
|
-
|
|
28
|
-
Can’t create package version. The ancestorVersion listed in your sfdx-project.json file doesn’t map to this package. Ensure the ancestor ID is correct, or set the ID to ancestorID:HIGHEST to ensure the highest released package version is used as the ancestor. Then try creating the package version again.
|
|
29
|
-
|
|
30
|
-
# errorAncestorIdVersionHighestOrNoneMismatch
|
|
31
|
-
|
|
32
|
-
Can’t create package version. The ancestorId [%s] and ancestorVersion [%s] in your sfdx-project.json file don’t map to the same package version. Remove the incorrect entry, and try creating the package version again.
|
|
33
|
-
|
|
34
6
|
# errorInvalidIdNoMatchingVersionId
|
|
35
7
|
|
|
36
8
|
The %s %s is invalid, as a corresponding %s was not found
|
|
@@ -61,16 +33,12 @@ Use "sfdx force:package:list" to verify the 0Ho package version ID.
|
|
|
61
33
|
|
|
62
34
|
# malformedPackageIdMessage
|
|
63
35
|
|
|
64
|
-
We can’t find this package ID for this Dev Hub.
|
|
36
|
+
We can’t find this package ID %s for this Dev Hub.
|
|
65
37
|
|
|
66
38
|
# notFoundMessage
|
|
67
39
|
|
|
68
40
|
The requested resource does not exist
|
|
69
41
|
|
|
70
|
-
# versionCreateFailedWithMultipleErrors
|
|
71
|
-
|
|
72
|
-
Multiple errors occurred:
|
|
73
|
-
|
|
74
42
|
# itemDoesNotFitWithinMaxLength
|
|
75
43
|
|
|
76
44
|
When calculating the number of items to be included in query "%s", when formatted, was too long.
|
|
@@ -91,3 +59,7 @@ Your Dev Hub does not have permission to specify a source org for your build org
|
|
|
91
59
|
# invalidIdOrAlias
|
|
92
60
|
|
|
93
61
|
The %s: %s isn't defined in the sfdx-project.json. Add it to the packageDirectories section and add the alias to packageAliases with its %s ID.
|
|
62
|
+
|
|
63
|
+
# errorInvalidPackageId
|
|
64
|
+
|
|
65
|
+
The provided package ID '%s' is invalid.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# errorInvalidIdNoRecordFound
|
|
2
|
+
|
|
3
|
+
The subscriber package version %s is invalid, no subscriber package version record found.
|
|
4
|
+
|
|
5
|
+
# errorInvalidAliasOrId
|
|
6
|
+
|
|
7
|
+
Invalid alias or ID: %s. Either your alias is invalid or undefined, or the ID (04t) provided is invalid.
|
|
8
|
+
|
|
9
|
+
# packageVersionInstallRequestIdInvalid
|
|
10
|
+
|
|
11
|
+
The provided package install request ID: [%s] is invalid. It must be a 15 or 18 character package install request ID (0Hf).
|
|
12
|
+
|
|
13
|
+
# packageVersionUninstallRequestIdInvalid
|
|
14
|
+
|
|
15
|
+
The provided package uninstall request ID: [%s] is invalid. It must be a 15 or 18 character package install request ID (06y).
|
|
16
|
+
|
|
17
|
+
# packageVersionInstallRequestNotFound
|
|
18
|
+
|
|
19
|
+
The provided package install request ID: [%s] could not be found.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/packaging",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "packing libraries to Salesforce packaging platform",
|
|
5
5
|
"main": "lib/exported",
|
|
6
6
|
"types": "lib/exported.d.ts",
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
"@types/globby": "^9.1.0",
|
|
65
65
|
"@types/jszip": "^3.4.1",
|
|
66
66
|
"@types/xml2js": "^0.4.11",
|
|
67
|
-
"@typescript-eslint/eslint-plugin": "^5.40.
|
|
67
|
+
"@typescript-eslint/eslint-plugin": "^5.40.1",
|
|
68
68
|
"@typescript-eslint/parser": "5.40.1",
|
|
69
69
|
"chai": "^4.3.6",
|
|
70
70
|
"commitizen": "^4.2.4",
|
|
71
|
-
"eslint": "^8.
|
|
71
|
+
"eslint": "^8.26.0",
|
|
72
72
|
"eslint-config-prettier": "^8.5.0",
|
|
73
73
|
"eslint-config-salesforce": "^0.1.6",
|
|
74
74
|
"eslint-config-salesforce-license": "^0.1.6",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2022, 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.listPackages = void 0;
|
|
10
|
-
const QUERY = 'SELECT Id, SubscriberPackageId, Name, Description, NamespacePrefix, ContainerOptions, IsOrgDependent, ConvertedFromPackageId, ' +
|
|
11
|
-
'PackageErrorUsername, CreatedById ' +
|
|
12
|
-
'FROM Package2 ' +
|
|
13
|
-
'WHERE IsDeprecated != true ' +
|
|
14
|
-
'ORDER BY NamespacePrefix, Name';
|
|
15
|
-
async function listPackages(connection) {
|
|
16
|
-
return connection.tooling.query(QUERY);
|
|
17
|
-
}
|
|
18
|
-
exports.listPackages = listPackages;
|
|
19
|
-
//# sourceMappingURL=packageList.js.map
|