@salesforce/plugin-api 1.2.0 → 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/README.md CHANGED
@@ -64,9 +64,9 @@ sf plugins
64
64
 
65
65
  ## `sf api request graphql`
66
66
 
67
- Execute GraphQL statements
67
+ Execute a GraphQL statement.
68
68
 
69
- ````
69
+ ```
70
70
  USAGE
71
71
  $ sf api request graphql -o <value> --body file [--json] [--flags-dir <value>] [--api-version <value>] [-S Example:
72
72
  report.xlsx | -i]
@@ -77,103 +77,113 @@ FLAGS
77
77
  -o, --target-org=<value> (required) Username or alias of the target org. Not required if the
78
78
  `target-org` configuration variable is already set.
79
79
  --api-version=<value> Override the api version used for api requests made by this command
80
- --body=file (required) File or content with GraphQL statement. Specify "-" to read from
81
- standard input.
80
+ --body=file (required) File or content with the GraphQL statement. Specify "-" to read
81
+ from standard input.
82
82
 
83
83
  GLOBAL FLAGS
84
84
  --flags-dir=<value> Import flag values from a directory.
85
85
  --json Format output as json.
86
86
 
87
87
  DESCRIPTION
88
- Execute GraphQL statements
88
+ Execute a GraphQL statement.
89
+
90
+ Specify the GraphQL statement with the "--body" flag, either directly at the command line or with a file that contains
91
+ the statement. You can query Salesforce records using a "query" statement or use mutations to modify Salesforce
92
+ records.
89
93
 
90
- Run any valid GraphQL statement via the /graphql
91
- [API](https://developer.salesforce.com/docs/platform/graphql/guide/graphql-about.html)
94
+ This command uses the GraphQL API to query or modify Salesforce objects. For details about the API, and examples of
95
+ queries and mutations, see https://developer.salesforce.com/docs/platform/graphql/guide/graphql-about.html.
92
96
 
93
97
  EXAMPLES
94
- - Runs the graphql query directly via the command line
95
- sf api request graphql --body "query accounts { uiapi { query { Account { edges { node { Id \n Name { value } } } } } } }"
96
- - Runs a mutation to create an Account, with an `example.txt` file, containing
97
- ```text
98
- mutation AccountExample{
99
- uiapi {
100
- AccountCreate(input: {
101
- Account: {
102
- Name: "Trailblazer Express"
103
- }
104
- }) {
105
- Record {
106
- Id
107
- Name {
108
- value
109
- }
110
- }
111
- }
112
- }
113
- }
114
- ````
115
-
116
- $ sf api request graphql --body example.txt
117
- will create a new account returning specified fields (Id, Name)
98
+ Execute a GraphQL query on the Account object by specifying the query directly to the "--body" flag; the command
99
+ uses your default org:
100
+
101
+ $ sf api request graphql --body "query accounts { uiapi { query { Account { edges { node { Id \n Name { value } \
102
+ } } } } } }"
103
+
104
+ Read the GraphQL statement from a file called "example.txt" and execute it on an org with alias "my-org":
118
105
 
106
+ $ sf api request graphql --body example.txt --target-org my-org
107
+
108
+ Pipe the GraphQL statement that you want to execute from standard input to the command:
109
+ $ echo graphql | sf api request graphql --body -
110
+
111
+ Write the output of the command to a file called "output.txt" and include the HTTP response status and headers:
112
+
113
+ $ sf api request graphql --body example.txt --stream-to-file output.txt --include
119
114
  ```
120
115
 
121
- _See code: [src/commands/api/request/graphql.ts](https://github.com/salesforcecli/plugin-api/blob/1.2.0/src/commands/api/request/graphql.ts)_
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)_
122
117
 
123
118
  ## `sf api request rest ENDPOINT`
124
119
 
125
- Make an authenticated HTTP request to Salesforce REST API and print the response.
120
+ Make an authenticated HTTP request using the Salesforce REST API.
126
121
 
127
122
  ```
128
-
129
123
  USAGE
130
- $ sf api request rest ENDPOINT -o <value> [--flags-dir <value>] [--api-version <value>] [-i | -S Example:
131
- report.xlsx] [-X GET|POST|PUT|PATCH|HEAD|DELETE|OPTIONS|TRACE] [-H key:value...] [--body file]
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]
132
126
 
133
127
  ARGUMENTS
