@salesforce/packaging 1.4.16 → 1.4.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.
Files changed (38) hide show
  1. package/lib/interfaces/packagingInterfacesAndType.d.ts +37 -33
  2. package/lib/package/package.d.ts +3 -3
  3. package/lib/package/package.js +14 -8
  4. package/lib/package/packageAncestry.d.ts +24 -25
  5. package/lib/package/packageAncestry.js +159 -147
  6. package/lib/package/packageConvert.d.ts +1 -1
  7. package/lib/package/packageConvert.js +15 -21
  8. package/lib/package/packageCreate.d.ts +1 -1
  9. package/lib/package/packageCreate.js +14 -25
  10. package/lib/package/packageDelete.js +4 -1
  11. package/lib/package/packageInstall.d.ts +5 -4
  12. package/lib/package/packageInstall.js +10 -9
  13. package/lib/package/packageProfileApi.d.ts +3 -6
  14. package/lib/package/packageProfileApi.js +153 -145
  15. package/lib/package/packageUninstall.js +15 -9
  16. package/lib/package/packageVersion.d.ts +6 -5
  17. package/lib/package/packageVersion.js +76 -46
  18. package/lib/package/packageVersionCreate.d.ts +2 -2
  19. package/lib/package/packageVersionCreate.js +81 -59
  20. package/lib/package/packageVersionCreateRequest.d.ts +2 -2
  21. package/lib/package/packageVersionCreateRequest.js +8 -11
  22. package/lib/package/packageVersionCreateRequestReport.js +4 -1
  23. package/lib/package/packageVersionList.d.ts +5 -4
  24. package/lib/package/packageVersionList.js +18 -18
  25. package/lib/package/packageVersionReport.js +6 -4
  26. package/lib/package/subscriberPackageVersion.d.ts +4 -4
  27. package/lib/package/subscriberPackageVersion.js +23 -10
  28. package/lib/package/versionNumber.d.ts +8 -3
  29. package/lib/package/versionNumber.js +13 -4
  30. package/lib/package1/package1Version.js +18 -13
  31. package/lib/utils/packageUtils.d.ts +11 -7
  32. package/lib/utils/packageUtils.js +25 -12
  33. package/messages/package.md +4 -0
  34. package/messages/package1Version.md +4 -0
  35. package/messages/package_version.md +8 -0
  36. package/messages/package_version_create.md +32 -4
  37. package/messages/pkg_utils.md +1 -1
  38. package/package.json +13 -12
