@salesforce/packaging 0.0.27 → 0.0.28

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 CHANGED
@@ -2,6 +2,12 @@
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.28](https://github.com/forcedotcom/packaging/compare/v0.0.27...v0.0.28) (2022-08-26)
6
+
7
+ ### Bug Fixes
8
+
9
+ - finish pvl, implement a few missing things ([9bb825c](https://github.com/forcedotcom/packaging/commit/9bb825c97b6cb8c8b9522ddcb5e5fb32e5653995))
10
+
5
11
  ### [0.0.27](https://github.com/forcedotcom/packaging/compare/v0.0.26...v0.0.27) (2022-08-26)
6
12
 
7
13
  ### Bug Fixes
@@ -147,17 +147,18 @@ export declare type PackageVersionCreateRequest = {
147
147
  CalculateCodeCoverage: boolean;
148
148
  SkipValidation: boolean;
149
149
  };
150
- export declare type PackageVersionQueryOptions = {
151
- project: SfProject;
150
+ export declare type PackageVersionListOptions = {
152
151
  orderBy: string;
153
152
  modifiedLastDays: number;
154
153
  createdLastDays: number;
155
154
  packages: string[];
156
- connection: Connection;
157
155
  verbose: boolean;
158
156
  concise: boolean;
159
157
  isReleased: boolean;
160
158
  };
159
+ export declare type ListPackageVersionOptions = PackageVersionListOptions & {
160
+ connection: Connection;
161
+ };
161
162
  export declare type PackageSaveResult = SaveResult;
162
163
  export declare type PackageVersionCreateRequestOptions = {
163
164
  path: string;
@@ -1,5 +1,5 @@
1
1
  import { Duration } from '@salesforce/kit';
2
- import { PackageSaveResult, PackageVersionCreateOptions, PackageVersionCreateRequestResult, PackageVersionOptions, PackageVersionReportResult } from '../interfaces';
2
+ import { PackageSaveResult, PackageVersionCreateOptions, PackageVersionCreateRequestResult, PackageVersionListOptions, PackageVersionListResult, PackageVersionOptions, PackageVersionReportResult } from '../interfaces';
3
3
  export declare class PackageVersion {
4
4
  private options;
5
5
  private readonly project;
@@ -56,7 +56,7 @@ export declare class PackageVersion {
56
56
  }): Promise<PackageVersionCreateRequestResult>;
57
57
  convert(): Promise<void>;
58
58
  install(): Promise<void>;
59
- list(): Promise<void>;
59
+ list(options: PackageVersionListOptions): Promise<PackageVersionListResult[]>;
60
60
  uninstall(): Promise<void>;
61
61
  promote(id: string): Promise<PackageSaveResult>;
62
62
  update(): Promise<void>;
@@ -13,6 +13,7 @@ const utils_1 = require("../utils");
13
13
  const packageVersionCreate_1 = require("./packageVersionCreate");
14
14
  const packageVersionReport_1 = require("./packageVersionReport");
15
15
  const packageVersionCreateRequestReport_1 = require("./packageVersionCreateRequestReport");
16
+ const packageVersionList_1 = require("./packageVersionList");
16
17
  core_1.Messages.importMessagesDirectory(__dirname);
17
18
  class PackageVersion {
18
19
  constructor(options) {
@@ -153,8 +154,8 @@ class PackageVersion {
153
154
  install() {
154
155
  return Promise.resolve(undefined);
155
156
  }
156
- list() {
157
- return Promise.resolve(undefined);
157
+ async list(options) {
158
+ return (await (0, packageVersionList_1.listPackageVersions)({ ...options, ...{ connection: this.connection } })).records;
158
159
  }
159
160
  uninstall() {
160
161
  return Promise.resolve(undefined);
@@ -1,9 +1,7 @@
1
- import { SfProject } from '@salesforce/core';
2
1
  import { QueryResult } from 'jsforce';
3
- import { PackageVersionListResult, PackageVersionQueryOptions } from '../interfaces';
2
+ import { PackageVersionListResult, ListPackageVersionOptions } from '../interfaces';
4
3
  export declare const DEFAULT_ORDER_BY_FIELDS = "Package2Id, Branch, MajorVersion, MinorVersion, PatchVersion, BuildNumber";
5
- export declare function listPackageVersions(options: PackageVersionQueryOptions): Promise<QueryResult<PackageVersionListResult>>;
6
- export declare function _constructQuery(options: PackageVersionQueryOptions): string;
7
- export declare function _assembleQueryParts(select: string, where: string[], orderBy?: string): string;
8
- export declare function _constructWhere(idsOrAliases: string[], createdLastDays: number, lastModLastDays: number, project: SfProject): string[];
9
- export declare function _getLastDays(paramName: string, lastDays: number): number;
4
+ export declare function listPackageVersions(options: ListPackageVersionOptions): Promise<QueryResult<PackageVersionListResult>>;
5
+ export declare function assembleQueryParts(select: string, where: string[], orderBy?: string): string;
6
+ export declare function constructWhere(packageIds: string[], createdLastDays: number, lastModLastDays: number, isReleased: boolean): string[];
7
+ export declare function validateDays(paramName: string, lastDays: number): number;
@@ -6,7 +6,7 @@
6
6
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports._getLastDays = exports._constructWhere = exports._assembleQueryParts = exports._constructQuery = exports.listPackageVersions = exports.DEFAULT_ORDER_BY_FIELDS = void 0;
9
+ exports.validateDays = exports.constructWhere = exports.assembleQueryParts = exports.listPackageVersions = exports.DEFAULT_ORDER_BY_FIELDS = void 0;
10
10
  const core_1 = require("@salesforce/core");
11
11
  const ts_types_1 = require("@salesforce/ts-types");
12
12
  const utils_1 = require("../utils");
@@ -25,67 +25,60 @@ const VERBOSE_SELECT = 'SELECT Id, Package2Id, SubscriberPackageVersionId, Name,
25
25
  exports.DEFAULT_ORDER_BY_FIELDS = 'Package2Id, Branch, MajorVersion, MinorVersion, PatchVersion, BuildNumber';
26
26
  const logger = core_1.Logger.childFromRoot('packageVersionList');
27
27
  async function listPackageVersions(options) {
28
- return options.connection.tooling.query(_constructQuery(options));
28
+ return options.connection.tooling.query(constructQuery(options));
29
29
  }
30
30
  exports.listPackageVersions = listPackageVersions;
31
- function _constructQuery(options) {
31
+ function constructQuery(options) {
32
32
  // construct custom WHERE clause, if applicable
33
- const where = _constructWhere(options.packages, options.createdLastDays, options.modifiedLastDays, options.project);
34
- if (options.isReleased) {
35
- where.push('IsReleased = true');
36
- }
37
- return _assembleQueryParts(options.verbose === true ? VERBOSE_SELECT : DEFAULT_SELECT, where, options.orderBy);
33
+ const where = constructWhere(options.packages, options.createdLastDays, options.modifiedLastDays, options.isReleased);
34
+ return assembleQueryParts(options.verbose === true ? VERBOSE_SELECT : DEFAULT_SELECT, where, options.orderBy);
38
35
  }
39
- exports._constructQuery = _constructQuery;
40
- function _assembleQueryParts(select, where, orderBy = exports.DEFAULT_ORDER_BY_FIELDS) {
36
+ function assembleQueryParts(select, where, orderBy) {
41
37
  // construct ORDER BY clause
42
- // TODO: validate given fields
43
38
  const orderByPart = `ORDER BY ${orderBy ? orderBy : exports.DEFAULT_ORDER_BY_FIELDS}`;
44
39
  const wherePart = where.length > 0 ? `WHERE ${where.join(' AND ')}` : '';
45
40
  const query = `${select} ${wherePart} ${orderByPart}`;
46
41
  logger.debug(query);
47
42
  return query;
48
43
  }
49
- exports._assembleQueryParts = _assembleQueryParts;
44
+ exports.assembleQueryParts = assembleQueryParts;
50
45
  // construct custom WHERE clause parts
51
- function _constructWhere(idsOrAliases, createdLastDays, lastModLastDays, project) {
46
+ function constructWhere(packageIds, createdLastDays, lastModLastDays, isReleased) {
52
47
  const where = [];
53
48
  // filter on given package ids
54
- if (idsOrAliases?.length > 0) {
49
+ if (packageIds?.length > 0) {
55
50
  // remove dups
56
- const aliasesOrIds = [...new Set(idsOrAliases)];
57
- // resolve any aliases
58
- const packageIds = aliasesOrIds.map((idOrAlias) => (0, utils_1.getPackageIdFromAlias)(idOrAlias, project));
51
+ const uniquePackageIds = [...new Set(packageIds)];
59
52
  // validate ids
60
- packageIds.forEach((packageId) => {
53
+ uniquePackageIds.forEach((packageId) => {
61
54
  (0, utils_1.validateId)(utils_1.BY_LABEL.PACKAGE_ID, packageId);
62
55
  });
63
56
  // stash where part
64
- where.push(`Package2Id IN ('${packageIds.join("','")}')`);
57
+ where.push(`Package2Id IN ('${uniquePackageIds.join("','")}')`);
65
58
  }
66
59
  // filter on created date, days ago: 0 for today, etc
67
60
  if ((0, ts_types_1.isNumber)(createdLastDays)) {
68
- createdLastDays = _getLastDays('createdlastdays', createdLastDays);
61
+ createdLastDays = validateDays('createdlastdays', createdLastDays);
69
62
  where.push(`CreatedDate = LAST_N_DAYS:${createdLastDays}`);
70
63
  }
71
64
  // filter on last mod date, days ago: 0 for today, etc
72
65
  if ((0, ts_types_1.isNumber)(lastModLastDays)) {
73
- lastModLastDays = _getLastDays('modifiedlastdays', lastModLastDays);
66
+ lastModLastDays = validateDays('modifiedlastdays', lastModLastDays);
74
67
  where.push(`LastModifiedDate = LAST_N_DAYS:${lastModLastDays}`);
75
68
  }
69
+ if (isReleased) {
70
+ where.push('IsReleased = true');
71
+ }
76
72
  // exclude deleted
77
73
  where.push('IsDeprecated = false');
78
74
  return where;
79
75
  }
80
- exports._constructWhere = _constructWhere;
81
- function _getLastDays(paramName, lastDays) {
82
- if (isNaN(lastDays)) {
83
- return 0;
84
- }
76
+ exports.constructWhere = constructWhere;
77
+ function validateDays(paramName, lastDays) {
85
78
  if (lastDays < 0) {
86
79
  throw messages.createError('invalidDaysNumber', [paramName, `${lastDays}`]);
87
80
  }
88
81
  return lastDays;
89
82
  }
90
- exports._getLastDays = _getLastDays;
83
+ exports.validateDays = validateDays;
91
84
  //# sourceMappingURL=packageVersionList.js.map
@@ -324,7 +324,9 @@ async function getPackageVersionStrings(subscriberPackageVersionIds, connection)
324
324
  }
325
325
  // remove any duplicate Ids
326
326
  const ids = [...new Set(subscriberPackageVersionIds)];
327
- const query = 'SELECT SubscriberPackageVersionId, MajorVersion, MinorVersion, PatchVersion, BuildNumber FROM Package2Version WHERE SubscriberPackageVersionId IN (%IDS%)';
327
+ const query = `SELECT SubscriberPackageVersionId, MajorVersion, MinorVersion, PatchVersion, BuildNumber FROM Package2Version WHERE SubscriberPackageVersionId IN (${ids
328
+ .map((id) => `'${id}'`)
329
+ .join(',')})`;
328
330
  const records = await queryWithInConditionChunking(query, ids, '%IDS%', connection);
329
331
  if (records && records.length > 0) {
330
332
  results = new Map(records.map((record) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/packaging",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "packing libraries to Salesforce packaging platform",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",