@salesforce/plugin-api 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/README.md +66 -48
- package/lib/commands/api/request/rest.d.ts +1 -0
- package/lib/commands/api/request/rest.js +1 -0
- package/lib/commands/api/request/rest.js.map +1 -1
- package/messages/graphql.md +12 -25
- package/messages/rest.md +15 -14
- package/npm-shrinkwrap.json +2 -2
- package/oclif.manifest.json +17 -8
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ sf plugins
|
|
|
64
64
|
|
|
65
65
|
## `sf api request graphql`
|
|
66
66
|
|
|
67
|
-
Execute GraphQL
|
|
67
|
+
Execute a GraphQL statement.
|
|
68
68
|
|
|
69
69
|
```
|
|
70
70
|
USAGE
|
|
@@ -77,48 +77,47 @@ 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
|
|
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
|
|
88
|
+
Execute a GraphQL statement.
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
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.
|
|
93
|
+
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
$ sf api request graphql --body example.txt
|
|
114
|
-
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":
|
|
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
|
|
115
114
|
```
|
|
116
115
|
|
|
117
|
-
_See code: [src/commands/api/request/graphql.ts](https://github.com/salesforcecli/plugin-api/blob/1.2.
|
|
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)_
|
|
118
117
|
|
|
119
118
|
## `sf api request rest ENDPOINT`
|
|
120
119
|
|
|
121
|
-
Make an authenticated HTTP request
|
|
120
|
+
Make an authenticated HTTP request using the Salesforce REST API.
|
|
122
121
|
|
|
123
122
|
```
|
|
124
123
|
USAGE
|
|
@@ -137,32 +136,51 @@ FLAGS
|
|
|
137
136
|
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the
|
|
138
137
|
`target-org` configuration variable is already set.
|
|
139
138
|
--api-version=<value> Override the api version used for api requests made by this command
|
|
140
|
-
--body=file File
|
|
141
|
-
input
|
|
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.
|
|
142
141
|
|
|
143
142
|
GLOBAL FLAGS
|
|
144
143
|
--flags-dir=<value> Import flag values from a directory.
|
|
145
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.
|
|
153
|
+
|
|
146
154
|
EXAMPLES
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
sf api request rest '
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
sf api request rest 'sobjects/account
|
|
155
|
+
List information about limits in the org with alias "my-org":
|
|
156
|
+
|
|
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'
|
|
167
|
+
|
|
168
|
+
Create an account record using the POST method; specify the request details directly in the "--body" flag:
|
|
169
|
+
|
|
170
|
+
$ sf api request rest 'sobjects/account' --body "{\"Name\" : \"Account from REST API\",\"ShippingCity\" : \
|
|
171
|
+
\"Boise\"}" --method POST
|
|
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
|
|
163
181
|
```
|
|
164
182
|
|
|
165
|
-
_See code: [src/commands/api/request/rest.ts](https://github.com/salesforcecli/plugin-api/blob/1.2.
|
|
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)_
|
|
166
184
|
|
|
167
185
|
<!-- commandsstop -->
|
|
168
186
|
|
|
@@ -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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 -1,44 +1,31 @@
|
|
|
1
1
|
# summary
|
|
2
2
|
|
|
3
|
-
Execute GraphQL
|
|
3
|
+
Execute a GraphQL statement.
|
|
4
4
|
|
|
5
5
|
# description
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
-
|
|
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
|
-
-
|
|
17
|
+
- Read the GraphQL statement from a file called "example.txt" and execute it on an org with alias "my-org":
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
uiapi {
|
|
19
|
-
AccountCreate(input: {
|
|
20
|
-
Account: {
|
|
21
|
-
Name: "Trailblazer Express"
|
|
22
|
-
}
|
|
23
|
-
}) {
|
|
24
|
-
Record {
|
|
25
|
-
Id
|
|
26
|
-
Name {
|
|
27
|
-
value
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
19
|
+
<%= config.bin %> <%= command.id %> --body example.txt --target-org my-org
|
|
33
20
|
|
|
34
|
-
|
|
21
|
+
- Pipe the GraphQL statement that you want to execute from standard input to the command:
|
|
35
22
|
|
|
36
|
-
|
|
23
|
+
$ echo graphql | sf api request graphql --body -
|
|
37
24
|
|
|
38
|
-
|
|
25
|
+
- Write the output of the command to a file called "output.txt" and include the HTTP response status and headers:
|
|
39
26
|
|
|
40
|
-
|
|
27
|
+
<%= config.bin %> <%= command.id %> --body example.txt --stream-to-file output.txt --include
|
|
41
28
|
|
|
42
29
|
# flags.body.summary
|
|
43
30
|
|
|
44
|
-
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
|
|
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,28 +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' --
|
|
23
|
+
<%= config.bin %> <%= command.id %> 'limits' --header 'Accept: application/xml'
|
|
18
24
|
|
|
19
|
-
- POST
|
|
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
|
-
-
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
"Name": "Demo",
|
|
27
|
-
"ShippingCity": "Boise"
|
|
28
|
-
}
|
|
29
|
+
- Create an account record using the information in a file called "info.json":
|
|
29
30
|
|
|
30
|
-
<%= config.bin %> <%= command.id %> 'sobjects/account' --body info.json --method POST
|
|
31
|
+
<%= config.bin %> <%= command.id %> 'sobjects/account' --body info.json --method POST
|
|
31
32
|
|
|
32
|
-
- Update
|
|
33
|
+
- Update an account record using the PATCH method:
|
|
33
34
|
|
|
34
35
|
<%= config.bin %> <%= command.id %> 'sobjects/account/<Account ID>' --body "{\"BillingCity\": \"San Francisco\"}" --method PATCH
|
|
35
36
|
|
|
@@ -43,4 +44,4 @@ HTTP header in "key:value" format.
|
|
|
43
44
|
|
|
44
45
|
# flags.body.summary
|
|
45
46
|
|
|
46
|
-
File
|
|
47
|
+
File or content for the body of the HTTP request. Specify "-" to read from standard input or "" for an empty body.
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/plugin-api",
|
|
3
|
-
"version": "1.2.
|
|
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.
|
|
9
|
+
"version": "1.2.2",
|
|
10
10
|
"license": "BSD-3-Clause",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@oclif/core": "^4",
|
package/oclif.manifest.json
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
"api:request:graphql": {
|
|
4
4
|
"aliases": [],
|
|
5
5
|
"args": {},
|
|
6
|
-
"description": "
|
|
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
|
-
"
|
|
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
|
|
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
|
-
"
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
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": "
|
|
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.
|
|
206
|
-
"signatureUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-api/1.2.
|
|
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
|
}
|