@salesforce/packaging 4.1.13 → 4.1.14-dev.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.
@@ -26,7 +26,7 @@ export type IPackageVersion2GP = {
26
26
  };
27
27
  export type PackageOptions = {
28
28
  connection: Connection;
29
- project: SfProject;
29
+ project?: SfProject;
30
30
  packageAliasOrId: string;
31
31
  };
32
32
  export type PackageUpdateOptions = {
@@ -232,7 +232,7 @@ export type PackageVersionOptions = {
232
232
  * 3. Alias for a 04t or 05i, defined in sfdx-project.json
233
233
  */
234
234
  idOrAlias: string;
235
- project: SfProject;
235
+ project?: SfProject;
236
236
  };
237
237
  export type SubscriberPackageVersionOptions = {
238
238
  connection: Connection;
@@ -342,7 +342,7 @@ export type PackageAncestryNodeData = {
342
342
  };
343
343
  export type PackageAncestryOptions = {
344
344
  packageId: string;
345
- project: SfProject;
345
+ project?: SfProject;
346
346
  connection: Connection;
347
347
  };
348
348
  export type AncestryRepresentationProducerOptions = {
@@ -51,7 +51,7 @@ export declare class Package {
51
51
  * @param project - instance of SfProject
52
52
  * @param options - see {@link PackageVersionListOptions}
53
53
  */
54
- static listVersions(connection: Connection, project: SfProject, options?: PackageVersionListOptions): Promise<PackageVersionListResult[]>;
54
+ static listVersions(connection: Connection, project?: SfProject, options?: PackageVersionListOptions): Promise<PackageVersionListResult[]>;
55
55
  /**
56
56
  * create a PackageAncestry instance
57
57
  *
@@ -59,7 +59,7 @@ export declare class Package {
59
59
  * @param project SfProject instance
60
60
  * @param connection Hub Org Connection
61
61
  */
62
- static getAncestry(packageId: string, project: SfProject, connection: Connection): Promise<PackageAncestry>;
62
+ static getAncestry(packageId: string, project: SfProject | undefined, connection: Connection): Promise<PackageAncestry>;
63
63
  /**
64
64
  * Convert a 1st generation package to a 2nd generation package.
65
65
  * See {@link ConvertPackageOptions} for conversion options.
@@ -62,8 +62,9 @@ class Package {
62
62
  this.options = options;
63
63
  let packageId = this.options.packageAliasOrId;
64
64
  if (!packageId.startsWith(packagePrefixes.PackageId)) {
65
- packageId =
66
- this.options.project.getPackageIdFromAlias(this.options.packageAliasOrId) ?? this.options.packageAliasOrId;
65
+ packageId = this.options.project
66
+ ? this.options.project.getPackageIdFromAlias(this.options.packageAliasOrId) ?? this.options.packageAliasOrId
67
+ : this.options.packageAliasOrId;
67
68
  if (packageId === this.options.packageAliasOrId) {
68
69
  throw messages.createError('packageAliasNotFound', [this.options.packageAliasOrId]);
69
70
  }
@@ -107,7 +108,7 @@ class Package {
107
108
  static async listVersions(connection, project, options) {
108
109
  // resolve/verify packages
109
110
  const packages = options?.packages?.map((pkg) => {
110
- const id = project.getPackageIdFromAlias(pkg) ?? pkg;
111
+ const id = project ? project.getPackageIdFromAlias(pkg) ?? pkg : pkg;
111
112
  // validate ID
112
113
  if (id.startsWith('0Ho')) {
113
114
  (0, packageUtils_1.validateId)(packageUtils_1.BY_LABEL.PACKAGE_ID, id);
@@ -200,7 +200,9 @@ class PackageAncestry extends kit_1.AsyncCreatable {
200
200
  }
201
201
  async getRootsFromRequestedId() {
202
202
  let roots = [];
203
- this.packageId = this.options.project.getPackageIdFromAlias(this.options.packageId) ?? this.options.packageId;
203
+ this.packageId = this.options.project
204
+ ? this.options.project.getPackageIdFromAlias(this.options.packageId) ?? this.options.packageId
205
+ : this.options.packageId;
204
206
  switch (this.requestedPackageId?.slice(0, 3)) {
205
207
  case '0Ho':
206
208
  pkgUtils.validateId(pkgUtils.BY_LABEL.PACKAGE_ID, this.requestedPackageId);
@@ -1,3 +1,3 @@
1
1
  import { Connection, SfProject } from '@salesforce/core';
2
2
  import { PackageSaveResult } from '../interfaces';
3
- export declare function deletePackage(idOrAlias: string, project: SfProject, connection: Connection, undelete: boolean): Promise<PackageSaveResult>;
3
+ export declare function deletePackage(idOrAlias: string, project: SfProject | undefined, connection: Connection, undelete: boolean): Promise<PackageSaveResult>;
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.deletePackage = deletePackage;
10
10
  const packageUtils_1 = require("../utils/packageUtils");
11
11
  async function deletePackage(idOrAlias, project, connection, undelete) {
12
- const packageId = project.getPackageIdFromAlias(idOrAlias) ?? idOrAlias;
12
+ const packageId = project ? project.getPackageIdFromAlias(idOrAlias) ?? idOrAlias : idOrAlias;
13
13
  (0, packageUtils_1.validateId)(packageUtils_1.BY_LABEL.PACKAGE_ID, packageId);
14
14
  const request = { Id: packageId, IsDeprecated: !undelete };
15
15
  const updateResult = await connection.tooling.update('Package2', request).catch((err) => {
@@ -45,7 +45,7 @@ export type Package2VersionQueryOptions = {
45
45
  */
46
46
  export declare class PackageVersion {
47
47
  private options;
48
- private readonly project;
48
+ private readonly project?;
49
49
  private readonly connection;
50
50
  private data?;
51
51
  private packageType?;
@@ -510,6 +510,9 @@ class PackageVersion {
510
510
  return updateResult;
511
511
  }
512
512
  async updateProjectWithPackageVersion(results) {
513
+ if (!this.project) {
514
+ throw new core_1.SfError('errors.RequiresProject');
515
+ }
513
516
  if (!kit_1.env.getBoolean('SF_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE')) {
514
517
  // get the newly created package version from the server
515
518
  const versionResult = (await this.connection.tooling.query(`SELECT Branch, MajorVersion, MinorVersion, PatchVersion, BuildNumber FROM Package2Version WHERE SubscriberPackageVersionId='${results.SubscriberPackageVersionId ?? ''}'`)).records[0];
@@ -533,7 +536,9 @@ class PackageVersion {
533
536
  }
534
537
  }
535
538
  resolveId() {
536
- return this.project.getPackageIdFromAlias(this.options.idOrAlias) ?? this.options.idOrAlias;
539
+ return this.project
540
+ ? this.project.getPackageIdFromAlias(this.options.idOrAlias) ?? this.options.idOrAlias
541
+ : this.options.idOrAlias;
537
542
  }
538
543
  }
539
544
  exports.PackageVersion = PackageVersion;
@@ -3,6 +3,6 @@ import { PackageVersionReportResult } from '../interfaces';
3
3
  export declare function getPackageVersionReport(options: {
4
4
  packageVersionId: string;
5
5
  connection: Connection;
6
- project: SfProject;
6
+ project?: SfProject;
7
7
  verbose: boolean;
8
8
  }): Promise<PackageVersionReportResult[]>;
@@ -21,3 +21,9 @@ Could not fetch the subscriber package version ID (04t).
21
21
  # maxPackage2VersionRecords
22
22
 
23
23
  The maximum result size (2000) was reached when querying the Package2Version SObject. This means there could be more records that were not returned by the query. If all records are required you may have to break the query into multiple requests filtered by date, then aggregate the results.
24
+
25
+ # errors.RequiresProject
26
+
27
+ This method expects an sfdx project to be available to write the new package version data in it.
28
+ Make sure to pass `options.project` when instantiating `PackageVersion`.
29
+ https://forcedotcom.github.io/packaging/classes/package_packageVersion.PackageVersion.html#constructor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/packaging",
3
- "version": "4.1.13",
3
+ "version": "4.1.14-dev.0",
4
4
  "description": "Packaging library for the Salesforce packaging platform",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",