@salesforce/plugin-api 1.3.0 → 1.3.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
@@ -113,7 +113,7 @@ 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.3.0/src/commands/api/request/graphql.ts)_
116
+ _See code: [src/commands/api/request/graphql.ts](https://github.com/salesforcecli/plugin-api/blob/1.3.2/src/commands/api/request/graphql.ts)_
117
117
 
118
118
  ## `sf api request rest [URL]`
119
119
 
@@ -121,8 +121,8 @@ Make an authenticated HTTP request using the Salesforce REST API.
121
121
 
122
122
  ```
123
123
  USAGE
124
- $ sf api request rest [URL] -o <value> [--flags-dir <value>] [--api-version <value>] [-i | -S Example: report.xlsx]
125
- [-X GET|POST|PUT|PATCH|HEAD|DELETE|OPTIONS|TRACE] [-H key:value...] [-f file] [-b 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
128
  URL Salesforce API endpoint
@@ -133,13 +133,13 @@ FLAGS
133
133
  -X, --method=<option> HTTP method for the request.
134
134
  <options: GET|POST|PUT|PATCH|HEAD|DELETE|OPTIONS|TRACE>
135
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.
136
+ standard input or "" for an empty body. If passing a file, prefix the
137
+ filename with '@'.
137
138
  -f, --file=file JSON file that contains values for the request header, body, method, and
138
139
  URL.
139
140
  -i, --include Include the HTTP response status and headers in the output.
140
141
  -o, --target-org=<value> (required) Username or alias of the target org. Not required if the
141
142
  `target-org` configuration variable is already set.
142
- --api-version=<value> Override the api version used for api requests made by this command
143
143
 
144
144
  GLOBAL FLAGS
145
145
  --flags-dir=<value> Import flag values from a directory.
@@ -156,30 +156,30 @@ DESCRIPTION
156
156
  EXAMPLES
157
157
  List information about limits in the org with alias "my-org":
158
158
 
159
- $ sf api request rest 'limits' --target-org my-org
159
+ $ sf api request rest 'services/data/v56.0/limits' --target-org my-org
160
160
 
161
161
  List all endpoints in your default org; write the output to a file called "output.txt" and include the HTTP response
162
162
  status and headers:
163
163
 
164
- $ 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
165
165
 
166
166
  Get the response in XML format by specifying the "Accept" HTTP header:
167
167
 
168
- $ sf api request rest 'limits' --header 'Accept: application/xml'
168
+ $ sf api request rest '/services/data/v56.0/limits' --header 'Accept: application/xml'
169
169
 
170
170
  Create an account record using the POST method; specify the request details directly in the "--body" flag:
171
171
 
172
- $ sf api request rest sobjects/account --body "{\"Name\" : \"Account from REST API\",\"ShippingCity\" : \
173
- \"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
174
174
 
175
- 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):
176
176
 
177
- $ 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
178
178
 
179
179
  Update an account record using the PATCH method:
180
180
 
181
- $ sf api request rest 'sobjects/account/<Account ID>' --body "{\"BillingCity\": \"San Francisco\"}" --method \
182
- PATCH
181
+ $ sf api request rest '/services/data/v56.0/sobjects/account/<Account ID>' --body "{\"BillingCity\": \"San \
182
+ Francisco\"}" --method PATCH
183
183
 
184
184
  Store the values for the request header, body, and so on, in a file, which you then specify with the --file flag;
185
185
  see the description of --file for more information:
@@ -222,7 +222,7 @@ FLAG DESCRIPTIONS
222
222
  https://github.com/salesforcecli/plugin-api/tree/main/test/test-files/data-project.
223
223
  ```
224
224
 
225
- _See code: [src/commands/api/request/rest.ts](https://github.com/salesforcecli/plugin-api/blob/1.3.0/src/commands/api/request/rest.ts)_
225
+ _See code: [src/commands/api/request/rest.ts](https://github.com/salesforcecli/plugin-api/blob/1.3.2/src/commands/api/request/rest.ts)_
226
226
 
227
227
  <!-- commandsstop -->
228
228
 
@@ -43,7 +43,6 @@ export declare class Rest extends SfCommand<void> {
43
43
  static enableJsonFlag: boolean;
44
44
  static readonly flags: {
45
45
  'target-org': import("@oclif/core/interfaces").OptionFlag<Org, import("@oclif/core/interfaces").CustomOptions>;
46
- 'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
47
46
  include: import("@oclif/core/interfaces").BooleanFlag<boolean>;
48
47
  method: import("@oclif/core/interfaces").OptionFlag<"GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "OPTIONS" | "TRACE" | "PATCH" | undefined, import("@oclif/core/interfaces").CustomOptions>;
49
48
  header: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -22,7 +22,6 @@ export class Rest extends SfCommand {
22
22
  static enableJsonFlag = false;
23
23
  static flags = {
24
24
  'target-org': Flags.requiredOrg(),
25
- 'api-version': Flags.orgApiVersion(),
26
25
  include: includeFlag,
27
26
  method: Flags.option({
28
27
  options: methodOptions,
@@ -40,6 +39,7 @@ export class Rest extends SfCommand {
40
39
  description: messages.getMessage('flags.file.description'),
41
40
  helpValue: 'file',
42
41
  char: 'f',
42
+ exclusive: ['body'],
43
43
  }),
44
44
  'stream-to-file': streamToFileFlag,
45
45
  body: Flags.string({
@@ -68,9 +68,7 @@ export class Rest extends SfCommand {
68
68
  }
69
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
70
  const specified = args.url ?? (fileOptions?.url).raw ?? fileOptions?.url;
71
- const url = new URL(`${org.getField(Org.Fields.INSTANCE_URL)}/services/data/v${flags['api-version'] ?? (await org.retrieveMaxApiVersion())
72
- // replace first '/' to create valid URL
73
- }/${specified.replace(/\//y, '')}`);
71
+ const url = new URL(`${org.getField(Org.Fields.INSTANCE_URL)}/${specified.replace(/\//y, '')}`);
74
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
75
73
  const method = flags.method ?? fileOptions?.method ?? 'GET';
76
74
  // @ts-expect-error users _could_ put one of these in their file without knowing it's wrong - TS is smarter than users here :)
@@ -78,7 +76,23 @@ export class Rest extends SfCommand {
78
76
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
79
77
  throw new SfError(`"${method}" must be one of ${methodOptions.join(', ')}`);
80
78
  }
81
- const body = method !== 'GET' ? flags.body ?? getBodyContents(fileOptions?.body) : undefined;
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
+ }
82
96
  let headers = getHeaders(flags.header ?? fileOptions?.header);
83
97
  if (body instanceof FormData) {
84
98
  // if it's a multi-part formdata request, those have extra headers
@@ -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,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,k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AI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;oBACjC,MAAM,IAAI,OAAO,CAAC,2CAA2C,MAAM,CAAC,GAAG,cAAc,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;gBACvG,CAAC;gBACD,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;YACnD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/messages/rest.md CHANGED
@@ -12,27 +12,27 @@ 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
36
 
37
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
38
 
@@ -81,4 +81,4 @@ HTTP header in "key:value" format.
81
81
 
82
82
  # flags.body.summary
83
83
 
84
- 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 '@'.
@@ -114,12 +114,12 @@
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
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"
124
124
  ],
125
125
  "flags": {
@@ -141,13 +141,6 @@
141
141
  "multiple": false,
142
142
  "type": "option"
143
143
  },
144
- "api-version": {
145
- "description": "Override the api version used for api requests made by this command",
146
- "name": "api-version",
147
- "hasDynamicHelp": false,
148
- "multiple": false,
149
- "type": "option"
150
- },
151
144
  "include": {
152
145
  "char": "i",
153
146
  "exclusive": [
@@ -188,6 +181,9 @@
188
181
  "file": {
189
182
  "char": "f",
190
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
+ ],
191
187
  "name": "file",
192
188
  "summary": "JSON file that contains values for the request header, body, method, and URL.",
193
189
  "hasDynamicHelp": false,
@@ -210,7 +206,7 @@
210
206
  "body": {
211
207
  "char": "b",
212
208
  "name": "body",
213
- "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 '@'.",
214
210
  "hasDynamicHelp": false,
215
211
  "helpValue": "file",
216
212
  "multiple": false,
@@ -246,5 +242,5 @@
246
242
  ]
247
243
  }
248
244
  },
249
- "version": "1.3.0"
245
+ "version": "1.3.2"
250
246
  }
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@salesforce/plugin-api",
3
3
  "description": "A plugin to call API endpoints via CLI commands",
4
- "version": "1.3.0",
4
+ "version": "1.3.2",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/forcedotcom/cli/issues",
7
7
  "dependencies": {
8
8
  "@oclif/core": "^4",
9
9
  "@salesforce/core": "^8.4.0",
10
10
  "@salesforce/kit": "^3.2.1",
11
- "@salesforce/sf-plugins-core": "^11.3.2",
11
+ "@salesforce/sf-plugins-core": "^12",
12
12
  "@salesforce/ts-types": "^2.0.12",
13
13
  "ansis": "^3.3.2",
14
14
  "form-data": "^4.0.0",
@@ -206,7 +206,7 @@
206
206
  "exports": "./lib/index.js",
207
207
  "type": "module",
208
208
  "sfdx": {
209
- "publicKeyUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-api/1.3.0.crt",
210
- "signatureUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-api/1.3.0.sig"
209
+ "publicKeyUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-api/1.3.2.crt",
210
+ "signatureUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-api/1.3.2.sig"
211
211
  }
212
212
  }