@salesforce/packaging 1.0.6 → 1.0.8

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/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # Salesforce Packaging
2
2
 
3
- > :warning: **This module is under heavy development, please do not use in production.**
4
-
5
3
  [![NPM](https://img.shields.io/npm/v/@salesforce/packaging.svg?label=@salesforce/packaging)](https://www.npmjs.com/package/@salesforce/packaging) [![Downloads/week](https://img.shields.io/npm/dw/@salesforce/packaging.svg)](https://npmjs.org/package/@salesforce/packaging) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://raw.githubusercontent.com/forcedotcom/packaging/main/LICENSE.txt)
6
4
 
7
5
  ## Description
@@ -12,12 +10,12 @@ A TypeScript library for packaging metadata in your Salesforce project. This lib
12
10
 
13
11
  There are 4 main classes to use from this library:
14
12
 
15
- 1. `Package1Version` - Work with 1st generation package versions.
16
- 1. `Package` - Work with 2nd generation packages.
17
- 1. `PackageVersion` - Work with 2nd generation package versions.
18
- 1. `SubscriberPackageVersion` - Work with 2nd generation subscriber package versions.
13
+ 1. [Package1Version](https://forcedotcom.github.io/packaging/classes/package1_package1Version.Package1Version.html) - Work with 1st generation package versions.
14
+ 1. [Package](https://forcedotcom.github.io/packaging/classes/package_package.Package.html) - Work with 2nd generation packages.
15
+ 1. [PackageVersion](https://forcedotcom.github.io/packaging/classes/package_packageVersion.PackageVersion.html) - Work with 2nd generation package versions.
16
+ 1. [SubscriberPackageVersion](https://forcedotcom.github.io/packaging/classes/package_subscriberPackageVersion.SubscriberPackageVersion.html) - Work with 2nd generation subscriber package versions.
19
17
 
20
- Please see the [API Documentation](https://forcedotcom.github.io/packaging/) for details.
18
+ Please reference the [API Documentation](https://forcedotcom.github.io/packaging/) for complete details of code and types.
21
19
 
22
20
  ## Contributing
23
21
 
@@ -3,10 +3,22 @@ import { ConvertPackageOptions, PackageCreateOptions, PackageOptions, PackageSav
3
3
  import { PackageAncestry } from './packageAncestry';
4
4
  export declare const Package2Fields: string[];
5
5
  /**
6
- * Package class.
6
+ * Provides the ability to list, create, update, delete, convert, and get version
7
+ * ancestry for a 2nd generation package.
7
8
  *
8
- * This class provides the base implementation for a package.
9
- * To create a new instance of a package, use the static async Package.create({connection, project, packageOrAliasId}) method.
9
+ * **Examples**
10
+ *
11
+ * Create a new instance and get the ID (0Ho):
12
+ *
13
+ * `const id = new Package({connection, project, packageOrAliasId}).getId();`
14
+ *
15
+ * Create a new package in the org:
16
+ *
17
+ * `const myPkg = await Package.create(connection, project, options);`
18
+ *
19
+ * List all packages in the org:
20
+ *
21
+ * `const pkgList = await Package.list(connection);`
10
22
  */
11
23
  export declare class Package {
12
24
  private options;
@@ -41,10 +41,22 @@ exports.Package2Fields = [
41
41
  'PackageErrorUsername',
42
42
  ];
43
43
  /**
44
- * Package class.
44
+ * Provides the ability to list, create, update, delete, convert, and get version
45
+ * ancestry for a 2nd generation package.
45
46
  *
46
- * This class provides the base implementation for a package.
47
- * To create a new instance of a package, use the static async Package.create({connection, project, packageOrAliasId}) method.
47
+ * **Examples**
48
+ *
49
+ * Create a new instance and get the ID (0Ho):
50
+ *
51
+ * `const id = new Package({connection, project, packageOrAliasId}).getId();`
52
+ *
53
+ * Create a new package in the org:
54
+ *
55
+ * `const myPkg = await Package.create(connection, project, options);`
56
+ *
57
+ * List all packages in the org:
58
+ *
59
+ * `const pkgList = await Package.list(connection);`
48
60
  */
49
61
  class Package {
50
62
  constructor(options) {
@@ -3,6 +3,24 @@ import { Duration } from '@salesforce/kit';
3
3
  import { PackageSaveResult, PackageType, PackageVersionCreateOptions, PackageVersionCreateRequestQueryOptions, PackageVersionCreateRequestResult, PackageVersionOptions, PackageVersionReportResult, PackageVersionUpdateOptions, PackagingSObjects } from '../interfaces';
4
4
  declare type Package2Version = PackagingSObjects.Package2Version;
5
5
  export declare const Package2VersionFields: string[];
6
+ /**
7
+ * Provides the ability to create, update, delete, and promote 2nd
8
+ * generation package versions.
9
+ *
10
+ * **Examples**
11
+ *
12
+ * Create a new instance and get the ID (05i):
13
+ *
14
+ * `const id = new PackageVersion({connection, project, idOrAlias}).getId();`
15
+ *
16
+ * Create a new package version in the org:
17
+ *
18
+ * `const myPkgVersion = await PackageVersion.create(options, pollingOptions);`
19
+ *
20
+ * Promote a package version:
21
+ *
22
+ * `new PackageVersion({connection, project, idOrAlias}).promote();`
23
+ */
6
24
  export declare class PackageVersion {
7
25
  private options;
8
26
  private readonly project;
@@ -125,16 +143,6 @@ export declare class PackageVersion {
125
143
  */
126
144
  promote(): Promise<PackageSaveResult>;
127
145
  update(options: PackageVersionUpdateOptions): Promise<PackageSaveResult>;
128
- /**
129
- * Creates a new package version.
130
- *
131
- * @param options
132
- * @param polling frequency and timeout Durations to be used in polling
133
- */
134
- create(options: PackageVersionCreateOptions, polling?: {
135
- frequency: Duration;
136
- timeout: Duration;
137
- }): Promise<Partial<PackageVersionCreateRequestResult>>;
138
146
  private updateDeprecation;
139
147
  private updateProjectWithPackageVersion;
140
148
  private resolveId;
@@ -50,6 +50,24 @@ exports.Package2VersionFields = [
50
50
  'BuildDurationInSeconds',
51
51
  'HasMetadataRemoved',
52
52
  ];
53
+ /**
54
+ * Provides the ability to create, update, delete, and promote 2nd
55
+ * generation package versions.
56
+ *
57
+ * **Examples**
58
+ *
59
+ * Create a new instance and get the ID (05i):
60
+ *
61
+ * `const id = new PackageVersion({connection, project, idOrAlias}).getId();`
62
+ *
63
+ * Create a new package version in the org:
64
+ *
65
+ * `const myPkgVersion = await PackageVersion.create(options, pollingOptions);`
66
+ *
67
+ * Promote a package version:
68
+ *
69
+ * `new PackageVersion({connection, project, idOrAlias}).promote();`
70
+ */
53
71
  class PackageVersion {
54
72
  constructor(options) {
55
73
  this.options = options;
@@ -407,27 +425,6 @@ class PackageVersion {
407
425
  result.id = await this.getSubscriberId();
408
426
  return result;
409
427
  }
410
- /**
411
- * Creates a new package version.
412
- *
413
- * @param options
414
- * @param polling frequency and timeout Durations to be used in polling
415
- */
416
- async create(options, polling = {
417
- frequency: kit_1.Duration.seconds(0),
418
- timeout: kit_1.Duration.seconds(0),
419
- }) {
420
- const pvc = new packageVersionCreate_1.PackageVersionCreate({ ...options, ...this.options });
421
- const createResult = await pvc.createPackageVersion();
422
- if (polling.timeout?.milliseconds > 0) {
423
- return PackageVersion.waitForCreateVersion(createResult.Id, this.project, this.connection, polling).catch((err) => {
424
- // TODO
425
- // until package2 is GA, wrap perm-based errors w/ 'contact sfdc' action (REMOVE once package2 is GA'd)
426
- throw (0, packageUtils_1.applyErrorAction)((0, packageUtils_1.massageErrorMessage)(err));
427
- });
428
- }
429
- return createResult;
430
- }
431
428
  async updateDeprecation(isDeprecated) {
432
429
  const id = await this.getId();
433
430
  // setup the request
@@ -446,7 +443,11 @@ class PackageVersion {
446
443
  if (!process.env.SFDX_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE) {
447
444
  // get the newly created package version from the server
448
445
  const versionResult = (await this.connection.tooling.query(`SELECT Branch, MajorVersion, MinorVersion, PatchVersion, BuildNumber FROM Package2Version WHERE SubscriberPackageVersionId='${results.SubscriberPackageVersionId}'`)).records[0];
449
- const version = `${this.project.getAliasesFromPackageId(results.Package2Id).join()}@${versionResult.MajorVersion ?? 0}.${versionResult.MinorVersion ?? 0}.${versionResult.PatchVersion ?? 0}`;
446
+ const aliases = this.project.getAliasesFromPackageId(results.Package2Id);
447
+ if (aliases.length === 0) {
448
+ throw messages.createError('packageAliasNotFound', [results.Package2Id]);
449
+ }
450
+ const version = `${aliases[0]}@${versionResult.MajorVersion ?? 0}.${versionResult.MinorVersion ?? 0}.${versionResult.PatchVersion ?? 0}`;
450
451
  const build = versionResult.BuildNumber ? `-${versionResult.BuildNumber}` : '';
451
452
  const branch = versionResult.Branch ? `-${versionResult.Branch}` : '';
452
453
  // set packageAliases entry '<package>@<major>.<minor>.<patch>-<build>-<branch>: <result.subscriberPackageVersionId>'
@@ -5,7 +5,18 @@ import { InstalledPackages, PackageInstallCreateRequest, PackageInstallOptions,
5
5
  import { VersionNumber } from './versionNumber';
6
6
  export declare const SubscriberPackageVersionFields: string[];
7
7
  /**
8
- * A class that represents a SubscriberPackageVersion
8
+ * Provides the ability to get, list, install, and uninstall 2nd
9
+ * generation subscriber package versions.
10
+ *
11
+ * **Examples**
12
+ *
13
+ * List all 2GP installed packages in the org:
14
+ *
15
+ * `const installedPkgs = await SubscriberPackageVersion.installedList(connection);`
16
+ *
17
+ * Install a 2GP subscriber package version:
18
+ *
19
+ * `const installStatus = await new SubscriberPackageVersion(options).install(request, options);`
9
20
  */
10
21
  export declare class SubscriberPackageVersion {
11
22
  private options;
@@ -75,7 +75,18 @@ const allZeroesInstallOptions = {
75
75
  publishTimeout: kit_1.Duration.minutes(0),
76
76
  };
77
77
  /**
78
- * A class that represents a SubscriberPackageVersion
78
+ * Provides the ability to get, list, install, and uninstall 2nd
79
+ * generation subscriber package versions.
80
+ *
81
+ * **Examples**
82
+ *
83
+ * List all 2GP installed packages in the org:
84
+ *
85
+ * `const installedPkgs = await SubscriberPackageVersion.installedList(connection);`
86
+ *
87
+ * Install a 2GP subscriber package version:
88
+ *
89
+ * `const installStatus = await new SubscriberPackageVersion(options).install(request, options);`
79
90
  */
80
91
  class SubscriberPackageVersion {
81
92
  constructor(options) {
@@ -3,9 +3,19 @@ import { Duration } from '@salesforce/kit';
3
3
  import { IPackageVersion1GP, Package1VersionCreateRequest, PackagingSObjects } from '../interfaces';
4
4
  import MetadataPackageVersion = PackagingSObjects.MetadataPackageVersion;
5
5
  /**
6
- * Package1Version class - Class to be used with 1st generation package versions
6
+ * Provides the ability to get, list, and create 1st generation package versions.
7
7
  *
8
- * implementation examples can be seen here: https://github.com/salesforcecli/plugin-packaging/tree/main/src/commands/force/package1/
8
+ * **Examples**
9
+ *
10
+ * List all 1GP package versions in the org:
11
+ *
12
+ * `const pkgList = await Package1Version.list(connection);`
13
+ *
14
+ * Create a new 1GP package vesion in the org:
15
+ *
16
+ * `const myPkg = await Package1Version.create(connection, options, pollingOptions);`
17
+ *
18
+ * More implementation examples are in the plugin here: https://github.com/salesforcecli/plugin-packaging/tree/main/src/commands/force/package1/
9
19
  */
10
20
  export declare class Package1Version implements IPackageVersion1GP {
11
21
  private connection;
@@ -14,9 +14,19 @@ const interfaces_1 = require("../interfaces");
14
14
  core_1.Messages.importMessagesDirectory(__dirname);
15
15
  const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'package1Version');
16
16
  /**
17
- * Package1Version class - Class to be used with 1st generation package versions
17
+ * Provides the ability to get, list, and create 1st generation package versions.
18
18
  *
19
- * implementation examples can be seen here: https://github.com/salesforcecli/plugin-packaging/tree/main/src/commands/force/package1/
19
+ * **Examples**
20
+ *
21
+ * List all 1GP package versions in the org:
22
+ *
23
+ * `const pkgList = await Package1Version.list(connection);`
24
+ *
25
+ * Create a new 1GP package vesion in the org:
26
+ *
27
+ * `const myPkg = await Package1Version.create(connection, options, pollingOptions);`
28
+ *
29
+ * More implementation examples are in the plugin here: https://github.com/salesforcecli/plugin-packaging/tree/main/src/commands/force/package1/
20
30
  */
21
31
  class Package1Version {
22
32
  /**
@@ -17,3 +17,7 @@ The provided package uninstall request ID: [%s] is invalid. It must be a 15 or 1
17
17
  # packageVersionInstallRequestNotFound
18
18
 
19
19
  The provided package install request ID: [%s] could not be found.
20
+
21
+ # packageAliasNotFound
22
+
23
+ The provided package id: [%s] could not be resolved to an alias.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/packaging",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Packaging library for the Salesforce packaging platform",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",