@salesforce/plugin-api 1.2.2 → 1.3.1

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/README.md CHANGED
@@ -60,7 +60,7 @@ sf plugins
60
60
  <!-- commands -->
61
61
 
62
62
  - [`sf api request graphql`](#sf-api-request-graphql)
63
- - [`sf api request rest ENDPOINT`](#sf-api-request-rest-endpoint)
63
+ - [`sf api request rest [URL]`](#sf-api-request-rest-url)
64
64
 
65
65
  ## `sf api request graphql`
66
66
 
@@ -113,31 +113,33 @@ EXAMPLES
113
113
  $ sf api request graphql --body example.txt --stream-to-file output.txt --include
114
114
  ```
115
115
 
116
- _See code: [src/commands/api/request/graphql.ts](https://github.com/salesforcecli/plugin-api/blob/1.2.2/src/commands/api/request/graphql.ts)_
116
+ _See code: [src/commands/api/request/graphql.ts](https://github.com/salesforcecli/plugin-api/blob/1.3.1/src/commands/api/request/graphql.ts)_
117
117
 
118
- ## `sf api request rest ENDPOINT`
118
+ ## `sf api request rest [URL]`
119
119
 
120
120
  Make an authenticated HTTP request using the Salesforce REST API.
121
121
 
122
122
  ```
123
123
  USAGE
124
- $ sf api request rest ENDPOINT -o <value> [--flags-dir <value>] [--api-version <value>] [-i | -S Example:
125
- report.xlsx] [-X GET|POST|PUT|PATCH|HEAD|DELETE|OPTIONS|TRACE] [-H key:value...] [--body file]
124
+ $ sf api request rest [URL] -o <value> [--flags-dir <value>] [-i | -S Example: report.xlsx] [-X
125
+ GET|POST|PUT|PATCH|HEAD|DELETE|OPTIONS|TRACE] [-H key:value...] [-f file | -b file]
126
126
 
127
127
  ARGUMENTS
128
- ENDPOINT Salesforce API endpoint
128
+ URL Salesforce API endpoint
129
129
 
130
130
  FLAGS
131
131
  -H, --header=key:value... HTTP header in "key:value" format.
132
132
  -S, --stream-to-file=Example: report.xlsx Stream responses to a file.
133
- -X, --method=<option> [default: GET] HTTP method for the request.
133
+ -X, --method=<option> HTTP method for the request.
134
134
  <options: GET|POST|PUT|PATCH|HEAD|DELETE|OPTIONS|TRACE>
135
+ -b, --body=file File or content for the body of the HTTP request. Specify "-" to read from
136
+ standard input or "" for an empty body. If passing a file, prefix the
137
+ filename with '@'.
138
+ -f, --file=file JSON file that contains values for the request header, body, method, and
139
+ URL.
135
140
  -i, --include Include the HTTP response status and headers in the output.
136
141
  -o, --target-org=<value> (required) Username or alias of the target org. Not required if the
137
142
  `target-org` configuration variable is already set.
138
- --api-version=<value> Override the api version used for api requests made by this command
139
- --body=file File or content for the body of the HTTP request. Specify "-" to read from
140
- standard input or "" for an empty body.
141
143
 
142
144
  GLOBAL FLAGS
143
145
  --flags-dir=<value> Import flag values from a directory.
@@ -154,33 +156,73 @@ DESCRIPTION
154
156
  EXAMPLES
155
157
  List information about limits in the org with alias "my-org":
156
158
 
157
- $ sf api request rest 'limits' --target-org my-org
159
+ $ sf api request rest 'services/data/v56.0/limits' --target-org my-org
158
160
 
159
161
  List all endpoints in your default org; write the output to a file called "output.txt" and include the HTTP response
160
162
  status and headers:
161
163
 
162
- $ sf api request rest '/' --stream-to-file output.txt --include
164
+ $ sf api request rest '/services/data/v56.0/' --stream-to-file output.txt --include
163
165
 
164
166
  Get the response in XML format by specifying the "Accept" HTTP header:
165
167
 
166
- $ sf api request rest 'limits' --header 'Accept: application/xml'
168
+ $ sf api request rest '/services/data/v56.0/limits' --header 'Accept: application/xml'
167
169
 
168
170
  Create an account record using the POST method; specify the request details directly in the "--body" flag:
169
171
 
170
- $ sf api request rest 'sobjects/account' --body "{\"Name\" : \"Account from REST API\",\"ShippingCity\" : \
171
- \"Boise\"}" --method POST
172
+ $ sf api request rest /services/data/v56.0/sobjects/account --body "{\"Name\" : \"Account from REST \
173
+ API\",\"ShippingCity\" : \"Boise\"}" --method POST
172
174
 
173
- Create an account record using the information in a file called "info.json":
175
+ Create an account record using the information in a file called "info.json" (note the @ prefixing the file name):
174
176
 
175
- $ sf api request rest 'sobjects/account' --body info.json --method POST
177
+ $ sf api request rest '/services/data/v56.0/sobjects/account' --body @info.json --method POST
176
178
 
177
179
  Update an account record using the PATCH method:
178
180
 
179
- $ sf api request rest 'sobjects/account/<Account ID>' --body "{\"BillingCity\": \"San Francisco\"}" --method \
180
- PATCH
181
+ $ sf api request rest '/services/data/v56.0/sobjects/account/<Account ID>' --body "{\"BillingCity\": \"San \
182
+ Francisco\"}" --method PATCH
183
+
184
+ Store the values for the request header, body, and so on, in a file, which you then specify with the --file flag;
185
+ see the description of --file for more information:
186
+
187
+ $ sf api request rest --file myFile.json
188
+
189
+ FLAG DESCRIPTIONS
190
+ -f, --file=file JSON file that contains values for the request header, body, method, and URL.
191
+
192
+ Use this flag instead of specifying the request details with individual flags, such as --body or --method. This
193
+ schema defines how to create the JSON file:
194
+
195
+ {
196
+ url: { raw: string } | string;
197
+ method: 'GET', 'POST', 'PUT', 'PATCH', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE';
198
+ description?: string;
199
+ header: string | Array<Record<string, string>>;
200
+ body: { mode: 'raw' | 'formdata'; raw: string; formdata: FormData };
201
+ }
202
+
203
+ Salesforce CLI defined this schema to be mimic Postman schemas; both share similar properties. The CLI's schema also
204
+ supports Postman Collections to reuse and share requests. As a result, you can build an API call using Postman,
205
+ export and save it to a file, and then use the file as a value to this flag. For information about Postman, see
206
+ https://learning.postman.com/.
207
+
208
+ Here's a simple example of a JSON file that contains values for the request URL, method, and body:
209
+
210
+ {
211
+ "url": "sobjects/Account/<Account ID>",
212
+ "method": "PATCH",
213
+ "body" : {
214
+ "mode": "raw",
215
+ "raw": {
216
+ "BillingCity": "Boise"
217
+ }
218
+ }
219
+ }
220
+
221
+ See more examples in the plugin-api test directory, including JSON files that use "formdata" to define collections:
222
+ https://github.com/salesforcecli/plugin-api/tree/main/test/test-files/data-project.
181
223
  ```
182
224
 
183
- _See code: [src/commands/api/request/rest.ts](https://github.com/salesforcecli/plugin-api/blob/1.2.2/src/commands/api/request/rest.ts)_
225
+ _See code: [src/commands/api/request/rest.ts](https://github.com/salesforcecli/plugin-api/blob/1.3.1/src/commands/api/request/rest.ts)_
184
226
 
185
227
  <!-- commandsstop -->
186
228
 
@@ -1,5 +1,40 @@
1
+ import type { Headers } from 'got';
1
2
  import { SfCommand } from '@salesforce/sf-plugins-core';
2
3
  import { Org } from '@salesforce/core';
4
+ import FormData from 'form-data';
5
+ declare const methodOptions: readonly ["GET", "POST", "PUT", "PATCH", "HEAD", "DELETE", "OPTIONS", "TRACE"];
6
+ type FileFormData = {
7
+ type: 'file';
8
+ src: string | string[];
9
+ key: string;
10
+ };
11
+ type StringFormData = {
12
+ type: 'text';
13
+ value: string;
14
+ key: string;
15
+ };
16
+ type FormDataPostmanSchema = {
17
+ mode: 'formdata';
18
+ formdata: Array<FileFormData | StringFormData>;
19
+ };
20
+ type RawPostmanSchema = {
21
+ mode: 'raw';
22
+ raw: string | Record<string, unknown>;
23
+ };
24
+ export type PostmanSchema = {
25
+ url: {
26
+ raw: string;
27
+ } | string;
28
+ method: typeof methodOptions;
29
+ description?: string;
30
+ header: string | Array<{
31
+ key: string;
32
+ value: string;
33
+ disabled?: boolean;
34
+ description?: string;
35
+ }>;
36
+ body: RawPostmanSchema | FormDataPostmanSchema;
37
+ };
3
38
  export declare class Rest extends SfCommand<void> {
4
39
  static readonly summary: string;
5
40
  static readonly description: string;
@@ -8,15 +43,18 @@ export declare class Rest extends SfCommand<void> {
8
43
  static enableJsonFlag: boolean;
9
44
  static readonly flags: {
10
45
  'target-org': import("@oclif/core/interfaces").OptionFlag<Org, import("@oclif/core/interfaces").CustomOptions>;
11
- 'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
46
  include: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
- method: import("@oclif/core/interfaces").OptionFlag<"GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "OPTIONS" | "TRACE" | "PATCH", import("@oclif/core/interfaces").CustomOptions>;
47
+ method: import("@oclif/core/interfaces").OptionFlag<"GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "OPTIONS" | "TRACE" | "PATCH" | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
48
  header: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
49
+ file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
50
  'stream-to-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
51
  body: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
52
  };
18
53
  static args: {
19
- endpoint: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
54
+ url: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
20
55
  };
21
56
  run(): Promise<void>;
22
57
  }
58
+ export declare const getBodyContents: (body?: PostmanSchema["body"]) => string | FormData;
59
+ export declare function getHeaders(keyValPair: string[] | PostmanSchema['header'] | undefined): Headers;
60
+ export {};
@@ -4,15 +4,16 @@
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
6
  */
7
- import { readFileSync, existsSync } from 'node:fs';
8
- import { join } from 'node:path';
7
+ import { readFileSync, createReadStream } from 'node:fs';
9
8
  import { ProxyAgent } from 'proxy-agent';
10
9
  import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
11
- import { Messages, Org, SFDX_HTTP_HEADERS } from '@salesforce/core';
10
+ import { Messages, Org, SFDX_HTTP_HEADERS, SfError } from '@salesforce/core';
12
11
  import { Args } from '@oclif/core';
13
- import { getHeaders, includeFlag, sendAndPrintRequest, streamToFileFlag } from '../../../shared/shared.js';
12
+ import FormData from 'form-data';
13
+ import { includeFlag, sendAndPrintRequest, streamToFileFlag } from '../../../shared/shared.js';
14
14
  Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
15
15
  const messages = Messages.loadMessages('@salesforce/plugin-api', 'rest');
16
+ const methodOptions = ['GET', 'POST', 'PUT', 'PATCH', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE'];
16
17
  export class Rest extends SfCommand {
17
18
  static summary = messages.getMessage('summary');
18
19
  static description = messages.getMessage('description');
@@ -21,13 +22,11 @@ export class Rest extends SfCommand {
21
22
  static enableJsonFlag = false;
22
23
  static flags = {
23
24
  'target-org': Flags.requiredOrg(),
24
- 'api-version': Flags.orgApiVersion(),
25
25
  include: includeFlag,
26
26
  method: Flags.option({
27
- options: ['GET', 'POST', 'PUT', 'PATCH', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE'],
27
+ options: methodOptions,
28
28
  summary: messages.getMessage('flags.method.summary'),
29
29
  char: 'X',
30
- default: 'GET',
31
30
  })(),
32
31
  header: Flags.string({
33
32
  summary: messages.getMessage('flags.header.summary'),
@@ -35,38 +34,73 @@ export class Rest extends SfCommand {
35
34
  char: 'H',
36
35
  multiple: true,
37
36
  }),
37
+ file: Flags.file({
38
+ summary: messages.getMessage('flags.file.summary'),
39
+ description: messages.getMessage('flags.file.description'),
40
+ helpValue: 'file',
41
+ char: 'f',
42
+ exclusive: ['body'],
43
+ }),
38
44
  'stream-to-file': streamToFileFlag,
39
45
  body: Flags.string({
40
46
  summary: messages.getMessage('flags.body.summary'),
41
47
  allowStdin: true,
42
48
  helpValue: 'file',
49
+ char: 'b',
43
50
  }),
44
51
  };
45
52
  static args = {
46
- endpoint: Args.string({
53
+ url: Args.string({
47
54
  description: 'Salesforce API endpoint',
48
- required: true,
55
+ required: false,
49
56
  }),
50
57
  };
51
58
  async run() {
52
59
  const { flags, args } = await this.parse(Rest);
53
60
  const org = flags['target-org'];
54
61
  const streamFile = flags['stream-to-file'];
55
- const headers = flags.header ? getHeaders(flags.header) : {};
56
- // replace first '/' to create valid URL
57
- const endpoint = args.endpoint.startsWith('/') ? args.endpoint.replace('/', '') : args.endpoint;
58
- const url = new URL(`${org.getField(Org.Fields.INSTANCE_URL)}/services/data/v${flags['api-version'] ?? (await org.retrieveMaxApiVersion())}/${endpoint}`);
59
- const body = flags.method === 'GET'
60
- ? undefined
61
- : // if they've passed in a file name, check and read it
62
- existsSync(join(process.cwd(), flags.body ?? ''))
63
- ? readFileSync(join(process.cwd(), flags.body ?? ''))
64
- : // otherwise it's a stdin, and we use it directly
65
- flags.body;
66
- await org.refreshAuth();
62
+ const fileOptions = flags.file
63
+ ? JSON.parse(readFileSync(flags.file, 'utf8'))
64
+ : undefined;
65
+ // validate that we have a URL to hit
66
+ if (!args.url && !fileOptions?.url) {
67
+ throw new SfError("The url is required either in --file file's content or as an argument");
68
+ }
69
+ // the conditional above ensures we either have an arg or it's in the file - now we just have to find where the URL value is
70
+ const specified = args.url ?? (fileOptions?.url).raw ?? fileOptions?.url;
71
+ const url = new URL(`${org.getField(Org.Fields.INSTANCE_URL)}/${specified.replace(/\//y, '')}`);
72
+ // default the method to GET here to allow flags to override, but not hinder reading from files, rather than setting the default in the flag definition
73
+ const method = flags.method ?? fileOptions?.method ?? 'GET';
74
+ // @ts-expect-error users _could_ put one of these in their file without knowing it's wrong - TS is smarter than users here :)
75
+ if (!methodOptions.includes(method)) {
76
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
77
+ throw new SfError(`"${method}" must be one of ${methodOptions.join(', ')}`);
78
+ }
79
+ // body can be undefined;
80
+ // if we have a --body @myfile.json, read the file
81
+ // if we have a --body '{"key":"value"}' use that
82
+ // else read from --file's body
83
+ let body;
84
+ if (method !== 'GET') {
85
+ if (flags.body && flags.body.startsWith('@')) {
86
+ // remove the '@' and read it
87
+ body = readFileSync(flags.body.substring(1));
88
+ }
89
+ else if (flags.body) {
90
+ body = flags.body;
91
+ }
92
+ else if (!flags.body) {
93
+ body = getBodyContents(fileOptions?.body);
94
+ }
95
+ }
96
+ let headers = getHeaders(flags.header ?? fileOptions?.header);
97
+ if (body instanceof FormData) {
98
+ // if it's a multi-part formdata request, those have extra headers
99
+ headers = { ...headers, ...body.getHeaders() };
100
+ }
67
101
  const options = {
68
102
  agent: { https: new ProxyAgent() },
69
- method: flags.method,
103
+ method,
70
104
  headers: {
71
105
  ...SFDX_HTTP_HEADERS,
72
106
  Authorization: `Bearer ${
@@ -79,7 +113,62 @@ export class Rest extends SfCommand {
79
113
  throwHttpErrors: false,
80
114
  followRedirect: false,
81
115
  };
116
+ await org.refreshAuth();
82
117
  await sendAndPrintRequest({ streamFile, url, options, include: flags.include, this: this });
83
118
  }
84
119
  }
120
+ export const getBodyContents = (body) => {
121
+ if (!body?.mode) {
122
+ throw new SfError("No 'mode' found in 'body' entry", undefined, ['add "mode":"raw" | "formdata" to your body']);
123
+ }
124
+ if (body?.mode === 'raw') {
125
+ return JSON.stringify(body.raw);
126
+ }
127
+ else {
128
+ // parse formdata
129
+ const form = new FormData();
130
+ body?.formdata.map((data) => {
131
+ if (data.type === 'text') {
132
+ form.append(data.key, data.value);
133
+ }
134
+ else if (data.type === 'file' && typeof data.src === 'string') {
135
+ form.append(data.key, createReadStream(data.src));
136
+ }
137
+ else if (Array.isArray(data.src)) {
138
+ form.append(data.key, data.src);
139
+ }
140
+ });
141
+ return form;
142
+ }
143
+ };
144
+ export function getHeaders(keyValPair) {
145
+ if (!keyValPair)
146
+ return {};
147
+ const headers = {};
148
+ if (typeof keyValPair === 'string') {
149
+ const [key, ...rest] = keyValPair.split(':');
150
+ headers[key.toLowerCase()] = rest.join(':').trim();
151
+ }
152
+ else {
153
+ keyValPair.map((header) => {
154
+ if (typeof header === 'string') {
155
+ const [key, ...rest] = header.split(':');
156
+ const value = rest.join(':').trim();
157
+ if (!key || !value) {
158
+ throw new SfError(`Failed to parse HTTP header: "${header}".`, 'Failed To Parse HTTP Header', [
159
+ 'Make sure the header is in a "key:value" format, e.g. "Accept: application/json"',
160
+ ]);
161
+ }
162
+ headers[key.toLowerCase()] = value;
163
+ }
164
+ else if (!header.disabled) {
165
+ if (!header.key || !header.value) {
166
+ throw new SfError(`Failed to validate header: missing key: ${header.key} or value: ${header.value}`);
167
+ }
168
+ headers[header.key.toLowerCase()] = header.value;
169
+ }
170
+ });
171
+ }
172
+ return headers;
173
+ }
85
174
  //# sourceMappingURL=rest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rest.js","sourceRoot":"","sources":["../../../../src/commands/api/request/rest.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE3G,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;AAEzE,MAAM,OAAO,IAAK,SAAQ,SAAe;IAChC,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC;IACtB,MAAM,CAAC,cAAc,GAAG,KAAK,CAAC;IAC9B,MAAM,CAAU,KAAK,GAAG;QAC7B,YAAY,EAAE,KAAK,C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C,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,6 +1,4 @@
1
- import type { Headers } from 'got';
2
1
  import { SfCommand } from '@salesforce/sf-plugins-core';
3
- export declare function getHeaders(keyValPair: string[]): Headers;
4
2
  export declare function sendAndPrintRequest(options: {
5
3
  streamFile?: string;
6
4
  url: URL;
@@ -11,20 +11,6 @@ import ansis from 'ansis';
11
11
  import got from 'got';
12
12
  Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
13
13
  const messages = Messages.loadMessages('@salesforce/plugin-api', 'shared');
14
- export function getHeaders(keyValPair) {
15
- const headers = {};
16
- for (const header of keyValPair) {
17
- const [key, ...rest] = header.split(':');
18
- const value = rest.join(':').trim();
19
- if (!key || !value) {
20
- throw new SfError(`Failed to parse HTTP header: "${header}".`, 'Failed To Parse HTTP Header', [
21
- 'Make sure the header is in a "key:value" format, e.g. "Accept: application/json"',
22
- ]);
23
- }
24
- headers[key] = value;
25
- }
26
- return headers;
27
- }
28
14
  export async function sendAndPrintRequest(options) {
29
15
  if (options.streamFile) {
30
16
  const responseStream = options.options.method
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/shared/shared.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,KAAK,EAAa,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,wBAAwB,EAAE,QAAQ,CAAC,CAAC;AAC3E,MAAM,UAAU,UAAU,CAAC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AAQ,CAAC,UAAU,CAAC,8BAA8B,CAAC;IAC5D,SAAS,EAAE,sBAAsB;IACjC,IAAI,EAAE,GAAG;IACT,SAAS,EAAE,CAAC,SAAS,CAAC;CACvB,CAAC,CAAC"}
package/messages/rest.md CHANGED
@@ -12,36 +12,73 @@ For a full list of supported REST endpoints and resources, see https://developer
12
12
 
13
13
  - List information about limits in the org with alias "my-org":
14
14
 
15
- <%= config.bin %> <%= command.id %> 'limits' --target-org my-org
15
+ <%= config.bin %> <%= command.id %> 'services/data/v56.0/limits' --target-org my-org
16
16
 
17
17
  - List all endpoints in your default org; write the output to a file called "output.txt" and include the HTTP response status and headers:
18
18
 
19
- <%= config.bin %> <%= command.id %> '/' --stream-to-file output.txt --include
19
+ <%= config.bin %> <%= command.id %> '/services/data/v56.0/' --stream-to-file output.txt --include
20
20
 
21
21
  - Get the response in XML format by specifying the "Accept" HTTP header:
22
22
 
23
- <%= config.bin %> <%= command.id %> 'limits' --header 'Accept: application/xml'
23
+ <%= config.bin %> <%= command.id %> '/services/data/v56.0/limits' --header 'Accept: application/xml'
24
24
 
25
25
  - Create an account record using the POST method; specify the request details directly in the "--body" flag:
26
26
 
27
- <%= config.bin %> <%= command.id %> 'sobjects/account' --body "{\"Name\" : \"Account from REST API\",\"ShippingCity\" : \"Boise\"}" --method POST
27
+ <%= config.bin %> <%= command.id %> /services/data/v56.0/sobjects/account --body "{\"Name\" : \"Account from REST API\",\"ShippingCity\" : \"Boise\"}" --method POST
28
28
 
29
- - Create an account record using the information in a file called "info.json":
29
+ - Create an account record using the information in a file called "info.json" (note the @ prefixing the file name):
30
30
 
31
- <%= config.bin %> <%= command.id %> 'sobjects/account' --body info.json --method POST
31
+ <%= config.bin %> <%= command.id %> '/services/data/v56.0/sobjects/account' --body @info.json --method POST
32
32
 
33
33
  - Update an account record using the PATCH method:
34
34
 
35
- <%= config.bin %> <%= command.id %> 'sobjects/account/<Account ID>' --body "{\"BillingCity\": \"San Francisco\"}" --method PATCH
35
+ <%= config.bin %> <%= command.id %> '/services/data/v56.0/sobjects/account/<Account ID>' --body "{\"BillingCity\": \"San Francisco\"}" --method PATCH
36
+
37
+ - Store the values for the request header, body, and so on, in a file, which you then specify with the --file flag; see the description of --file for more information:
38
+
39
+ <%= config.bin %> <%= command.id %> --file myFile.json
36
40
 
37
41
  # flags.method.summary
38
42
 
39
43
  HTTP method for the request.
40
44
 
45
+ # flags.file.summary
46
+
47
+ JSON file that contains values for the request header, body, method, and URL.
48
+
49
+ # flags.file.description
50
+
51
+ Use this flag instead of specifying the request details with individual flags, such as --body or --method. This schema defines how to create the JSON file:
52
+
53
+ {
54
+ url: { raw: string } | string;
55
+ method: 'GET', 'POST', 'PUT', 'PATCH', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE';
56
+ description?: string;
57
+ header: string | Array<Record<string, string>>;
58
+ body: { mode: 'raw' | 'formdata'; raw: string; formdata: FormData };
59
+ }
60
+
61
+ Salesforce CLI defined this schema to be mimic Postman schemas; both share similar properties. The CLI's schema also supports Postman Collections to reuse and share requests. As a result, you can build an API call using Postman, export and save it to a file, and then use the file as a value to this flag. For information about Postman, see https://learning.postman.com/.
62
+
63
+ Here's a simple example of a JSON file that contains values for the request URL, method, and body:
64
+
65
+ {
66
+ "url": "sobjects/Account/<Account ID>",
67
+ "method": "PATCH",
68
+ "body" : {
69
+ "mode": "raw",
70
+ "raw": {
71
+ "BillingCity": "Boise"
72
+ }
73
+ }
74
+ }
75
+
76
+ See more examples in the plugin-api test directory, including JSON files that use "formdata" to define collections: https://github.com/salesforcecli/plugin-api/tree/main/test/test-files/data-project.
77
+
41
78
  # flags.header.summary
42
79
 
43
80
  HTTP header in "key:value" format.
44
81
 
45
82
  # flags.body.summary
46
83
 
47
- File or content for the body of the HTTP request. Specify "-" to read from standard input or "" for an empty body.
84
+ File or content for the body of the HTTP request. Specify "-" to read from standard input or "" for an empty body. If passing a file, prefix the filename with '@'.
@@ -106,20 +106,21 @@
106
106
  "api:request:rest": {
107
107
  "aliases": [],
108
108
  "args": {
109
- "endpoint": {
109
+ "url": {
110
110
  "description": "Salesforce API endpoint",
111
- "name": "endpoint",
112
- "required": true
111
+ "name": "url",
112
+ "required": false
113
113
  }
114
114
  },
115
115
  "description": "When sending the HTTP request with the \"--body\" flag, you can specify the request directly at the command line or with a file that contains the request.\n\nFor a full list of supported REST endpoints and resources, see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_list.htm.",
116
116
  "examples": [
117
- "List information about limits in the org with alias \"my-org\":\n<%= config.bin %> <%= command.id %> 'limits' --target-org my-org",
118
- "List all endpoints in your default org; write the output to a file called \"output.txt\" and include the HTTP response status and headers:\n<%= config.bin %> <%= command.id %> '/' --stream-to-file output.txt --include",
119
- "Get the response in XML format by specifying the \"Accept\" HTTP header:\n<%= config.bin %> <%= command.id %> 'limits' --header 'Accept: application/xml'",
120
- "Create an account record using the POST method; specify the request details directly in the \"--body\" flag:\n<%= config.bin %> <%= command.id %> 'sobjects/account' --body \"{\\\"Name\\\" : \\\"Account from REST API\\\",\\\"ShippingCity\\\" : \\\"Boise\\\"}\" --method POST",
121
- "Create an account record using the information in a file called \"info.json\":\n<%= config.bin %> <%= command.id %> 'sobjects/account' --body info.json --method POST",
122
- "Update an account record using the PATCH method:\n<%= config.bin %> <%= command.id %> 'sobjects/account/<Account ID>' --body \"{\\\"BillingCity\\\": \\\"San Francisco\\\"}\" --method PATCH"
117
+ "List information about limits in the org with alias \"my-org\":\n<%= config.bin %> <%= command.id %> 'services/data/v56.0/limits' --target-org my-org",
118
+ "List all endpoints in your default org; write the output to a file called \"output.txt\" and include the HTTP response status and headers:\n<%= config.bin %> <%= command.id %> '/services/data/v56.0/' --stream-to-file output.txt --include",
119
+ "Get the response in XML format by specifying the \"Accept\" HTTP header:\n<%= config.bin %> <%= command.id %> '/services/data/v56.0/limits' --header 'Accept: application/xml'",
120
+ "Create an account record using the POST method; specify the request details directly in the \"--body\" flag:\n<%= config.bin %> <%= command.id %> /services/data/v56.0/sobjects/account --body \"{\\\"Name\\\" : \\\"Account from REST API\\\",\\\"ShippingCity\\\" : \\\"Boise\\\"}\" --method POST",
121
+ "Create an account record using the information in a file called \"info.json\" (note the @ prefixing the file name):\n<%= config.bin %> <%= command.id %> '/services/data/v56.0/sobjects/account' --body @info.json --method POST",
122
+ "Update an account record using the PATCH method:\n<%= config.bin %> <%= command.id %> '/services/data/v56.0/sobjects/account/<Account ID>' --body \"{\\\"BillingCity\\\": \\\"San Francisco\\\"}\" --method PATCH",
123
+ "Store the values for the request header, body, and so on, in a file, which you then specify with the --file flag; see the description of --file for more information:\n<%= config.bin %> <%= command.id %> --file myFile.json"
123
124
  ],
124
125
  "flags": {
125
126
  "flags-dir": {
@@ -140,13 +141,6 @@
140
141
  "multiple": false,
141
142
  "type": "option"
142
143
  },
143
- "api-version": {
144
- "description": "Override the api version used for api requests made by this command",
145
- "name": "api-version",
146
- "hasDynamicHelp": false,
147
- "multiple": false,
148
- "type": "option"
149
- },
150
144
  "include": {
151
145
  "char": "i",
152
146
  "exclusive": [
@@ -161,7 +155,6 @@
161
155
  "char": "X",
162
156
  "name": "method",
163
157
  "summary": "HTTP method for the request.",
164
- "default": "GET",
165
158
  "hasDynamicHelp": false,
166
159
  "multiple": false,
167
160
  "options": [
@@ -185,6 +178,19 @@
185
178
  "multiple": true,
186
179
  "type": "option"
187
180
  },
181
+ "file": {
182
+ "char": "f",
183
+ "description": "Use this flag instead of specifying the request details with individual flags, such as --body or --method. This schema defines how to create the JSON file:\n\n{\nurl: { raw: string } | string;\nmethod: 'GET', 'POST', 'PUT', 'PATCH', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE';\ndescription?: string;\nheader: string | Array<Record<string, string>>;\nbody: { mode: 'raw' | 'formdata'; raw: string; formdata: FormData };\n}\n\nSalesforce CLI defined this schema to be mimic Postman schemas; both share similar properties. The CLI's schema also supports Postman Collections to reuse and share requests. As a result, you can build an API call using Postman, export and save it to a file, and then use the file as a value to this flag. For information about Postman, see https://learning.postman.com/.\n\nHere's a simple example of a JSON file that contains values for the request URL, method, and body:\n\n{\n\"url\": \"sobjects/Account/<Account ID>\",\n\"method\": \"PATCH\",\n\"body\" : {\n\"mode\": \"raw\",\n\"raw\": {\n\"BillingCity\": \"Boise\"\n}\n}\n}\n\nSee more examples in the plugin-api test directory, including JSON files that use \"formdata\" to define collections: https://github.com/salesforcecli/plugin-api/tree/main/test/test-files/data-project.",
184
+ "exclusive": [
185
+ "body"
186
+ ],
187
+ "name": "file",
188
+ "summary": "JSON file that contains values for the request header, body, method, and URL.",
189
+ "hasDynamicHelp": false,
190
+ "helpValue": "file",
191
+ "multiple": false,
192
+ "type": "option"
193
+ },
188
194
  "stream-to-file": {
189
195
  "char": "S",
190
196
  "exclusive": [
@@ -198,8 +204,9 @@
198
204
  "type": "option"
199
205
  },
200
206
  "body": {
207
+ "char": "b",
201
208
  "name": "body",
202
- "summary": "File or content for the body of the HTTP request. Specify \"-\" to read from standard input or \"\" for an empty body.",
209
+ "summary": "File or content for the body of the HTTP request. Specify \"-\" to read from standard input or \"\" for an empty body. If passing a file, prefix the filename with '@'.",
203
210
  "hasDynamicHelp": false,
204
211
  "helpValue": "file",
205
212
  "multiple": false,
@@ -235,5 +242,5 @@
235
242
  ]
236
243
  }
237
244
  },
238
- "version": "1.2.2"
245
+ "version": "1.3.1"
239
246
  }