Skip to content

Commit e4e62d3

Browse files
authored
fix: remove deprecated command/flags W-18384354 (#1237)
* fix: remove deprecated command/flags * chore: update snapshot * chore: update messages
1 parent 30f6872 commit e4e62d3

File tree

9 files changed

+16
-484
lines changed

9 files changed

+16
-484
lines changed

command-snapshot.json

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,10 @@
176176
"alias": ["force:data:soql:query"],
177177
"command": "data:query",
178178
"flagAliases": ["apiversion", "resultformat", "soqlqueryfile", "targetusername", "u", "usetoolingapi"],
179-
"flagChars": ["b", "f", "o", "q", "r", "t", "w"],
179+
"flagChars": ["f", "o", "q", "r", "t"],
180180
"flags": [
181181
"all-rows",
182182
"api-version",
183-
"async",
184-
"bulk",
185183
"file",
186184
"flags-dir",
187185
"json",
@@ -191,25 +189,7 @@
191189
"query",
192190
"result-format",
193191
"target-org",
194-
"use-tooling-api",
195-
"wait"
196-
],
197-
"plugin": "@salesforce/plugin-data"
198-
},
199-
{
200-
"alias": ["force:data:soql:bulk:report"],
201-
"command": "data:query:resume",
202-
"flagAliases": ["apiversion", "bulkqueryid", "resultformat", "targetusername", "u"],
203-
"flagChars": ["i", "o", "r"],
204-
"flags": [
205-
"api-version",
206-
"bulk-query-id",
207-
"flags-dir",
208-
"json",
209-
"loglevel",
210-
"result-format",
211-
"target-org",
212-
"use-most-recent"
192+
"use-tooling-api"
213193
],
214194
"plugin": "@salesforce/plugin-data"
215195
},

messages/bulk.report.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

messages/soql.query.md

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ Execute a SOQL query.
66

77
Specify the SOQL query at the command line with the --query flag or read the query from a file with the --file flag.
88

9-
If your query returns more than 10,000 records, specify the --bulk flag. The command then runs the query using Bulk API 2.0, which has higher limits than the default API used by the command.
10-
11-
When using --bulk, the command waits 3 minutes by default for the query to complete. Use the --wait parameter to specify a different number of minutes to wait, or set --wait to 0 to immediately return control to the terminal. If you set --wait to 0, or you use the --async flag, or the command simply times out, the command displays an ID. Pass this ID to the the "data query resume" command using the --bulk-query-id flag to get the results; pass the ID to the "data resume" command to get the job status.
9+
If your query returns more than 10,000 records, prefer to use the `sf data export bulk` command instead. It runs the query using Bulk API 2.0, which has higher limits than the default API used by the command.
1210

1311
# examples
1412

@@ -24,10 +22,6 @@ When using --bulk, the command waits 3 minutes by default for the query to compl
2422

2523
<%= config.bin %> <%= command.id %> --query "SELECT Name FROM ApexTrigger" --use-tooling-api
2624

27-
- Use Bulk API 2.0 to run a query that returns many rows, and return control to the terminal immediately:
28-
29-
<%= config.bin %> <%= command.id %> --query "SELECT Id FROM Contact" --bulk --wait 0
30-
3125
# flags.query.summary
3226

3327
SOQL query to execute.
@@ -40,22 +34,10 @@ Use Tooling API so you can run queries on Tooling API objects.
4034

4135
File that contains the SOQL query.
4236

43-
# flags.bulk.summary
44-
45-
Use Bulk API 2.0 to run the query.
46-
47-
# flags.async.summary
48-
49-
Use Bulk API 2.0, but don't wait for the job to complete.
50-
5137
# flags.all-rows.summary
5238

5339
Include deleted records. By default, deleted records are not returned.
5440

55-
# flags.wait.summary
56-
57-
Time to wait for the command to finish, in minutes.
58-
5941
# flags.output-file.summary
6042

6143
File where records are written; only CSV and JSON output formats are supported.
@@ -67,10 +49,3 @@ Total number of records retrieved: %s.
6749
# queryRunningMessage
6850

6951
Querying Data
70-
71-
# bulkQueryTimeout
72-
73-
Query ID: %s
74-
Query is in progress.
75-
76-
Run "sf data query resume -i %s -o %s" to get the latest status and results.