134
- ENDPOINT Salesforce API endpoint
128
+ ENDPOINT Salesforce API endpoint
135
129
 
136
130
  FLAGS
137
- -H, --header=key:value... HTTP header in "key:value" format.
138
- -S, --stream-to-file=Example: report.xlsx Stream responses to a file.
139
- -X, --method=<option> [default: GET] HTTP method for the request.
140
- <options: GET|POST|PUT|PATCH|HEAD|DELETE|OPTIONS|TRACE>
141
- -i, --include Include the HTTP response status and headers in the output.
142
- -o, --target-org=<value> (required) Username or alias of the target org. Not required if the
143
- `target-org` configuration variable is already set.
144
- --api-version=<value> Override the api version used for api requests made by this command
145
- --body=file File to use as the body for the request. Specify "-" to read from standard
146
- input; specify "" for an empty body.
131
+ -H, --header=key:value... HTTP header in "key:value" format.
132
+ -S, --stream-to-file=Example: report.xlsx Stream responses to a file.
133
+ -X, --method=<option> [default: GET] HTTP method for the request.
134
+ <options: GET|POST|PUT|PATCH|HEAD|DELETE|OPTIONS|TRACE>
135
+ -i, --include Include the HTTP response status and headers in the output.
136
+ -o, --target-org=<value> (required) Username or alias of the target org. Not required if the
137
+ `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.
147
141
 
148
142
  GLOBAL FLAGS
149
- --flags-dir=<value> Import flag values from a directory.
143
+ --flags-dir=<value> Import flag values from a directory.
144
+
145
+ DESCRIPTION
146
+ Make an authenticated HTTP request using the Salesforce REST API.
147
+
148
+ When sending the HTTP request with the "--body" flag, you can specify the request directly at the command line or with
149
+ a file that contains the request.
150
+
151
+ For a full list of supported REST endpoints and resources, see
152
+ https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_list.htm.
150
153
 
151
154
  EXAMPLES
155
+ List information about limits in the org with alias "my-org":
152
156
 
153
- - List information about limits in the org with alias "my-org":
154
- sf api request rest 'limits' --target-org my-org
155
- - List all endpoints
156
- sf api request rest '/'
157
- - Get the response in XML format by specifying the "Accept" HTTP header:
158
- sf api request rest 'limits' --target-org my-org --header 'Accept: application/xml'
159
- - POST to create an Account object
160
- sf api request rest 'sobjects/account' --body "{\"Name\" : \"Account from REST API\",\"ShippingCity\" : \"Boise\"}" --method POST
161
- - or with a file 'info.json' containing
162
-
163
- ```json
164
- {
165
- "Name": "Demo",
166
- "ShippingCity": "Boise"
167
- }
168
- ```
157
+ $ sf api request rest 'limits' --target-org my-org
158
+
159
+ List all endpoints in your default org; write the output to a file called "output.txt" and include the HTTP response
160
+ status and headers:
161
+
162
+ $ sf api request rest '/' --stream-to-file output.txt --include
163
+
164
+ Get the response in XML format by specifying the "Accept" HTTP header:
165
+
166
+ $ sf api request rest 'limits' --header 'Accept: application/xml'
169
167
 
170
- $ sf api request rest 'sobjects/account' --body info.json --method POST
168
+ Create an account record using the POST method; specify the request details directly in the "--body" flag:
171
169
 
172
- - Update object
173
- sf api request rest 'sobjects/account/<Account ID>' --body "{\"BillingCity\": \"San Francisco\"}" --method PATCH
170
+ $ sf api request rest 'sobjects/account' --body "{\"Name\" : \"Account from REST API\",\"ShippingCity\" : \
171
+ \"Boise\"}" --method POST
174
172
 
173
+ Create an account record using the information in a file called "info.json":
174
+
175
+ $ sf api request rest 'sobjects/account' --body info.json --method POST
176
+
177
+ Update an account record using the PATCH method:
178
+
179
+ $ sf api request rest 'sobjects/account/<Account ID>' --body "{\"BillingCity\": \"San Francisco\"}" --method \
180
+ PATCH
175
181
  ```
176
182
 
177
- _See code: [src/commands/api/request/rest.ts](https://github.com/salesforcecli/plugin-api/blob/1.2.0/src/commands/api/request/rest.ts)_
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)_
184
+
178
185
  <!-- commandsstop -->
