@salesforce/source-testkit 1.2.1 → 1.2.2

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
+ ### [1.2.2](https://github.com/salesforcecli/source-testkit/compare/v1.2.1...v1.2.2) (2022-06-18)
6
+
7
+ ### Bug Fixes
8
+
9
+ - shared autoFetchQuery ([1c23a9f](https://github.com/salesforcecli/source-testkit/commit/1c23a9f84eaaa548558b4deb71ae621497a9e922))
10
+
5
11
  ### [1.2.1](https://github.com/salesforcecli/source-testkit/compare/v1.2.0...v1.2.1) (2022-06-18)
6
12
 
7
13
  ### Bug Fixes
package/lib/assertions.js CHANGED
@@ -15,8 +15,8 @@ const fg = require("fast-glob");
15
15
  const source_deploy_retrieve_1 = require("@salesforce/source-deploy-retrieve");
16
16
  const debug_1 = require("debug");
17
17
  const fileTracker_1 = require("./fileTracker");
18
+ const autoFetchQuery_1 = require("./autoFetchQuery");
18
19
  (0, chai_1.use)(chaiEach);
19
- const SOQL_QUERY_LIMIT = 50000;
20
20
  /**
21
21
  * Assertions is a class that is designed to encapsulate common assertions we want to
22
22
  * make during NUT testings
@@ -335,9 +335,8 @@ class Assertions {
335
335
  (0, chai_1.expect)(someAreNotUpdated, 'expect some SourceMembers to not be updated').to.be.true;
336
336
  }
337
337
  async retrieveSourceMembers(globs, ignore = []) {
338
- var _a;
339
338
  const query = 'SELECT Id,MemberName,MemberType,RevisionCounter FROM SourceMember';
340
- const result = await ((_a = this.connection) === null || _a === void 0 ? void 0 : _a.tooling.query(`${query} limit ${SOQL_QUERY_LIMIT}`));
339
+ const result = this.connection ? await (0, autoFetchQuery_1.autoFetchQuery)(query, this.connection, true) : undefined;
341
340
  const all = await this.doGlob(globs);
342
341
  const ignoreFiles = await this.doGlob(ignore, false);
343
342
  const toTrack = all.filter((file) => !ignoreFiles.includes(file));
@@ -363,15 +362,13 @@ class Assertions {
363
362
  });
364
363
  }
365
364
  async retrieveApexTestResults() {
366
- var _a;
367
365
  const query = 'SELECT TestTimestamp, ApexClassId FROM ApexTestResult';
368
- const result = await ((_a = this.connection) === null || _a === void 0 ? void 0 : _a.tooling.query(`${query} limit ${SOQL_QUERY_LIMIT}`));
366
+ const result = this.connection ? await (0, autoFetchQuery_1.autoFetchQuery)(query, this.connection, true) : undefined;
369
367
  return (result === null || result === void 0 ? void 0 : result.records) || [];
370
368
  }
371
369
  async retrieveApexClasses(classNames) {
372
- var _a;
373
370
  const query = 'SELECT Name,Id FROM ApexClass';
374
- const result = await ((_a = this.connection) === null || _a === void 0 ? void 0 : _a.tooling.query(`${query} limit ${SOQL_QUERY_LIMIT}`));
371
+ const result = this.connection ? await (0, autoFetchQuery_1.autoFetchQuery)(query, this.connection, true) : undefined;
375
372
  const records = (result === null || result === void 0 ? void 0 : result.records) || [];
376
373
  return classNames ? records.filter((r) => classNames.includes(r.Name)) : records;
377
374
  }
@@ -0,0 +1,3 @@
1
+ import { Connection } from '@salesforce/core';
2
+ import { QueryResult } from 'jsforce';
3
+ export declare const autoFetchQuery: <T>(query: string, conn: Connection, useTooling?: boolean, maxFetch?: number) => Promise<QueryResult<T>>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2020, 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.autoFetchQuery = void 0;
10
+ const autoFetchQuery = async (query, conn, useTooling = false, maxFetch = 50000) => {
11
+ return new Promise((resolve, reject) => {
12
+ const records = [];
13
+ const res = (useTooling ? conn.tooling : conn)
14
+ .query(query)
15
+ .on('record', (rec) => records.push(rec))
16
+ .on('error', (err) => reject(err))
17
+ .on('end', () => {
18
+ var _a;
19
+ resolve({
20
+ done: true,
21
+ totalSize: (_a = res.totalSize) !== null && _a !== void 0 ? _a : 0,
22
+ records,
23
+ });
24
+ })
25
+ .run({ autoFetch: true, maxFetch });
26
+ });
27
+ };
28
+ exports.autoFetchQuery = autoFetchQuery;
29
+ //# sourceMappingURL=autoFetchQuery.js.map
@@ -8,6 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.ExecutionLog = void 0;
10
10
  const ts_types_1 = require("@salesforce/ts-types");
11
+ const autoFetchQuery_1 = require("./autoFetchQuery");
11
12
  /**
12
13
  * This class maintains a map of command execution history.
13
14
  *
@@ -49,9 +50,10 @@ class ExecutionLog {
49
50
  return sorted[0];
50
51
  }
51
52
  async querySourceMembers() {
52
- var _a;
53
53
  const query = 'SELECT Id,MemberName,MemberType,RevisionCounter FROM SourceMember';
54
- const result = await ((_a = this.context.connection) === null || _a === void 0 ? void 0 : _a.tooling.query(`${query} limit 50000`));
54
+ const result = this.context.connection
55
+ ? await (0, autoFetchQuery_1.autoFetchQuery)(query, this.context.connection, true)
56
+ : undefined;
55
57
  return (result === null || result === void 0 ? void 0 : result.records) || [];
56
58
  }
57
59
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@salesforce/source-testkit",
3
3
  "description": "testkit for running NUTs for source related commands",
4
- "version": "1.2.1",
4
+ "version": "1.2.2",
5
5
  "author": "Salesforce",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "lib/index.js",