src/bulkDataRequestCache.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -102,27 +102,6 @@ export abstract class BulkDataRequestCache extends TTLConfig<TTLConfig.Options,
102102
}
103103
}
104104

105-
export class BulkQueryRequestCache extends BulkDataRequestCache {
106-
public static getDefaultOptions(): TTLConfig.Options {
107-
return {
108-
isGlobal: true,
109-
isState: true,
110-
filename: BulkQueryRequestCache.getFileName(),
111-
stateFolder: Global.SF_STATE_FOLDER,
112-
ttl: Duration.days(3),
113-
};
114-
}
115-
116-
public static getFileName(): string {
117-
return 'bulk-data-query-cache.json';
118-
}
119-
120-
public static async unset(key: string): Promise<void> {
121-
const cache = await BulkQueryRequestCache.create();
122-
cache.unset(key);
123-
await cache.write();
124-
}
125-
}
126105
export class BulkDeleteRequestCache extends BulkDataRequestCache {
127106
public static getDefaultOptions(): TTLConfig.Options {
128107
return {

src/commands/data/query.ts

Lines changed: 9 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import fs from 'node:fs';
9-
import { Connection, Logger, Messages, SfError } from '@salesforce/core';
9+
import { Connection, Logger, Messages } from '@salesforce/core';
1010
import type { Record as jsforceRecord } from '@jsforce/jsforce-node';
1111
import {
1212
AnyJson,
@@ -18,13 +18,10 @@ import {
1818
JsonArray,
1919
toJsonMap,
2020
} from '@salesforce/ts-types';
21-
import { Duration } from '@salesforce/kit';
2221
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
23-
import { BulkV2, QueryJobV2 } from '@jsforce/jsforce-node/lib/api/bulk2.js';
2422
import { orgFlags, perflogFlag, resultFormatFlag } from '../../flags.js';
2523
import { Field, FieldType, SoqlQueryResult } from '../../types.js';
26-
import { displayResults, transformBulkResults } from '../../queryUtils.js';
27-
import { BulkQueryRequestCache } from '../../bulkDataRequestCache.js';
24+
import { displayResults } from '../../queryUtils.js';
2825

2926
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
3027
const messages = Messages.loadMessages('@salesforce/plugin-data', 'soql.query');
@@ -63,26 +60,6 @@ export class DataSoqlQueryCommand extends SfCommand<DataQueryResult> {
6360
summary: messages.getMessage('flags.use-tooling-api.summary'),
6461
aliases: ['usetoolingapi'],
6562
deprecateAliases: true,
66-
exclusive: ['bulk'],
67-
}),
68-
bulk: Flags.boolean({
69-
char: 'b',
70-
default: false,
71-
summary: messages.getMessage('flags.bulk.summary'),
72-
exclusive: ['use-tooling-api'],
73-
}),
74-
wait: Flags.duration({
75-
unit: 'minutes',
76-
char: 'w',
77-
summary: messages.getMessage('flags.wait.summary'),
78-
dependsOn: ['bulk'],
79-
exclusive: ['async'],
80-
}),
81-
async: Flags.boolean({
82-
summary: messages.getMessage('flags.async.summary'),
83-
dependsOn: ['bulk'],
84-
exclusive: ['wait'],
85-
deprecated: true,
8663
}),
8764
'all-rows': Flags.boolean({
8865
summary: messages.getMessage('flags.all-rows.summary'),
@@ -128,32 +105,18 @@ export class DataSoqlQueryCommand extends SfCommand<DataQueryResult> {
128105
this.logger = await Logger.child('data:soql:query');
129106
const flags = (await this.parse(DataSoqlQueryCommand)).flags;
130107

131-
if (flags.bulk || flags.wait || flags.async) {
132-
this
133-
.warn(`Bulk mode for "data query" is deprecated, the following flags will be removed after April 2025: --bulk | --wait | --async.
134-
Use "data export bulk" for bulk queries instead.
135-
`);
136-
}
137-
138108
try {
139109
// --file will be present if flags.query isn't. Oclif exactlyOne isn't quite that clever
140110
const queryString = flags.query ?? fs.readFileSync(flags.file as string, 'utf8');
141111
const conn = flags['target-org'].getConnection(flags['api-version']);
142112
if (flags['result-format'] !== 'json') this.spinner.start(messages.getMessage('queryRunningMessage'));
143-
const queryResult = flags.bulk
144-
? await this.runBulkSoqlQuery(
145-
conn,
146-
queryString,
147-
flags.async ? Duration.minutes(0) : flags.wait ?? Duration.minutes(0),
148-
flags['all-rows'] === true
149-
)
150-
: await this.runSoqlQuery(
151-
flags['use-tooling-api'] ? conn.tooling : conn,
152-
queryString,
153-
this.logger,
154-
this.configAggregator.getInfo('org-max-query-limit').value as number,
155-
flags['all-rows']
156-
);
113+
const queryResult = await this.runSoqlQuery(
114+
flags['use-tooling-api'] ? conn.tooling : conn,
115+
queryString,
116+
this.logger,
117+
this.configAggregator.getInfo('org-max-query-limit').value as number,
118+
flags['all-rows']
119+
);
157120

158121
if (flags['output-file'] ?? !this.jsonEnabled()) {
159122
displayResults({ ...queryResult }, flags['result-format'], flags['output-file']);
@@ -169,48 +132,6 @@ Use "data export bulk" for bulk queries instead.
169132
if (flags['result-format'] !== 'json') this.spinner.stop();
170133
}
171134
}
172-
/**
173-
* Executes a SOQL query using the bulk 2.0 API
174-
*
175-
* @param connection
176-
* @param query
177-
* @param timeout
178-
*/
179-
private async runBulkSoqlQuery(
180-
connection: Connection,
181-
query: string,
182-
timeout: Duration,
183-
allRows: boolean | undefined = false
184-
): Promise<SoqlQueryResult> {
185-
if (timeout.milliseconds === 0) {
186-
const job = new QueryJobV2(connection, {
187-
bodyParams: {
188-
query,
189-
operation: allRows ? 'queryAll' : 'query',
190-
},
191-
pollingOptions: { pollTimeout: timeout.milliseconds, pollInterval: 5000 },
192-
});
193-
const info = await job.open();
194-
return prepareAsyncQueryResponse(connection)(this)({ query, jobId: info.id });
195-
}
196-
try {
197-
const bulk2 = new BulkV2(connection);
198-
const res =
199-
(await bulk2.query(query, {
200-
pollTimeout: timeout.milliseconds ?? Duration.minutes(5).milliseconds,
201-
pollInterval: 5000,
202-
...(allRows ? { scanAll: true } : {}),
203-
})) ?? [];
204-
return transformBulkResults((await res.toArray()) as jsforceRecord[], query);
205-
} catch (e) {
206-
if (e instanceof Error && e.name === 'JobPollingTimeout' && 'jobId' in e && typeof e.jobId === 'string') {
207-
process.exitCode = 69;
208-
return prepareAsyncQueryResponse(connection)(this)({ query, jobId: e.jobId });
209-
} else {
210-
throw e instanceof Error || typeof e === 'string' ? SfError.wrap(e) : e;
211-
}
212-
}
213-
}
214135

215136
private async runSoqlQuery(
216137
connection: Connection | Connection['tooling'],
@@ -248,22 +169,6 @@ Use "data export bulk" for bulk queries instead.
248169
}
249170
}
250171

251-
const prepareAsyncQueryResponse =
252-
(connection: Connection) =>
253-
(cmd: SfCommand<unknown>) =>
254-
async ({ query, jobId }: { query: string; jobId: string }): Promise<SoqlQueryResult> => {
255-
const cache = await BulkQueryRequestCache.create();
256-
await cache.createCacheEntryForRequest(jobId, connection.getUsername(), connection.getApiVersion());
257-
cmd.log(messages.getMessage('bulkQueryTimeout', [jobId, jobId, connection.getUsername()]));
258-
return buildEmptyQueryResult({ query, jobId });
259-
};
260-
261-
const buildEmptyQueryResult = ({ query, jobId }: { query: string; jobId: string }): SoqlQueryResult => ({
262-
columns: [],
263-
result: { done: false, records: [], totalSize: 0, id: jobId },
264-
query,
265-
});
266-
267172
const searchSubColumnsRecursively = (parent: AnyJson): string[] => {
268173
const column = ensureJsonMap(parent);
269174
const name = ensureString(column.columnName);

src/commands/data/query/resume.ts

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)