186
+
187
+ ```
188
+
179
189
  ```
@@ -2,6 +2,7 @@ import { SfCommand } from '@salesforce/sf-plugins-core';
2
2
  import { Org } from '@salesforce/core';
3
3
  export declare class Rest extends SfCommand<void> {
4
4
  static readonly summary: string;
5
+ static readonly description: string;
5
6
  static readonly examples: string[];
6
7
  static state: string;
7
8
  static enableJsonFlag: boolean;
@@ -15,6 +15,7 @@ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
15
15
  const messages = Messages.loadMessages('@salesforce/plugin-api', 'rest');
16
16
  export class Rest extends SfCommand {
17
17
  static summary = messages.getMessage('summary');
18
+ static description = messages.getMessage('description');
18
19
  static examples = messages.getMessages('examples');
19
20
  static state = 'beta';
20
21
  static enableJsonFlag = false;
@@ -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,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;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WAC7C,EAAE;gBACF,GAAG,OAAO;aACX;YACD,IAAI;YACJ,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,KAAK;SACtB,CAAC;QAEF,MAAM,mBAAmB,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9F,CAAC"}
@@ -1,46 +1,31 @@
1
1
  # summary
2
2
 
3
- Execute GraphQL statements
3
+ Execute a GraphQL statement.
4
4
 
5
5
  # description
6
6
 
7
- Run any valid GraphQL statement via the /graphql [API](https://developer.salesforce.com/docs/platform/graphql/guide/graphql-about.html)
7
+ Specify the GraphQL statement with the "--body" flag, either directly at the command line or with a file that contains the statement. You can query Salesforce records using a "query" statement or use mutations to modify Salesforce records.
8
+
9
+ This command uses the GraphQL API to query or modify Salesforce objects. For details about the API, and examples of queries and mutations, see https://developer.salesforce.com/docs/platform/graphql/guide/graphql-about.html.
8
10
 
9
11
  # examples
10
12
 
11
- - Runs the graphql query directly via the command line
13
+ - Execute a GraphQL query on the Account object by specifying the query directly to the "--body" flag; the command uses your default org:
12
14
 
13
15
  <%= config.bin %> <%= command.id %> --body "query accounts { uiapi { query { Account { edges { node { Id \n Name { value } } } } } } }"
14
16
 
15
- - Runs a mutation to create an Account, with an `example.txt` file, containing
17
+ - Read the GraphQL statement from a file called "example.txt" and execute it on an org with alias "my-org":
16
18
 
17
- ```text
18
- mutation AccountExample{
19
- uiapi {
20
- AccountCreate(input: {
21
- Account: {
22
- Name: "Trailblazer Express"
23
- }
24
- }) {
25
- Record {
26
- Id
27
- Name {
28
- value
29
- }
30
- }
31
- }
32
- }
33
- }
34
- ```
19
+ <%= config.bin %> <%= command.id %> --body example.txt --target-org my-org
35
20
 
36
- <%= config.bin %> <%= command.id %> --body example.txt
21
+ - Pipe the GraphQL statement that you want to execute from standard input to the command:
37
22
 
38
- will create a new account returning specified fields (Id, Name)
23
+ $ echo graphql | sf api request graphql --body -
39
24
 
40
- # flags.header.summary
25
+ - Write the output of the command to a file called "output.txt" and include the HTTP response status and headers:
41
26
 
42
- HTTP header in "key:value" format.
27
+ <%= config.bin %> <%= command.id %> --body example.txt --stream-to-file output.txt --include
43
28
 
44
29
  # flags.body.summary
45
30
 
46
- File or content with GraphQL statement. Specify "-" to read from standard input.
31
+ File or content with the GraphQL statement. Specify "-" to read from standard input.
package/messages/rest.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # summary
2
2
 
3
- Make an authenticated HTTP request to Salesforce REST API and print the response.
3
+ Make an authenticated HTTP request using the Salesforce REST API.
4
+
5
+ # description
6
+
7
+ 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.
8
+
9
+ For 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.
4
10
 
5
11
  # examples
6
12
 
@@ -8,30 +14,23 @@ Make an authenticated HTTP request to Salesforce REST API and print the response
8
14
 
9
15
  <%= config.bin %> <%= command.id %> 'limits' --target-org my-org
10
16
 
11
- - List all endpoints
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:
12
18
 
13
- <%= config.bin %> <%= command.id %> '/'
19
+ <%= config.bin %> <%= command.id %> '/' --stream-to-file output.txt --include
14
20
 
15
21
  - Get the response in XML format by specifying the "Accept" HTTP header:
16
22
 
17
- <%= config.bin %> <%= command.id %> 'limits' --target-org my-org --header 'Accept: application/xml'
23
+ <%= config.bin %> <%= command.id %> 'limits' --header 'Accept: application/xml'
18
24
 
19
- - POST to create an Account object
25
+ - Create an account record using the POST method; specify the request details directly in the "--body" flag:
20
26
 
21
27
  <%= config.bin %> <%= command.id %> 'sobjects/account' --body "{\"Name\" : \"Account from REST API\",\"ShippingCity\" : \"Boise\"}" --method POST
22
28
 
23
- - or with a file 'info.json' containing
24
-
25
- ```json
26
- {
27
- "Name": "Demo",
28
- "ShippingCity": "Boise"
29
- }
30
- ```
29
+ - Create an account record using the information in a file called "info.json":
31
30
 
32
- <%= config.bin %> <%= command.id %> 'sobjects/account' --body info.json --method POST
31
+ <%= config.bin %> <%= command.id %> 'sobjects/account' --body info.json --method POST
33
32
 
34
- - Update object
33
+ - Update an account record using the PATCH method:
35
34
 
36
35
  <%= config.bin %> <%= command.id %> 'sobjects/account/<Account ID>' --body "{\"BillingCity\": \"San Francisco\"}" --method PATCH
37
36
 
@@ -45,4 +44,4 @@ HTTP header in "key:value" format.
45
44
 
46
45
  # flags.body.summary
47
46
 
48
- File to use as the body for the request. Specify "-" to read from standard input; specify "" for an empty body.
47
+ File or content for the body of the HTTP request. Specify "-" to read from standard input or "" for an empty body.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@salesforce/plugin-api",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@salesforce/plugin-api",
9
- "version": "1.2.0",
9
+ "version": "1.2.2",
10
10
  "license": "BSD-3-Clause",
11
11
  "dependencies": {
12
12
  "@oclif/core": "^4",
@@ -3,9 +3,12 @@
3
3
  "api:request:graphql": {
4
4
  "aliases": [],
5
5
  "args": {},
6
- "description": "Run any valid GraphQL statement via the /graphql [API](https://developer.salesforce.com/docs/platform/graphql/guide/graphql-about.html)",
6
+ "description": "Specify the GraphQL statement with the \"--body\" flag, either directly at the command line or with a file that contains the statement. You can query Salesforce records using a \"query\" statement or use mutations to modify Salesforce records.\n\nThis command uses the GraphQL API to query or modify Salesforce objects. For details about the API, and examples of queries and mutations, see https://developer.salesforce.com/docs/platform/graphql/guide/graphql-about.html.",
7
7
  "examples": [
8
- "- Runs the graphql query directly via the command line\n\n <%= config.bin %> <%= command.id %> --body \"query accounts { uiapi { query { Account { edges { node { Id \\n Name { value } } } } } } }\"\n\n- Runs a mutation to create an Account, with an `example.txt` file, containing\n\n```text\nmutation AccountExample{\n uiapi {\n AccountCreate(input: {\n Account: {\n Name: \"Trailblazer Express\"\n }\n }) {\n Record {\n Id\n Name {\n value\n }\n }\n }\n }\n}\n```\n\n<%= config.bin %> <%= command.id %> --body example.txt\n\nwill create a new account returning specified fields (Id, Name)"
8
+ "Execute a GraphQL query on the Account object by specifying the query directly to the \"--body\" flag; the command uses your default org:\n<%= config.bin %> <%= command.id %> --body \"query accounts { uiapi { query { Account { edges { node { Id \\n Name { value } } } } } } }\"",
9
+ "Read the GraphQL statement from a file called \"example.txt\" and execute it on an org with alias \"my-org\":\n<%= config.bin %> <%= command.id %> --body example.txt --target-org my-org",
10
+ "Pipe the GraphQL statement that you want to execute from standard input to the command:\n$ echo graphql | sf api request graphql --body -",
11
+ "Write the output of the command to a file called \"output.txt\" and include the HTTP response status and headers:\n<%= config.bin %> <%= command.id %> --body example.txt --stream-to-file output.txt --include"
9
12
  ],
10
13
  "flags": {
11
14
  "json": {
@@ -65,7 +68,7 @@
65
68
  "body": {
66
69
  "name": "body",
67
70
  "required": true,
68
- "summary": "File or content with GraphQL statement. Specify \"-\" to read from standard input.",
71
+ "summary": "File or content with the GraphQL statement. Specify \"-\" to read from standard input.",
69
72
  "hasDynamicHelp": false,
70
73
  "helpValue": "file",
71
74
  "multiple": false,
@@ -80,7 +83,7 @@
80
83
  "pluginType": "core",
81
84
  "state": "beta",
82
85
  "strict": true,
83
- "summary": "Execute GraphQL statements",
86
+ "summary": "Execute a GraphQL statement.",
84
87
  "enableJsonFlag": true,
85
88
  "isESM": true,
86
89
  "relativePath": [
@@ -109,8 +112,14 @@
109
112
  "required": true
110
113
  }
111
114
  },
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.",
112
116
  "examples": [
113
- "- List information about limits in the org with alias \"my-org\":\n\n <%= config.bin %> <%= command.id %> 'limits' --target-org my-org\n\n- List all endpoints\n\n <%= config.bin %> <%= command.id %> '/'\n\n- Get the response in XML format by specifying the \"Accept\" HTTP header:\n\n <%= config.bin %> <%= command.id %> 'limits' --target-org my-org --header 'Accept: application/xml'\n\n- POST to create an Account object\n\n <%= config.bin %> <%= command.id %> 'sobjects/account' --body \"{\\\"Name\\\" : \\\"Account from REST API\\\",\\\"ShippingCity\\\" : \\\"Boise\\\"}\" --method POST\n\n- or with a file 'info.json' containing\n\n```json\n{\n \"Name\": \"Demo\",\n \"ShippingCity\": \"Boise\"\n}\n```\n\n<%= config.bin %> <%= command.id %> 'sobjects/account' --body info.json --method POST\n\n- Update object\n\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 %> '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"
114
123
  ],
115
124
  "flags": {
116
125
  "flags-dir": {
@@ -190,7 +199,7 @@
190
199
  },
191
200
  "body": {
192
201
  "name": "body",
193
- "summary": "File to use as the body for the request. Specify \"-\" to read from standard input; specify \"\" for an empty body.",
202
+ "summary": "File or content for the body of the HTTP request. Specify \"-\" to read from standard input or \"\" for an empty body.",
194
203
  "hasDynamicHelp": false,
195
204
  "helpValue": "file",
196
205
  "multiple": false,
@@ -205,7 +214,7 @@
205
214
  "pluginType": "core",
206
215
  "state": "beta",
207
216
  "strict": true,
208
- "summary": "Make an authenticated HTTP request to Salesforce REST API and print the response.",
217
+ "summary": "Make an authenticated HTTP request using the Salesforce REST API.",
209
218
  "enableJsonFlag": false,
210
219
  "isESM": true,
211
220
  "relativePath": [
@@ -226,5 +235,5 @@
226
235
  ]
227
236
  }
228
237
  },
229
- "version": "1.2.0"
238
+ "version": "1.2.2"
230
239
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@salesforce/plugin-api",
3
3
  "description": "A plugin to call API endpoints via CLI commands",
4
- "version": "1.2.0",
4
+ "version": "1.2.2",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/forcedotcom/cli/issues",
7
7
  "dependencies": {
@@ -58,7 +58,12 @@
58
58
  ],
59
59
  "topics": {
60
60
  "api": {
61
- "description": "commands to send and interact with API calls"
61
+ "description": "Commands to interact with API calls.",
62
+ "subtopics": {
63
+ "request": {
64
+ "description": "Commands that make API requests."
65
+ }
66
+ }
62
67
  }
63
68
  },
64
69
  "flexibleTaxonomy": true
@@ -202,7 +207,7 @@
202
207
  "exports": "./lib/index.js",
203
208
  "type": "module",
204
209
  "sfdx": {
205
- "publicKeyUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-api/1.2.0.crt",
206
- "signatureUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-api/1.2.0.sig"
210
+ "publicKeyUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-api/1.2.2.crt",
211
+ "signatureUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-api/1.2.2.sig"
207
212
  }
208
213
  }