@@ -135,23 +135,23 @@ export type PackageDescriptorJson = Partial<NamedPackageDir> & Partial<{
135
135
  export type PackageVersionCreateRequest = {
136
136
  Package2Id: string;
137
137
  VersionInfo: string;
138
- Tag: string;
139
- Branch: string;
140
- InstallKey: string;
141
- Instance: string;
142
- SourceOrg: string;
138
+ Tag?: string;
139
+ Branch?: string;
140
+ InstallKey?: string;
141
+ Instance?: string;
142
+ SourceOrg?: string;
143
143
  Language?: string;
144
144
  CalculateCodeCoverage: boolean;
145
145
  SkipValidation: boolean;
146
146
  };
147
147
  export type PackageVersionListOptions = {
148
- orderBy: string;
149
- modifiedLastDays: number;
150
- createdLastDays: number;
151
- packages: string[];
152
- verbose: boolean;
153
- concise: boolean;
154
- isReleased: boolean;
148
+ orderBy?: string;
149
+ modifiedLastDays?: number;
150
+ createdLastDays?: number;
151
+ packages?: string[];
152
+ verbose?: boolean;
153
+ concise?: boolean;
154
+ isReleased?: boolean;
155
155
  };
156
156
  export type PackageVersionUpdateOptions = {
157
157
  InstallKey?: string;
@@ -160,9 +160,6 @@ export type PackageVersionUpdateOptions = {
160
160
  Branch?: string;
161
161
  Tag?: string;
162
162
  };
163
- export type ListPackageVersionOptions = PackageVersionListOptions & {
164
- connection: Connection;
165
- };
166
163
  export type PackageSaveResult = SaveResult;
167
164
  export type PackageVersionCreateRequestOptions = {
168
165
  path: string;
@@ -259,7 +256,6 @@ export type PackageVersionCreateOptions = {
259
256
  }>;
260
257
  export type PackageVersionCreateRequestQueryOptions = {
261
258
  createdlastdays?: number;
262
- connection?: Connection;
263
259
  status?: 'Queued' | 'InProgress' | 'Success' | 'Error';
264
260
  id?: string;
265
261
  };
@@ -268,12 +264,17 @@ export type ProfileApiOptions = {
268
264
  includeUserLicenses: boolean;
269
265
  generateProfileInformation: boolean;
270
266
  };
271
- export type PackageVersionReportResult = Partial<PackagingSObjects.Package2Version> & {
272
- Package2: Partial<PackagingSObjects.Package2>;
267
+ export type PackageVersionReportResult = Partial<Omit<PackagingSObjects.Package2Version, 'AncestorId' | 'HasPassedCodeCoverageCheck' | 'HasMetadataRemoved'>> & {
268
+ Package2: Partial<Omit<PackagingSObjects.Package2, 'IsOrgDependent'>> & {
269
+ IsOrgDependent: boolean | null | undefined;
270
+ };
273
271
  SubscriberPackageVersion?: Pick<PackagingSObjects.SubscriberPackageVersion, 'Dependencies'>;
274
272
  Version: string;
275
- AncestorVersion?: string;
276
- PackageType: PackageType;
273
+ AncestorVersion?: string | null;
274
+ AncestorId?: string | null;
275
+ PackageType?: PackageType | null;
276
+ HasPassedCodeCoverageCheck?: boolean | null;
277
+ HasMetadataRemoved?: boolean | null;
277
278
  };
278
279
  export type PackageVersionCreateReportProgress = PackageVersionCreateRequestResult & {
279
280
  remainingWaitTime: Duration;
@@ -300,14 +301,17 @@ export type CodeCoveragePercentages = null | {
300
301
  };
301
302
  export type PackageAncestryNodeOptions = Attributes & {
302
303
  AncestorId?: string;
303
- SubscriberPackageVersionId?: string;
304
- MajorVersion?: string | number;
305
- MinorVersion?: string | number;
306
- PatchVersion?: string | number;
307
- BuildNumber?: string | number;
308
- depthCounter?: number;
309
- };
310
- export type PackageAncestryData = Omit<PackageAncestryNodeOptions, 'AncestorId'>;
304
+ SubscriberPackageVersionId: string;
305
+ MajorVersion: string | number;
306
+ MinorVersion: string | number;
307
+ PatchVersion: string | number;
308
+ BuildNumber: string | number;
309
+ depthCounter: number;
310
+ };
311
+ export type PackageAncestryNodeAttributes = PackageAncestryNodeOptions & {
312
+ node: PackageAncestryNode;
313
+ };
314
+ export type PackageAncestryData = Omit<PackageAncestryNodeAttributes, 'AncestorId'>;
311
315
  export type PackageAncestryNodeData = {
312
316
  data: PackageAncestryNodeOptions;
313
317
  children: PackageAncestryNodeData[];
@@ -318,16 +322,16 @@ export type PackageAncestryOptions = {
318
322
  connection: Connection;
319
323
  };
320
324
  export type AncestryRepresentationProducerOptions = {
321
- [key: string]: unknown;
322
- node: PackageAncestryNode;
323
- depth?: number;
325
+ packageNode?: PackageAncestryNode;
326
+ depth: number;
324
327
  verbose?: boolean;
328
+ logger?: (text: string) => void;
325
329
  };
326
330
  export interface AncestryRepresentationProducer {
327
331
  label: string;
328
- options: AncestryRepresentationProducerOptions;
332
+ options?: AncestryRepresentationProducerOptions;
329
333
  addNode(node: AncestryRepresentationProducer): void;
330
- produce<T>(): T | string | void;
334
+ produce(): PackageAncestryNodeData | string | void;
331
335
  }
332
336
  export declare const PackageEvents: {
333
337
  convert: {
@@ -23,7 +23,7 @@ export declare const Package2Fields: string[];
23
23
  export declare class Package {
24
24
  private options;
25
25
  private readonly packageId;
26
- private packageData;
26
+ private packageData?;
27
27
  constructor(options: PackageOptions);
28
28
  /**
29
29
  * Create a new package.
@@ -80,7 +80,7 @@ export declare class Package {
80
80
  *
81
81
  * @returns {Promise<PackageType>}
82
82
  */
83
- getType(): Promise<PackageType>;
83
+ getType(): Promise<PackageType | undefined>;
84
84
  /**
85
85
  * Returns the list of package versions for the package.
86
86
  * See {@link PackageVersionListOptions} for list options
@@ -111,5 +111,5 @@ export declare class Package {
111
111
  *
112
112
  * @param force force a refresh of the package data
113
113
  */
114
- getPackageData(force?: boolean): Promise<PackagingSObjects.Package2>;
114
+ getPackageData(force?: boolean): Promise<PackagingSObjects.Package2 | undefined>;
115
115
  }
@@ -119,9 +119,9 @@ class Package {
119
119
  throw messages.createError('invalidPackageId', [id, '0Ho']);
120
120
  }
121
121
  });
122
- const opts = options || {};
123
- opts.packages = packages || [];
124
- return (await (0, packageVersionList_1.listPackageVersions)({ ...opts, ...{ connection } })).records;
122
+ const opts = options ?? {};
123
+ opts.packages = packages ?? [];
124
+ return (await (0, packageVersionList_1.listPackageVersions)(connection, opts)).records;
125
125
  }
126
126
  /**
127
127
  * create a PackageAncestry instance
@@ -163,7 +163,7 @@ class Package {
163
163
  * @returns {Promise<PackageType>}
164
164
  */
165
165
  async getType() {
166
- return (await this.getPackageData()).ContainerOptions;
166
+ return (await this.getPackageData())?.ContainerOptions;
167
167
  }
168
168
  /**
169
169
  * Returns the list of package versions for the package.
@@ -204,15 +204,18 @@ class Package {
204
204
  async update(options) {
205
205
  try {
206
206
  // filter out any undefined values and their keys
207
- Object.keys(options).forEach((key) => options[key] === undefined && delete options[key]);
208
- const result = await this.options.connection.tooling.update('Package2', options);
207
+ const opts = Object.fromEntries(Object.entries(options).filter(([, value]) => value !== undefined));
208
+ const result = await this.options.connection.tooling.update('Package2', opts);
209
209
  if (!result.success) {
210
210
  throw new core_1.SfError(result.errors.join(', '));
211
211
  }
212
212
  return result;
213
213
  }
214
214
  catch (err) {
215
- throw (0, packageUtils_1.applyErrorAction)((0, packageUtils_1.massageErrorMessage)(err));
215
+ if (err instanceof Error) {
216
+ throw (0, packageUtils_1.applyErrorAction)((0, packageUtils_1.massageErrorMessage)(err));
217
+ }
218
+ throw err;
216
219
  }
217
220
  }
218
221
  /**
@@ -221,10 +224,13 @@ class Package {
221
224
  * @param force force a refresh of the package data
222
225
  */
223
226
  async getPackageData(force = false) {
224
- if (!this.packageData || force) {
227
+ if (!this.packageData ?? force) {
225
228
  this.packageData = (await this.options.connection.tooling
226
229
  .sobject('Package2')
227
230
  .retrieve(this.packageId));
231
+ if (!this.packageData) {
232
+ throw messages.createError('packageNotFound', [this.packageId]);
233
+ }
228
234
  }
229
235
  return this.packageData;
230
236
  }
@@ -1,25 +1,25 @@
1
1
  import { DirectedGraph } from 'graphology';
2
2
  import { AsyncCreatable } from '@salesforce/kit';
3
3
  import { Tree } from '@oclif/core/lib/cli-ux/styled/tree';
4
- import { Attributes } from 'graphology-types';
5
- import { AncestryRepresentationProducer, AncestryRepresentationProducerOptions, PackageAncestryNodeOptions, PackageAncestryOptions } from '../interfaces';
4
+ import { AncestryRepresentationProducer, AncestryRepresentationProducerOptions, PackageAncestryNodeData, PackageAncestryNodeOptions, PackageAncestryOptions } from '../interfaces';
6
5
  import { VersionNumber } from './versionNumber';
7
6
  /**
8
7
  * A class that represents the package ancestry graph.
9
8
  * Given a package Id (0Ho) or a package version Id (04t), it will build a graph of the package's ancestors.
10
9
  */
11
10
  export declare class PackageAncestry extends AsyncCreatable<PackageAncestryOptions> {
12
- #private;
13
11
  private options;
14
- private graph;
15
12
  private roots;
13
+ private graph;
14
+ private packageId;
16
15
  constructor(options: PackageAncestryOptions);
17
- get requestedPackageId(): string;
16
+ get requestedPackageId(): string | undefined;
17
+ private static createAttributes;
18
18
  init(): Promise<void>;
19
19
  /**
20
20
  * Returns the internal representation of the requested package ancestry graph.
21
21
  */
22
- getAncestryGraph(): DirectedGraph<Attributes, Attributes, Attributes>;
22
+ getAncestryGraph(): DirectedGraph;
23
23
  /**
24
24
  * Convenience method to get the json representation of the package ancestry graph.
25
25
  */
@@ -36,9 +36,9 @@ export declare class PackageAncestry extends AsyncCreatable<PackageAncestryOptio
36
36
  * Returns the producer representation of the package ancestry graph.
37
37
  *
38
38
  * @param producerCtor - function that returns a new instance of the producer
39
- * @param root - the subscriber package version id of the root node
39
+ * @param rootPackageId - the subscriber package version id of the root node
40
40
  */
41
- getRepresentationProducer(producerCtor: (options?: AncestryRepresentationProducerOptions) => AncestryRepresentationProducer, root: string | undefined): AncestryRepresentationProducer;
41
+ getRepresentationProducer(producerCtor: (options: AncestryRepresentationProducerOptions) => AncestryRepresentationProducer, rootPackageId: string | undefined): AncestryRepresentationProducer;
42
42
  /**
43
43
  * Returns a list of ancestry nodes that represent the path from subscriber package version id to the root of the
44
44
  * package ancestry tree.
@@ -47,7 +47,7 @@ export declare class PackageAncestry extends AsyncCreatable<PackageAncestryOptio
47
47
  */
48
48
  getLeafPathToRoot(subscriberPackageVersionId?: string): PackageAncestryNode[][];
49
49
  private buildAncestryTree;
50
- private getRoots;
50
+ private getRootsFromRequestedId;
51
51
  private findRootsForPackageVersion;
52
52
  private validatePackageType;
53
53
  private getPackageVersion;
@@ -59,8 +59,8 @@ export declare class PackageAncestry extends AsyncCreatable<PackageAncestryOptio
59
59
  }
60
60
  export declare class AncestryTreeProducer extends Tree implements AncestryRepresentationProducer {
61
61
  label: string;
62
- options: AncestryRepresentationProducerOptions;
63
- private verbose;
62
+ options?: AncestryRepresentationProducerOptions;
63
+ private readonly verbose;
64
64
  constructor(options?: AncestryRepresentationProducerOptions);
65
65
  addNode(node: AncestryTreeProducer): void;
66
66
  produce(): void;
@@ -68,16 +68,16 @@ export declare class AncestryTreeProducer extends Tree implements AncestryRepres
68
68
  }
69
69
  export declare class AncestryJsonProducer implements AncestryRepresentationProducer {
70
70
  label: string;
71
- options: AncestryRepresentationProducerOptions;
71
+ options?: AncestryRepresentationProducerOptions;
72
72
  private children;
73
73
  private readonly data;
74
- constructor(options?: AncestryRepresentationProducerOptions);
74
+ constructor(options: AncestryRepresentationProducerOptions);
75
75
  addNode(node: AncestryJsonProducer): void;
76
- produce<PackageAncestryNodeData>(): PackageAncestryNodeData;
76
+ produce(): PackageAncestryNodeData;
77
77
  }
78
78
  export declare class AncestryDotProducer implements AncestryRepresentationProducer {
79
79
  label: string;
80
- options: AncestryRepresentationProducerOptions;
80
+ options?: AncestryRepresentationProducerOptions;
81
81
  private children;
82
82
  constructor(options?: AncestryRepresentationProducerOptions);
83
83
  /**
@@ -96,18 +96,17 @@ export declare class AncestryDotProducer implements AncestryRepresentationProduc
96
96
  addNode(node: AncestryDotProducer): void;
97
97
  produce(): string;
98
98
  }
99
- export declare class PackageAncestryNode extends AsyncCreatable<PackageAncestryNodeOptions> implements Attributes {
100
- #private;
99
+ export declare class PackageAncestryNode extends AsyncCreatable<PackageAncestryNodeOptions> {
101
100
  options: PackageAncestryNodeOptions;
101
+ readonly version: VersionNumber;
102
+ readonly MajorVersion: number;
103
+ readonly MinorVersion: number;
104
+ readonly PatchVersion: number;
105
+ readonly BuildNumber: number | string;
106
+ readonly AncestorId: string | undefined;
107
+ readonly SubscriberPackageVersionId: string;
108
+ readonly depthCounter = 0;
102
109
  constructor(options: PackageAncestryNodeOptions);
103
- get AncestorId(): string;
104
- get SubscriberPackageVersionId(): string;
105
- get version(): VersionNumber;
106
- get MinorVersion(): number;
107
- get PatchVersion(): number;
108
- get BuildNumber(): number | string;
109
- get MajorVersion(): number;
110
- get depthCounter(): number;
111
110
  getVersion(): string;
112
111
  protected init(): Promise<void>;
113
112
  }